Hi Michael,
you're right, st_ctim is in struct stat if it's read via lstat and I missed the
NOTES-section where it's clearly stated ("The nanosecond components of each
timestamp are available via names of the form st_atim.tv_nsec").
I originally came from nftw(3) where I concluded from the sentence "sb is a
pointer to the stat structure returned by a call to stat(2) for fpath." that I
can find the description for struct stat in stat(2).
In stat(2) I found that "struct timespec st_mtim" exists in struct stat, so I
tried to read st_mtim.tv_sec from struct stat that nftw returned.
But the compiler complained: "‘const struct stat’ has no member named ‘st_mtim’;
did you mean ‘st_mtime’" and I concluded that there is no st_mtim in struct stat
and as there isn't any description of st_atim, st_mtim and st_ctim in the
explanation "The fields in the stat structure are as follows:" I assumed that
it's an typing error in the manual.
It isn't and I surely did something wrong somewhere (I've to admit that I'm not
that experienced programmer).
So, sorry for false alarm.
Best,
Christoph
On 9/30/20 9:38 PM, Michael Kerrisk (man-pages) wrote:
On 9/30/20 2:22 PM, Florian Weimer wrote:
* Christoph Kalchreuter:
There are three Letters "e" missing in Section "DESCRIPTION",
Subsection "The stat structure":
struct timespec st_atim; /* Time of last access */
struct timespec st_mtim; /* Time of last modification */
sruct timespec st_ctim; /* Time of last status change */
should possibly be:
struct timespec st_atime; /* Time of last access */
struct timespec st_mtime; /* Time of last modification */
sruct timespec st_ctime; /* Time of last status change */
This typo is also present in POSIX, so we cannot change it (like the
creat function).
Hi Christoph,
Florian was being very deadpan in his humor! The names
really are correct. In the header files, one can find
[[ # /usr/include/bits/stat.h
struct timespec st_atim; /* Time of last access. */
struct timespec st_mtim; /* Time of last modification. */
struct timespec st_ctim; /* Time of last status change. */
# define st_atime st_atim.tv_sec /* Backward compatibility. */
# define st_mtime st_mtim.tv_sec
# define st_ctime st_ctim.tv_sec
]]
And struct timespec is defined as
struct timespec {
time_t tv_sec; /* Seconds */
long tv_nsec; /* Nanoseconds */
};
Thanks,
Michael