Fix Bug to corrupt the img file
PATCH RESEND v2 1/1 Fix Bug to corrupt the img file
From: Rock <[email protected]>
Reproduce steps:
Quoted 2 lines
dd if=/dev/zero of=btrfs-small.img bs=1M count=1
ls -lh btrfs-small.img
-rw-rw-r--. 1 rock rock 1.0M Oct 24 09:51 btrfs-small.img
^^^
Quoted 1 line
mkfs.btrfs btrfs-small.img
-rw-rw-r--. 1 rock rock 2.0M Oct 24 09:53 btrfs-small.img
^^^
Here you can see the original img file's size goes larger to 2Mb.
Signed-off-by Rock Lee <[email protected]>
--- utils.c | 6 ++++++ 1 file changed, 6 insertions(+)
utils.c +6 -0
@@ -557,6 +557,12 @@ int btrfs_prepare_device(int fd, char *file, int zero_end, u64 *block_count_ret, }if (max_block_count) block_count =min (block_count, max_block_count); + +if (block_count <2 *1024 *1024 ) { +fprintf (stderr,"size of %s is too small(less than 2Mb)\n" , file); +exit (1 ); + } + zero_end =1 ;if (block_count <1024 *1024 *1024 && !(*mixed)) {
Signature · 1 line
1.7.9.5