From: Theodore Ts'o Date: Fri, 17 Feb 2012 14:19:33 +0000 (-0500) Subject: e2image: fix logic bug which could cause a raw image not to be extended X-Git-Tag: v1.42.1~12 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=2b7a30cc52fd27a1cf479d8682880d11ffd9850f;p=tools%2Fe2fsprogs.git e2image: fix logic bug which could cause a raw image not to be extended If the size of the last "hole" in the raw file was an exact multiple of a megabyte, then we wouldn't write a null at the end of the file in order to extend the size of the raw image to correspond with the file system size. Thanks to Lukas Czerner for suggesting the fix, and Phillip Susi for pointing out the problem. Signed-off-by: "Theodore Ts'o" --- diff --git a/misc/e2image.c b/misc/e2image.c index d888e5a..3cb92fe 100644 --- a/misc/e2image.c +++ b/misc/e2image.c @@ -504,10 +504,9 @@ static void output_meta_data_blocks(ext2_filsys fs, int fd) continue; } sparse += fs->blocksize; - if (sparse >= 1024*1024) { - - write_block(fd, 0, sparse, 0, 0); - sparse = 0; + if (sparse > 1024*1024) { + write_block(fd, 0, 1024*1024, 0, 0); + sparse -= 1024*1024; } } }