summaryrefslogtreecommitdiff
path: root/src/basic
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2021-02-01 16:57:46 +0100
committerLennart Poettering <lennart@poettering.net>2021-02-03 23:24:55 +0100
commitfb934d53f90dafeed9c39468ce2c3a73baf4d71d (patch)
tree969d85dcdc4c89c2c316b7d0e649c4361af357ce /src/basic
parent0fb613000de5e3ae343778290bed0ff9e9f741e4 (diff)
downloadsystemd-fb934d53f90dafeed9c39468ce2c3a73baf4d71d.tar.gz
copy: also attempt to copy atime/mtime when copying symlinks, device nodes, fifos
Diffstat (limited to 'src/basic')
-rw-r--r--src/basic/copy.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/basic/copy.c b/src/basic/copy.c
index aa805bb8e2..c2c337c1a1 100644
--- a/src/basic/copy.c
+++ b/src/basic/copy.c
@@ -391,9 +391,10 @@ static int fd_copy_symlink(
uid_is_valid(override_uid) ? override_uid : st->st_uid,
gid_is_valid(override_gid) ? override_gid : st->st_gid,
AT_SYMLINK_NOFOLLOW) < 0)
- return -errno;
+ r = -errno;
- return 0;
+ (void) utimensat(dt, to, (struct timespec[]) { st->st_atim, st->st_mtim }, AT_SYMLINK_NOFOLLOW);
+ return r;
}
/* Encapsulates the database we store potential hardlink targets in */
@@ -693,6 +694,8 @@ static int fd_copy_fifo(
if (fchmodat(dt, to, st->st_mode & 07777, 0) < 0)
r = -errno;
+ (void) utimensat(dt, to, (struct timespec[]) { st->st_atim, st->st_mtim }, AT_SYMLINK_NOFOLLOW);
+
(void) memorize_hardlink(hardlink_context, st, dt, to);
return r;
}
@@ -739,6 +742,8 @@ static int fd_copy_node(
if (fchmodat(dt, to, st->st_mode & 07777, 0) < 0)
r = -errno;
+ (void) utimensat(dt, to, (struct timespec[]) { st->st_atim, st->st_mtim }, AT_SYMLINK_NOFOLLOW);
+
(void) memorize_hardlink(hardlink_context, st, dt, to);
return r;
}