[gparted] Fix logical partition grow overlaps extended partition end (#686668)



commit 83ccbce1995147bf171eca1c6bd283483ec1dd05
Author: Curtis Gedak <gedakc gmail com>
Date:   Sun Nov 25 14:01:52 2012 -0700

    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 files changed, 7 insertions(+), 0 deletions(-)
---
diff --git a/src/GParted_Core.cc b/src/GParted_Core.cc
index 631ea2f..c56f27a 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



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]