Opened 16 months ago

Last modified 4 days ago

#58729 assigned enhancement

legacy-support missing futimens() (and utimensat)

Reported by: RJVB (René Bertin) Owned by: kencu (Ken)
Priority: Normal Milestone:
Component: ports Version:
Keywords: Cc: cjones051073 (Chris Jones)
Port: legacy-support

Description (last modified by RJVB (René Bertin))

From man futimens on Linux:

NAME
       utimensat, futimens - change file timestamps with nanosecond precision

SYNOPSIS
       #include <fcntl.h> /* Definition of AT_* constants */
       #include <sys/stat.h>

       int utimensat(int dirfd, const char *pathname,
                     const struct timespec times[2], int flags);

       int futimens(int fd, const struct timespec times[2]);

   Feature Test Macro Requirements for glibc (see feature_test_macros(7)):

       utimensat():
           Since glibc 2.10:
               _XOPEN_SOURCE >= 700 || _POSIX_C_SOURCE >= 200809L
           Before glibc 2.10:
               _ATFILE_SOURCE
       futimens():
           Since glibc 2.10:
                  _XOPEN_SOURCE >= 700 || _POSIX_C_SOURCE >= 200809L
           Before glibc 2.10:
                  _GNU_SOURCE

I just encountered futimens() trying to build a new kf5-kio version. It was easy enough to emulate using futimes().

What I do not know is whether this function is available on any Darwin version, nor what the project policy is for such situations (so feel free to close this if the function isn't acceptable).

Change History (10)

comment:1 Changed 16 months ago by RJVB (René Bertin)

Description: modified (diff)

comment:2 Changed 16 months ago by cjones051073 (Chris Jones)

If you are suggesting an addition to the legacy-support package, then please file an PR implementing your changes at https://github.com/macports/macports-legacy-support

comment:3 Changed 16 months ago by cjones051073 (Chris Jones)

Resolution: wontfix
Status: newclosed

comment:4 Changed 16 months ago by kencu (Ken)

thanks for suggestion. will see if darwin has this. if so, we should add it. if you get a moment, please paste up your replacement.

comment:5 Changed 16 months ago by cjones051073 (Chris Jones)

Prior to APFS, does macOS have nano-second precision on timestamps ? I believe it is not supported at all in HFS+ etc.

I believe these methods are available in mac OS 10.13+ Prior to that, if the filesystem in use cannot support nano-second precision, is it even sensible to try and emulate it ?

comment:6 Changed 16 months ago by kencu (Ken)

That's true enough, and I also wondered if older systems had the chops to implement it properly; I suspect not, as I believe I read somewhere that level of fs resolution was added to APFS.

Perhaps we might consider a "best approximation" so that software builds at least, and works as best the OS can support. I am thinking that is (or should be) what people are hoping for by extending the use of their older systems with our methods.

comment:7 Changed 16 months ago by cjones051073 (Chris Jones)

I am not conviced, in this case, that emulating the methods on older systems is necessarily a good idea. The problem is if people are using these methods then presumably they want/need (or at least think they do) nanosecnd precision. So if the underlying file system simply cannot do this, if we pretend otherwise this could lead to all sorts of issues. Worst case, file corruption.... So in this case I remind unconvinced emulating these methods is actually doing anyone a favour...

comment:8 Changed 2 months ago by kencu (Ken)

Resolution: wontfix
Status: closedreopened

I'm coming across software that doesn't specifically need nanosecond timespec resolution for setting file access times, but is using these functions as they are assumed to exist, eg dosbox-x.

I think that adding compatibility functions for utimensat and futimens would be acceptable for the vast majority of these cases, rather than putting #ifdefs into the source to use the older microsecond resolution functions.

comment:9 Changed 2 months ago by kencu (Ken)

Owner: set to kencu
Status: reopenedassigned

comment:10 Changed 4 days ago by kencu (Ken)

Cc: ken-cunningham-webuse removed
Note: See TracTickets for help on using tickets.