[parted-devel] [PATCH] libparted: Fix starting CHS in protective MBR

Petr Uzel puzel at suse.cz
Fri Mar 11 14:11:49 UTC 2016


On Thu, Mar 10, 2016 at 09:42:59AM -0800, Brian C. Lane wrote:
> On Thu, Mar 10, 2016 at 02:18:52PM +0100, Petr Uzel wrote:
> > The CHS address for protective partition start in protective MBR
> > should be 0/0/2, according to UEFI spec (v2.6, section 5.2.1).
> > 
> > * libparted/labels/gpt.c (_write_pmbr): Fix starting CHS address
> > 
> > Reported by Steffen Winterfeldt in https://bugzilla.suse.com/969165
> > 
> > Signed-off-by: Petr Uzel <petr.uzel at suse.cz>
> > ---
> >  libparted/labels/gpt.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/libparted/labels/gpt.c b/libparted/labels/gpt.c
> > index d69377a..6027eb3 100644
> > --- a/libparted/labels/gpt.c
> > +++ b/libparted/labels/gpt.c
> > @@ -1139,7 +1139,7 @@ _write_pmbr (PedDevice *dev, bool pmbr_boot)
> >  
> >    pmbr->Signature = PED_CPU_TO_LE16 (MSDOS_MBR_SIGNATURE);
> >    pmbr->PartitionRecord[0].OSType = EFI_PMBR_OSTYPE_EFI;
> > -  pmbr->PartitionRecord[0].StartSector = 1;
> > +  pmbr->PartitionRecord[0].StartSector = 2;
> >    pmbr->PartitionRecord[0].EndHead = 0xFE;
> 
> And after re-reading the spec, shouldn't this be 0xFF?

Hmm, according to the Table 17 in UEFI spec, the EndingCHS should be

"Set to the CHS address of the last logical block on the
disk. Set to 0xFFFFFF if it is not possible to represent
the value in this field." 

IOW, the exact value should be calculated based on the size of the
disk.


        Petr

-- 
Petr Uzel
TL SUSE L3 Team 2



More information about the parted-devel mailing list