Re: st_* variables of ctim vs ctime vs ctimespec; is there a history & recommended use?
Date: Sun, 01 Oct 2023 17:49:20 UTC
"Edward Sanford Sutton, III": > After recently finding stat(1) EXAMPLES error (I filed under PR274189 with > patch and reasoning), I was trying to learn the meanings of these variables > which lead me through reading stat(2) (found by `man lstat`) which says it > uses st_mtim and provides both st_mtime and st_mtimespec for compatibility. > I didn't find any listed reason for the compatibility otherwise and > wondered if that is documented somewhere. Historically, in old Unix and POSIX, struct stat had fields st_mtime etc. that were of type time_t and held a timestamp accurate to one second. At some point, computers got sufficiently fast that several things could happen inside a single second, and higher precision timestamps became desirable. st_mtimespec etc. was added as a non-standard BSD extension. (Also, filesystems were changed to record such timestamps in the first place.) Eventually, POSIX recognized the need for higher precision timestamps and standardized st_mtim etc. "Compatibility" is about source-code compatibility with older code bases. -- Christian "naddy" Weisgerber naddy@mips.inka.de