Skip to content

Commit

Permalink
lguest example launcher truncates block device file to 0 length on pr…
Browse files Browse the repository at this point in the history
…oblems

The function should also use ftruncate64() rather than ftruncate() to prevent
files over 4GB (not uncommon for a root filesystem) being zeroed.

Signed-off-by: Chris Malley <mail@chrismalley.co.uk>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Chris Malley authored and Linus Torvalds committed Sep 26, 2007
1 parent 78bd8fb commit f6a592e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion Documentation/lguest/lguest.c
Original file line number Diff line number Diff line change
Expand Up @@ -882,7 +882,7 @@ static u32 handle_block_output(int fd, const struct iovec *iov,
* of the block file (possibly extending it). */
if (off + len > device_len) {
/* Trim it back to the correct length */
ftruncate(dev->fd, device_len);
ftruncate64(dev->fd, device_len);
/* Die, bad Guest, die. */
errx(1, "Write past end %llu+%u", off, len);
}
Expand Down

0 comments on commit f6a592e

Please sign in to comment.