]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
Include utimens.h.
authorJim Meyering <jim@meyering.net>
Sat, 9 Aug 2003 17:47:34 +0000 (17:47 +0000)
committerJim Meyering <jim@meyering.net>
Sat, 9 Aug 2003 17:47:34 +0000 (17:47 +0000)
(change_timestamps): Set file timestamps with utimens, not utime.

src/install.c

index f92aec08d22b608866fedc8fb3c4a1f49c77e18e..5b32eea78cdd472becc0808e5edf6e9c0f73a153 100644 (file)
@@ -34,6 +34,7 @@
 #include "modechange.h"
 #include "path-concat.h"
 #include "quote.h"
+#include "utimens.h"
 #include "xstrtol.h"
 
 /* The official name of this program (e.g., no `g' prefix).  */
@@ -485,7 +486,7 @@ static int
 change_timestamps (const char *from, const char *to)
 {
   struct stat stb;
-  struct utimbuf utb;
+  struct timespec timespec[2];
 
   if (stat (from, &stb))
     {
@@ -493,13 +494,11 @@ change_timestamps (const char *from, const char *to)
       return 1;
     }
 
-  /* There's currently no interface to set file timestamps with
-     better than 1-second resolution, so discard any fractional
-     part of the source timestamp.  */
-
-  utb.actime = stb.st_atime;
-  utb.modtime = stb.st_mtime;
-  if (utime (to, &utb))
+  timespec[0].tv_sec = stb.st_atime;
+  timespec[0].tv_nsec = TIMESPEC_NS (stb.st_atim);
+  timespec[1].tv_sec = stb.st_mtime;
+  timespec[1].tv_nsec = TIMESPEC_NS (stb.st_mtim);
+  if (utimens (to, timespec))
     {
       error (0, errno, _("cannot set time stamps for %s"), quote (to));
       return 1;