A conforming C-language application must include <sys/stat.h> for
functions that have arguments or return values of type mode_t
, so
that symbolic values for that type can be used. An alternative
would be to require that these constants are also defined by
including <sys/types.h>.
The S_ISUID and S_ISGID bits may be cleared on any write, not
just on open(), as some historical implementations do.
System calls that update the time entry fields in the stat
structure must be documented by the implementors. POSIX-
conforming systems should not update the time entry fields for
functions listed in the System Interfaces volume of POSIX.1‐2017
unless the standard requires that they do, except in the case of
documented extensions to the standard.
Upon assignment, file timestamps are immediately converted to the
resolution of the file system by truncation (i.e., the recorded
time can be older than the actual time). For example, if the file
system resolution is 1 microsecond, then a conforming stat() must
always return an st_mtim.tv_nsec that is a multiple of 1000. Some
older implementations returned higher-resolution timestamps while
the inode information was cached, and then spontaneously
truncated the tv_nsec fields when they were stored to and
retrieved from disk, but this behavior does not conform.
Note that st_dev must be unique within a Local Area Network (LAN)
in a ``system'' made up of multiple computers' file systems
connected by a LAN.
Networked implementations of a POSIX-conforming system must
guarantee that all files visible within the file tree (including
parts of the tree that may be remotely mounted from other
machines on the network) on each individual processor are
uniquely identified by the combination of the st_ino and st_dev
fields.
The unit for the st_blocks member of the stat
structure is not
defined within POSIX.1‐2008. In some implementations it is 512
bytes. It may differ on a file system basis. There is no
correlation between values of the st_blocks and st_blksize, and
the f_bsize (from <sys/statvfs.h>) structure members.
Traditionally, some implementations defined the multiplier for
st_blocks in <sys/param.h> as the symbol DEV_BSIZE.
Some earlier versions of this standard did not specify values for
the file mode bit macros. The expectation was that some
implementors might choose to use a different encoding for these
bits than the traditional one, and that new applications would
use symbolic file modes instead of numeric. This version of the
standard specifies the traditional encoding, in recognition that
nearly 20 years after the first publication of this standard
numeric file modes are still in widespread use by application
developers, and that all conforming implementations still use the
traditional encoding.