From: Gao Xiang Date: Sun, 9 Feb 2025 03:51:24 +0000 (+0800) Subject: erofs-utils: lib: tar: keep non-existent directories with their parents X-Git-Tag: accepted/tizen/unified/20250610.081809~45 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=19db1bca00215341b12f9c2e3680f036ed700404;p=platform%2Fupstream%2Ferofs-utils.git erofs-utils: lib: tar: keep non-existent directories with their parents To avoid lack of basic permissions for now. Signed-off-by: Gao Xiang Link: https://lore.kernel.org/r/20250209035124.2168333-1-hsiangkao@linux.alibaba.com --- diff --git a/lib/rebuild.c b/lib/rebuild.c index 3e58f00..5787bb3 100644 --- a/lib/rebuild.c +++ b/lib/rebuild.c @@ -25,6 +25,14 @@ #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);