From: Arun Thomas Date: Fri, 9 Nov 2007 20:46:10 +0000 (-0500) Subject: e2image in raw-mode appends an extra byte to image-file X-Git-Tag: v1.40.3~11 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=20abd3ea2ab0b5fe185c459bfc36fec712ad167c;p=thirdparty%2Fe2fsprogs.git e2image in raw-mode appends an extra byte to image-file In raw mode (-r), e2image appends an extra byte to the image-file's end if the last block requires a sparse write. Consequently, the resulting image-file is one byte larger than the original in size. This patch fixes the problem by seeking to one less than the given offset, so that the byte write does not overflow into the next block. This problem can be reproduced by doing an e2image -r dev image-file and comparing the original and resulting image sizes. This assumes the image is sparse at the end. For my tests, I created a 100MB sparse image with two files. Signed-off-by: Arun Thomas Signed-off-by: "Theodore Ts'o" --- diff --git a/misc/e2image.c b/misc/e2image.c index dd13cea5e..b4836eafd 100644 --- a/misc/e2image.c +++ b/misc/e2image.c @@ -440,7 +440,8 @@ static void output_meta_data_blocks(ext2_filsys fs, int fd) } } } - write_block(fd, zero_buf, sparse, 1, -1); + if (sparse) + write_block(fd, zero_buf, sparse-1, 1, -1); free(zero_buf); free(buf); }