From 11de9261c156e2b274aab0997808a1eb3cf1ddb5 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Fri, 30 May 2008 15:23:24 -0400 Subject: [PATCH] e2fsck: Don't double count an extent after deleting the last extent ext2fs_extent_delete() will leave the extent handle pointing at the next extent --- except if the last extent in the node. To deal with this last case, call ext2fs_get_extent_info() and stop scanning after processing info->num_entries extents. Signed-off-by: "Theodore Ts'o" --- e2fsck/pass1.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/e2fsck/pass1.c b/e2fsck/pass1.c index 5ca2d83b..c36683e7 100644 --- a/e2fsck/pass1.c +++ b/e2fsck/pass1.c @@ -1622,11 +1622,15 @@ static void scan_extent_node(e2fsck_t ctx, struct problem_context *pctx, int i; int is_dir, is_leaf; errcode_t problem; + struct ext2_extent_info info; + pctx->errcode = ext2fs_extent_get_info(ehandle, &info); + if (pctx->errcode) + return; pctx->errcode = ext2fs_extent_get(ehandle, EXT2_EXTENT_FIRST_SIB, &extent); - while (!pctx->errcode) { + while (!pctx->errcode && info.num_entries-- > 0) { is_leaf = extent.e_flags & EXT2_EXTENT_FLAGS_LEAF; is_dir = LINUX_S_ISDIR(pctx->inode->i_mode); -- 2.11.0