Convert file system minimum from sector to byte value
This commit is contained in:
parent
4d658a10a8
commit
40d7dbac4b
|
@ -117,7 +117,7 @@ struct FS
|
|||
Support check ; //some checktool available?
|
||||
Support copy ;
|
||||
|
||||
Sector MIN ;
|
||||
Byte_Value MIN ;
|
||||
Sector MAX ;
|
||||
|
||||
FS()
|
||||
|
|
|
@ -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 )
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 ) ) ) ;
|
||||
}
|
||||
|
||||
|
|
|
@ -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 ;
|
||||
|
|
|
@ -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."),
|
||||
|
|
|
@ -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 ;
|
||||
|
|
|
@ -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 ;
|
||||
}
|
||||
|
|
|
@ -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 ;
|
||||
}
|
||||
|
|
|
@ -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 ;
|
||||
}
|
||||
|
|
|
@ -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 ;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue