From 83ccbce1995147bf171eca1c6bd283483ec1dd05 Mon Sep 17 00:00:00 2001 From: Curtis Gedak Date: Sun, 25 Nov 2012 14:01:52 -0700 Subject: [PATCH] Fix logical partition grow overlaps extended partition end (#686668) In certain situations with a mixture of partition alignments, the MiB alignment option would try to set the end of a logical partition beyond the end of the extended partition. This, of course, is an invalid partition geometry and the libparted library correctly reports failure when this is attempted. This enhancement to MiB alignment adds a check to see if the end of the logical partition would be beyond the extended partition, and adjusts the end of the logical partition if required. Closes Bug #686668 - Growing logical partition overlaps end of extended partition --- src/GParted_Core.cc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/GParted_Core.cc b/src/GParted_Core.cc index 631ea2fe..c56f27af 100644 --- a/src/GParted_Core.cc +++ b/src/GParted_Core.cc @@ -543,6 +543,13 @@ bool GParted_Core::snap_to_mebibyte( const Device & device, Partition & partitio partition .sector_end -= ( MEBIBYTE / partition .sector_size ) ; } } + + //If the logical partition end is beyond the end of the extended partition + // then reduce logical partition end by a mebibyte to address the overlap. + if ( ( index_extended != -1 ) + && ( partition .sector_end > device .partitions[ index_extended ] .sector_end ) + ) + partition .sector_end -= ( MEBIBYTE / partition .sector_size ) ; } //If this is a primary or an extended partition and the partition overlaps