diff options
Diffstat (limited to 'src/copy.c')
-rw-r--r-- | src/copy.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/copy.c b/src/copy.c index ba6ce4860..026a18d3a 100644 --- a/src/copy.c +++ b/src/copy.c @@ -403,6 +403,20 @@ copy_reg (char const *src_name, char const *dst_name, } } + if (x->preserve_timestamps) + { + struct timespec timespec[2]; + timespec[0] = get_stat_atime (src_sb); + timespec[1] = get_stat_mtime (src_sb); + + if (futimens (dest_desc, dst_name, timespec) != 0) + { + error (0, errno, _("preserving times for %s"), quote (dst_name)); + if (x->require_preserve) + return_val = false; + } + } + close_src_and_dst_desc: if (close (dest_desc) < 0) { @@ -1564,10 +1578,9 @@ copy_internal (char const *src_name, char const *dst_name, chown turns off set[ug]id bits for non-root, so do the chmod last. */ - if (x->preserve_timestamps) + if (!copied_as_regular && x->preserve_timestamps) { struct timespec timespec[2]; - timespec[0] = get_stat_atime (&src_sb); timespec[1] = get_stat_mtime (&src_sb); |