From: Kevin Wolf <kwolf@redhat.com>
To: Blue Swirl <blauwirbel@gmail.com>
Cc: pbonzini@redhat.com, aliguori@us.ibm.com,
Markus Armbruster <armbru@redhat.com>,
stefanha@linux.vnet.ibm.com, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 03/32] vvfat: Fix partition table
Date: Wed, 04 Jul 2012 17:17:27 +0200 [thread overview]
Message-ID: <4FF45E87.8060100@redhat.com> (raw)
In-Reply-To: <CAAu8pHtQORnuc2G8DiWTt1QcWOKbp7L8WJ=P7HMMZCNV7L-NRQ@mail.gmail.com>
Am 29.06.2012 22:33, schrieb Blue Swirl:
> On Fri, Jun 29, 2012 at 3:34 PM, Markus Armbruster <armbru@redhat.com> wrote:
>> 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 <armbru@redhat.com>
>> ---
>> block/vvfat.c | 7 ++++---
>> 1 files changed, 4 insertions(+), 3 deletions(-)
>>
>> diff --git a/block/vvfat.c b/block/vvfat.c
>> index 0fd3367..62745b5 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);
>
> Spaces around '-'. Thanks for fixing the other cases, BTW.
For compensation there's an extra space before the '='.
>> + partition->length_sector_long = cpu_to_le32(s->bs->total_sectors
>> + - s->first_sectors_number + 1);
Just wondering... This should be the same as s->sector_count, right?
This whole geometry calculation code in vvfat is way too convoluted to
understand when you haven't looked at it for some months...
Kevin
next prev parent reply other threads:[~2012-07-04 15:17 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1340984094-5451-1-git-send-email-armbru@redhat.com>
[not found] ` <1340984094-5451-19-git-send-email-armbru@redhat.com>
2012-07-02 12:55 ` [Qemu-devel] [PATCH 18/32] hd-geometry: Switch to uint32_t to match BlockConf Stefan Hajnoczi
2012-07-02 13:07 ` Andreas Färber
2012-07-02 14:15 ` Markus Armbruster
2012-07-02 14:34 ` Stefan Hajnoczi
2012-07-03 19:11 ` Blue Swirl
2012-07-03 20:15 ` Andreas Färber
2012-07-04 16:19 ` Paolo Bonzini
2012-07-04 16:36 ` Eric Blake
2012-07-05 18:37 ` Blue Swirl
2012-07-05 18:30 ` Blue Swirl
[not found] ` <1340984094-5451-9-git-send-email-armbru@redhat.com>
[not found] ` <CAAu8pHsKC6QMrhjUADiXT8DUrhy9HzbkN8pbYeWjM2aAE38ZwQ@mail.gmail.com>
[not found] ` <m3k3ypmjqu.fsf@blackfin.pond.sub.org>
2012-07-03 18:40 ` [Qemu-devel] [PATCH 08/32] hd-geometry: Move disk geometry guessing back from block.c Blue Swirl
2012-07-04 8:24 ` Kevin Wolf
[not found] ` <1340984094-5451-4-git-send-email-armbru@redhat.com>
[not found] ` <CAAu8pHtQORnuc2G8DiWTt1QcWOKbp7L8WJ=P7HMMZCNV7L-NRQ@mail.gmail.com>
2012-07-04 15:17 ` Kevin Wolf [this message]
2012-07-05 9:23 ` [Qemu-devel] [PATCH 03/32] vvfat: Fix partition table Markus Armbruster
2012-07-05 9:55 ` Kevin Wolf
2012-07-05 11:10 ` Markus Armbruster
2012-07-05 11:14 ` Kevin Wolf
[not found] ` <1340984094-5451-5-git-send-email-armbru@redhat.com>
2012-07-04 15:23 ` [Qemu-devel] [PATCH 04/32] vvfat: Do not clobber the user's geometry Kevin Wolf
2012-07-04 16:25 ` Paolo Bonzini
2012-07-05 7:06 ` Kevin Wolf
2012-07-05 9:16 ` Markus Armbruster
2012-07-05 11:13 ` Markus Armbruster
[not found] ` <1340984094-5451-6-git-send-email-armbru@redhat.com>
2012-07-05 8:29 ` [Qemu-devel] [PATCH 05/32] qtest: Tidy up temporary files properly Kevin Wolf
2012-07-05 9:27 ` Markus Armbruster
[not found] ` <1340984094-5451-14-git-send-email-armbru@redhat.com>
2012-07-05 9:16 ` [Qemu-devel] [PATCH 13/32] hd-geometry: Clean up confusing use of prior translation hint Kevin Wolf
2012-07-05 9:28 ` Markus Armbruster
[not found] ` <1340984094-5451-23-git-send-email-armbru@redhat.com>
2012-07-05 11:33 ` [Qemu-devel] [PATCH 22/32] qtest: Cover qdev properties for disk geometry Kevin Wolf
2012-07-05 12:08 ` Markus Armbruster
[not found] ` <1340984094-5451-33-git-send-email-armbru@redhat.com>
2012-07-05 15:27 ` [Qemu-devel] [PATCH 32/32] Relax IDE CHS limits from 16383, 16, 63 to 65535, 16, 255 Kevin Wolf
2012-07-05 16:20 ` Markus Armbruster
2012-07-05 16:39 ` Markus Armbruster
2012-07-06 8:50 ` Kevin Wolf
2012-07-11 13:10 ` Markus Armbruster
2012-07-06 14:50 ` Alexander Graf
2012-07-06 18:15 ` Markus Armbruster
2012-07-06 6:57 [Qemu-devel] [PATCH 00/32] Disk geometry cleanup Markus Armbruster
2012-07-06 6:57 ` [Qemu-devel] [PATCH 03/32] vvfat: Fix partition table Markus Armbruster
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4FF45E87.8060100@redhat.com \
--to=kwolf@redhat.com \
--cc=aliguori@us.ibm.com \
--cc=armbru@redhat.com \
--cc=blauwirbel@gmail.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@linux.vnet.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).