unix - Effect of file creation/opening on st_mtime and st_atime -


when create or open file in unix using o_creat flag, st_mtime,st_ctime , st_atime of file changes. when create or open file using o_trunc flag, st_mtime , st_ctime changes , not st_atime.

from understanding, st_atime changes when file accessed. when open or create file using o_trunc flag, not accessing file?

this question bit old, answer future generations @ least...

from stat(2) man page (on host linux 2.6.32 kernel):

the field st_atime changed file accesses, example, execve(2), mknod(2), pipe(2), utime(2) , read(2) (of more 0 bytes). other routines, mmap(2), may or may not update st_atime.

the field st_mtime changed file modifications, example, mknod(2), truncate(2), utime(2) , write(2) (of more 0 bytes). moreover, st_mtime of directory changed creation or deletion of files in directory. st_mtime field not changed changes in owner, group, hard link count, or mode.

the field st_ctime changed writing or setting inode information (i.e., owner, group, link count, mode, etc.).


Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -