我在用:
debugfs -R 'stat <7473635>' /dev/sda7
获取文件创建时间 ( crtime
)。
Inode: 7473635 Type: regular Mode: 0664 Flags: 0x80000
Generation: 1874934325 Version: 0x00000000:00000001
User: 1000 Group: 1000 Size: 34
File ACL: 0 Directory ACL: 0
Links: 1 Blockcount: 8
Fragment: Address: 0 Number: 0 Size: 0
ctime: 0x55b65ebc:98040bc4 -- Mon Jul 27 22:09:24 2015
atime: 0x55da0168:60b33f74 -- Sun Aug 23 22:52:48 2015
mtime: 0x55b65ebc:98040bc4 -- Mon Jul 27 22:09:24 2015
crtime: 0x55b65ebc:970fe7cc -- Mon Jul 27 22:09:24 2015
Size of extra inode fields: 28
EXTENTS:
(0):29919781
为什么我没有进入crtime
纳秒即使ext4
支持纳秒分辨率?
答案1
它确实显示时间戳(精度为纳秒)但是十六进制;它是后面的字段crtime:
,例如在您的输出中0x55b65ebc:970fe7cc
。冒号后面的部分是纳秒。
本文提供更多详细信息并解释如何计算时间戳/纳秒。因此,例如将十六进制值转换为时间戳阿拉 stat
你可以运行:
日期 -d @$(printf %d 0x55b65ebc).$(( $(printf %d 0x970fe7cc) / 4 )) +'%F %T.%N %z'
2015-07-27 19:39:24.633600499 +0300
答案2
看起来 debugfs 还不支持打印亚秒部分(i_ 的高 30 位)Xasctime
time_extra) 的基于其格式的时间戳。从http://git.kernel.org/cgit/fs/ext2/e2fsprogs.git/tree/debugfs/debugfs.c:
if (is_large_inode && large_inode->i_extra_isize >= 24) {
fprintf(out, "%s ctime: 0x%08x:%08x -- %s", prefix,
inode->i_ctime, large_inode->i_ctime_extra,
time_to_string(inode->i_ctime));
fprintf(out, "%s atime: 0x%08x:%08x -- %s", prefix,
inode->i_atime, large_inode->i_atime_extra,
time_to_string(inode->i_atime));
fprintf(out, "%s mtime: 0x%08x:%08x -- %s", prefix,
inode->i_mtime, large_inode->i_mtime_extra,
time_to_string(inode->i_mtime));
fprintf(out, "%scrtime: 0x%08x:%08x -- %s", prefix,
large_inode->i_crtime, large_inode->i_crtime_extra,
time_to_string(large_inode->i_crtime));