[gparted] Fix paste destination partition smaller than source (#639393)
- From: Curtis Gedak <gedakc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gparted] Fix paste destination partition smaller than source (#639393)
- Date: Sat, 15 Jan 2011 18:04:46 +0000 (UTC)
commit 6ae39268f21d35679764817be23fceefd371a583
Author: Curtis Gedak <gedakc gmail com>
Date: Sat Jan 15 11:00:42 2011 -0700
Fix paste destination partition smaller than source (#639393)
Re-work logic for copying a cylinder aligned partition to a new
MiB aligned partition. Previously this was partially fixed in
bug #626946 - Destination partition smaller than source partition
Closes Bug #639393 - Redux: Destination partition smaller than
source partition
src/Dialog_Base_Partition.cc | 19 +++++++++++++------
src/Dialog_Partition_Copy.cc | 2 +-
2 files changed, 14 insertions(+), 7 deletions(-)
---
diff --git a/src/Dialog_Base_Partition.cc b/src/Dialog_Base_Partition.cc
index 7ed9885..a71ce04 100644
--- a/src/Dialog_Base_Partition.cc
+++ b/src/Dialog_Base_Partition.cc
@@ -173,13 +173,20 @@ Partition Dialog_Base_Partition::Get_New_Partition( Byte_Value sector_size )
case 0 : selected_partition .alignment = ALIGN_CYLINDER; break;
case 1 : selected_partition .alignment = ALIGN_MEBIBYTE;
{
- //if start sector not MiB aligned and free space available then add ~1 MiB to partition so requested size is kept
- Sector diff = ( MEBIBYTE / selected_partition .sector_size ) - ( selected_partition .sector_end + 1 ) % ( MEBIBYTE / selected_partition .sector_size ) ;
- if ( diff
- && ( selected_partition .sector_start % (MEBIBYTE / selected_partition .sector_size ) ) > 0
- && ( ( selected_partition .sector_end - START +1 + diff ) < total_length )
+ //if partition size is not an integer multiple of MiB
+ // or the start or end sectors are not MiB aligned,
+ // and space is available,
+ // then add 1 MiB to partition so requested size is kept
+ // after GParted_Core::snap_to_mebibyte method rounding
+ Sector partition_size = selected_partition .sector_end - selected_partition .sector_start + Sector(1) ;
+ Sector sectors_in_mib = MEBIBYTE / selected_partition .sector_size ;
+ if ( ( ( ( partition_size % sectors_in_mib ) > 0 )
+ || ( ( selected_partition .sector_start % sectors_in_mib ) > 0 )
+ || ( ( ( selected_partition .sector_end + Sector(1) ) % sectors_in_mib ) > 0 )
+ )
+ && ( ( partition_size + sectors_in_mib ) < total_length )
)
- selected_partition .sector_end += diff ;
+ selected_partition .sector_end += sectors_in_mib ;
}
break;
case 2 : selected_partition .alignment = ALIGN_STRICT; break;
diff --git a/src/Dialog_Partition_Copy.cc b/src/Dialog_Partition_Copy.cc
index 95ba865..11268d0 100644
--- a/src/Dialog_Partition_Copy.cc
+++ b/src/Dialog_Partition_Copy.cc
@@ -49,7 +49,7 @@ void Dialog_Partition_Copy::Set_Data( const Partition & selected_partition, cons
// handle situation where src sector size is smaller than dst sector size and an additional partial dst sector is required.
Sector copied_min_sectors = ( copied_partition .get_byte_length() + (selected_partition .sector_size - 1) ) / selected_partition .sector_size ;
- long COPIED_LENGTH_MB = Utils::round( Utils::sector_to_unit( copied_min_sectors, selected_partition .sector_size, UNIT_MIB ) ) ;
+ long COPIED_LENGTH_MB = ceil( Utils::sector_to_unit( copied_min_sectors, selected_partition .sector_size, UNIT_MIB ) ) ;
//now calculate proportional length of partition
frame_resizer_base ->set_x_min_space_before( Utils::round( MIN_SPACE_BEFORE_MB / MB_PER_PIXEL ) ) ;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]