Index: block.c =================================================================== RCS file: /cvsroot/qemu/qemu/block.c,v retrieving revision 1.10 diff -u -r1.10 block.c --- block.c 14 Jul 2004 17:20:30 -0000 1.10 +++ block.c 23 Jul 2004 15:12:21 -0000 @@ -311,6 +311,7 @@ { int ret, n, fd; int64_t offset; + int bytes = 512; if (!bs->inserted) return -1; @@ -320,7 +321,7 @@ fd = bs->cow_fd; offset = bs->cow_sectors_offset; } else if (sector_num == 0 && bs->boot_sector_enabled) { - memcpy(buf, bs->boot_sector_data, 512); + memcpy(buf, bs->boot_sector_data, bytes); n = 1; goto next; } else { @@ -335,8 +336,11 @@ offset += sector_num * 512; lseek64(fd, offset, SEEK_SET); ret = read(fd, buf, n * 512); + if (ret != n * 512) { - return -1; + if (ret == -1) + return -1; + bytes = ret; } } next: