读书人

文件atime未变有关问题的研究

发布时间: 2013-09-28 10:01:20 作者: rapoo

文件atime未变问题的研究
1. atime, ctime 以及mtime

这三个名词属于文件/文件夹的属性,存在于inode数据结构之中。

通过系统调用stat可以获取stat结构,其中包括:atime(accesstime), ctime(create time) 以及mtime(modify time)的信息,man stat后的信息:

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

atime: The field st_atime is changed by file accesses, e.g. byexecve, mknod, pipe, utime and read (of more than zero bytes).

ctime: The field st_ctime is changed by writing or by settinginode information (i.e., owner, group, link count, mode, etc.).

mtime: The field st_mtime is changed by file modifications, e.g.by mknod, truncate, utime and write (of more than zero bytes). Moreover, st_mtime of a directory is changedby the creation or deletion of files in that directory. The st_mtime field isnot changed for changes in owner, group, hard link count, or mode.

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


值得注意的是,严格意义上说,ctime并不是创建文件的时间。

同样我们也可以通过ls命令来获取文件的atime,ctime, mtime:

mount -o remount,rw,strictatime /

这样挂载在”/”目录的文件系统就能够及时的更新atime了。

5. 参考

1. http://stackoverflow.com/questions/15547649/is-it-necessary-to-enable-atime-in-etc-fstab-to-get-the-correct-last-accessed

2. http://www.h-online.com/open/news/item/Kernel-Log-What-s-coming-in-2-6-30-File-systems-New-and-revamped-file-systems-741319.html

读书人网 >其他相关

热点推荐