[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 04/41] vvfat: Fix partition table
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PATCH 04/41] vvfat: Fix partition table |
Date: |
Tue, 17 Jul 2012 18:00:01 +0200 |
From: Markus Armbruster <address@hidden>
Unless parameter ":floppy:" is given, vvfat creates a virtual image
with DOS MBR defining a single partition which holds the FAT file
system. The size of the virtual image depends on the width of the
FAT: 32 MiB (CHS 64, 16, 63) for 12 bit FAT, 504 MiB (CHS 1024, 16,
63) for 16 and 32 bit FAT, leaving (64*16-1)*63 = 64449 and
(1024*16-1)*64 = 1032129 sectors for the partition.
However, it screws up the end of the partition in the MBR:
FAT width param. start CHS end CHS start LBA size
:32: 0,1,1 1023,14,63 63 1032065
:16: 0,1,1 1023,14,55 63 1032057
:12: 0,1,1 63,14,55 63 64377
The actual FAT file system nevertheless assumes the partition has
1032129 or 64449 sectors. Oops.
Signed-off-by: Markus Armbruster <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
block/vvfat.c | 7 ++++---
1 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/block/vvfat.c b/block/vvfat.c
index 0fd3367..e2b83a2 100644
--- a/block/vvfat.c
+++ b/block/vvfat.c
@@ -394,11 +394,12 @@ static void init_mbr(BDRVVVFATState* s)
/* LBA is used when partition is outside the CHS geometry */
lba = sector2CHS(s->bs, &partition->start_CHS, s->first_sectors_number-1);
- lba|= sector2CHS(s->bs, &partition->end_CHS, s->sector_count);
+ lba |= sector2CHS(s->bs, &partition->end_CHS, s->bs->total_sectors - 1);
/*LBA partitions are identified only by start/length_sector_long not by
CHS*/
- partition->start_sector_long =cpu_to_le32(s->first_sectors_number-1);
- partition->length_sector_long=cpu_to_le32(s->sector_count -
s->first_sectors_number+1);
+ partition->start_sector_long = cpu_to_le32(s->first_sectors_number - 1);
+ partition->length_sector_long = cpu_to_le32(s->bs->total_sectors
+ - s->first_sectors_number + 1);
/* FAT12/FAT16/FAT32 */
/* DOS uses different types when partition is LBA,
--
1.7.6.5
- [Qemu-devel] [PULL 00/41] Block patches, Kevin Wolf, 2012/07/17
- [Qemu-devel] [PATCH 01/41] sheepdog: always use coroutine-based network functions, Kevin Wolf, 2012/07/17
- [Qemu-devel] [PATCH 02/41] sheepdog: do not blindly memset all read buffers, Kevin Wolf, 2012/07/17
- [Qemu-devel] [PATCH 03/41] fdc: Move floppy geometry guessing back from block.c, Kevin Wolf, 2012/07/17
- [Qemu-devel] [PATCH 09/41] hd-geometry: Unnest conditional in hd_geometry_guess(), Kevin Wolf, 2012/07/17
- [Qemu-devel] [PATCH 07/41] hd-geometry: Move disk geometry guessing back from block.c, Kevin Wolf, 2012/07/17
- [Qemu-devel] [PATCH 05/41] vvfat: Do not clobber the user's geometry, Kevin Wolf, 2012/07/17
- [Qemu-devel] [PATCH 11/41] hd-geometry: Clean up gratuitous goto in hd_geometry_guess(), Kevin Wolf, 2012/07/17
- [Qemu-devel] [PATCH 06/41] qtest: Add hard disk geometry test, Kevin Wolf, 2012/07/17
- [Qemu-devel] [PATCH 04/41] vvfat: Fix partition table,
Kevin Wolf <=
- [Qemu-devel] [PATCH 10/41] hd-geometry: Factor out guess_chs_for_size(), Kevin Wolf, 2012/07/17
- [Qemu-devel] [PATCH 08/41] hd-geometry: Add tracepoints, Kevin Wolf, 2012/07/17
- [Qemu-devel] [PATCH 13/41] hd-geometry: Cut out block layer translation middleman, Kevin Wolf, 2012/07/17
- [Qemu-devel] [PATCH 15/41] blockdev: Save geometry in DriveInfo, Kevin Wolf, 2012/07/17
- [Qemu-devel] [PATCH 16/41] qdev: Introduce block geometry properties, Kevin Wolf, 2012/07/17
- [Qemu-devel] [PATCH 14/41] ide pc: Cut out the block layer geometry middleman, Kevin Wolf, 2012/07/17
- [Qemu-devel] [PATCH 29/41] hd-geometry: Compute BIOS CHS translation in one place, Kevin Wolf, 2012/07/17
- [Qemu-devel] [PATCH 22/41] qdev: Collect private helpers in one place, Kevin Wolf, 2012/07/17
- [Qemu-devel] [PATCH 33/41] hw/block-common: Factor out fall back to legacy -drive serial=..., Kevin Wolf, 2012/07/17
- [Qemu-devel] [PATCH 30/41] blockdev: Drop redundant CHS validation for if=ide, Kevin Wolf, 2012/07/17