Ext4
為什麼 debugfs 不以納秒為單位顯示 crtime?
我在用:
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
支持納秒解析度,我也沒有進入納秒?
它確實顯示了時間戳(精度為納秒),但以十六進制顯示;它是之後的欄位
crtime:
,例如在您的輸出0x55b65ebc:970fe7cc
中。冒號之後的部分是納秒。本文提供了更多詳細資訊並解釋瞭如何計算時間戳/納秒。因此,例如,要將十六進制值轉換為時間戳*,*
stat
您可以執行:日期 -d @$(printf %d 0x55b65ebc).$(( $(printf %d 0x970fe7cc) / 4 )) +'%F %T.%N %z'
2015-07-27 19:39:24.633600499 +0300
看起來 debugfs 還不支持以基於 - 的格式列印出時間戳的亞秒部分(i_x time_extra的
asctime
高 30 位) 。從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));