tytso / e2fsprogs

Ext2/3/4 file system utilities
http://ext4.wiki.kernel.org
383 stars 224 forks source link

badblocks: fix status output when bb found #154

Open LaurentChardon opened 1 year ago

LaurentChardon commented 1 year ago

Fixes garbled output when -vv parameter is used and a bad block is found.

Output from test with bad blocks 1024 and 2048. Before:

$ sudo misc/badblocks -vv /dev/sda1
Checking blocks 0 to 204799
Checking for bad blocks (read-only test): 102450% done, 0:00 elapsed. (0/0/0 errors)
204800% done, 0:00 elapsed. (1/0/0 errors)
done                                                 
Pass completed, 2 bad blocks found. (2/0/0 errors)

After:

$ sudo misc/badblocks -vv /dev/sda1
Checking blocks 0 to 204799
Checking for bad blocks (read-only test): 1024                                                                                                                           
2048                                                                                                                           
done                                                 
Pass completed, 2 bad blocks found. (2/0/0 errors)

I moved the function bb_output because it uses print_status that was defined later. The changes in it are where the if (v_flag > 1) blocks are, lines 464-470 and 475-476.

I could have added a function prototype for print_status instead of moving bb_output but that's not done for any other function. I could have added prototypes for all functions instead. I didn't do it so as not to modify the code too much, but let me know if you prefer that I do that.