erofs-utils: lib: fix --force-{g,u}id support for tarerofs
PATCH 1/1 erofs-utils: lib: fix --force-{g,u}id support for tarerofs
Temporarily move the common part into __erofs_fill_inode() for tarerofs.
Signed-off-by Gao Xiang <[email protected]>
--- include/erofs/inode.h | 2 ++ lib/inode.c | 19 ++++++++++++++++--- lib/tar.c | 16 ++++++++++------ 3 files changed, 28 insertions(+), 9 deletions(-)
include/erofs/inode.h +2 -0
@@ -34,6 +34,8 @@ struct erofs_dentry *erofs_d_alloc(struct erofs_inode *parent, const char *name);int erofs_rebuild_dump_tree (struct erofs_inode *dir);int erofs_init_empty_dir (struct erofs_inode *dir); +int __erofs_fill_inode (struct erofs_inode *inode,struct stat *st, +const char *path);struct erofs_inode *erofs_new_inode (void );struct erofs_inode *erofs_mkfs_build_tree_from_path (const char *path);struct erofs_inode *erofs_mkfs_build_special_from_fd (int fd,const char *name);
lib/inode.c +16 -3
@@ -912,15 +912,15 @@ static int erofs_droid_inode_fsconfig(struct erofs_inode *inode, }#endif -static int erofs_fill_inode (struct erofs_inode *inode,struct stat *st, -const char *path) +int __erofs_fill_inode (struct erofs_inode *inode,struct stat *st, +const char *path) {int err =erofs_droid_inode_fsconfig (inode, st, path);struct erofs_sb_info *sbi = inode->sbi;if (err)return err; - inode->i_mode = st->st_mode; + inode->i_uid = cfg.c_uid ==-1 ? st->st_uid : cfg.c_uid; inode->i_gid = cfg.c_gid ==-1 ? st->st_gid : cfg.c_gid;
@@ -945,6 +945,19 @@ static int erofs_fill_inode(struct erofs_inode *inode, struct stat *st,default :break ; } + +return 0 ; +} + +static int erofs_fill_inode (struct erofs_inode *inode,struct stat *st, +const char *path) +{ +int err =__erofs_fill_inode (inode, st, path); + +if (err) +return err; + + inode->i_mode = st->st_mode; inode->i_nlink =1 ;/* fix up later if needed */ switch (inode->i_mode &S_IFMT ) {
lib/tar.c +10 -6
@@ -923,11 +923,17 @@ new_inode:if (S_ISBLK (st.st_mode) ||S_ISCHR (st.st_mode)) inode->u.i_rdev =erofs_new_encode_dev (st.st_rdev); } + inode->i_srcpath =strdup (eh.path); - inode->i_uid = st.st_uid; - inode->i_gid = st.st_gid; +if (!inode->i_srcpath) { + ret = -ENOMEM ; + goto out; + } + + ret =__erofs_fill_inode (inode, &st, eh.path); +if (ret) + goto out; inode->i_size = st.st_size; - inode->i_mtime = st.st_mtime;if (!S_ISDIR (inode->i_mode)) {if (S_ISLNK (inode->i_mode)) {
@@ -940,10 +946,8 @@ new_inode: data_offset); else ret =tarerofs_write_file_data (inode, tar); -if (ret) { -erofs_iput (inode); +if (ret) goto out; - } } inode->i_nlink++; }else if (!inode->i_nlink) {
Signature · 1 line
2.39.3