Whamcloud - gitweb
debugfs: Fix find_free_block to avoid reporting the block more than once
authorTheodore Ts'o <tytso@mit.edu>
Wed, 27 Feb 2008 18:38:56 +0000 (13:38 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Wed, 27 Feb 2008 18:38:56 +0000 (13:38 -0500)
Addresses-Sourceforge-Bug: #1096315

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
debugfs/debugfs.c

index 818ce53..a92933d 100644 (file)
@@ -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;