Replaced boolean 'resize' with 'shrink' and 'grow'. It seems some

* Replaced boolean 'resize' with 'shrink' and 'grow'. It seems some filesystems only support growing (e.g. xfs) so i need
  two flags to control the behaviour of the filesystemclasses.
This commit is contained in:
Bart Hakvoort 2004-12-13 13:58:51 +00:00
parent 47f357a8c4
commit 4815b17153
12 changed files with 45 additions and 35 deletions

View File

@ -1,3 +1,8 @@
2004-12-13 Bart Hakvoort <gparted@users.sf.net>
* Replaced boolean 'resize' with 'shrink' and 'grow'. It seems some filesystems only support growing (e.g. xfs) so i need
two flags to control the behaviour of the filesystemclasses.
2004-12-13 Bart Hakvoort <gparted@users.sf.net> 2004-12-13 Bart Hakvoort <gparted@users.sf.net>
* include/GParted_Core.h, * include/GParted_Core.h,

View File

@ -45,7 +45,8 @@ struct FS
Glib::ustring filesystem ; Glib::ustring filesystem ;
bool read ; //can we get the amount of used sectors? bool read ; //can we get the amount of used sectors?
bool create ; bool create ;
bool resize ; //only endpoint bool grow ;
bool shrink ;
bool move ; //startpoint and endpoint bool move ; //startpoint and endpoint
bool check ; //some checktool available? bool check ; //some checktool available?
bool copy ; bool copy ;
@ -54,7 +55,7 @@ struct FS
FS( ) FS( )
{ {
read = create = resize = move = check = copy = false ; read = create = grow = shrink = move = check = copy = false ;
MIN = 0 ; MIN = 0 ;
MAX = 0 ; MAX = 0 ;
} }

View File

@ -175,6 +175,7 @@ private:
unsigned short primary_count ;//primary_count checks for max. of 4 pimary partitions unsigned short primary_count ;//primary_count checks for max. of 4 pimary partitions
unsigned short new_count;//new_count keeps track of the new created partitions unsigned short new_count;//new_count keeps track of the new created partitions
Glib::ustring str_temp ; //mostly used for constructing dialogmessages Glib::ustring str_temp ; //mostly used for constructing dialogmessages
FS fs ;
GParted_Core gparted_core ; GParted_Core gparted_core ;
GParted::Device *temp_device ; GParted::Device *temp_device ;

View File

@ -111,7 +111,9 @@ void Dialog_Partition_Resize_Move::Resize_Move_Normal( const std::vector <Partit
frame_resizer_base ->set_x_end( ( Round( (double) (selected_partition.sector_end - selected_partition.sector_start) / ( (double)total_length/500) )) + frame_resizer_base ->get_x_start() ) ; frame_resizer_base ->set_x_end( ( Round( (double) (selected_partition.sector_end - selected_partition.sector_start) / ( (double)total_length/500) )) + frame_resizer_base ->get_x_start() ) ;
frame_resizer_base ->set_used( Round( (double) selected_partition.sectors_used / ( (double)total_length/500) ) ) ; frame_resizer_base ->set_used( Round( (double) selected_partition.sectors_used / ( (double)total_length/500) ) ) ;
//since some filesystems have upper and lower limits we need to check for this if ( fs .shrink )
{
//since some filesystems have lower limits we need to check for this
if ( selected_partition .Get_Used_MB( ) > fs .MIN ) if ( selected_partition .Get_Used_MB( ) > fs .MIN )
fs .MIN = selected_partition .Get_Used_MB( ) ; fs .MIN = selected_partition .Get_Used_MB( ) ;
@ -121,11 +123,11 @@ void Dialog_Partition_Resize_Move::Resize_Move_Normal( const std::vector <Partit
//in certain (rare) cases fs .MIN is a bit too high... //in certain (rare) cases fs .MIN is a bit too high...
if ( fs .MIN > selected_partition .Get_Length_MB( ) ) if ( fs .MIN > selected_partition .Get_Length_MB( ) )
fs .MIN = selected_partition .Get_Length_MB( ) ; fs .MIN = selected_partition .Get_Length_MB( ) ;
}
else //only grow..
fs .MIN = selected_partition .Get_Length_MB( ) ;
if ( ! fs .MAX ) if ( ! fs .MAX || fs .MAX > TOTAL_MB )
fs .MAX = TOTAL_MB ;
if ( fs .MAX > TOTAL_MB )
fs .MAX = TOTAL_MB ; fs .MAX = TOTAL_MB ;
//set values of spinbutton_before //set values of spinbutton_before

View File

@ -617,14 +617,13 @@ void Win_GParted::Set_Valid_Operations()
allow_convert( true ) ; allow_convert( true ) ;
//find out if resizing/moving and copying is possible //find out if resizing/moving and copying is possible
if ( Get_FS( selected_partition .filesystem, gparted_core .get_fs( ) ) .resize && ! devices[ current_device ] .readonly ) fs = Get_FS( selected_partition .filesystem, gparted_core .get_fs( ) ) ;
if ( (fs .grow || fs .shrink) && ! devices[ current_device ] .readonly )
{ {
allow_resize( true ) ; allow_resize( true ) ;
//only allow copying of real partitions //only allow copying of real partitions
if ( selected_partition .status != GParted::STAT_NEW && if ( selected_partition .status != GParted::STAT_NEW && selected_partition .status != GParted::STAT_COPY && fs .copy )
selected_partition .status != GParted::STAT_COPY &&
Get_FS( selected_partition .filesystem, gparted_core .get_fs( ) ) .copy )
allow_copy( true ) ; allow_copy( true ) ;
} }
@ -803,7 +802,6 @@ void Win_GParted::mouse_click( GdkEventButton *event, const Partition & partitio
Set_Valid_Operations( ) ; Set_Valid_Operations( ) ;
treeview_detail .Set_Selected( partition ); treeview_detail .Set_Selected( partition );
vbox_visual_disk ->Set_Selected( partition ); vbox_visual_disk ->Set_Selected( partition );
@ -1076,7 +1074,7 @@ void Win_GParted::activate_convert( const Glib::ustring & new_fs )
dialog .hide( ) ;//i want to be sure the dialog is gone _before_ operationslist shows up (only matters if first operation) dialog .hide( ) ;//i want to be sure the dialog is gone _before_ operationslist shows up (only matters if first operation)
//check for some limits... //check for some limits...
FS fs = Get_FS( new_fs, gparted_core .get_fs( ) ) ; fs = Get_FS( new_fs, gparted_core .get_fs( ) ) ;
if ( selected_partition .Get_Length_MB( ) < fs .MIN || ( fs .MAX && selected_partition .Get_Length_MB( ) > fs .MAX ) ) if ( selected_partition .Get_Length_MB( ) < fs .MIN || ( fs .MAX && selected_partition .Get_Length_MB( ) > fs .MAX ) )
{ {

View File

@ -37,7 +37,7 @@ FS ext2::get_filesystem_support( )
//resizing is a delicate process which requires 3 commands.. //resizing is a delicate process which requires 3 commands..
if ( ! system( "which resize2fs 1>/dev/null 2>/dev/null" ) && fs .read && fs .check ) if ( ! system( "which resize2fs 1>/dev/null 2>/dev/null" ) && fs .read && fs .check )
fs .resize = true ; fs .grow = fs .shrink = true ;
if ( ! system( "which dd 1>/dev/null 2>/dev/null" ) ) if ( ! system( "which dd 1>/dev/null 2>/dev/null" ) )
fs .copy = true ; fs .copy = true ;

View File

@ -37,7 +37,7 @@ FS ext3::get_filesystem_support( )
//resizing is a delicate process which requires 3 commands.. //resizing is a delicate process which requires 3 commands..
if ( ! system( "which resize2fs 1>/dev/null 2>/dev/null" ) && fs .read && fs .check ) if ( ! system( "which resize2fs 1>/dev/null 2>/dev/null" ) && fs .read && fs .check )
fs .resize = true ; fs .grow = fs .shrink = true ;
if ( ! system( "which dd 1>/dev/null 2>/dev/null" ) ) if ( ! system( "which dd 1>/dev/null 2>/dev/null" ) )
fs .copy = true ; fs .copy = true ;

View File

@ -36,7 +36,8 @@ FS fat16::get_filesystem_support( )
fs .check = true ; fs .check = true ;
//resizing of start and endpoint are provided by libparted //resizing of start and endpoint are provided by libparted
fs .resize = true ; fs .grow = true ;
fs .shrink = true ;
fs .move = true ; fs .move = true ;
if ( ! system( "which dd 1>/dev/null 2>/dev/null" ) ) if ( ! system( "which dd 1>/dev/null 2>/dev/null" ) )

View File

@ -36,7 +36,8 @@ FS fat32::get_filesystem_support( )
fs .check = true ; fs .check = true ;
//resizing of start and endpoint are provided by libparted //resizing of start and endpoint are provided by libparted
fs .resize = true ; fs .grow = true ;
fs .shrink = true ;
fs .move = true ; fs .move = true ;
if ( ! system( "which dd 1>/dev/null 2>/dev/null" ) ) if ( ! system( "which dd 1>/dev/null 2>/dev/null" ) )

View File

@ -28,7 +28,8 @@ FS linux_swap::get_filesystem_support( )
fs .filesystem = "linux-swap" ; fs .filesystem = "linux-swap" ;
fs .read = false ; //used/unused isn't relevant for swapspace fs .read = false ; //used/unused isn't relevant for swapspace
fs .create = true ; fs .create = true ;
fs .resize = true ; fs .grow = true ;
fs .shrink = true ;
fs .move = true ; fs .move = true ;
if ( ! system( "which dd 1>/dev/null 2>/dev/null" ) ) if ( ! system( "which dd 1>/dev/null 2>/dev/null" ) )

View File

@ -37,10 +37,10 @@ FS ntfs::get_filesystem_support( )
//resizing is a delicate process which requires 3 commands.. //resizing is a delicate process which requires 3 commands..
if ( ! system( "which ntfsresize 1>/dev/null 2>/dev/null" ) && fs .read && fs .check ) if ( ! system( "which ntfsresize 1>/dev/null 2>/dev/null" ) && fs .read && fs .check )
fs .resize = true ; fs .grow = fs .shrink = true ;
//we need resize to set correct used/unused after cloning //we need ntfsresize to set correct used/unused after cloning
if ( ! system( "which ntfsclone 1>/dev/null 2>/dev/null" ) && fs .resize ) if ( ! system( "which ntfsclone 1>/dev/null 2>/dev/null" ) && fs .grow )
fs .copy = true ; fs .copy = true ;
return fs ; return fs ;

View File

@ -38,10 +38,10 @@ FS reiserfs::get_filesystem_support( )
//resizing is a delicate process which requires 3 commands.. //resizing is a delicate process which requires 3 commands..
if ( ! system( "which resize_reiserfs 1>/dev/null 2>/dev/null" ) && fs .read && fs .check ) if ( ! system( "which resize_reiserfs 1>/dev/null 2>/dev/null" ) && fs .read && fs .check )
fs .resize = true ; fs .grow = fs .shrink = true ;
//we need to call resize_reiserfs after a copy to get proper used/unused //we need to call resize_reiserfs after a copy to get proper used/unused
if ( ! system( "which dd 1>/dev/null 2>/dev/null" ) && fs .resize ) if ( ! system( "which dd 1>/dev/null 2>/dev/null" ) && fs .grow )
fs .copy = true ; fs .copy = true ;
fs .MIN = 32 ; fs .MIN = 32 ;