Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1Bo1mx-000556-UN for qemu-devel@nongnu.org; Fri, 23 Jul 2004 11:16:48 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1Bo1mx-00054u-EF for qemu-devel@nongnu.org; Fri, 23 Jul 2004 11:16:47 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1Bo1mv-00054q-EU for qemu-devel@nongnu.org; Fri, 23 Jul 2004 11:16:47 -0400 Received: from [194.105.28.94] (helo=iv.ro) by monty-python.gnu.org with smtp (Exim 4.34) id 1Bo1ju-0005Wp-Mx for qemu-devel@nongnu.org; Fri, 23 Jul 2004 11:13:39 -0400 Date: Fri, 23 Jul 2004 18:12:28 +0300 From: Jani Monoses Subject: Re: [Qemu-devel] QEMU floppy problems (was: ecos and qemu) Message-Id: <20040723181228.4eee1763.jani@iv.ro> In-Reply-To: References: <20040723111415.4c10521f.jani@iv.ro> <87oem6vkcs.fsf@benpfaff.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="Multipart=_Fri__23_Jul_2004_18_12_28_+0300_NqGV7cpg.=mlcMoZ" Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org This is a multi-part message in MIME format. --Multipart=_Fri__23_Jul_2004_18_12_28_+0300_NqGV7cpg.=mlcMoZ Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit and this patch fixes it :) it's ugly though... does it work for you guys? Jani --Multipart=_Fri__23_Jul_2004_18_12_28_+0300_NqGV7cpg.=mlcMoZ Content-Type: text/x-diff; name=",l.diff" Content-Disposition: attachment; filename=",l.diff" Content-Transfer-Encoding: 7bit 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: --Multipart=_Fri__23_Jul_2004_18_12_28_+0300_NqGV7cpg.=mlcMoZ--