1
0
mirror of https://github.com/systemd/systemd.git synced 2025-01-11 09:18:07 +03:00

copy: also attempt to copy atime/mtime when copying symlinks, device nodes, fifos

This commit is contained in:
Lennart Poettering 2021-02-01 16:57:46 +01:00
parent 0fb613000d
commit fb934d53f9

View File

@ -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;
}