[PATCH] uml: fix off-by-one bug in VM file creation

Fix an off-by-one bug in temp file creation.  Seeking to the desired length
and writing a byte resulted in the file being one byte longer than expected.

Signed-off-by: Jeff Dike <jdike@addtoit.com>
Cc: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This commit is contained in:
Jeff Dike 2006-06-30 01:55:55 -07:00 committed by Linus Torvalds
parent c2b7a4bb30
commit 190f493922

View File

@ -210,8 +210,11 @@ int create_tmp_file(unsigned long long len)
exit(1);
}
if (lseek64(fd, len, SEEK_SET) < 0) {
perror("os_seek_file");
/* Seek to len - 1 because writing a character there will
* increase the file size by one byte, to the desired length.
*/
if (lseek64(fd, len - 1, SEEK_SET) < 0) {
perror("os_seek_file");
exit(1);
}