4.7 File Times Update
Each file has three distinct associated time values: st_atime, st_mtime, and st_ctime.
The st_atime field is associated with the times that the file data is accessed; st_mtime
is associated with the times that the file data is modified; and st_ctime is associated
with the times that the file status is changed. These values are returned in the file
characteristics structure, as described in <sys/stat.h>.
Each function or utility in IEEE Std 1003.1-2001 that reads or writes data or changes file
status indicates which of the appropriate time-related fields shall be "marked for update".
If an implementation of such a function or utility marks for update a time-related field
not specified by IEEE Std 1003.1-2001, this shall be documented, except that any changes
caused by pathname resolution need not be documented. For the other functions or utilities
in IEEE Std 1003.1-2001 (those that are not explicitly required to read or write file data
or change file status, but that in some implementations happen to do so), the effect is
unspecified.
An implementation may update fields that are marked for update immediately, or it may update
such fields periodically. At an update point in time, any marked fields shall be set to the
current time and the update marks shall be cleared. All fields that are marked for update
shall be updated when the file ceases to be open by any process, or when a stat(), fstat(),
or lstat() is performed on the file. Other times at which updates are done are unspecified.
Marks for update, and updates themselves, are not done for files on read-only file systems;
see Read-Only File System.