From: Theodore Ts'o Date: Wed, 27 Feb 2008 18:38:56 +0000 (-0500) Subject: debugfs: Fix find_free_block to avoid reporting the block more than once X-Git-Tag: v1.40.7~15 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5aae7c292fe0e10ec4e36d664da86939d15aca31;p=thirdparty%2Fe2fsprogs.git debugfs: Fix find_free_block to avoid reporting the block more than once Addresses-Sourceforge-Bug: #1096315 Signed-off-by: "Theodore Ts'o" --- diff --git a/debugfs/debugfs.c b/debugfs/debugfs.c index 818ce530a..a92933d20 100644 --- a/debugfs/debugfs.c +++ b/debugfs/debugfs.c @@ -1155,7 +1155,7 @@ void do_unlink(int argc, char *argv[]) void do_find_free_block(int argc, char *argv[]) { - blk_t free_blk, goal; + blk_t free_blk, goal, first_free = 0; int count; errcode_t retval; char *tmp; @@ -1191,6 +1191,11 @@ void do_find_free_block(int argc, char *argv[]) while (count-- > 0) { retval = ext2fs_new_block(current_fs, free_blk + 1, 0, &free_blk); + if (first_free) { + if (first_free == free_blk) + break; + } else + first_free = free_blk; if (retval) { com_err("ext2fs_new_block", retval, 0); return;