ptg10805159
Section 4.19 File Times 125
Thelscommand displays or sorts only on one of the three time values. By default,
when invoked with either the-lor the-toption, it uses the modification time of a file.
The-uoption causes thelscommand to use the access time, and the-coption causes
it to use the changed-status time.
Figure4.20 summarizes the effects of the various functions that we’ve described on
these three times. Recall from Section 4.14 that a directory is simply a file containing
directory entries: filenames and associated i-node numbers. Adding, deleting, or
modifying these directory entries can affect the three times associated with that
directory.This is why Figure4.20 contains one column for the three times associated
with the file or directory and another column for the three times associated with the
parent directory of the referenced file or directory.For example, creating a new file
affects the directory that contains the new file, and it affects the i-node for the new file.
Reading or writing a file, however,affects only the i-node of the file and has no effect on
the directory.
Parent directory
Function Referenced file of referenced file Section Note
or directory or directory
am c am c
chmod,fchmod •4.9
chown,fchown •4.11
creat ••• •• 3.4 O_CREATnew file
creat •• 3.4 O_TRUNCexisting file
exec •8.10
lchown •4.11
link •••4.15 parent of second argument
mkdir ••• •• 4.21
mkfifo ••• ••15.5
open ••• •• 3.3 O_CREATnew file
open •• 3.3 O_TRUNCexisting file
pipe ••• 15.2
read •3.7
remove •••4.15 remove file =unlink
remove •• 4.15 remove directory =rmdir
rename •••4.16 for both arguments
rmdir •• 4.21
truncate,ftruncate •• 4.13
unlink •••4.15
utimes,utimensat,futimens ••• 4.20
write •• 3.8
Figure 4.20Effect of various functions on the access, modification, and changed-status times
(The mkdir and rmdir functions arecovered in Section 4.21. The utimes,
utimensat,andfutimensfunctions arecovered in the next section. The sevenexec
functions aredescribed in Section 8.10. We describe themkfifoandpipefunctions in
Chapter 15.)