From: Lennart Poettering Date: Tue, 19 Aug 2025 19:17:32 +0000 (+0200) Subject: copy: optionally apply source inode's stat() when doing a merge copy X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=0a9e2e45f03b605b59b8b20c0968524ff4ff8714;p=thirdparty%2Fsystemd.git copy: optionally apply source inode's stat() when doing a merge copy --- diff --git a/src/shared/copy.c b/src/shared/copy.c index 981427214ba..baed8b06961 100644 --- a/src/shared/copy.c +++ b/src/shared/copy.c @@ -1257,7 +1257,7 @@ static int fd_copy_directory( } finish: - if (!exists) { + if (FLAGS_SET(copy_flags, COPY_MERGE_APPLY_STAT) || !exists) { if (fchown(fdt, uid_is_valid(override_uid) ? override_uid : st->st_uid, gid_is_valid(override_gid) ? override_gid : st->st_gid) < 0) diff --git a/src/shared/copy.h b/src/shared/copy.h index d4b131d1025..8dd3176e8e4 100644 --- a/src/shared/copy.h +++ b/src/shared/copy.h @@ -33,6 +33,7 @@ typedef enum CopyFlags { */ COPY_NOCOW_AFTER = 1 << 20, COPY_PRESERVE_FS_VERITY = 1 << 21, /* Preserve fs-verity when copying. */ + COPY_MERGE_APPLY_STAT = 1 << 22, /* When we reuse an existing directory inode, apply source ownership/mode/xattrs/timestamps */ } CopyFlags; typedef enum DenyType {