diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2005-09-23 20:38:34 +0000 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2005-09-23 20:38:34 +0000 |
commit | 35044438af981921afed8284bc8aea687bcba2d0 (patch) | |
tree | 0248724f8423423b998095712812d9821414f689 | |
parent | 2c4a088886d61229807a6028c0440a079a6e9014 (diff) | |
download | coreutils-35044438af981921afed8284bc8aea687bcba2d0.tar.xz |
(copy_reg): Preserve time stamps if
x->preserve_timestamps is set, using futimens so that
we needn't resolve the path again.
(copy_internal): Don't preserve time stamps if copy_reg did it
already.
-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); |