[parted-devel] [PATCH] parted: improve snapping to boundaries of free space

Petr Uzel puzel at suse.cz
Thu Jul 21 14:31:49 UTC 2016


On Tue, Oct 27, 2015 at 01:53:32PM -0700, Brian C. Lane wrote:
> On Fri, Oct 23, 2015 at 04:08:14PM +0200, Petr Uzel wrote:
> > When creating a new partition, parted tries to snap its boundaries.
> > If the new partition lies within free space, it only makes sense
> > to snap it so that is it bigger, not smaller.
> > 
> > * parted/parted.c (snap_to_boundaries): Limit direction in what snapping
> > is done.
> > ---
> >  parted/parted.c | 8 ++++++++
> >  1 file changed, 8 insertions(+)
> > 
> > diff --git a/parted/parted.c b/parted/parted.c
> > index a9426c4..840e9e3 100644
> > --- a/parted/parted.c
> > +++ b/parted/parted.c
> > @@ -379,6 +379,14 @@ snap_to_boundaries (PedGeometry* new_geom, PedGeometry* old_geom,
> >          end_part = ped_disk_get_partition_by_sector (disk, end);
> >          adjacent = (start_part->geom.end + 1 == end_part->geom.start);
> >  
> > +	/* If start lies within free space, then don't allow it to move up.
> > +	 * If end   lies within free space, then don't allow it to move down.
> > +	 */
> > +	if (start_part->type == PED_PARTITION_FREESPACE)
> > +		start_allow &= ~MOVE_UP;
> > +	if (end_part->type == PED_PARTITION_FREESPACE)
> > +		end_allow &= ~MOVE_DOWN;
> > +
> >          /* If we can snap to old_geom, then we will... */
> >          /* and this will enforce the snapped positions  */
> >          if (old_geom) {
> > -- 
> > 1.8.4.5
> > 
> > 
> 
> Looks ok to me, but we could use a test to go along with it.

I do not think I can trigger the bug with upstream parted/libparted,
so I do not see how to write a test for this. In my opinion, this is
still a valid bug [1] which should be fixed.

Any chance you could take the patch even without a test?


[1] For rather historical reasons, SUSE parted package has a bit
hackish patch included (not suitable to be sent to upstream, at least
not in its current form). With this patch, the bug can be triggered
reliably. I can provide more details if needed.


        Petr

-- 
Petr Uzel
TL SUSE L3 Team 2
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.alioth.debian.org/pipermail/parted-devel/attachments/20160721/6d655dc8/attachment.sig>


More information about the parted-devel mailing list