Skip to contentSkip to conversation

lguest example launcher truncates block device file to 0 length on problems

PATCH New Rusty Russell 1 participant 1 message Sep 26, 2007 Documentation

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 lguest example launcher truncates block device file to 0 length on problems

From: Chris Malley <[email protected]>

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

Documentation/lguest/lguest.c +1 -1
diff -r bcbb99849fd9 Documentation/lguest/lguest.c
@@ -882,7 +882,7 @@ static u32 handle_block_output(int fd, c
 		 * 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);
 		}