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.
This commit is contained in:
Curtis Gedak 2010-05-27 09:27:00 -06:00
parent b74dba4f67
commit 87e48efe88
2 changed files with 20 additions and 8 deletions

View File

@ -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) )
{

View File

@ -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) )
{