]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
e2image: fix logic bug which could cause a raw image not to be extended
authorTheodore Ts'o <tytso@mit.edu>
Fri, 17 Feb 2012 14:19:33 +0000 (09:19 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Fri, 17 Feb 2012 20:28:20 +0000 (15:28 -0500)
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" <tytso@mit.edu>
misc/e2image.c

index d888e5aee1231c61b3a94c7ab3594acc1260a934..3cb92fee27763ac56c970c5a15d4ef3faff5a1a3 100644 (file)
@@ -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;
                        }
                }
        }