>From 5141074863eee7a8dbb76921aa1f406cb7168dee Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Wed, 24 Sep 2014 13:09:50 +0100 Subject: [PATCH] utimens: handle lack of UTIME_* on GNU/Hurd The Hurd has futimens, but does not currently support UTIME_NOW/UTIME_OMIT (https://bugs.debian.org/762677). Resolve these to real timestamps if necessary. Although the lutimens function is structured similarly, it does not need the same change because the Hurd does not have utimensat, so it will always fall back to other methods after calling update_timespec. --- lib/utimens.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/utimens.c b/lib/utimens.c index dd3ec66..2d0e9f6 100644 --- a/lib/utimens.c +++ b/lib/utimens.c @@ -243,6 +243,18 @@ fdutimens (int fd, char const *file, struct timespec const timespec[2]) adjustment_needed++; } # endif +# ifdef __GNU__ + /* Work around lack of UTIME_NOW/UTIME_OMIT support: + . */ + if (adjustment_needed > 0) + { + if (fd < 0 ? stat (file, &st) : fstat (fd, &st)) + return -1; + update_timespec (&st, &ts); + /* Note that st is good, in case futimens gives ENOSYS. */ + adjustment_needed = 3; + } +# endif # if HAVE_UTIMENSAT if (fd < 0) { -- 2.1.0