From b77a5e229dae407b40fdf6661483a3808797251d Mon Sep 17 00:00:00 2001 From: Curtis Gedak Date: Thu, 9 Sep 2010 13:09:55 -0600 Subject: [PATCH] Fix paste destination partition smaller than source (#626946) Prior to this enhancement when copying and pasting a partition after a cylinder aligned partition, the destination partition would become smaller than the source partition if align to MiB was selected. Closes bug #626946 - Destination partition smaller than source partition. --- src/Dialog_Base_Partition.cc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Dialog_Base_Partition.cc b/src/Dialog_Base_Partition.cc index c5c283ff..8f18c079 100644 --- a/src/Dialog_Base_Partition.cc +++ b/src/Dialog_Base_Partition.cc @@ -171,7 +171,16 @@ Partition Dialog_Base_Partition::Get_New_Partition( Byte_Value sector_size ) switch ( optionmenu_alignment .get_history() ) { case 0 : selected_partition .alignment = ALIGN_CYLINDER; break; - case 1 : selected_partition .alignment = ALIGN_MEBIBYTE; break; + case 1 : selected_partition .alignment = ALIGN_MEBIBYTE; + { + //if free space available, grow partition so sector_end on mebibyte boundary + Sector diff = ( MEBIBYTE / selected_partition .sector_size ) - ( selected_partition .sector_end + 1 ) % ( MEBIBYTE / selected_partition .sector_size ) ; + if ( diff + && ( ( selected_partition .sector_end - START +1 + diff ) < total_length ) + ) + selected_partition .sector_end += diff ; + } + break; case 2 : selected_partition .alignment = ALIGN_STRICT; break; default : selected_partition .alignment = ALIGN_MEBIBYTE ;