[gparted] Only show exactly 1 MiB unallocated space if not MBR or EBR



commit 87e48efe884b78e2565dbf9acba86000eff702d5
Author: Curtis Gedak <gedakc gmail com>
Date:   Thu May 27 09:27:00 2010 -0600

    Only show exactly 1 MiB unallocated space if not MBR or EBR
    
    Do not show unallocated space of exactly 1 MiB in size if:
    
      a) The space is at the front of the drive.
    
         This space is reserved for the partition table and the
         Master Boot Record.
    
    or
    
      b) The space immediately precedes a logical partition.
    
         This space is reserved for the Extended Boot Record.

 src/GParted_Core.cc |   14 ++++++++++----
 src/Operation.cc    |   14 ++++++++++----
 2 files changed, 20 insertions(+), 8 deletions(-)
---
diff --git a/src/GParted_Core.cc b/src/GParted_Core.cc
index 3179db1..7b175dc 100644
--- a/src/GParted_Core.cc
+++ b/src/GParted_Core.cc
@@ -1218,7 +1218,7 @@ void GParted_Core::insert_unallocated( const Glib::ustring & device_path,
 	}
 		
 	//start <---> first partition start
-	if ( (partitions .front() .sector_start - start) >= (MEBIBYTE / sector_size) )
+	if ( (partitions .front() .sector_start - start) > (MEBIBYTE / sector_size) )
 	{
 		partition_temp .sector_start = start ;
 		partition_temp .sector_end = partitions .front() .sector_start -1 ;
@@ -1228,14 +1228,20 @@ void GParted_Core::insert_unallocated( const Glib::ustring & device_path,
 	
 	//look for gaps in between
 	for ( unsigned int t =0 ; t < partitions .size() -1 ; t++ )
-		if ( ( partitions[ t +1 ] .sector_start - partitions[ t ] .sector_end ) >= (MEBIBYTE / sector_size) )
+	{
+		if (   ( ( partitions[ t + 1 ] .sector_start - partitions[ t ] .sector_end ) > (MEBIBYTE / sector_size) )
+		    || (   ( partitions[ t + 1 ] .type != TYPE_LOGICAL )  // Only show exactly 1 MiB if following partition is not logical.
+		        && ( partitions[ t + 1 ] .sector_start - partitions[ t ] .sector_end ) == (MEBIBYTE / sector_size)
+			   )
+		   )
 		{
 			partition_temp .sector_start = partitions[ t ] .sector_end +1 ;
 			partition_temp .sector_end = partitions[ t +1 ] .sector_start -1 ;
-		
+
 			partitions .insert( partitions .begin() + ++t, partition_temp );
 		}
-		
+	}
+
 	//last partition end <---> end
 	if ( (end - partitions .back() .sector_end ) >= (MEBIBYTE / sector_size) )
 	{
diff --git a/src/Operation.cc b/src/Operation.cc
index ca04915..afd4467 100644
--- a/src/Operation.cc
+++ b/src/Operation.cc
@@ -60,7 +60,7 @@ void Operation::insert_unallocated( std::vector<Partition> & partitions, Sector
 	}
 		
 	//start <---> first partition start
-	if ( (partitions .front() .sector_start - start) >= (MEBIBYTE / sector_size) )
+	if ( (partitions .front() .sector_start - start) > (MEBIBYTE / sector_size) )
 	{
 		UNALLOCATED .sector_start = start ;
 		UNALLOCATED .sector_end = partitions .front() .sector_start -1 ;
@@ -70,14 +70,20 @@ void Operation::insert_unallocated( std::vector<Partition> & partitions, Sector
 	
 	//look for gaps in between
 	for ( unsigned int t =0 ; t < partitions .size() -1 ; t++ )
-		if ( ( partitions[ t +1 ] .sector_start - partitions[ t ] .sector_end ) >= (MEBIBYTE / sector_size) )
+	{
+		if (   ( ( partitions[ t + 1 ] .sector_start - partitions[ t ] .sector_end ) > (MEBIBYTE / sector_size) )
+		    || (   ( partitions[ t + 1 ] .type != TYPE_LOGICAL )  // Only show exactly 1 MiB if following partition is not logical.
+		        && ( partitions[ t + 1 ] .sector_start - partitions[ t ] .sector_end ) == (MEBIBYTE / sector_size)
+		       )
+		   )
 		{
 			UNALLOCATED .sector_start = partitions[ t ] .sector_end +1 ;
 			UNALLOCATED .sector_end = partitions[ t +1 ] .sector_start -1 ;
-		
+
 			partitions .insert( partitions .begin() + ++t, UNALLOCATED );
 		}
-		
+	}
+
 	//last partition end <---> end
 	if ( (end - partitions .back() .sector_end ) >= (MEBIBYTE / sector_size) )
 	{



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