summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2003-08-09 17:48:41 +0000
committerJim Meyering <jim@meyering.net>2003-08-09 17:48:41 +0000
commit9b51a5db83bfbc24f38ae1f4d8aa74faa4dd7709 (patch)
treed25ae6c00506197266f1412599dbb1c3a8575e92 /src
parentc9df366ee50991f0feb28398e0be573e0a1c32ac (diff)
downloadcoreutils-9b51a5db83bfbc24f38ae1f4d8aa74faa4dd7709.tar.xz
Include utimens.h.
(copy_internal): Set file timestamps with utimens, not utime.
Diffstat (limited to 'src')
-rw-r--r--src/copy.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/copy.c b/src/copy.c
index 7a3ae3396..607e69840 100644
--- a/src/copy.c
+++ b/src/copy.c
@@ -40,6 +40,7 @@
#include "path-concat.h"
#include "quote.h"
#include "same.h"
+#include "utimens.h"
#include "xreadlink.h"
#define DO_CHOWN(Chown, File, New_uid, New_gid) \
@@ -1523,16 +1524,14 @@ copy_internal (const char *src_path, const char *dst_path,
if (x->preserve_timestamps)
{
- struct utimbuf utb;
+ struct timespec timespec[2];
- /* There's currently no interface to set file timestamps with
- better than 1-second resolution, so discard any fractional
- part of the source timestamp. */
+ timespec[0].tv_sec = src_sb.st_atime;
+ timespec[0].tv_nsec = TIMESPEC_NS (src_sb.st_atim);
+ timespec[1].tv_sec = src_sb.st_mtime;
+ timespec[1].tv_nsec = TIMESPEC_NS (src_sb.st_mtim);
- utb.actime = src_sb.st_atime;
- utb.modtime = src_sb.st_mtime;
-
- if (utime (dst_path, &utb))
+ if (utimens (dst_path, timespec))
{
error (0, errno, _("preserving times for %s"), quote (dst_path));
if (x->require_preserve)