erofs-utils: lib: tar: keep non-existent directories with their parents
authorGao Xiang <hsiangkao@linux.alibaba.com>
Sun, 9 Feb 2025 03:51:24 +0000 (11:51 +0800)
committerGao Xiang <hsiangkao@linux.alibaba.com>
Sun, 9 Feb 2025 06:34:48 +0000 (14:34 +0800)
To avoid lack of basic permissions for now.

Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Link: https://lore.kernel.org/r/20250209035124.2168333-1-hsiangkao@linux.alibaba.com
lib/rebuild.c

index 3e58f00e0b2c30ad200bbb06cd36b4f1f7813bd1..5787bb36f30e6405e5f074b8a8673cd5bebaa527 100644 (file)
 #define AUFS_WH_DIROPQ         AUFS_WH_PFX AUFS_DIROPQ_NAME
 #endif
 
+/*
+ * These non-existent parent directories are created with the same permissions
+ * as their parent directories.  It is expected that a call to create these
+ * parent directories with the correct permissions will be made later, at which
+ * point the permissions will be updated.  We handle mtime in the same way.
+ * Also see: https://github.com/containerd/containerd/issues/3017
+ *           https://github.com/containerd/containerd/pull/3528
+ */
 static struct erofs_dentry *erofs_rebuild_mkdir(struct erofs_inode *dir,
                                                const char *s)
 {
@@ -41,11 +49,15 @@ static struct erofs_dentry *erofs_rebuild_mkdir(struct erofs_inode *dir,
                return ERR_PTR(-ENOMEM);
        }
        inode->i_mode = S_IFDIR | 0755;
+       if (dir->i_mode & S_IWGRP)
+               inode->i_mode |= S_IWGRP;
+       if (dir->i_mode & S_IWOTH)
+               inode->i_mode |= S_IWOTH;
        inode->i_parent = dir;
-       inode->i_uid = getuid();
-       inode->i_gid = getgid();
-       inode->i_mtime = inode->sbi->build_time;
-       inode->i_mtime_nsec = inode->sbi->build_time_nsec;
+       inode->i_uid = dir->i_uid;
+       inode->i_gid = dir->i_gid;
+       inode->i_mtime = dir->i_mtime;
+       inode->i_mtime_nsec = dir->i_mtime_nsec;
        inode->dev = dir->dev;
        erofs_init_empty_dir(inode);