The Linux Programming Interface

(nextflipdebug5) #1

286 Chapter 15


In Sections 14.8.1 and 15.5, we describe mount(2) options and per-file flags that pre-
vent updates to the last access time of a file. The open() O_NOATIME flag described in
Section 4.3.1 also serves a similar purpose. In some applications, this can be useful
for performance reasons, since it reduces the number of disk operations that are
required when a file is accessed.

Although most UNIX systems don’t record the creation time of a file, on
recent BSD systems, this time is recorded in a stat field named st_birthtime.

Table 15-2: Effect of various functions on file timestamps

Function

File or
directory

Parent
directory Notes
amc amc
chmod() • Same for fchmod()
chown() • Same for lchown() and fchown()
exec() •
link() •••Affects parent directory of second argument
mkdir() ••• ••
mkfifo() ••• ••
mknod() ••• ••
mmap() • •• st_mtime and st_ctime are changed only on updates
to MAP_SHARED mapping
msync() •• Changed only if file is modified
open(), creat() ••• ••When creating new file
open(), creat() •• When truncating existing file
pipe() •••
read() • Same for readv(), pread(), and preadv()
readdir() • readdir() may buffer directory entries; timestamps
updated only if directory is read
removexattr() • Same for fremovexattr() and lremovexattr()
rename() •• • Affects timestamps in both parent directories;
SUSv3 doesn’t specify file st_ctime change, but
notes that some implementations do this
rmdir() ••Same for remove(directory)
sendfile() • Timestamp changed for input file
setxattr() • Same for fsetxattr() and lsetxattr()
symlink() ••• ••Sets timestamps of link (not target file)
truncate() •• Same for ftruncate(); timestamps change only if
file size changes
unlink() •••Same for remove(file); file st_ctime changes if
previous link count was > 1
utime() ••• Same for utimes(), futimes(), futimens(), lutimes(),
and utimensat()
write() •• Same for writev(), pwrite(), and pwritev()
Free download pdf