From: Hongzhen Luo Date: Wed, 27 Nov 2024 11:13:46 +0000 (+0800) Subject: erofs-utils: rebuild: set the appropriate `dev` field for dirs X-Git-Tag: accepted/tizen/unified/20250610.081809~88 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=80156068eb4980342c0ad3ee47ac7261acce5caf;p=platform%2Fupstream%2Ferofs-utils.git erofs-utils: rebuild: set the appropriate `dev` field for dirs Currently, setting a default `dev` value (i.e., 0) for directories during parsing tar files can lead to the following error: erofs: bogus i_mode (0) @ nid 0 erofs: failed to read inode @ 0 Consider the following incremental build scenario, where the path "dir1/dir2" is currently being parsed in tarerofs_parse_tar() and the directory "dir1" has never appeared before. `erofs_rebuild_get_dentry()` will call erofs_rebuild_mkdir() to allocate a new inode for "dir1", with its `dev` field set to 0 by default. During the dump tree phase, since `dir1->dev` matches `sbi->dev` (both are 0), erofs_rebuild_load_basedir() will be called to read the contents of directory "dir1" from the disk. However, since there is no information for the new directory "dir1" on the disk, the above error occurs. This patch resolves the above issue by setting the appropriate value for the directory's `dev` field during the tar file parsing phase. Fixes: f64d9d02576b ("erofs-utils: introduce incremental builds") Signed-off-by: Hongzhen Luo Link: https://lore.kernel.org/r/20241127111346.49290-1-hongzhen@linux.alibaba.com Signed-off-by: Gao Xiang --- diff --git a/lib/rebuild.c b/lib/rebuild.c index b37823e..3e58f00 100644 --- a/lib/rebuild.c +++ b/lib/rebuild.c @@ -46,6 +46,7 @@ static struct erofs_dentry *erofs_rebuild_mkdir(struct erofs_inode *dir, inode->i_gid = getgid(); inode->i_mtime = inode->sbi->build_time; inode->i_mtime_nsec = inode->sbi->build_time_nsec; + inode->dev = dir->dev; erofs_init_empty_dir(inode); d = erofs_d_alloc(dir, s); diff --git a/lib/tar.c b/lib/tar.c index 990c6cb..0dd990e 100644 --- a/lib/tar.c +++ b/lib/tar.c @@ -667,6 +667,7 @@ int tarerofs_parse_tar(struct erofs_inode *root, struct erofs_tarfile *tar) unsigned int j, csum, cksum; int ckksum, ret, rem; + root->dev = tar->dev; if (eh.path) eh.path = strdup(eh.path); if (eh.link)