Imported Upstream version 2.8.4
[platform/upstream/man-db.git] / patches / fdutimens-hurd.patch
1 commit 15ab8fc0974755c0b56554b6dc6f9dec65290b8c
2 Author: Colin Watson <cjwatson@debian.org>
3 Date:   Wed Sep 24 13:09:50 2014 +0100
4
5     utimens: handle lack of UTIME_* on GNU/Hurd
6     
7     The Hurd has futimens, but does not currently support
8     UTIME_NOW/UTIME_OMIT (https://bugs.debian.org/762677).  Resolve these to
9     real timestamps if necessary.
10     
11     Although the lutimens function is structured similarly, it does not need
12     the same change because the Hurd does not have utimensat, so it will
13     always fall back to other methods after calling update_timespec.
14
15 diff --git a/gl/lib/utimens.c b/gl/lib/utimens.c
16 index dd3ec66..2d0e9f6 100644
17 --- a/gl/lib/utimens.c
18 +++ b/gl/lib/utimens.c
19 @@ -243,6 +243,18 @@ fdutimens (int fd, char const *file, struct timespec const timespec[2])
20            adjustment_needed++;
21          }
22  # endif
23 +# ifdef __GNU__
24 +      /* Work around lack of UTIME_NOW/UTIME_OMIT support:
25 +         <https://bugs.debian.org/762677>.  */
26 +      if (adjustment_needed > 0)
27 +        {
28 +          if (fd < 0 ? stat (file, &st) : fstat (fd, &st))
29 +            return -1;
30 +          update_timespec (&st, &ts);
31 +          /* Note that st is good, in case futimens gives ENOSYS.  */
32 +          adjustment_needed = 3;
33 +        }
34 +# endif
35  # if HAVE_UTIMENSAT
36        if (fd < 0)
37          {