Feature #13111
closedWant futimes(), lutimes() and timespec/timeval conversion macros
100%
Description
The futimes()
, lutimes()
functions and the TIMESPEC_TO_TIMEVAL()
and TIMEVAL_TO_TIMESPEC()
macros are not standardised but found in Linux and BSDs.
Even though software should move to the POSIX futimens() and utimensat(), some software expects these functions/macros to exist and they are trivial to implement.
Testing notes, see attached Gerrit review:
build:illumos:ig_timesfunc% LD_LIBRARY_PATH=../../../../../proto/root_i386-nd/usr/lib ./utimes.32 Testing: ... atime: 1280793678.123456789 ... mtime: 1492732800.000000017 ..... utimes() ..... lutimes() ..... futimes() ..... futimesat() ..... futimens() ..... utimensat() Testing: ... atime: 1320796855.000000009 ... mtime: 1498953611.987654321 ..... utimes() ..... lutimes() ..... futimes() ..... futimesat() ..... futimens() ..... utimensat() build:illumos:ig_timesfunc% LD_LIBRARY_PATH=../../../../../proto/root_i386-nd/usr/lib/amd64 ./utimes.64 Testing: ... atime: 1280793678.123456789 ... mtime: 1492732800.000000017 ..... utimes() ..... lutimes() ..... futimes() ..... futimesat() ..... futimens() ..... utimensat() Testing: ... atime: 1320796855.000000009 ... mtime: 1498953611.987654321 ..... utimes() ..... lutimes() ..... futimes() ..... futimesat() ..... futimens() ..... utimensat()
Related issues
Updated by Andy Fiddaman almost 2 years ago
- Related to Bug #6162: utimes(2) man page is stale added
Updated by Andy Fiddaman almost 2 years ago
In addition to running the new tests, I also ran the libc symbol visibility tests to confirm that the new functions and macros are only visible when they should be (i.e. when no standards are selected)
Updated by Andy Fiddaman almost 2 years ago
- Subject changed from Want futimes() and lutimes() functions to Want futimes(), lutimes() and timespec/timeval conversion macros
- Description updated (diff)
Updated by Andy Fiddaman almost 2 years ago
I wrote a test program to convert from timespec to timeval and back again using the new macros, and to print the values at each step:
% ./utimes TS ... atime: 1280793678.123456789 ... mtime: 1492732800.000000017 TV ... atime: 1280793678.000123456 ... mtime: 1492732800.000000000 TS ... atime: 1280793678.123456000 ... mtime: 1492732800.000000000 TS ... atime: 1320796855.000000009 ... mtime: 1498953611.987654321 TV ... atime: 1320796855.000000000 ... mtime: 1498953611.000987654 TS ... atime: 1320796855.000000000 ... mtime: 1498953611.987654000
The expected loss of precision and subsequent multiplication can be seen in the output. Here's the test program fragment
printf("TS ... atime: %ld.%.9ld\n ... mtime: %ld.%.9ld\n", atim->tv_sec, atim->tv_nsec, mtim->tv_sec, mtim->tv_nsec); TIMESPEC_TO_TIMEVAL(&tv[0], atim); TIMESPEC_TO_TIMEVAL(&tv[1], mtim); printf("TV ... atime: %ld.%.9ld\n ... mtime: %ld.%.9ld\n", tv[0].tv_sec, tv[0].tv_usec, tv[1].tv_sec, tv[1].tv_usec); TIMEVAL_TO_TIMESPEC(&tv[0], atim); TIMEVAL_TO_TIMESPEC(&tv[1], mtim); printf("TS ... atime: %ld.%.9ld\n ... mtime: %ld.%.9ld\n", atim->tv_sec, atim->tv_nsec, mtim->tv_sec, mtim->tv_nsec); printf("\n");
Updated by Electric Monk almost 2 years ago
- Status changed from In Progress to Closed
- % Done changed from 0 to 100
git commit b7a7784945b3504d0b69ea02a08e1cddb5578907
commit b7a7784945b3504d0b69ea02a08e1cddb5578907 Author: Andy Fiddaman <omnios@citrus-it.co.uk> Date: 2020-09-17T18:19:33.000Z 13111 Want futimes(), lutimes() and timespec/timeval conversion macros Reviewed by: Robert Mustacchi <rm@fingolfin.org> Reviewed by: Marco van Wieringen <mvw@planets.elm.net> Approved by: Dan McDonald <danmcd@joyent.com>