如何解决debugfs set_inode_field ctime 纳秒
我正在使用 debugfs
在 ext4 文件系统上更改文件的 ctime(附加到此特定文件的 ctime 的程序循环)。
因此使用的命令是:
debugfs -w -R 'set_inode_field foo/bar ctime 20130503145204' /dev/vdb1
但这会导致后面跟着一个 ctime:
myserver:~ # stat foo/bar
File: „foo/bar“
Size: 1234 Blocks: 24 IO Block: 4096 reguläre Datei
Device: 1234h/1234d Inode: 1234567 Links: 1
Access: (0660/-rw-rw----) Uid: ( 123/ whatever) Gid: ( 1234/ whatever)
Access: 2021-02-12 21:17:51.146954174 +0100
Modify: 2021-02-12 14:51:32.152323937 +0100
Change: 2013-05-03 16:52:04.991865222 +0200
不符合预期:2013-05-03 16:52:04.000000000 +0200
原因,它正常工作的原因是旧的 ext3 FS 仅以第二个分辨率存储 ctime。 ext2/ext3 中的 inode structur size
为 128 字节。使用 ext4,此大小增加到 156 字节(i_extra_isize = 28,请参阅:https://ext4.wiki.kernel.org/index.php/Ext4_Disk_Layout#Inode_Size)导致纳秒分辨率。
如何格式化 debugfs 命令以将 ctime 设置为精确的纳秒?
解决方法
经过一番挖掘,我设法解决了这个问题。解决方法:阅读手册。
-
https://ext4.wiki.kernel.org/index.php/Ext4_Disk_Layout#Inode_Table
-
https://ext4.wiki.kernel.org/index.php/Ext4_Disk_Layout#Inode_Timestamps
debugfs 支持设置 ctime/atime/mtime/crtime time_extra bytes with
package com.todolist.webbapp.config;
import java.beans.PropertyVetoException;
import java.util.Properties;
import javax.sql.DataSource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.core.env.Environment;
import org.springframework.orm.hibernate5.HibernateTransactionManager;
import org.springframework.orm.hibernate5.LocalSessionFactoryBean;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.web.servlet.ViewResolver;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import org.springframework.web.servlet.view.InternalResourceViewResolver;
import com.mchange.v2.c3p0.ComboPooledDataSource;
@Configuration
@EnableTransactionManagement
@EnableWebMvc
@ComponentScan(basePackages = "com.todolist.webbapp")
@PropertySource("classpath:persistence-mysql.properties")
public class WebAppConfig implements WebMvcConfigurer {
@Autowired
private Environment env;
@Bean
public ViewResolver viewResolver() {
InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();
viewResolver.setPrefix("/WEB-INF/view/");
viewResolver.setSuffix(".jsp");
viewResolver.setContentType("text/html ; charset=UTF-8");
return viewResolver;
}
ctime_extra 字段是一个无符号整数,因此值 0 给出了预期的设置。
dtime 没有加宽,因此不支持 dtime_extra
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。