From 8ee07437322862dbe631f04e817d8c371fd28ec6 Mon Sep 17 00:00:00 2001 From: Sandeep Dhavale Date: Thu, 5 Oct 2023 15:40:08 -0700 Subject: erofs-utils: Fix cross compile with autoconf AC_RUN_IFELSE expects the action if cross compiling. If not provided cross compilation fails with error "configure: error: cannot run test program while cross compiling". Use 4096 as the buest guess PAGESIZE if cross compiling as it is still the most common page size. Reported-in: https://lore.kernel.org/all/0101018aec71b531-0a354b1a-0b70-47a1-8efc-fea8c439304c-000000@us-west-2.amazonses.com/ Fixes: 8ee2e591dfd6 ("erofs-utils: support detecting maximum block size") Signed-off-by: Sandeep Dhavale Link: https://lore.kernel.org/r/20231005224008.817830-1-dhavale@google.com Signed-off-by: Gao Xiang --- configure.ac | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 13ee616..a546310 100644 --- a/configure.ac +++ b/configure.ac @@ -284,8 +284,8 @@ AS_IF([test "x$MAX_BLOCK_SIZE" = "x"], [ return 0; ]])], [erofs_cv_max_block_size=`cat conftest.out`], - [], - [])) + [erofs_cv_max_block_size=4096], + [erofs_cv_max_block_size=4096])) ], [erofs_cv_max_block_size=$MAX_BLOCK_SIZE]) # Configure debug mode -- cgit v1.2.3 From c0b5c3d2a85bc13c7b92a6de3be16c60c2308a0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20Sj=C3=B6lund?= Date: Mon, 2 Oct 2023 19:36:08 +0200 Subject: erofs-utils: errno shouldn't set to a negative value in lib/tar.c `errno` should be set to a non-negative value here. Link: https://lore.kernel.org/r/CAB+1q0Q3+7s1Lt8uW6DWZ7vfjhEKhG7O7MAQhCuH-C10cr9F4g@mail.gmail.com Signed-off-by: Gao Xiang --- lib/tar.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tar.c b/lib/tar.c index 0744972..8204939 100644 --- a/lib/tar.c +++ b/lib/tar.c @@ -241,7 +241,7 @@ static long long tarerofs_otoi(const char *ptr, int len) val = strtol(ptr, &endp, 8); if ((!val && endp == inp) | (*endp && *endp != ' ')) - errno = -EINVAL; + errno = EINVAL; return val; } -- cgit v1.2.3 From 8cbc205185a18b9510f4c1fbd54957354f696321 Mon Sep 17 00:00:00 2001 From: Gao Xiang Date: Tue, 17 Oct 2023 22:44:20 +0800 Subject: erofs-utils: mkfs: fix corrupted directories with hardlinks An inode with hard links may belong to several directories. It's invalid to update `subdirs_queued` for hard-link inodes since it only records one of the parent directories. References: https://github.com/NixOS/nixpkgs/issues/261394 Fixes: 21d84349e79a ("erofs-utils: rearrange on-disk metadata") Signed-off-by: Gao Xiang Link: https://lore.kernel.org/r/20231017144420.289469-1-hsiangkao@linux.alibaba.com --- include/erofs/internal.h | 5 +++-- lib/inode.c | 29 ++++++++++++----------------- 2 files changed, 15 insertions(+), 19 deletions(-) diff --git a/include/erofs/internal.h b/include/erofs/internal.h index d859905..c1ff582 100644 --- a/include/erofs/internal.h +++ b/include/erofs/internal.h @@ -159,8 +159,9 @@ struct erofs_inode { union { /* (erofsfuse) runtime flags */ unsigned int flags; - /* (mkfs.erofs) queued sub-directories blocking dump */ - u32 subdirs_queued; + + /* (mkfs.erofs) next pointer for directory dumping */ + struct erofs_inode *next_dirwrite; }; unsigned int i_count; struct erofs_sb_info *sbi; diff --git a/lib/inode.c b/lib/inode.c index fb062a1..71af396 100644 --- a/lib/inode.c +++ b/lib/inode.c @@ -1210,7 +1210,6 @@ fail: inode->i_parent = dir; erofs_igrab(inode); list_add_tail(&inode->i_subdirs, dirs); - ++dir->subdirs_queued; } ftype = erofs_mode_to_ftype(inode->i_mode); i_nlink += (ftype == EROFS_FT_DIR); @@ -1235,17 +1234,10 @@ err_closedir: return ret; } -static void erofs_mkfs_dump_directory(struct erofs_inode *dir) -{ - erofs_write_dir_file(dir); - erofs_write_tail_end(dir); - dir->bh->op = &erofs_write_inode_bhops; -} - struct erofs_inode *erofs_mkfs_build_tree_from_path(const char *path) { LIST_HEAD(dirs); - struct erofs_inode *inode, *root, *parent; + struct erofs_inode *inode, *root, *dumpdir; root = erofs_iget_from_path(path, true); if (IS_ERR(root)) @@ -1253,9 +1245,9 @@ struct erofs_inode *erofs_mkfs_build_tree_from_path(const char *path) (void)erofs_igrab(root); root->i_parent = root; /* rootdir mark */ - root->subdirs_queued = 1; list_add(&root->i_subdirs, &dirs); + dumpdir = NULL; do { int err; char *trimmed; @@ -1275,15 +1267,18 @@ struct erofs_inode *erofs_mkfs_build_tree_from_path(const char *path) root = ERR_PTR(err); break; } - parent = inode->i_parent; - DBG_BUGON(!parent->subdirs_queued); - if (S_ISDIR(inode->i_mode) && !inode->subdirs_queued) - erofs_mkfs_dump_directory(inode); - if (!--parent->subdirs_queued) - erofs_mkfs_dump_directory(parent); - erofs_iput(inode); + if (S_ISDIR(inode->i_mode)) { + inode->next_dirwrite = dumpdir; + dumpdir = inode; + } } while (!list_empty(&dirs)); + + for (; dumpdir; dumpdir = dumpdir->next_dirwrite) { + erofs_write_dir_file(dumpdir); + erofs_write_tail_end(dumpdir); + dumpdir->bh->op = &erofs_write_inode_bhops; + } return root; } -- cgit v1.2.3 From 8300aaba8e8d6a755718313e7169534f021c8cf2 Mon Sep 17 00:00:00 2001 From: Gao Xiang Date: Fri, 20 Oct 2023 06:43:28 +0800 Subject: erofs-utils: fix reference leak in erofs_mkfs_build_tree_from_path() commit 8cbc205185a1 ("erofs-utils: mkfs: fix corrupted directories with hardlinks") introduced a reference leak although it has no real impact to users. Fix it now. Signed-off-by: Gao Xiang Link: https://lore.kernel.org/r/20231019224328.26015-1-xiang@kernel.org --- lib/inode.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/inode.c b/lib/inode.c index 71af396..8409ccd 100644 --- a/lib/inode.c +++ b/lib/inode.c @@ -1271,13 +1271,18 @@ struct erofs_inode *erofs_mkfs_build_tree_from_path(const char *path) if (S_ISDIR(inode->i_mode)) { inode->next_dirwrite = dumpdir; dumpdir = inode; + } else { + erofs_iput(inode); } } while (!list_empty(&dirs)); - for (; dumpdir; dumpdir = dumpdir->next_dirwrite) { - erofs_write_dir_file(dumpdir); - erofs_write_tail_end(dumpdir); - dumpdir->bh->op = &erofs_write_inode_bhops; + while (dumpdir) { + inode = dumpdir; + erofs_write_dir_file(inode); + erofs_write_tail_end(inode); + inode->bh->op = &erofs_write_inode_bhops; + dumpdir = inode->next_dirwrite; + erofs_iput(inode); } return root; } -- cgit v1.2.3 From 83d94dc619075e71ca4d0f42941cfc18d269a2af Mon Sep 17 00:00:00 2001 From: Gao Xiang Date: Fri, 20 Oct 2023 06:45:01 +0800 Subject: erofs-utils: release 1.7.1 Signed-off-by: Gao Xiang --- ChangeLog | 9 +++++++++ VERSION | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2387d07..99220c8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +erofs-utils 1.7.1 + + * A quick maintenance release includes the following fixes: + - fix a build issue of cross-compilation with autoconf (Sandeep Dhavale); + - fix an invalid error code in lib/tar.c (Erik Sjölund); + - fix corrupted directories with hardlinks. + + -- Gao Xiang Fri, 20 Oct 2023 00:00:00 +0800 + erofs-utils 1.7 * This release includes the following updates: diff --git a/VERSION b/VERSION index 04ee5d6..8cf9ed8 100644 --- a/VERSION +++ b/VERSION @@ -1,2 +1,2 @@ -1.7 -2023-09-21 +1.7.1 +2023-10-20 -- cgit v1.2.3