From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LRV0I-0003ke-0J for qemu-devel@nongnu.org; Mon, 26 Jan 2009 12:12:06 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LRV0G-0003jt-Ly for qemu-devel@nongnu.org; Mon, 26 Jan 2009 12:12:05 -0500 Received: from [199.232.76.173] (port=38141 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LRV0G-0003jR-BX for qemu-devel@nongnu.org; Mon, 26 Jan 2009 12:12:04 -0500 Received: from ns.suse.de ([195.135.220.2]:55279 helo=mx1.suse.de) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LRV0B-00047b-4n for qemu-devel@nongnu.org; Mon, 26 Jan 2009 12:12:00 -0500 Received: from Relay2.suse.de (mail2.suse.de [195.135.221.8]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.suse.de (Postfix) with ESMTP id C09E74459C for ; Mon, 26 Jan 2009 17:53:07 +0100 (CET) From: Kevin Wolf Date: Mon, 26 Jan 2009 17:59:24 +0100 Message-Id: <1232989168-27759-4-git-send-email-kwolf@suse.de> In-Reply-To: <1232989168-27759-1-git-send-email-kwolf@suse.de> References: <1232989168-27759-1-git-send-email-kwolf@suse.de> Subject: [Qemu-devel] [PATCH 3/7] block-vpc: Fix disk size 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 Cc: Kevin Wolf VirtualPC bases the virtual disk size on the geometry rather than on the size stored in the header. Signed-off-by: Kevin Wolf --- block-vpc.c | 9 ++++++--- 1 files changed, 6 insertions(+), 3 deletions(-) diff --git a/block-vpc.c b/block-vpc.c index 3f25785..3c92bb3 100644 --- a/block-vpc.c +++ b/block-vpc.c @@ -150,6 +150,12 @@ static int vpc_open(BlockDriverState *bs, const char *filename, int flags) if (strncmp(footer->creator, "conectix", 8)) goto fail; + // The visible size of a image in Virtual PC depends on the geometry + // rather than on the size stored in the footer (the size in the footer + // is too large usually) + bs->total_sectors = (int64_t) + be16_to_cpu(footer->cyls) * footer->heads * footer->secs_per_cyl; + lseek(s->fd, be64_to_cpu(footer->data_offset), SEEK_SET); if (read(fd, buf, HEADER_SIZE) != HEADER_SIZE) goto fail; @@ -160,9 +166,6 @@ static int vpc_open(BlockDriverState *bs, const char *filename, int flags) if (strncmp(dyndisk_header->magic, "cxsparse", 8)) goto fail; - bs->total_sectors = ((uint64_t)be32_to_cpu(dyndisk_header->max_table_entries) * - be32_to_cpu(dyndisk_header->block_size)) / 512; - lseek(s->fd, be64_to_cpu(dyndisk_header->table_offset), SEEK_SET); s->max_table_entries = be32_to_cpu(dyndisk_header->max_table_entries); -- 1.6.0.2