修改目录如何影响其在 Linux 中的父目录时间戳?
How does modifying a directory affect its Parent Directory timestamp in Linux?
例如,如果我创建一个目录,检查它的时间戳,然后在一分钟后在第一个目录中创建一个目录,mtime 的时间戳将更改为创建新目录的时间。但是,如果我再等一分钟并在第二个目录中创建第三个目录,第二个目录会将 mtime 更新为第三个目录的时间,而第一个目录仍将具有第二个目录的原始 mtime。尽管创建第三个目录时第一个目录的内容发生了变化,但 mtime 并没有改变。
是否有关于 linux 如何更改 mtime 的文档?还是只能看到直接子变化更新mtime?
这是我能找到的最接近的。来自 stat
手册页:
The field st_mtime is changed by file modifications, for example, by
mknod(2), truncate(2), utime(2) and write(2) (of more than zero
bytes). Moreover, st_mtime of a directory is changed by the creation
or deletion of files in that directory. The st_mtime field is not
changed for changes in owner, group, hard link count, or mode.
-Source
这个措辞对我来说意味着嵌套目录的 mtime 修改不被父目录视为修改,因为它不符合 mknod
、truncate
、utime
,或write
运算。
希望对您有所帮助!
例如,如果我创建一个目录,检查它的时间戳,然后在一分钟后在第一个目录中创建一个目录,mtime 的时间戳将更改为创建新目录的时间。但是,如果我再等一分钟并在第二个目录中创建第三个目录,第二个目录会将 mtime 更新为第三个目录的时间,而第一个目录仍将具有第二个目录的原始 mtime。尽管创建第三个目录时第一个目录的内容发生了变化,但 mtime 并没有改变。
是否有关于 linux 如何更改 mtime 的文档?还是只能看到直接子变化更新mtime?
这是我能找到的最接近的。来自 stat
手册页:
The field st_mtime is changed by file modifications, for example, by mknod(2), truncate(2), utime(2) and write(2) (of more than zero bytes). Moreover, st_mtime of a directory is changed by the creation or deletion of files in that directory. The st_mtime field is not changed for changes in owner, group, hard link count, or mode. -Source
这个措辞对我来说意味着嵌套目录的 mtime 修改不被父目录视为修改,因为它不符合 mknod
、truncate
、utime
,或write
运算。
希望对您有所帮助!