Project

General

Profile

Actions

Feature #13111

closed

Want futimes(), lutimes() and timespec/timeval conversion macros

Added by Andy Fiddaman 11 months ago. Updated 11 months ago.

Status:
Closed
Priority:
Low
Assignee:
Category:
lib - userland libraries
Start date:
Due date:
% Done:

100%

Estimated time:
Difficulty:
Bite-size
Tags:
Gerrit CR:

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

Related to illumos gate - Bug #6162: utimes(2) man page is staleClosedDamian Wojslaw2015-08-25

Actions
Actions #1

Updated by Electric Monk 11 months ago

  • Gerrit CR set to 897
Actions #2

Updated by Andy Fiddaman 11 months ago

  • Related to Bug #6162: utimes(2) man page is stale added
Actions #3

Updated by Andy Fiddaman 11 months 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)

Actions #4

Updated by Andy Fiddaman 11 months ago

  • Subject changed from Want futimes() and lutimes() functions to Want futimes(), lutimes() and timespec/timeval conversion macros
  • Description updated (diff)
Actions #5

Updated by Andy Fiddaman 11 months 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");

Actions #6

Updated by Electric Monk 11 months 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>

Actions

Also available in: Atom PDF