summaryrefslogtreecommitdiff
path: root/src/install.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2003-08-09 17:47:34 +0000
committerJim Meyering <jim@meyering.net>2003-08-09 17:47:34 +0000
commitc9df366ee50991f0feb28398e0be573e0a1c32ac (patch)
tree93eb769d4b242269c855193bff0c45f6b9498b08 /src/install.c
parent40802a2fbd0ebbce24835ac8df116a1fc2a5db42 (diff)
downloadcoreutils-c9df366ee50991f0feb28398e0be573e0a1c32ac.tar.xz
Include utimens.h.
(change_timestamps): Set file timestamps with utimens, not utime.
Diffstat (limited to 'src/install.c')
-rw-r--r--src/install.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/install.c b/src/install.c
index f92aec08d..5b32eea78 100644
--- a/src/install.c
+++ b/src/install.c
@@ -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;