]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
copy: optionally apply source inode's stat() when doing a merge copy
authorLennart Poettering <lennart@poettering.net>
Tue, 19 Aug 2025 19:17:32 +0000 (21:17 +0200)
committerLennart Poettering <lennart@poettering.net>
Tue, 21 Oct 2025 21:09:50 +0000 (23:09 +0200)
src/shared/copy.c
src/shared/copy.h

index 981427214ba43d217ac09fcf31f1b90955f08789..baed8b06961a1bf8b39659a87fcc0227fe931403 100644 (file)
@@ -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)
index d4b131d10259a871fc6f9b2cce3b24084e93e32e..8dd3176e8e4f7b7219072390501bd9a3240e7f50 100644 (file)
@@ -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 {