[parted-devel] [PATCH] Always allow at least two sectors for extended boot record

Petr Uzel petr.uzel at suse.cz
Tue Apr 13 16:29:56 UTC 2010


On Thu, Apr 08, 2010 at 02:26:28PM +0200, Jim Meyering wrote:
> Colin Watson wrote:
> > Unless specifically told otherwise, the Linux kernel considers extended
> > boot records to be two sectors long, in order to "leave room for LILO".
> > When using anything other than cylinder alignment, libparted was only
> > allowing one sector in the minimum extended partition geometry, which in
> > some situations (e.g. following Phillip Susi's patch to reintroduce
> > BLKPG) could confuse the kernel into thinking that the EBR and the first
> > logical partition overlapped.
> >
> > * libparted/labels/dos.c (_get_min_extended_part_geom): Allow at least
> > two sectors for the extended boot record.
> > ---
> >  libparted/labels/dos.c |    6 +++++-
> >  1 files changed, 5 insertions(+), 1 deletions(-)
> >
> > diff --git a/libparted/labels/dos.c b/libparted/labels/dos.c
> > index 6fb4aef..c25d35a 100644
> > --- a/libparted/labels/dos.c
> > +++ b/libparted/labels/dos.c
> > @@ -1747,7 +1747,11 @@ _get_min_extended_part_geom (const PedPartition* ext_part,
> >  	min_geom = ped_geometry_duplicate (&walk->geom);
> >  	if (!min_geom)
> >  		return NULL;
> > -	ped_geometry_set_start (min_geom, walk->geom.start - 1 * head_size);
> > +	/* We must always allow at least two sectors at the start, to leave
> > +	 * room for LILO.  See linux/fs/partitions/msdos.c.
> > +	 */
> > +	ped_geometry_set_start (min_geom,
> > +				walk->geom.start - PED_MAX (1 * head_size, 2));
> >
> >  	for (walk = ext_part->part_list; walk; walk = walk->next) {
> >  		if (!ped_partition_is_active (walk) || walk->num == 5)
> 
> Colin,
> 
> Here is your patch followed by a quick attempt at exercising it.
> As you can see from the FIXME comment, this test appears to be
> exercising different code.  Can you suggest how to fix it?

Just a blind guess: did you run the test with parted with 'reintroduce
BLKPG' patch applied? AFAIK the bug doesn't show with BLKRRPART. 

> 
> From a223da5d2539cc8f33023b049266ab3017dad9cf Mon Sep 17 00:00:00 2001
> From: Colin Watson <cjwatson at ubuntu.com>
> Date: Mon, 29 Mar 2010 14:40:54 +0100
> Subject: [PATCH 1/2] dos: always allow at least two sectors for extended boot record
> 
> Unless specifically told otherwise, the Linux kernel considers extended
> boot records to be two sectors long, in order to "leave room for LILO".
> When using anything other than cylinder alignment, libparted was only
> allowing one sector in the minimum extended partition geometry, which in
> some situations (e.g. following Phillip Susi's patch to reintroduce
> BLKPG) could confuse the kernel into thinking that the EBR and the first
> logical partition overlapped.
[...]

Petr

--
Petr Uzel, openSUSE Boosters Team
IRC: ptr_uzl @ freenode
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.alioth.debian.org/pipermail/parted-devel/attachments/20100413/23b29244/attachment.pgp>


More information about the parted-devel mailing list