stat ¶POSIX specification:
https://pubs.opengroup.org/onlinepubs/9799919799/functions/stat.html
Portability problems fixed by Gnulib:
off_t is a 32-bit type, stat may not correctly
report the size of files or block devices 2 GiB and larger.
See Large File Support.
st_atime, st_ctime, st_mtime fields are affected by
the current time zone and by the DST flag of the current time zone on some
platforms:
mingw, MSVC 14 (when the environment variable TZ is set).
ENOENT
on files such as ‘C:\pagefile.sys’ and
on directories such as ‘C:\System Volume Information’.
stat("link-to-file/",buf) succeeds instead
of failing with ENOTDIR.
macOS 14, FreeBSD 7.2, AIX 7.1, Solaris 9, mingw64.
stat(".",buf) and stat("./",buf) give
different results:
mingw, MSVC 14.
st_mode field of stat("NUL",buf) is bogus,
suggesting that NUL is a regular file.
tv_sec value, tv_nsec might be in the range
−999999999..−1, representing a negative nanoseconds
offset from tv_sec. Solaris 11.4 is similar, except that
tv_sec might also be −1000000000.
"NUL" instead of "/dev/null".
Portability problems not fixed by Gnulib:
struct stat.
stat function sometimes sets errno to EACCES when
ENOENT would be more appropriate.
st_ino only to the low-order 32 bits of
the inode number of a socket or pipe, which thus can disagree
with the st_ino obtained by fstat:
macOS 14.
struct stat, it is not possible to
portably replace stat via an object-like macro. Therefore,
expressions such as (islnk ? lstat : stat) (name, buf) are not
portable, and should instead be written islnk ? lstat (name,
buf) : stat (name, buf).