diff options
author | Arun Thomas <thomasar@us.ibm.com> | 2007-11-09 15:46:10 -0500 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2007-11-26 06:26:31 -0500 |
commit | 20abd3ea2ab0b5fe185c459bfc36fec712ad167c (patch) | |
tree | 9815a53066da3470b5e47ec86c69992142e32523 /misc/e2image.c | |
parent | 3eaf8627b0cd94aeb3a3a56709e80d02a38ae939 (diff) | |
download | e2fsprogs-20abd3ea2ab0b5fe185c459bfc36fec712ad167c.tar.gz |
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 <thomasar@us.ibm.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'misc/e2image.c')
-rw-r--r-- | misc/e2image.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/misc/e2image.c b/misc/e2image.c index dd13cea5..b4836eaf 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); } |