[hackers] [sbase] cp: Also preserve atime/mtime for symlinks || Michael Forney
commit 24810426519a002749016cbb04e6c21cd2d890cb
Author: Michael Forney <mforney_AT_mforney.org>
AuthorDate: Tue Dec 27 14:49:57 2016 +0100
Commit: Laslo Hunhold <dev_AT_frign.de>
CommitDate: Tue Dec 27 14:50:58 2016 +0100
cp: Also preserve atime/mtime for symlinks
Laslo: Fixed style a bit and added comment
diff --git a/libutil/cp.c b/libutil/cp.c
index 7d4c174..9bb517a 100644
--- a/libutil/cp.c
+++ b/libutil/cp.c
_AT_@ -152,14 +152,16 @@ cp(const char *s1, const char *s2, int depth)
}
if (cp_aflag || cp_pflag) {
- /* timestamp and owner */
+ /* atime and mtime */
+ times[0] = st.st_atim;
+ times[1] = st.st_mtim;
+ if (utimensat(AT_FDCWD, s2, times, AT_SYMLINK_NOFOLLOW) < 0) {
+ weprintf("utimensat %s:", s2);
+ cp_status = 1;
+ }
+
+ /* owner */
if (!S_ISLNK(st.st_mode)) {
- times[0] = st.st_atim;
- times[1] = st.st_mtim;
- if (utimensat(AT_FDCWD, s2, times, 0) < 0) {
- weprintf("utimensat %s:", s2);
- cp_status = 1;
- }
if (chown(s2, st.st_uid, st.st_gid) < 0) {
weprintf("chown %s:", s2);
cp_status = 1;
Received on Tue Dec 27 2016 - 15:04:03 CET
This archive was generated by hypermail 2.3.0
: Tue Dec 27 2016 - 15:13:48 CET