[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 3/7] block-vpc: Fix disk size
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PATCH 3/7] block-vpc: Fix disk size |
Date: |
Mon, 26 Jan 2009 17:59:24 +0100 |
VirtualPC bases the virtual disk size on the geometry rather than on
the size stored in the header.
Signed-off-by: Kevin Wolf <address@hidden>
---
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
- [Qemu-devel] [PATCH 0/7] block-vpc: Improve support for VHD images, Kevin Wolf, 2009/01/26
- [Qemu-devel] [PATCH 1/7] block-vpc: Split up struct vpc_subheader, Kevin Wolf, 2009/01/26
- [Qemu-devel] [PATCH 5/7] block-vpc: Use the qemu block layer, Kevin Wolf, 2009/01/26
- [Qemu-devel] [PATCH 3/7] block-vpc: Fix disk size,
Kevin Wolf <=
- [Qemu-devel] [PATCH 7/7] block-vpc: Create images, Kevin Wolf, 2009/01/26
- [Qemu-devel] [PATCH 2/7] block-vpc: Adapt header structures to official documentation, Kevin Wolf, 2009/01/26
- [Qemu-devel] [PATCH 6/7] block-vpc: Write support, Kevin Wolf, 2009/01/26
- [Qemu-devel] [PATCH 4/7] block-vpc: Fix support for images > 4 GB, Kevin Wolf, 2009/01/26
- Re: [Qemu-devel] [PATCH 0/7] block-vpc: Improve support for VHD images, Jamie Lokier, 2009/01/26