[PATCH] erofs-utils: fsck: fix directory loop tracking
Vansh Choudhary
ch at vnsh.in
Sun Mar 22 01:28:52 AEDT 2026
Store the current directory nid in the recursion stack.
The loop check compares inode.nid against the entries already on the
stack, so pushing pnid there can miss self-referential directory loops
and report the wrong failure later.
Signed-off-by: Vansh Choudhary <ch at vnsh.in>
---
fsck/main.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fsck/main.c b/fsck/main.c
index 16a354f..3530707 100644
--- a/fsck/main.c
+++ b/fsck/main.c
@@ -1022,7 +1022,7 @@ static int erofsfsck_check_inode(erofs_nid_t pnid, erofs_nid_t nid)
for (i = 0; i < fsckcfg.dirstack.top; ++i)
if (inode.nid == fsckcfg.dirstack.dirs[i])
return -ELOOP;
- fsckcfg.dirstack.dirs[fsckcfg.dirstack.top++] = pnid;
+ fsckcfg.dirstack.dirs[fsckcfg.dirstack.top++] = inode.nid;
ret = erofs_iterate_dir(&ctx, true);
--fsckcfg.dirstack.top;
}
--
2.51.0
More information about the Linux-erofs
mailing list