about summary refs log tree commit diff
path: root/sysdeps/mach/hurd/futimens.c
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2018-03-06 00:13:54 +0100
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2018-03-06 00:14:26 +0100
commitec1300cfc83c716f33ee3231bba0a6e270abfc73 (patch)
tree739118fdbbe5f662bbc00f29d0b9566e6b3fef70 /sysdeps/mach/hurd/futimens.c
parentbbe762d1e596d7f5a1cd560a229387cb856916e0 (diff)
downloadglibc-ec1300cfc83c716f33ee3231bba0a6e270abfc73.tar.gz
glibc-ec1300cfc83c716f33ee3231bba0a6e270abfc73.tar.xz
glibc-ec1300cfc83c716f33ee3231bba0a6e270abfc73.zip
hurd: Add futimesat and utimensat support
	* sysdeps/mach/hurd/utime-helper.c (hurd_futimens): Rename function to
	hurd_futimes.
	* sysdeps/mach/hurd/utimes.c (__utimes): Update call accordingly.
	* sysdeps/mach/hurd/lutimes.c (__lutimes): Likewise.
	* sysdeps/mach/hurd/futimens.c: Include "utime-helper.c".
	(__futimens): Move implementation to...
	* sysdeps/mach/hurd/utime-helper.c (utime_ts_from_tspec,
	utime_tvalue_from_tspec): ... new helper functions.
	(hurd_futimens): New function.
	* sysdeps/mach/hurd/futimesat.c: New file.
	* sysdeps/mach/hurd/utimensat.c: New file.
Diffstat (limited to 'sysdeps/mach/hurd/futimens.c')
-rw-r--r--sysdeps/mach/hurd/futimens.c37
1 files changed, 4 insertions, 33 deletions
diff --git a/sysdeps/mach/hurd/futimens.c b/sysdeps/mach/hurd/futimens.c
index 4a8b0f7fa4..4a3943e673 100644
--- a/sysdeps/mach/hurd/futimens.c
+++ b/sysdeps/mach/hurd/futimens.c
@@ -22,6 +22,8 @@
 #include <hurd.h>
 #include <hurd/fd.h>
 
+#include "utime-helper.c"
+
 /* Change the access time of FD to TSP[0] and
    the modification time of FD to TSP[1].  */
 int
@@ -30,20 +32,7 @@ __futimens (int fd, const struct timespec tsp[2])
   struct timespec atime, mtime;
   error_t err;
 
-  if (tsp == NULL)
-    {
-      /* Setting the number of nanoseconds to UTIME_NOW tells the
-         underlying filesystems to use the current time.  */
-      atime.tv_sec = 0;
-      atime.tv_nsec = UTIME_NOW;
-      mtime.tv_sec = 0;
-      mtime.tv_nsec = UTIME_NOW;
-    }
-  else
-    {
-      atime = tsp[0];
-      mtime = tsp[1];
-    }
+  utime_ts_from_tspec (tsp, &atime, &mtime);
 
   err = HURD_DPORT_USE (fd, __file_utimens (port, atime, mtime));
 
@@ -51,25 +40,7 @@ __futimens (int fd, const struct timespec tsp[2])
     {
       time_value_t atim, mtim;
 
-      if (tsp == NULL)
-        /* Setting the number of microseconds to `-1' tells the
-           underlying filesystems to use the current time.  */
-        atim.microseconds = mtim.microseconds = -1;
-      else
-        {
-          if (tsp[0].tv_nsec == UTIME_NOW)
-            atim.microseconds = -1;
-          else if (tsp[0].tv_nsec == UTIME_OMIT)
-            atim.microseconds = -2;
-          else
-            TIMESPEC_TO_TIME_VALUE (&atim, &(tsp[0]));
-          if (tsp[1].tv_nsec == UTIME_NOW)
-            mtim.microseconds = -1;
-          else if (tsp[1].tv_nsec == UTIME_OMIT)
-            mtim.microseconds = -2;
-          else
-            TIMESPEC_TO_TIME_VALUE (&mtim, &(tsp[1]));
-        }
+      utime_tvalue_from_tspec (tsp, &atim, &mtim);
 
       err = HURD_DPORT_USE (fd, __file_utimes (port, atim, mtim));
   }