[gparted] Convert file system maximum from sector to byte value
- From: Curtis Gedak <gedakc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gparted] Convert file system maximum from sector to byte value
- Date: Wed, 24 Mar 2010 20:37:56 +0000 (UTC)
commit f9f603256e4cec1e9719e11878b3816b8b365ce5
Author: Curtis Gedak <gedakc gmail com>
Date: Tue Mar 16 13:25:58 2010 -0600
Convert file system maximum from sector to byte value
include/Utils.h | 2 +-
src/Dialog_Partition_Copy.cc | 10 +++++-----
src/Dialog_Partition_New.cc | 11 +++++------
src/Dialog_Partition_Resize_Move.cc | 14 +++++++-------
src/Win_GParted.cc | 4 ++--
src/fat16.cc | 2 +-
src/hfs.cc | 2 +-
7 files changed, 22 insertions(+), 23 deletions(-)
---
diff --git a/include/Utils.h b/include/Utils.h
index e7917c8..a330b0d 100644
--- a/include/Utils.h
+++ b/include/Utils.h
@@ -118,7 +118,7 @@ struct FS
Support copy ;
Byte_Value MIN ;
- Sector MAX ;
+ Byte_Value MAX ;
FS()
{
diff --git a/src/Dialog_Partition_Copy.cc b/src/Dialog_Partition_Copy.cc
index 12bef12..26725d4 100644
--- a/src/Dialog_Partition_Copy.cc
+++ b/src/Dialog_Partition_Copy.cc
@@ -99,9 +99,9 @@ void Dialog_Partition_Copy::Set_Data( const Partition & selected_partition, cons
copied_partition .sectors_used, GParted::UNIT_MIB ) / (TOTAL_MB/500.00) ) ) ;
if ( fs .grow )
- fs .MAX = ( ! fs .MAX || fs .MAX > (TOTAL_MB * MEBIBYTE) ) ? (TOTAL_MB * MEBIBYTE) : fs .MAX - BUF ;
+ 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() ;
+ fs .MAX = copied_partition .get_length() * DEFAULT_SECTOR_SIZE ;
if ( fs .filesystem == GParted::FS_XFS ) //bit hackisch, but most effective, since it's a unique situation
@@ -117,7 +117,7 @@ void Dialog_Partition_Copy::Set_Data( const Partition & selected_partition, cons
//set values of spinbutton_size
spinbutton_size .set_range(
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 ) ) ) ;
+ Utils::round( Utils::sector_to_unit( (fs .MAX / DEFAULT_SECTOR_SIZE), GParted::UNIT_MIB ) ) ) ;
spinbutton_size .set_value( COPIED_LENGTH_MB ) ;
//set values of spinbutton_after
@@ -126,12 +126,12 @@ void Dialog_Partition_Copy::Set_Data( const Partition & selected_partition, cons
GRIP = false ;
frame_resizer_base ->set_size_limits( Utils::round( fs .MIN / (MB_PER_PIXEL * MEBI_FACTOR) ),
- Utils::round( fs .MAX / (MB_PER_PIXEL * MEBIBYTE) ) ) ;
+ 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), GParted::UNIT_MIB ) ),
- Utils::round( Utils::sector_to_unit( fs .MAX, GParted::UNIT_MIB ) ) ) ;
+ Utils::round( Utils::sector_to_unit( (fs .MAX / DEFAULT_SECTOR_SIZE), GParted::UNIT_MIB ) ) ) ;
//set global selected_partition (see Dialog_Base_Partition::Get_New_Partition )
this ->selected_partition = copied_partition ;
diff --git a/src/Dialog_Partition_New.cc b/src/Dialog_Partition_New.cc
index 0239cde..dd22cf4 100644
--- a/src/Dialog_Partition_New.cc
+++ b/src/Dialog_Partition_New.cc
@@ -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, GParted::UNIT_MIB ) ) ) ;
+ spinbutton_size .set_value( Utils::round( Utils::sector_to_unit( (fs .MAX / DEFAULT_SECTOR_SIZE), GParted::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)
@@ -260,25 +260,24 @@ void Dialog_Partition_New::optionmenu_changed( bool type )
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 ;
+ fs .MAX = ( fs .MAX && ( fs .MAX < (TOTAL_MB * MEBI_FACTOR) ) ) ? fs .MAX : (TOTAL_MB * MEBI_FACTOR) ;
frame_resizer_base ->set_size_limits( Utils::round( fs .MIN / (MB_PER_PIXEL * MEBI_FACTOR) ),
- Utils::round( fs .MAX / (MB_PER_PIXEL * MEBIBYTE) ) ) ;
+ Utils::round( fs .MAX / (MB_PER_PIXEL * MEBI_FACTOR) ) ) ;
//set new spinbutton ranges
spinbutton_before .set_range(
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 / DEFAULT_SECTOR_SIZE), GParted::UNIT_MIB ) ),
- Utils::round( Utils::sector_to_unit( fs .MAX, GParted::UNIT_MIB ) ) ) ;
+ Utils::round( Utils::sector_to_unit( (fs .MAX / DEFAULT_SECTOR_SIZE), GParted::UNIT_MIB ) ) ) ;
spinbutton_after .set_range(
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 / DEFAULT_SECTOR_SIZE), GParted::UNIT_MIB ) ),
- Utils::round( Utils::sector_to_unit( fs .MAX, GParted::UNIT_MIB ) ) ) ;
+ Utils::round( Utils::sector_to_unit( (fs .MAX / DEFAULT_SECTOR_SIZE), GParted::UNIT_MIB ) ) ) ;
}
//set fitting resizer colors
diff --git a/src/Dialog_Partition_Resize_Move.cc b/src/Dialog_Partition_Resize_Move.cc
index 2ecbb09..ce61f48 100644
--- a/src/Dialog_Partition_Resize_Move.cc
+++ b/src/Dialog_Partition_Resize_Move.cc
@@ -133,13 +133,13 @@ void Dialog_Partition_Resize_Move::Resize_Move_Normal( const std::vector<Partiti
//set MAX
if ( fs .grow )
{
- if ( ! fs .MAX || fs .MAX > (TOTAL_MB * MEBIBYTE) )
- fs .MAX = TOTAL_MB * MEBIBYTE ;
+ if ( ! fs .MAX || fs .MAX > (TOTAL_MB * MEBI_FACTOR) )
+ fs .MAX = TOTAL_MB * MEBI_FACTOR ;
else
- fs .MAX -= BUF/2 ;
+ fs .MAX -= (BUF/2 * DEFAULT_SECTOR_SIZE) ;
}
else
- fs .MAX = selected_partition .get_length() ;
+ fs .MAX = selected_partition .get_length() * DEFAULT_SECTOR_SIZE ;
//set values of spinbutton_before
@@ -155,7 +155,7 @@ void Dialog_Partition_Resize_Move::Resize_Move_Normal( const std::vector<Partiti
//set values of spinbutton_size
spinbutton_size .set_range(
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 ) ) ) ;
+ Utils::round( Utils::sector_to_unit( (fs .MAX / DEFAULT_SECTOR_SIZE), GParted::UNIT_MIB ) ) ) ;
spinbutton_size .set_value(
Utils::round( Utils::sector_to_unit( selected_partition .get_length(), GParted::UNIT_MIB ) ) ) ;
@@ -168,12 +168,12 @@ void Dialog_Partition_Resize_Move::Resize_Move_Normal( const std::vector<Partiti
Utils::round( Utils::sector_to_unit( next, GParted::UNIT_MIB ) ) ) ;
frame_resizer_base ->set_size_limits( Utils::round( fs .MIN / (MB_PER_PIXEL * MEBI_FACTOR) ),
- Utils::round( fs .MAX / (MB_PER_PIXEL * MEBIBYTE) ) ) ;
+ 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), GParted::UNIT_MIB ) ),
- Utils::round( Utils::sector_to_unit( fs .MAX, GParted::UNIT_MIB ) ) ) ;
+ Utils::round( Utils::sector_to_unit( (fs .MAX / DEFAULT_SECTOR_SIZE), GParted::UNIT_MIB ) ) ) ;
}
void Dialog_Partition_Resize_Move::Resize_Move_Extended( const std::vector<Partition> & partitions )
diff --git a/src/Win_GParted.cc b/src/Win_GParted.cc
index 2c0eed1..117b439 100644
--- a/src/Win_GParted.cc
+++ b/src/Win_GParted.cc
@@ -1641,7 +1641,7 @@ void Win_GParted::activate_format( GParted::FILESYSTEM new_fs )
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 ) )
+ ( fs .MAX && selected_partition .get_length() > (fs .MAX / DEFAULT_SECTOR_SIZE) ) )
{
Gtk::MessageDialog dialog( *this,
String::ucompose( _("Cannot format this file system to %1."),
@@ -1660,7 +1660,7 @@ void Win_GParted::activate_format( GParted::FILESYSTEM new_fs )
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 ) ) );
+ Utils::format_size( (fs .MAX / DEFAULT_SECTOR_SIZE) ) ) );
dialog .run() ;
return ;
diff --git a/src/fat16.cc b/src/fat16.cc
index bb2cc76..4e59b44 100644
--- a/src/fat16.cc
+++ b/src/fat16.cc
@@ -57,7 +57,7 @@ FS fat16::get_filesystem_support()
fs .copy = GParted::FS::GPARTED ;
fs .MIN = 16 * MEBI_FACTOR ;
- fs .MAX = 4096 * MEBIBYTE ;
+ fs .MAX = (4096 - 1) * MEBI_FACTOR ; //Maximum seems to be just less than 4096 MiB
return fs ;
}
diff --git a/src/hfs.cc b/src/hfs.cc
index 8e41a85..1ca6e4a 100644
--- a/src/hfs.cc
+++ b/src/hfs.cc
@@ -43,7 +43,7 @@ FS hfs::get_filesystem_support()
fs .copy = GParted::FS::GPARTED ;
fs .move = GParted::FS::GPARTED ;
- fs .MAX = 2048 * MEBIBYTE ;
+ fs .MAX = 2048 * MEBI_FACTOR ;
return fs ;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]