[gparted] Add logic for copy and paste between devices with different sector sizes
- From: Curtis Gedak <gedakc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gparted] Add logic for copy and paste between devices with different sector sizes
- Date: Fri, 23 Apr 2010 19:29:41 +0000 (UTC)
commit 0d5c06f85d5d61c644fc7cd3b031446fa49b7fc6
Author: Curtis Gedak <gedakc gmail com>
Date: Fri Apr 23 13:28:41 2010 -0600
Add logic for copy and paste between devices with different sector sizes
This change is in preparation for supporting sectors sizes > 512 bytes.
src/Dialog_Partition_Copy.cc | 18 +++++++++++-------
1 files changed, 11 insertions(+), 7 deletions(-)
---
diff --git a/src/Dialog_Partition_Copy.cc b/src/Dialog_Partition_Copy.cc
index 89f4847..94ef09f 100644
--- a/src/Dialog_Partition_Copy.cc
+++ b/src/Dialog_Partition_Copy.cc
@@ -41,10 +41,14 @@ void Dialog_Partition_Copy::Set_Data( const Partition & selected_partition, cons
//set some widely used values...
START = selected_partition .sector_start ;
total_length = selected_partition .get_length() ;
- TOTAL_MB = Utils::round( Utils::sector_to_unit( selected_partition .get_length(), DEFAULT_SECTOR_SIZE, UNIT_MIB ) ) ;
+ TOTAL_MB = Utils::round( Utils::sector_to_unit( selected_partition .get_length(), selected_partition .sector_size, UNIT_MIB ) ) ;
MB_PER_PIXEL = TOTAL_MB / 500.00 ;
-
- long COPIED_LENGTH_MB = Utils::round( Utils::sector_to_unit( copied_partition .get_length(), DEFAULT_SECTOR_SIZE, UNIT_MIB ) ) ;
+
+ //Determine minimum number of sectors needed in destination (selected) partition and
+ // 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_length() * copied_partition .sector_size + (selected_partition .sector_size - 1) ) / selected_partition .sector_size ;
+
+ long COPIED_LENGTH_MB = Utils::round( Utils::sector_to_unit( copied_min_sectors, copied_partition .sector_size, UNIT_MIB ) ) ;
// /* Copy Primary not at start of disk to within Extended partition */
// Adjust when a primary partition is copied and pasted
// into an unallocated space in an extended partition
@@ -96,16 +100,16 @@ void Dialog_Partition_Copy::Set_Data( const Partition & selected_partition, cons
frame_resizer_base ->set_x_end( x_end > 500 ? 500 : x_end ) ;
frame_resizer_base ->set_used(
Utils::round( Utils::sector_to_unit(
- copied_partition .sectors_used, DEFAULT_SECTOR_SIZE, UNIT_MIB ) / (TOTAL_MB/500.00) ) ) ;
-
+ copied_partition .sectors_used, copied_partition .sector_size, UNIT_MIB ) / (TOTAL_MB/500.00) ) ) ;
+
if ( fs .grow )
fs .MAX = ( ! fs .MAX || fs .MAX > (TOTAL_MB * MEBI_FACTOR) ) ? (TOTAL_MB * MEBI_FACTOR) : fs .MAX - (BUF * DEFAULT_SECTOR_SIZE) ;
else
- fs .MAX = copied_partition .get_length() * DEFAULT_SECTOR_SIZE ;
+ fs .MAX = copied_partition .get_length() * copied_partition .sector_size ;
if ( fs .filesystem == GParted::FS_XFS ) //bit hackisch, but most effective, since it's a unique situation
- fs .MIN = ( copied_partition .sectors_used + (BUF * 2) ) * DEFAULT_SECTOR_SIZE;
+ fs .MIN = ( copied_partition .sectors_used + (BUF * 2) ) * copied_partition .sector_size;
else
fs .MIN = COPIED_LENGTH_MB * MEBI_FACTOR ;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]