[gparted] Replace default sector size with appropriate sector size



commit 5d2bf2ec5d4a5408ca1bcb52b80bd94ddc00d802
Author: Curtis Gedak <gedakc gmail com>
Date:   Mon Apr 26 11:42:23 2010 -0600

    Replace default sector size with appropriate sector size
    
    This change is in preparation for supporting sectors sizes > 512 bytes.

 src/Dialog_Partition_Copy.cc        |   16 ++++----
 src/Dialog_Partition_Info.cc        |    8 ++--
 src/Dialog_Partition_New.cc         |   28 ++++++++--------
 src/Dialog_Partition_Resize_Move.cc |   64 +++++++++++++++++-----------------
 src/DrawingAreaVisualDisk.cc        |    2 +-
 src/GParted_Core.cc                 |   34 +++++++++---------
 src/OperationCopy.cc                |    2 +-
 src/OperationCreate.cc              |    2 +-
 src/OperationDelete.cc              |    2 +-
 src/OperationResizeMove.cc          |    4 +-
 src/TreeView_Detail.cc              |    6 ++--
 src/Win_GParted.cc                  |   18 +++++-----
 src/ext2.cc                         |    2 +-
 src/ext3.cc                         |    2 +-
 src/ext4.cc                         |    2 +-
 src/ntfs.cc                         |    2 +-
 src/reiserfs.cc                     |    2 +-
 17 files changed, 98 insertions(+), 98 deletions(-)
---
diff --git a/src/Dialog_Partition_Copy.cc b/src/Dialog_Partition_Copy.cc
index 94ef09f..74e1974 100644
--- a/src/Dialog_Partition_Copy.cc
+++ b/src/Dialog_Partition_Copy.cc
@@ -103,11 +103,11 @@ void Dialog_Partition_Copy::Set_Data( const Partition & selected_partition, cons
 				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) ;
+		fs .MAX = ( ! fs .MAX || fs .MAX > (TOTAL_MB * MEBI_FACTOR) ) ? (TOTAL_MB * MEBI_FACTOR) : fs .MAX - (BUF * selected_partition .sector_size) ;
 	else
 		fs .MAX = copied_partition .get_length() * copied_partition .sector_size ;
 
-	
+	//TODO: Since BUF is the cylinder size of the current device, the cylinder size of the copied device could differ for small disks
 	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) ) * copied_partition .sector_size;
 	else
@@ -115,17 +115,17 @@ void Dialog_Partition_Copy::Set_Data( const Partition & selected_partition, cons
 	
 	GRIP = true ;
 	//set values of spinbutton_before
-	spinbutton_before .set_range( 0, TOTAL_MB - Utils::round( Utils::sector_to_unit( (fs .MIN / DEFAULT_SECTOR_SIZE), DEFAULT_SECTOR_SIZE, UNIT_MIB ) ) ) ;
+	spinbutton_before .set_range( 0, TOTAL_MB - Utils::round( Utils::sector_to_unit( fs .MIN, 1 /* Byte */, UNIT_MIB ) ) ) ;
 	spinbutton_before .set_value( 0 ) ;
 		
 	//set values of spinbutton_size
 	spinbutton_size .set_range(
-		Utils::round( Utils::sector_to_unit( (fs .MIN / DEFAULT_SECTOR_SIZE), DEFAULT_SECTOR_SIZE, UNIT_MIB ) ),
-		Utils::round( Utils::sector_to_unit( (fs .MAX / DEFAULT_SECTOR_SIZE), DEFAULT_SECTOR_SIZE, UNIT_MIB ) ) ) ;
+		Utils::round( Utils::sector_to_unit( fs .MIN, 1 /* Byte */, UNIT_MIB ) ),
+		Utils::round( Utils::sector_to_unit( fs .MAX, 1 /* Byte */, UNIT_MIB ) ) ) ;
 	spinbutton_size .set_value( COPIED_LENGTH_MB ) ;
 	
 	//set values of spinbutton_after
-	spinbutton_after .set_range( 0, TOTAL_MB - Utils::round( Utils::sector_to_unit( (fs .MIN / DEFAULT_SECTOR_SIZE), DEFAULT_SECTOR_SIZE, UNIT_MIB ) ) ) ;
+	spinbutton_after .set_range( 0, TOTAL_MB - Utils::round( Utils::sector_to_unit( fs .MIN, 1 /* Byte */, UNIT_MIB ) ) ) ;
 	spinbutton_after .set_value( TOTAL_MB - COPIED_LENGTH_MB ) ; 
 	GRIP = false ;
 	
@@ -134,8 +134,8 @@ void Dialog_Partition_Copy::Set_Data( const Partition & selected_partition, cons
 	
 	//set contents of label_minmax
 	Set_MinMax_Text( 
-		Utils::round( Utils::sector_to_unit( (fs .MIN / DEFAULT_SECTOR_SIZE), DEFAULT_SECTOR_SIZE, UNIT_MIB ) ),
-		Utils::round( Utils::sector_to_unit( (fs .MAX / DEFAULT_SECTOR_SIZE), DEFAULT_SECTOR_SIZE, UNIT_MIB ) ) ) ;
+		Utils::round( Utils::sector_to_unit( fs .MIN, 1 /* Byte */, UNIT_MIB ) ),
+		Utils::round( Utils::sector_to_unit( fs .MAX, 1 /* Byte */, UNIT_MIB ) ) ) ;
 
 	//set global selected_partition (see Dialog_Base_Partition::Get_New_Partition )
 	this ->selected_partition = copied_partition ;
diff --git a/src/Dialog_Partition_Info.cc b/src/Dialog_Partition_Info.cc
index a99eb24..873b267 100644
--- a/src/Dialog_Partition_Info.cc
+++ b/src/Dialog_Partition_Info.cc
@@ -136,7 +136,7 @@ void Dialog_Partition_Info::init_drawingarea()
 	
 	//set text of pangolayout
 	pango_layout = drawingarea .create_pango_layout( 
-		partition .get_path() + "\n" + Utils::format_size( partition .get_length(), DEFAULT_SECTOR_SIZE ) ) ;
+		partition .get_path() + "\n" + Utils::format_size( partition .get_length(), partition .sector_size ) ) ;
 }
 
 void Dialog_Partition_Info::Display_Info()
@@ -163,7 +163,7 @@ void Dialog_Partition_Info::Display_Info()
 			0, 1,
 			top, bottom,
 			Gtk::FILL) ;
-	table ->attach( * Utils::mk_label( Utils::format_size( partition .get_length(), DEFAULT_SECTOR_SIZE ), true, Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER, false, true ),
+	table ->attach( * Utils::mk_label( Utils::format_size( partition .get_length(), partition .sector_size ), true, Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER, false, true ),
 			1, 2,
 			top++, bottom++,
 			Gtk::FILL ) ;
@@ -179,7 +179,7 @@ void Dialog_Partition_Info::Display_Info()
 				0, 1,
 				top, bottom,
 				Gtk::FILL ) ;
-		table ->attach( * Utils::mk_label( Utils::format_size( partition .sectors_used, DEFAULT_SECTOR_SIZE ), true, Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER, false, true ),
+		table ->attach( * Utils::mk_label( Utils::format_size( partition .sectors_used, partition .sector_size ), true, Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER, false, true ),
 				1, 2,
 				top, bottom,
 				Gtk::FILL ) ;
@@ -193,7 +193,7 @@ void Dialog_Partition_Info::Display_Info()
 				0, 1,
 				top, bottom,
 				Gtk::FILL ) ;
-		table ->attach( * Utils::mk_label( Utils::format_size( partition .sectors_unused, DEFAULT_SECTOR_SIZE ), true, Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER, false, true ),
+		table ->attach( * Utils::mk_label( Utils::format_size( partition .sectors_unused, partition .sector_size ), true, Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER, false, true ),
 				1, 2,
 				top, bottom,
 				Gtk::FILL ) ;
diff --git a/src/Dialog_Partition_New.cc b/src/Dialog_Partition_New.cc
index 492c265..6dafbec 100644
--- a/src/Dialog_Partition_New.cc
+++ b/src/Dialog_Partition_New.cc
@@ -142,7 +142,7 @@ void Dialog_Partition_New::Set_Data( const Partition & partition,
 	//set some widely used values...
 	START = partition.sector_start ;
 	total_length = partition.sector_end - partition.sector_start ;
-	TOTAL_MB = Utils::round( Utils::sector_to_unit( this ->selected_partition .get_length(), DEFAULT_SECTOR_SIZE, UNIT_MIB ) ) ;
+	TOTAL_MB = Utils::round( Utils::sector_to_unit( this ->selected_partition .get_length(), this ->selected_partition .sector_size, UNIT_MIB ) ) ;
 	MB_PER_PIXEL = TOTAL_MB / 500.00 ;
 	
 	//set first enabled file system
@@ -151,7 +151,7 @@ void Dialog_Partition_New::Set_Data( const Partition & partition,
 	
 	//set spinbuttons initial values
 	spinbutton_after .set_value( 0 ) ;
-	spinbutton_size .set_value( Utils::round( Utils::sector_to_unit( (fs .MAX / DEFAULT_SECTOR_SIZE), DEFAULT_SECTOR_SIZE, UNIT_MIB ) ) ) ; 
+	spinbutton_size .set_value( Utils::round( Utils::sector_to_unit( fs .MAX, 1 /* Byte */, UNIT_MIB ) ) ) ; 
 	spinbutton_before .set_value( 0 ) ;
 	
 	//euhrm, this wil only happen when there's a very small free space (usually the effect of a bad partitionmanager)
@@ -253,14 +253,14 @@ void Dialog_Partition_New::optionmenu_changed( bool type )
 
 		if ( checkbutton_round_to_cylinders .get_active() )
 		{
-			if ( (fs .MIN / DEFAULT_SECTOR_SIZE) < cylinder_size )
-				fs .MIN = cylinder_size * DEFAULT_SECTOR_SIZE ;
+			if ( (fs .MIN / selected_partition .sector_size) < cylinder_size )
+				fs .MIN = cylinder_size * selected_partition .sector_size ;
 		}
-		else if ( (fs .MIN / DEFAULT_SECTOR_SIZE) < MEBIBYTE )
+		else if ( fs .MIN < MEBI_FACTOR )
 			fs .MIN = MEBI_FACTOR ;
 		
-		if ( selected_partition .get_length() < (fs .MIN /DEFAULT_SECTOR_SIZE) )
-			fs .MIN = selected_partition .get_length() * DEFAULT_SECTOR_SIZE ;
+		if ( selected_partition .get_length() < (fs .MIN / selected_partition .sector_size) )
+			fs .MIN = selected_partition .get_length() * selected_partition .sector_size ;
 				
 		fs .MAX = ( fs .MAX && ( fs .MAX < (TOTAL_MB * MEBI_FACTOR) ) ) ? fs .MAX : (TOTAL_MB * MEBI_FACTOR) ;
 		
@@ -269,17 +269,17 @@ void Dialog_Partition_New::optionmenu_changed( bool type )
 				
 		//set new spinbutton ranges
 		spinbutton_before .set_range( 
-			0, TOTAL_MB - Utils::round( Utils::sector_to_unit( (fs .MIN / DEFAULT_SECTOR_SIZE), DEFAULT_SECTOR_SIZE, UNIT_MIB ) ) ) ;
+			0, TOTAL_MB - Utils::round( Utils::sector_to_unit( fs .MIN, 1 /* Byte */, UNIT_MIB ) ) ) ;
 		spinbutton_size .set_range(
-				Utils::round( Utils::sector_to_unit( (fs .MIN / DEFAULT_SECTOR_SIZE), DEFAULT_SECTOR_SIZE, UNIT_MIB ) ),
-				Utils::round( Utils::sector_to_unit( (fs .MAX / DEFAULT_SECTOR_SIZE), DEFAULT_SECTOR_SIZE, UNIT_MIB ) ) ) ;
+				Utils::round( Utils::sector_to_unit( fs .MIN, 1 /* Byte */, UNIT_MIB ) ),
+				Utils::round( Utils::sector_to_unit( fs .MAX, 1 /* Byte */, UNIT_MIB ) ) ) ;
 		spinbutton_after .set_range(
-			0, TOTAL_MB - Utils::round( Utils::sector_to_unit( (fs .MIN / DEFAULT_SECTOR_SIZE), DEFAULT_SECTOR_SIZE, UNIT_MIB ) ) ) ;
+			0, TOTAL_MB - Utils::round( Utils::sector_to_unit( fs .MIN, 1 /* Byte */, UNIT_MIB ) ) ) ;
 				
 		//set contents of label_minmax
 		Set_MinMax_Text(
-			Utils::round( Utils::sector_to_unit( (fs .MIN / DEFAULT_SECTOR_SIZE), DEFAULT_SECTOR_SIZE, UNIT_MIB ) ),
-			Utils::round( Utils::sector_to_unit( (fs .MAX / DEFAULT_SECTOR_SIZE), DEFAULT_SECTOR_SIZE, UNIT_MIB ) ) ) ;
+			Utils::round( Utils::sector_to_unit( fs .MIN, 1 /* Byte */, UNIT_MIB ) ),
+			Utils::round( Utils::sector_to_unit( fs .MAX, 1 /* Byte */, UNIT_MIB ) ) ) ;
 	}
 	
 	//set fitting resizer colors
@@ -306,7 +306,7 @@ void Dialog_Partition_New::Build_Filesystems_Menu( bool only_unformatted )
 			Gtk::Menu_Helpers::MenuElem( Utils::get_filesystem_string( FILESYSTEMS[ t ] .filesystem ) ) ) ;
 		menu_filesystem .items() .back() .set_sensitive(
 			! only_unformatted && FILESYSTEMS[ t ] .create &&
-			this ->selected_partition .get_length() >= (FILESYSTEMS[ t ] .MIN / DEFAULT_SECTOR_SIZE) ) ;
+			this ->selected_partition .get_length() >= (FILESYSTEMS[ t ] .MIN / this ->selected_partition .sector_size) ) ;
 	}
 	
 	//unformatted is always available
diff --git a/src/Dialog_Partition_Resize_Move.cc b/src/Dialog_Partition_Resize_Move.cc
index c6623ea..7b23321 100644
--- a/src/Dialog_Partition_Resize_Move.cc
+++ b/src/Dialog_Partition_Resize_Move.cc
@@ -104,7 +104,7 @@ void Dialog_Partition_Resize_Move::Resize_Move_Normal( const std::vector<Partiti
 		next = partitions[t +1] .get_length() ;
 	
 	total_length = previous + selected_partition .get_length() + next;
-	TOTAL_MB = Utils::round( Utils::sector_to_unit( total_length, DEFAULT_SECTOR_SIZE, UNIT_MIB ) ) ;
+	TOTAL_MB = Utils::round( Utils::sector_to_unit( total_length, selected_partition .sector_size, UNIT_MIB ) ) ;
 	
 	MB_PER_PIXEL = TOTAL_MB / 500.00 ;
 		
@@ -118,29 +118,29 @@ void Dialog_Partition_Resize_Move::Resize_Move_Normal( const std::vector<Partiti
 	if ( fs .shrink )
 	{
 		//since some file systems have lower limits we need to check for this
-		if ( selected_partition .sectors_used > (fs .MIN / DEFAULT_SECTOR_SIZE) )
-			fs .MIN = selected_partition .sectors_used * DEFAULT_SECTOR_SIZE ;
+		if ( selected_partition .sectors_used > (fs .MIN / selected_partition .sector_size) )
+			fs .MIN = selected_partition .sectors_used * selected_partition .sector_size ;
 
 		//if fs. MIN is 0 here (means used == 0 as well) it's safe to have BUF / 2
-		fs .MIN += fs .MIN ? (BUF * DEFAULT_SECTOR_SIZE) : (BUF/2 * DEFAULT_SECTOR_SIZE) ;
+		fs .MIN += fs .MIN ? (BUF * selected_partition .sector_size) : (BUF/2 * selected_partition .sector_size) ;
 
 		//in certain (rare) cases fs .MIN is (now) larger than 'selected_partition'..
-		if ( (fs .MIN / DEFAULT_SECTOR_SIZE) > selected_partition .get_length() )
-			fs .MIN = selected_partition .get_length() * DEFAULT_SECTOR_SIZE ;
+		if ( (fs .MIN / selected_partition .sector_size) > selected_partition .get_length() )
+			fs .MIN = selected_partition .get_length() * selected_partition .sector_size ;
 	}
 	else
-		fs .MIN = selected_partition .get_length() * DEFAULT_SECTOR_SIZE ;
-	
+		fs .MIN = selected_partition .get_length() * selected_partition .sector_size ;
+
 	//set MAX
 	if ( fs .grow )
 	{
 		if ( ! fs .MAX || fs .MAX > (TOTAL_MB * MEBI_FACTOR) ) 
 			fs .MAX = TOTAL_MB * MEBI_FACTOR ;
 		else
-			fs .MAX -= (BUF/2 * DEFAULT_SECTOR_SIZE) ;
+			fs .MAX -= (BUF/2 * selected_partition .sector_size) ;
 	}
 	else
-		fs .MAX = selected_partition .get_length() * DEFAULT_SECTOR_SIZE ;
+		fs .MAX = selected_partition .get_length() * selected_partition .sector_size ;
 
 	
 	//set values of spinbutton_before
@@ -148,33 +148,33 @@ void Dialog_Partition_Resize_Move::Resize_Move_Normal( const std::vector<Partiti
 	{
 		spinbutton_before .set_range( 
 			0,
-			TOTAL_MB - Utils::round( Utils::sector_to_unit( (fs .MIN / DEFAULT_SECTOR_SIZE), DEFAULT_SECTOR_SIZE, UNIT_MIB ) ) ) ;
+			TOTAL_MB - Utils::round( Utils::sector_to_unit( fs .MIN, 1 /* Byte */, UNIT_MIB ) ) ) ;
 		spinbutton_before .set_value( 
-			Utils::round( Utils::sector_to_unit( previous, DEFAULT_SECTOR_SIZE, UNIT_MIB ) ) ) ;
+			Utils::round( Utils::sector_to_unit( previous, selected_partition .sector_size, UNIT_MIB ) ) ) ;
 	}
 	
 	//set values of spinbutton_size 
 	spinbutton_size .set_range( 
-		Utils::round( Utils::sector_to_unit( (fs .MIN / DEFAULT_SECTOR_SIZE), DEFAULT_SECTOR_SIZE, UNIT_MIB ) ),
-		Utils::round( Utils::sector_to_unit( (fs .MAX / DEFAULT_SECTOR_SIZE), DEFAULT_SECTOR_SIZE, UNIT_MIB ) ) ) ;
+		Utils::round( Utils::sector_to_unit( fs .MIN, 1 /* Byte */, UNIT_MIB ) ),
+		Utils::round( Utils::sector_to_unit( fs .MAX, 1 /* Byte */, UNIT_MIB ) ) ) ;
 	spinbutton_size .set_value( 
-		Utils::round( Utils::sector_to_unit( selected_partition .get_length(), DEFAULT_SECTOR_SIZE, UNIT_MIB ) ) ) ;
+		Utils::round( Utils::sector_to_unit( selected_partition .get_length(), selected_partition .sector_size, UNIT_MIB ) ) ) ;
 	
 	//set values of spinbutton_after
 	Sector after_min = ( ! fs .grow && ! fs .move ) ? next : 0 ;
 	spinbutton_after .set_range( 
-		Utils::round( Utils::sector_to_unit( after_min, DEFAULT_SECTOR_SIZE, UNIT_MIB ) ),
-		TOTAL_MB - Utils::round( Utils::sector_to_unit( (fs .MIN / DEFAULT_SECTOR_SIZE), DEFAULT_SECTOR_SIZE, UNIT_MIB ) ) ) ;
+		Utils::round( Utils::sector_to_unit( after_min, selected_partition .sector_size, UNIT_MIB ) ),
+		TOTAL_MB - Utils::round( Utils::sector_to_unit( fs .MIN, 1 /* Byte */, UNIT_MIB ) ) ) ;
 	spinbutton_after .set_value( 
-		Utils::round( Utils::sector_to_unit( next, DEFAULT_SECTOR_SIZE, UNIT_MIB ) ) ) ;
+		Utils::round( Utils::sector_to_unit( next, selected_partition .sector_size, UNIT_MIB ) ) ) ;
 	
 	frame_resizer_base ->set_size_limits( Utils::round( fs .MIN / (MB_PER_PIXEL * MEBI_FACTOR) ),
 					      Utils::round( fs .MAX / (MB_PER_PIXEL * MEBI_FACTOR) ) ) ;
 	
 	//set contents of label_minmax
 	Set_MinMax_Text( 
-		Utils::round( Utils::sector_to_unit( (fs .MIN / DEFAULT_SECTOR_SIZE), DEFAULT_SECTOR_SIZE, UNIT_MIB ) ),
-		Utils::round( Utils::sector_to_unit( (fs .MAX / DEFAULT_SECTOR_SIZE), DEFAULT_SECTOR_SIZE, UNIT_MIB ) ) ) ;
+		Utils::round( Utils::sector_to_unit( fs .MIN, 1 /* Byte */, UNIT_MIB ) ),
+		Utils::round( Utils::sector_to_unit( fs .MAX, 1 /* Byte */, UNIT_MIB ) ) ) ;
 }
 
 void Dialog_Partition_Resize_Move::Resize_Move_Extended( const std::vector<Partition> & partitions )
@@ -201,7 +201,7 @@ void Dialog_Partition_Resize_Move::Resize_Move_Extended( const std::vector<Parti
 		
 	//now we have enough data to calculate some important values..
 	total_length = previous + selected_partition .get_length() + next;
-	TOTAL_MB = Utils::round( Utils::sector_to_unit( total_length, DEFAULT_SECTOR_SIZE, UNIT_MIB ) ) ;
+	TOTAL_MB = Utils::round( Utils::sector_to_unit( total_length, selected_partition .sector_size, UNIT_MIB ) ) ;
 	MB_PER_PIXEL = TOTAL_MB / 500.00 ;
 	
 	//calculate proportional length of partition ( in pixels )
@@ -227,34 +227,34 @@ void Dialog_Partition_Resize_Move::Resize_Move_Extended( const std::vector<Parti
 	
 	//set values of spinbutton_before (we assume there is no fixed start.)
 	if ( first == 0 ) //no logicals
-		spinbutton_before .set_range( 0, TOTAL_MB - Utils::round( Utils::sector_to_unit( BUF/2, DEFAULT_SECTOR_SIZE, UNIT_MIB ) ) ) ;
+		spinbutton_before .set_range( 0, TOTAL_MB - Utils::round( Utils::sector_to_unit( BUF/2, selected_partition .sector_size, UNIT_MIB ) ) ) ;
 	else
-		spinbutton_before .set_range( 0, Utils::round( Utils::sector_to_unit( first - START, DEFAULT_SECTOR_SIZE, UNIT_MIB ) ) ) ;
+		spinbutton_before .set_range( 0, Utils::round( Utils::sector_to_unit( first - START, selected_partition .sector_size, UNIT_MIB ) ) ) ;
 	
-	spinbutton_before .set_value( Utils::round( Utils::sector_to_unit( previous, DEFAULT_SECTOR_SIZE, UNIT_MIB ) ) ) ;
+	spinbutton_before .set_value( Utils::round( Utils::sector_to_unit( previous, selected_partition .sector_size, UNIT_MIB ) ) ) ;
 	
 	//set values of spinbutton_size
 	if ( first == 0 ) //no logicals
-		spinbutton_size .set_range( Utils::round( Utils::sector_to_unit( BUF/2, DEFAULT_SECTOR_SIZE, UNIT_MIB ) ), TOTAL_MB ) ;
+		spinbutton_size .set_range( Utils::round( Utils::sector_to_unit( BUF/2, selected_partition .sector_size, UNIT_MIB ) ), TOTAL_MB ) ;
 	else
-		spinbutton_size .set_range( Utils::round( Utils::sector_to_unit( used, DEFAULT_SECTOR_SIZE, UNIT_MIB ) ), TOTAL_MB ) ;
+		spinbutton_size .set_range( Utils::round( Utils::sector_to_unit( used, selected_partition .sector_size, UNIT_MIB ) ), TOTAL_MB ) ;
 	
 	spinbutton_size .set_value(
-		Utils::round( Utils::sector_to_unit( selected_partition .get_length(), DEFAULT_SECTOR_SIZE, UNIT_MIB ) ) ) ;
+		Utils::round( Utils::sector_to_unit( selected_partition .get_length(), selected_partition .sector_size, UNIT_MIB ) ) ) ;
 	
 	//set values of spinbutton_after
 	if ( first == 0 ) //no logicals
 		spinbutton_after .set_range( 
-			0, TOTAL_MB - Utils::round( Utils::sector_to_unit( BUF/2, DEFAULT_SECTOR_SIZE, UNIT_MIB ) ) ) ;
+			0, TOTAL_MB - Utils::round( Utils::sector_to_unit( BUF/2, selected_partition .sector_size, UNIT_MIB ) ) ) ;
 	else
 		spinbutton_after .set_range( 
-			0, Utils::round( Utils::sector_to_unit( total_length + START - first - used, DEFAULT_SECTOR_SIZE, UNIT_MIB ) ) ) ;
+			0, Utils::round( Utils::sector_to_unit( total_length + START - first - used, selected_partition .sector_size, UNIT_MIB ) ) ) ;
 	
-	spinbutton_after .set_value( Utils::round( Utils::sector_to_unit( next, DEFAULT_SECTOR_SIZE, UNIT_MIB ) ) ) ;
+	spinbutton_after .set_value( Utils::round( Utils::sector_to_unit( next, selected_partition .sector_size, UNIT_MIB ) ) ) ;
 	
 	//set contents of label_minmax
-	Set_MinMax_Text( Utils::round( Utils::sector_to_unit( first == 0 ? BUF/2 : used, DEFAULT_SECTOR_SIZE, UNIT_MIB ) ),
-			 Utils::round( Utils::sector_to_unit( total_length, DEFAULT_SECTOR_SIZE, UNIT_MIB ) ) ) ;
+	Set_MinMax_Text( Utils::round( Utils::sector_to_unit( first == 0 ? BUF/2 : used, selected_partition .sector_size, UNIT_MIB ) ),
+			 Utils::round( Utils::sector_to_unit( total_length, selected_partition .sector_size, UNIT_MIB ) ) ) ;
 }
 
 } //GParted
diff --git a/src/DrawingAreaVisualDisk.cc b/src/DrawingAreaVisualDisk.cc
index ea5f035..180c689 100644
--- a/src/DrawingAreaVisualDisk.cc
+++ b/src/DrawingAreaVisualDisk.cc
@@ -108,7 +108,7 @@ void DrawingAreaVisualDisk::set_static_data( const std::vector<Partition> & part
 	   			         partitions[ t ] .get_length() ) ;
 		else
 			visual_partitions .back() .pango_layout = create_pango_layout( 
-				partitions[ t ] .get_path() + "\n" + Utils::format_size( partitions[ t ] .get_length(), DEFAULT_SECTOR_SIZE ) ) ;
+				partitions[ t ] .get_path() + "\n" + Utils::format_size( partitions[ t ] .get_length(), partitions[ t ] .sector_size ) ) ;
 	}
 }
 
diff --git a/src/GParted_Core.cc b/src/GParted_Core.cc
index ec802b0..8993389 100644
--- a/src/GParted_Core.cc
+++ b/src/GParted_Core.cc
@@ -480,7 +480,7 @@ bool GParted_Core::apply_operation_to_disk( Operation * operation )
 
 					 copy( static_cast<OperationCopy*>( operation ) ->partition_copied,
 					       operation ->partition_new,
-					       static_cast<OperationCopy*>( operation ) ->partition_copied .get_length() * DEFAULT_SECTOR_SIZE,
+					       static_cast<OperationCopy*>( operation ) ->partition_copied .get_length() * static_cast<OperationCopy*>( operation ) ->partition_copied .sector_size,
 					       operation ->operation_detail ) ;
 				break ;
 			case OPERATION_LABEL_PARTITION:
@@ -1307,7 +1307,7 @@ bool GParted_Core::create( const Device & device, Partition & new_partition, Ope
 	{
 		return create_partition( new_partition, operationdetail ) ;
 	}
-	else if ( create_partition( new_partition, operationdetail, (get_fs( new_partition .filesystem ) .MIN / DEFAULT_SECTOR_SIZE) ) )
+	else if ( create_partition( new_partition, operationdetail, (get_fs( new_partition .filesystem ) .MIN / new_partition .sector_size) ) )
 	{
 		if ( new_partition .filesystem == GParted::FS_UNFORMATTED )
 			return true ;
@@ -1394,7 +1394,7 @@ bool GParted_Core::create_partition( Partition & new_partition, OperationDetail
 						String::ucompose( _("end: %1"), new_partition .sector_end ) + "\n" +
 						String::ucompose( _("size: %1 (%2)"),
 								new_partition .get_length(),
-								Utils::format_size( new_partition .get_length(), DEFAULT_SECTOR_SIZE ) ),
+								Utils::format_size( new_partition .get_length(), new_partition .sector_size ) ),
 						STATUS_NONE,
 						FONT_ITALIC ) ) ;
 				}
@@ -1828,8 +1828,8 @@ bool GParted_Core::resize_move_partition( const Partition & partition_old,
 
 	if ( ! description .empty() && action != NONE && action != MOVE_LEFT && action != MOVE_RIGHT )
 		description = String::ucompose( description,
-						Utils::format_size( partition_old .get_length(), DEFAULT_SECTOR_SIZE ),
-						Utils::format_size( partition_new .get_length(), DEFAULT_SECTOR_SIZE ) ) ;
+						Utils::format_size( partition_old .get_length(), partition_old .sector_size ),
+						Utils::format_size( partition_new .get_length(), partition_new .sector_size ) ) ;
 
 	operationdetail .add_child( OperationDetail( description ) ) ;
 
@@ -1851,7 +1851,7 @@ bool GParted_Core::resize_move_partition( const Partition & partition_old,
 			String::ucompose( _("old end: %1"), partition_old .sector_end ) + "\n" +
 			String::ucompose( _("old size: %1 (%2)"),
 					partition_old .get_length(),
-					Utils::format_size( partition_old .get_length(), DEFAULT_SECTOR_SIZE ) ),
+					Utils::format_size( partition_old .get_length(), partition_old .sector_size ) ),
 		STATUS_NONE, 
 		FONT_ITALIC ) ) ;
 	
@@ -1912,7 +1912,7 @@ bool GParted_Core::resize_move_partition( const Partition & partition_old,
 				String::ucompose( _("new end: %1"), new_end ) + "\n" +
 				String::ucompose( _("new size: %1 (%2)"),
 						new_end - new_start + 1,
-						Utils::format_size( new_end - new_start + 1, DEFAULT_SECTOR_SIZE ) ),
+						Utils::format_size( new_end - new_start + 1, partition_new .sector_size ) ),
 			STATUS_NONE, 
 			FONT_ITALIC ) ) ;
 
@@ -2026,7 +2026,7 @@ bool GParted_Core::copy( const Partition & partition_src,
 		if ( partition_dst .status == GParted::STAT_COPY )
 		{
 			/* Handle situation where src sector size is smaller than dst sector size and an additional partial dst sector is required. */
-			succes = create_partition( partition_dst, operationdetail, ( (min_size + (DEFAULT_SECTOR_SIZE - 1)) / DEFAULT_SECTOR_SIZE ) ) ;
+			succes = create_partition( partition_dst, operationdetail, ( (min_size + (partition_dst .sector_size - 1)) / partition_dst .sector_size ) ) ;
 		}
 
 		if ( succes && set_partition_type( partition_dst, operationdetail ) )
@@ -2096,7 +2096,7 @@ bool GParted_Core::copy_filesystem( const Partition & partition_src,
 				partition_dst .sector_start,
 				partition_src .sector_size,
 				partition_dst .sector_size,
-				partition_src .get_length() * DEFAULT_SECTOR_SIZE,
+				partition_src .get_length() * partition_src .sector_size,
 				operationdetail,
 				readonly,
 				dummy ) ;
@@ -2113,7 +2113,7 @@ bool GParted_Core::copy_filesystem( const Partition & partition_src,
 				partition_dst .sector_start,
 				partition_src .sector_size,
 				partition_dst .sector_size,
-				partition_src .get_length() * DEFAULT_SECTOR_SIZE,
+				partition_src .get_length() * partition_src .sector_size,
 				operationdetail,
 				false,
 				total_done ) ;
@@ -2239,13 +2239,13 @@ void GParted_Core::rollback_transaction( const Partition & partition_src,
 
 		if ( partition_dst .sector_start > partition_src .sector_start )
 		{
-			temp_src .sector_start = temp_src .sector_end - ( (total_done / DEFAULT_SECTOR_SIZE) - 1 ) ;
-			temp_dst .sector_start = temp_dst .sector_end - ( (total_done / DEFAULT_SECTOR_SIZE) - 1 ) ;
+			temp_src .sector_start = temp_src .sector_end - ( (total_done / temp_src .sector_size) - 1 ) ;
+			temp_dst .sector_start = temp_dst .sector_end - ( (total_done / temp_dst .sector_size) - 1 ) ;
 		}
 		else
 		{
-			temp_src .sector_end = temp_src .sector_start + ( (total_done / DEFAULT_SECTOR_SIZE) - 1 ) ;
-			temp_dst .sector_end = temp_dst .sector_start + ( (total_done / DEFAULT_SECTOR_SIZE) - 1 ) ;
+			temp_src .sector_end = temp_src .sector_start + ( (total_done / temp_src .sector_size) - 1 ) ;
+			temp_dst .sector_end = temp_dst .sector_start + ( (total_done / temp_dst .sector_size) - 1 ) ;
 		}
 
 		//and copy it back (NOTE the reversed dst and src)
@@ -2578,7 +2578,7 @@ bool GParted_Core::calibrate_partition( Partition & partition, OperationDetail &
 						String::ucompose( _("end: %1"), partition .sector_end ) + "\n" +
 						String::ucompose( _("size: %1 (%2)"),
 								partition .get_length(),
-								Utils::format_size( partition .get_length(), DEFAULT_SECTOR_SIZE ) ),
+								Utils::format_size( partition .get_length(), partition .sector_size ) ),
 					STATUS_NONE, 
 					FONT_ITALIC ) ) ;
 				succes = true ;
@@ -2607,7 +2607,7 @@ bool GParted_Core::calculate_exact_geom( const Partition & partition_old,
 			String::ucompose( _("requested end: %1"), partition_new .sector_end ) + "\n" +
 			String::ucompose( _("requested size: %1 (%2)"),
 					partition_new .get_length(),
-					Utils::format_size( partition_new .get_length(), DEFAULT_SECTOR_SIZE ) ),
+					Utils::format_size( partition_new .get_length(), partition_new .sector_size ) ),
 		STATUS_NONE,
 		FONT_ITALIC ) ) ;
 	
@@ -2658,7 +2658,7 @@ bool GParted_Core::calculate_exact_geom( const Partition & partition_old,
 				String::ucompose( _("new end: %1"), partition_new .sector_end ) + "\n" +
 				String::ucompose( _("new size: %1 (%2)"),
 						partition_new .get_length(),
-						Utils::format_size( partition_new .get_length(), DEFAULT_SECTOR_SIZE ) ),
+						Utils::format_size( partition_new .get_length(), partition_new .sector_size ) ),
 			STATUS_NONE,
 			FONT_ITALIC ) ) ;
 
diff --git a/src/OperationCopy.cc b/src/OperationCopy.cc
index 332825a..315bb1d 100644
--- a/src/OperationCopy.cc
+++ b/src/OperationCopy.cc
@@ -80,7 +80,7 @@ void OperationCopy::create_description()
 		description = String::ucompose( _("Copy %1 to %2 (start at %3)"),
 					        partition_copied .get_path(),
 					        device .get_path(),
-					        Utils::format_size( partition_new .sector_start, DEFAULT_SECTOR_SIZE ) ) ;
+					        Utils::format_size( partition_new .sector_start, partition_new .sector_size ) ) ;
 	}
 	else
 	{
diff --git a/src/OperationCreate.cc b/src/OperationCreate.cc
index 9c7616d..2dddf21 100644
--- a/src/OperationCreate.cc
+++ b/src/OperationCreate.cc
@@ -89,7 +89,7 @@ void OperationCreate::create_description()
 				 	description, 
 					partition_new .partition_number, 
 					Utils::get_filesystem_string( partition_new .filesystem ), 
-					Utils::format_size( partition_new .get_length(), DEFAULT_SECTOR_SIZE ),
+					Utils::format_size( partition_new .get_length(), partition_new .sector_size ),
 					device .get_path() ) ;
 }
 
diff --git a/src/OperationDelete.cc b/src/OperationDelete.cc
index 659eef1..5da92c0 100644
--- a/src/OperationDelete.cc
+++ b/src/OperationDelete.cc
@@ -82,7 +82,7 @@ void OperationDelete::create_description()
 	description = String::ucompose( _("Delete %1 (%2, %3) from %4"),
 					description,
 					Utils::get_filesystem_string( partition_original .filesystem ), 
-					Utils::format_size( partition_original .get_length(), DEFAULT_SECTOR_SIZE ),
+					Utils::format_size( partition_original .get_length(), partition_original .sector_size ),
 					partition_original .device_path ) ;
 }
 	
diff --git a/src/OperationResizeMove.cc b/src/OperationResizeMove.cc
index 57e31a6..2acb763 100644
--- a/src/OperationResizeMove.cc
+++ b/src/OperationResizeMove.cc
@@ -117,8 +117,8 @@ void OperationResizeMove::create_description()
 	if ( ! description .empty() && action != NONE && action != MOVE_LEFT && action != MOVE_RIGHT )
 		description = String::ucompose( description,
 						partition_original .get_path(),
-						Utils::format_size( partition_original .get_length(), DEFAULT_SECTOR_SIZE ),
-						Utils::format_size( partition_new .get_length(), DEFAULT_SECTOR_SIZE ) ) ;
+						Utils::format_size( partition_original .get_length(), partition_original .sector_size ),
+						Utils::format_size( partition_new .get_length(), partition_new .sector_size ) ) ;
 }
 
 void OperationResizeMove::apply_normal_to_visual( std::vector<Partition> & partitions )
diff --git a/src/TreeView_Detail.cc b/src/TreeView_Detail.cc
index 167a9de..dec80fe 100644
--- a/src/TreeView_Detail.cc
+++ b/src/TreeView_Detail.cc
@@ -187,15 +187,15 @@ void TreeView_Detail::create_row( const Gtk::TreeRow & treerow, const Partition
 	treerow[ treeview_detail_columns .label ] = partition .label ;
 		
 	//size
-	treerow[ treeview_detail_columns .size ] = Utils::format_size( partition .get_length(), DEFAULT_SECTOR_SIZE ) ;
+	treerow[ treeview_detail_columns .size ] = Utils::format_size( partition .get_length(), partition .sector_size ) ;
 	
 	//used
 	treerow[ treeview_detail_columns .used ] =
-		partition .sectors_used == -1 ? "---" : Utils::format_size( partition .sectors_used, DEFAULT_SECTOR_SIZE ) ;
+		partition .sectors_used == -1 ? "---" : Utils::format_size( partition .sectors_used, partition .sector_size ) ;
 
 	//unused
 	treerow[ treeview_detail_columns .unused ] = 
-		partition .sectors_unused == -1 ? "---" : Utils::format_size( partition .sectors_unused, DEFAULT_SECTOR_SIZE ) ;
+		partition .sectors_unused == -1 ? "---" : Utils::format_size( partition .sectors_unused, partition .sector_size ) ;
 
 	//flags	
 	treerow[ treeview_detail_columns .flags ] = 
diff --git a/src/Win_GParted.cc b/src/Win_GParted.cc
index 9e012a9..973924f 100644
--- a/src/Win_GParted.cc
+++ b/src/Win_GParted.cc
@@ -565,12 +565,12 @@ void Win_GParted::refresh_combo_devices()
 		treerow[ treeview_devices_columns .icon ] =
 			render_icon( Gtk::Stock::HARDDISK, Gtk::ICON_SIZE_LARGE_TOOLBAR ) ;
 		treerow[ treeview_devices_columns .device ] = devices[ i ] .get_path() ;
-		treerow[ treeview_devices_columns .size ] = "(" + Utils::format_size( devices[ i ] .length, DEFAULT_SECTOR_SIZE ) + ")" ; 
+		treerow[ treeview_devices_columns .size ] = "(" + Utils::format_size( devices[ i ] .length, devices[ i ] .sector_size ) + ")" ; 
 	
 		//devices submenu....
 		hbox = manage( new Gtk::HBox() ) ;
 		hbox ->pack_start( * Utils::mk_label( devices[ i ] .get_path() ), Gtk::PACK_SHRINK ) ;
-		hbox ->pack_start( * Utils::mk_label( "   (" + Utils::format_size( devices[ i ] .length, DEFAULT_SECTOR_SIZE ) + ")",
+		hbox ->pack_start( * Utils::mk_label( "   (" + Utils::format_size( devices[ i ] .length, devices[ i ] .sector_size ) + ")",
 					              true,
 						      Gtk::ALIGN_RIGHT ),
 				   Gtk::PACK_EXPAND_WIDGET ) ;
@@ -645,7 +645,7 @@ void Win_GParted::Fill_Label_Device_Info( bool clear )
 		
 		//global info...
 		device_info[ t++ ] ->set_text( devices[ current_device ] .model ) ;
-		device_info[ t++ ] ->set_text( Utils::format_size( devices[ current_device ] .length, DEFAULT_SECTOR_SIZE ) ) ;
+		device_info[ t++ ] ->set_text( Utils::format_size( devices[ current_device ] .length, devices[ current_device ] .sector_size ) ) ;
 		device_info[ t++ ] ->set_text( Glib::build_path( "\n", devices[ current_device ] .get_paths() ) ) ;
 		
 		//detailed info
@@ -1582,7 +1582,7 @@ void Win_GParted::activate_delete()
 		dialog .set_title( String::ucompose( _("Delete %1 (%2, %3)"), 
 						     selected_partition .get_path(), 
 						     Utils::get_filesystem_string( selected_partition .filesystem ),
-						     Utils::format_size( selected_partition .get_length(), DEFAULT_SECTOR_SIZE ) ) );
+						     Utils::format_size( selected_partition .get_length(), selected_partition .sector_size ) ) );
 		dialog .add_button( Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL );
 		dialog .add_button( Gtk::Stock::DELETE, Gtk::RESPONSE_OK );
 	
@@ -1641,8 +1641,8 @@ void Win_GParted::activate_format( GParted::FILESYSTEM new_fs )
 	//check for some limits...
 	fs = gparted_core .get_fs( new_fs ) ;
 	
-	if ( ( selected_partition .get_length() < (fs .MIN / DEFAULT_SECTOR_SIZE) ) ||
-	     ( fs .MAX && selected_partition .get_length() > (fs .MAX / DEFAULT_SECTOR_SIZE) ) )
+	if ( ( selected_partition .get_length() < (fs .MIN / selected_partition .sector_size) ) ||
+	     ( fs .MAX && selected_partition .get_length() > (fs .MAX / selected_partition .sector_size) ) )
 	{
 		Gtk::MessageDialog dialog( *this,
 					   String::ucompose( _("Cannot format this file system to %1."),
@@ -1652,16 +1652,16 @@ void Win_GParted::activate_format( GParted::FILESYSTEM new_fs )
 					   Gtk::BUTTONS_OK,
 					   true );
 
-		if ( selected_partition .get_length() < (fs .MIN / DEFAULT_SECTOR_SIZE) )
+		if ( selected_partition .get_length() < (fs .MIN / selected_partition .sector_size) )
 			dialog .set_secondary_text( String::ucompose( 
 						_( "A %1 file system requires a partition of at least %2."),
 						Utils::get_filesystem_string( new_fs ),
-						Utils::format_size( (fs .MIN / DEFAULT_SECTOR_SIZE), DEFAULT_SECTOR_SIZE ) ) );
+						Utils::format_size( fs .MIN, 1 /* Byte */ ) ) );
 		else
 			dialog .set_secondary_text( String::ucompose( 
 						_( "A partition with a %1 file system has a maximum size of %2."),
 						Utils::get_filesystem_string( new_fs ),
-						Utils::format_size( (fs .MAX / DEFAULT_SECTOR_SIZE), DEFAULT_SECTOR_SIZE ) ) );
+						Utils::format_size( fs .MAX, 1 /* Byte */ ) ) );
 		
 		dialog .run() ;
 		return ;
diff --git a/src/ext2.cc b/src/ext2.cc
index c307660..c473c48 100644
--- a/src/ext2.cc
+++ b/src/ext2.cc
@@ -116,7 +116,7 @@ bool ext2::resize( const Partition & partition_new, OperationDetail & operationd
 	
 	if ( ! fill_partition )
 		str_temp += " " + Utils::num_to_str( Utils::round( Utils::sector_to_unit( 
-					partition_new .get_length(), DEFAULT_SECTOR_SIZE, UNIT_KIB ) ) -1 ) + "K" ; 
+					partition_new .get_length(), partition_new .sector_size, UNIT_KIB ) ) -1 ) + "K" ; 
 		
 	return ! execute_command( str_temp, operationdetail ) ;
 }
diff --git a/src/ext3.cc b/src/ext3.cc
index 341d988..cd2f8e6 100644
--- a/src/ext3.cc
+++ b/src/ext3.cc
@@ -117,7 +117,7 @@ bool ext3::resize( const Partition & partition_new, OperationDetail & operationd
 	
 	if ( ! fill_partition )
 		str_temp += " " + Utils::num_to_str( Utils::round( Utils::sector_to_unit( 
-					partition_new .get_length(), DEFAULT_SECTOR_SIZE, UNIT_KIB ) ) -1 ) + "K" ; 
+					partition_new .get_length(), partition_new .sector_size, UNIT_KIB ) ) -1 ) + "K" ; 
 		
 	return ! execute_command( str_temp, operationdetail ) ;
 }
diff --git a/src/ext4.cc b/src/ext4.cc
index 063ad12..86b1abc 100644
--- a/src/ext4.cc
+++ b/src/ext4.cc
@@ -120,7 +120,7 @@ bool ext4::resize( const Partition & partition_new, OperationDetail & operationd
 	
 	if ( ! fill_partition )
 		str_temp += " " + Utils::num_to_str( Utils::round( Utils::sector_to_unit( 
-					partition_new .get_length(), DEFAULT_SECTOR_SIZE, UNIT_KIB ) ) -1 ) + "K" ; 
+					partition_new .get_length(), partition_new .sector_size, UNIT_KIB ) ) -1 ) + "K" ; 
 		
 	return ! execute_command( str_temp, operationdetail ) ;
 }
diff --git a/src/ntfs.cc b/src/ntfs.cc
index 235a6f1..39d2b69 100644
--- a/src/ntfs.cc
+++ b/src/ntfs.cc
@@ -118,7 +118,7 @@ bool ntfs::resize( const Partition & partition_new, OperationDetail & operationd
 	{
 		str_temp += " -s " ;
 		str_temp += Utils::num_to_str( Utils::round( Utils::sector_to_unit(
-				partition_new .get_length(), DEFAULT_SECTOR_SIZE, UNIT_BYTE ) ) -1 ) ;
+				partition_new .get_length(), partition_new .sector_size, UNIT_BYTE ) ) -1 ) ;
 	}
 	
 	//simulation..
diff --git a/src/reiserfs.cc b/src/reiserfs.cc
index 46022a8..b36b39e 100644
--- a/src/reiserfs.cc
+++ b/src/reiserfs.cc
@@ -125,7 +125,7 @@ bool reiserfs::resize( const Partition & partition_new, OperationDetail & operat
 	{
 		str_temp += " -s " ;
 		str_temp += Utils::num_to_str( Utils::round( Utils::sector_to_unit(
-				partition_new .get_length(), DEFAULT_SECTOR_SIZE, UNIT_BYTE ) ) -1 ) ;
+				partition_new .get_length(), partition_new .sector_size, UNIT_BYTE ) ) -1 ) ;
 	}
 
 	exit_status = execute_command( str_temp, operationdetail ) ;



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