summaryrefslogtreecommitdiffstats
path: root/patches/fdutimens-hurd.patch
blob: de0d683fcf998ce7561f86afc767d910d5b3a364 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
commit 15ab8fc0974755c0b56554b6dc6f9dec65290b8c
Author: Colin Watson <cjwatson@debian.org>
Date:   Wed Sep 24 13:09:50 2014 +0100

    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.

diff --git a/gl/lib/utimens.c b/gl/lib/utimens.c
index dd3ec66..2d0e9f6 100644
--- a/gl/lib/utimens.c
+++ b/gl/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:
+         <https://bugs.debian.org/762677>.  */
+      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)
         {