[gparted] Convert file system minimum from sector to byte value



commit 40d7dbac4b904614f367cd503235c19366f158a8
Author: Curtis Gedak <gedakc gmail com>
Date:   Tue Mar 16 11:24:08 2010 -0600

    Convert file system minimum from sector to byte value

 include/Utils.h                     |    2 +-
 src/Dialog_Partition_Copy.cc        |   14 +++++++-------
 src/Dialog_Partition_New.cc         |   24 ++++++++++++------------
 src/Dialog_Partition_Resize_Move.cc |   22 +++++++++++-----------
 src/GParted_Core.cc                 |    2 +-
 src/Win_GParted.cc                  |    6 +++---
 src/fat16.cc                        |    2 +-
 src/fat32.cc                        |    2 +-
 src/jfs.cc                          |    2 +-
 src/reiserfs.cc                     |    3 ++-
 src/xfs.cc                          |    2 +-
 11 files changed, 41 insertions(+), 40 deletions(-)
---
diff --git a/include/Utils.h b/include/Utils.h
index 7ef28c3..e7917c8 100644
--- a/include/Utils.h
+++ b/include/Utils.h
@@ -117,7 +117,7 @@ struct FS
 	Support check ; //some checktool available?
 	Support copy ;
 
-	Sector MIN ; 
+	Byte_Value MIN ; 
 	Sector MAX ;
 	
 	FS()
diff --git a/src/Dialog_Partition_Copy.cc b/src/Dialog_Partition_Copy.cc
index 9f4ea0c..12bef12 100644
--- a/src/Dialog_Partition_Copy.cc
+++ b/src/Dialog_Partition_Copy.cc
@@ -105,32 +105,32 @@ void Dialog_Partition_Copy::Set_Data( const Partition & selected_partition, cons
 
 	
 	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) ;
+		fs .MIN = ( copied_partition .sectors_used + (BUF * 2) ) * DEFAULT_SECTOR_SIZE;
 	else
-		fs .MIN = COPIED_LENGTH_MB * MEBIBYTE ;
+		fs .MIN = COPIED_LENGTH_MB * MEBI_FACTOR ;
 	
 	GRIP = true ;
 	//set values of spinbutton_before
-	spinbutton_before .set_range( 0, TOTAL_MB - Utils::round( Utils::sector_to_unit( fs .MIN, GParted::UNIT_MIB ) ) ) ;
+	spinbutton_before .set_range( 0, TOTAL_MB - Utils::round( Utils::sector_to_unit( (fs .MIN / DEFAULT_SECTOR_SIZE), GParted::UNIT_MIB ) ) ) ;
 	spinbutton_before .set_value( 0 ) ;
 		
 	//set values of spinbutton_size
 	spinbutton_size .set_range(
-		Utils::round( Utils::sector_to_unit( fs .MIN, GParted::UNIT_MIB ) ),
+		Utils::round( Utils::sector_to_unit( (fs .MIN / DEFAULT_SECTOR_SIZE), GParted::UNIT_MIB ) ),
 		Utils::round( Utils::sector_to_unit( fs .MAX, GParted::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, GParted::UNIT_MIB ) ) ) ;
+	spinbutton_after .set_range( 0, TOTAL_MB - Utils::round( Utils::sector_to_unit( (fs .MIN / DEFAULT_SECTOR_SIZE), GParted::UNIT_MIB ) ) ) ;
 	spinbutton_after .set_value( TOTAL_MB - COPIED_LENGTH_MB ) ; 
 	GRIP = false ;
 	
-	frame_resizer_base ->set_size_limits( Utils::round( fs .MIN / (MB_PER_PIXEL * MEBIBYTE) ),
+	frame_resizer_base ->set_size_limits( Utils::round( fs .MIN / (MB_PER_PIXEL * MEBI_FACTOR) ),
 					      Utils::round( fs .MAX / (MB_PER_PIXEL * MEBIBYTE) ) ) ;
 	
 	//set contents of label_minmax
 	Set_MinMax_Text( 
-		Utils::round( Utils::sector_to_unit( fs .MIN, GParted::UNIT_MIB ) ),
+		Utils::round( Utils::sector_to_unit( (fs .MIN / DEFAULT_SECTOR_SIZE), GParted::UNIT_MIB ) ),
 		Utils::round( Utils::sector_to_unit( fs .MAX, GParted::UNIT_MIB ) ) ) ;
 
 	//set global selected_partition (see Dialog_Base_Partition::Get_New_Partition )
diff --git a/src/Dialog_Partition_New.cc b/src/Dialog_Partition_New.cc
index 19bbf89..0239cde 100644
--- a/src/Dialog_Partition_New.cc
+++ b/src/Dialog_Partition_New.cc
@@ -251,33 +251,33 @@ void Dialog_Partition_New::optionmenu_changed( bool type )
 
 		if ( checkbutton_round_to_cylinders .get_active() )
 		{
-			if ( fs .MIN < cylinder_size )
-				fs .MIN = cylinder_size ;
+			if ( (fs .MIN / DEFAULT_SECTOR_SIZE) < cylinder_size )
+				fs .MIN = cylinder_size * DEFAULT_SECTOR_SIZE ;
 		}
-		else if ( fs .MIN < MEBIBYTE )
-			fs .MIN = MEBIBYTE ;
+		else if ( (fs .MIN / DEFAULT_SECTOR_SIZE) < MEBIBYTE )
+			fs .MIN = MEBI_FACTOR ;
 		
-		if ( selected_partition .get_length() < fs .MIN )
-			fs .MIN = selected_partition .get_length() ;
+		if ( selected_partition .get_length() < (fs .MIN /DEFAULT_SECTOR_SIZE) )
+			fs .MIN = selected_partition .get_length() * DEFAULT_SECTOR_SIZE ;
 				
 		fs .MAX = ( fs .MAX && ( fs .MAX - cylinder_size ) < (TOTAL_MB * MEBIBYTE) ) ?
 				fs .MAX - cylinder_size : TOTAL_MB * MEBIBYTE ;
 		
-		frame_resizer_base ->set_size_limits( Utils::round( fs .MIN / (MB_PER_PIXEL * MEBIBYTE) ),
+		frame_resizer_base ->set_size_limits( Utils::round( fs .MIN / (MB_PER_PIXEL * MEBI_FACTOR) ),
 						      Utils::round( fs .MAX / (MB_PER_PIXEL * MEBIBYTE) ) ) ;
 				
 		//set new spinbutton ranges
 		spinbutton_before .set_range( 
-			0, TOTAL_MB - Utils::round( Utils::sector_to_unit( fs .MIN, GParted::UNIT_MIB ) ) ) ;
+			0, TOTAL_MB - Utils::round( Utils::sector_to_unit( (fs .MIN / DEFAULT_SECTOR_SIZE), GParted::UNIT_MIB ) ) ) ;
 		spinbutton_size .set_range(
-				Utils::round( Utils::sector_to_unit( fs .MIN, GParted::UNIT_MIB ) ),
+				Utils::round( Utils::sector_to_unit( (fs .MIN / DEFAULT_SECTOR_SIZE), GParted::UNIT_MIB ) ),
 				Utils::round( Utils::sector_to_unit( fs .MAX, GParted::UNIT_MIB ) ) ) ;
 		spinbutton_after .set_range(
-			0, TOTAL_MB - Utils::round( Utils::sector_to_unit( fs .MIN, GParted::UNIT_MIB ) ) ) ;
+			0, TOTAL_MB - Utils::round( Utils::sector_to_unit( (fs .MIN / DEFAULT_SECTOR_SIZE), GParted::UNIT_MIB ) ) ) ;
 				
 		//set contents of label_minmax
 		Set_MinMax_Text(
-			Utils::round( Utils::sector_to_unit( fs .MIN, GParted::UNIT_MIB ) ),
+			Utils::round( Utils::sector_to_unit( (fs .MIN / DEFAULT_SECTOR_SIZE), GParted::UNIT_MIB ) ),
 			Utils::round( Utils::sector_to_unit( fs .MAX, GParted::UNIT_MIB ) ) ) ;
 	}
 	
@@ -305,7 +305,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 ) ;
+			this ->selected_partition .get_length() >= (FILESYSTEMS[ t ] .MIN / DEFAULT_SECTOR_SIZE) ) ;
 	}
 	
 	//unformatted is always available
diff --git a/src/Dialog_Partition_Resize_Move.cc b/src/Dialog_Partition_Resize_Move.cc
index 8d201f1..2ecbb09 100644
--- a/src/Dialog_Partition_Resize_Move.cc
+++ b/src/Dialog_Partition_Resize_Move.cc
@@ -117,18 +117,18 @@ 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 )
-			fs .MIN = selected_partition .sectors_used ;
+		if ( selected_partition .sectors_used > (fs .MIN / DEFAULT_SECTOR_SIZE) )
+			fs .MIN = selected_partition .sectors_used * DEFAULT_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 : BUF/2 ;
+		fs .MIN += fs .MIN ? (BUF * DEFAULT_SECTOR_SIZE) : (BUF/2 * DEFAULT_SECTOR_SIZE) ;
 
 		//in certain (rare) cases fs .MIN is (now) larger than 'selected_partition'..
-		if ( fs .MIN > selected_partition .get_length() )
-			fs .MIN = selected_partition .get_length() ;
+		if ( (fs .MIN / DEFAULT_SECTOR_SIZE) > selected_partition .get_length() )
+			fs .MIN = selected_partition .get_length() * DEFAULT_SECTOR_SIZE ;
 	}
 	else
-		fs .MIN = selected_partition .get_length() ;
+		fs .MIN = selected_partition .get_length() * DEFAULT_SECTOR_SIZE ;
 	
 	//set MAX
 	if ( fs .grow )
@@ -147,14 +147,14 @@ 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, GParted::UNIT_MIB ) ) ) ;
+			TOTAL_MB - Utils::round( Utils::sector_to_unit( (fs .MIN / DEFAULT_SECTOR_SIZE), GParted::UNIT_MIB ) ) ) ;
 		spinbutton_before .set_value( 
 			Utils::round( Utils::sector_to_unit( previous, GParted::UNIT_MIB ) ) ) ;
 	}
 	
 	//set values of spinbutton_size 
 	spinbutton_size .set_range( 
-		Utils::round( Utils::sector_to_unit( fs .MIN, GParted::UNIT_MIB ) ),
+		Utils::round( Utils::sector_to_unit( (fs .MIN / DEFAULT_SECTOR_SIZE), GParted::UNIT_MIB ) ),
 		Utils::round( Utils::sector_to_unit( fs .MAX, GParted::UNIT_MIB ) ) ) ;
 	spinbutton_size .set_value( 
 		Utils::round( Utils::sector_to_unit( selected_partition .get_length(), GParted::UNIT_MIB ) ) ) ;
@@ -163,16 +163,16 @@ void Dialog_Partition_Resize_Move::Resize_Move_Normal( const std::vector<Partiti
 	Sector after_min = ( ! fs .grow && ! fs .move ) ? next : 0 ;
 	spinbutton_after .set_range( 
 		Utils::round( Utils::sector_to_unit( after_min, GParted::UNIT_MIB ) ),
-		TOTAL_MB - Utils::round( Utils::sector_to_unit( fs .MIN, GParted::UNIT_MIB ) ) ) ;
+		TOTAL_MB - Utils::round( Utils::sector_to_unit( (fs .MIN / DEFAULT_SECTOR_SIZE), GParted::UNIT_MIB ) ) ) ;
 	spinbutton_after .set_value( 
 		Utils::round( Utils::sector_to_unit( next, GParted::UNIT_MIB ) ) ) ;
 	
-	frame_resizer_base ->set_size_limits( Utils::round( fs .MIN / (MB_PER_PIXEL * MEBIBYTE) ),
+	frame_resizer_base ->set_size_limits( Utils::round( fs .MIN / (MB_PER_PIXEL * MEBI_FACTOR) ),
 					      Utils::round( fs .MAX / (MB_PER_PIXEL * MEBIBYTE) ) ) ;
 	
 	//set contents of label_minmax
 	Set_MinMax_Text( 
-		Utils::round( Utils::sector_to_unit( fs .MIN, GParted::UNIT_MIB ) ),
+		Utils::round( Utils::sector_to_unit( (fs .MIN / DEFAULT_SECTOR_SIZE), GParted::UNIT_MIB ) ),
 		Utils::round( Utils::sector_to_unit( fs .MAX, GParted::UNIT_MIB ) ) ) ;
 }
 
diff --git a/src/GParted_Core.cc b/src/GParted_Core.cc
index 0133692..89c5fdf 100644
--- a/src/GParted_Core.cc
+++ b/src/GParted_Core.cc
@@ -1302,7 +1302,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 ) )
+	else if ( create_partition( new_partition, operationdetail, (get_fs( new_partition .filesystem ) .MIN / DEFAULT_SECTOR_SIZE) ) )
 	{
 		if ( new_partition .filesystem == GParted::FS_UNFORMATTED )
 			return true ;
diff --git a/src/Win_GParted.cc b/src/Win_GParted.cc
index 69c3de2..2c0eed1 100644
--- a/src/Win_GParted.cc
+++ b/src/Win_GParted.cc
@@ -1640,7 +1640,7 @@ 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 ) ||
+	if ( ( selected_partition .get_length() < (fs .MIN / DEFAULT_SECTOR_SIZE) ) ||
 	     ( fs .MAX && selected_partition .get_length() > fs .MAX ) )
 	{
 		Gtk::MessageDialog dialog( *this,
@@ -1651,11 +1651,11 @@ void Win_GParted::activate_format( GParted::FILESYSTEM new_fs )
 					   Gtk::BUTTONS_OK,
 					   true );
 
-		if ( selected_partition .get_length() < fs .MIN )
+		if ( selected_partition .get_length() < (fs .MIN / DEFAULT_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 ) ) );
+						Utils::format_size( (fs .MIN / DEFAULT_SECTOR_SIZE) ) ) );
 		else
 			dialog .set_secondary_text( String::ucompose( 
 						_( "A partition with a %1 file system has a maximum size of %2."),
diff --git a/src/fat16.cc b/src/fat16.cc
index dbccfaf..bb2cc76 100644
--- a/src/fat16.cc
+++ b/src/fat16.cc
@@ -56,7 +56,7 @@ FS fat16::get_filesystem_support()
 		
 	fs .copy = GParted::FS::GPARTED ;
 	
-	fs .MIN = 16 * MEBIBYTE ;
+	fs .MIN = 16 * MEBI_FACTOR ;
 	fs .MAX = 4096 * MEBIBYTE ;
 	
 	return fs ;
diff --git a/src/fat32.cc b/src/fat32.cc
index 9c99018..cbbd11d 100644
--- a/src/fat32.cc
+++ b/src/fat32.cc
@@ -56,7 +56,7 @@ FS fat32::get_filesystem_support()
 		
 	fs .copy = GParted::FS::GPARTED ;
 	
-	fs .MIN = 32 * MEBIBYTE ; //smaller fs'es will cause windows scandisk to fail..
+	fs .MIN = 32 * MEBI_FACTOR ; //smaller fs'es will cause windows scandisk to fail..
 	
 	return fs ;
 }
diff --git a/src/jfs.cc b/src/jfs.cc
index 5e036e4..d430e83 100644
--- a/src/jfs.cc
+++ b/src/jfs.cc
@@ -71,7 +71,7 @@ FS jfs::get_filesystem_support()
 		fs .copy = GParted::FS::GPARTED ;
 	}
 	
-	fs .MIN = 16 * MEBIBYTE ;
+	fs .MIN = 16 * MEBI_FACTOR ;
 	
 	return fs ;
 }
diff --git a/src/reiserfs.cc b/src/reiserfs.cc
index 0fc42d3..22ae73f 100644
--- a/src/reiserfs.cc
+++ b/src/reiserfs.cc
@@ -57,7 +57,8 @@ FS reiserfs::get_filesystem_support()
 		fs .move = GParted::FS::GPARTED ;
 	}
 
-	fs .MIN = 32 * MEBIBYTE ;
+	//Actual minimum is at least 18 blocks larger than 32 MiB for the journal offset
+	fs .MIN = 34 * MEBI_FACTOR ;
 	
 	return fs ;
 }
diff --git a/src/xfs.cc b/src/xfs.cc
index 525a6b4..f03d0bc 100644
--- a/src/xfs.cc
+++ b/src/xfs.cc
@@ -72,7 +72,7 @@ FS xfs::get_filesystem_support()
 	if ( fs .check )
 		fs .move = GParted::FS::GPARTED ;
 
-	fs .MIN = 32 * MEBIBYTE ;//official minsize = 16MB, but the smallest xfs_repair can handle is 32MB...
+	fs .MIN = 32 * MEBI_FACTOR ;//official minsize = 16MB, but the smallest xfs_repair can handle is 32MB...
 	
 	return fs ;
 }



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