diff options
author | Theodore Ts'o <tytso@mit.edu> | 2009-08-22 23:02:41 -0400 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2009-08-22 23:04:33 -0400 |
commit | 4087bbd68bc129c19f0130ba36679e3e8c80c617 (patch) | |
tree | 59b6e797bac3249487ae18e7adcffc10b8535f5d /contrib | |
parent | 154a5d7537c35959aa646ef8f18daed8c9f1a2be (diff) | |
download | e2fsprogs-4087bbd68bc129c19f0130ba36679e3e8c80c617.tar.gz |
make-sparse: Write a zero-byte at the end of the image
This is necessary to preserve the i_size of the output file; otherwise
programs like e2fsck will complain that the filesystem has been
truncated.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'contrib')
-rw-r--r-- | contrib/make-sparse.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/contrib/make-sparse.c b/contrib/make-sparse.c index 4a7a3155..1b3d5506 100644 --- a/contrib/make-sparse.c +++ b/contrib/make-sparse.c @@ -48,6 +48,7 @@ int full_read(int fd, char *buf, size_t count) int main(int argc, char **argv) { int fd, got, i; + int zflag = 0; char buf[1024]; if (argc != 2) { @@ -69,11 +70,18 @@ int main(int argc, char **argv) break; if (i == sizeof(buf)) { lseek(fd, sizeof(buf), SEEK_CUR); + zflag = 1; continue; } } + zflag = 0; write(fd, buf, got); } + if (zflag) { + lseek(fd, -1, SEEK_CUR); + buf[0] = 0; + write(fd, buf, 1); + } return 0; } |