:Set_Valid_Operations()

* Refined checks for functionality a bit. e.g. even if a filesystem can't be read, it's still possible to grow it
  (but shrinking gets disabled). Also removed that stupid grow_only flag from Utils.h and reordered Win_GParted::Set_Valid_Operations()
This commit is contained in:
Bart Hakvoort 2004-12-15 10:33:12 +00:00
parent 8a0ed3b6ac
commit d100935b55
11 changed files with 59 additions and 64 deletions

View File

@ -1,3 +1,8 @@
2004-12-15 Bart Hakvoort <gparted@users.sf.net>
* Refined checks for functionality a bit. e.g. even if a filesystem can't be read, it's still possible to grow it
(but shrinking gets disabled). Also removed that stupid grow_only flag from Utils.h and reordered Win_GParted::Set_Valid_Operations()
2004-12-14 Bart Hakvoort <gparted@users.sf.net>
* added support for jfs (create, copy, grow) and hfs (create, copy)

View File

@ -50,13 +50,12 @@ struct FS
bool move ; //startpoint and endpoint
bool check ; //some checktool available?
bool copy ;
bool grow_only ; //xfs,jfs (only used in Parted_Core::set_device_partitions)
int MIN ;
int MAX ;
FS( )
{
read = create = grow = shrink = move = check = copy = grow_only = false ;
read = create = grow = shrink = move = check = copy = false ;
MIN = 0 ;
MAX = 0 ;
}

View File

@ -65,6 +65,8 @@ void Dialog_Partition_Resize_Move::Set_Data( const Partition & selected_partitio
void Dialog_Partition_Resize_Move::Resize_Move_Normal( const std::vector <Partition> & partitions )
{
fs = Get_FS( selected_partition .filesystem, FILESYSTEMS ) ;
if ( ! selected_partition .error .empty( ) )
fs .shrink = false ;
//see if we need a fixed_start
if ( fs .move )

View File

@ -182,20 +182,13 @@ void GParted_Core::set_device_partitions( Device & device, bool deep_scan )
if ( partition_temp .sectors_used == -1 && partition_temp .error .empty( ) )
{
partition_temp .error = _("Unable to read the contents of this filesystem!") ;
fs = Get_FS( partition_temp .filesystem, FILESYSTEMS ) ;
if ( ! fs .grow_only )
{
partition_temp .error += "\n" ;
partition_temp .error += ("As a result you won't be able to resize this partition.") ;
}
partition_temp .error += "\n" ;
partition_temp .error += _("Because of this some operations may be unavailable.") ;
}
}
partition_temp .flags = Get_Flags( c_partition ) ;
if ( partition_temp .busy )
device .busy = true ;

View File

@ -603,9 +603,9 @@ void Win_GParted::Set_Valid_Operations()
}
//EXTENDED
else if ( selected_partition .type == GParted::EXTENDED )
if ( selected_partition .type == GParted::EXTENDED )
{
if ( ! any_logic ) //deletion is only allowed when there are nog logical partitions inside.
if ( ! any_logic ) //deletion is only allowed when there are no logical partitions inside.
allow_delete( true ) ;
if ( ! devices[ current_device ] .readonly )
@ -614,31 +614,11 @@ void Win_GParted::Set_Valid_Operations()
return ;
}
fs = Get_FS( selected_partition .filesystem, gparted_core .get_fs( ) ) ;
//FIXME too much redundacy here (just not in the mood to fix it now :P )
//if there was an error reading the filesystem we allow delete and convert ( see also Device::Get_Used_Sectors() )
//since growing doesn't affect the space already in use, we allow resinzing of 'grow-only' filesystems
if ( ! selected_partition .error .empty( ) )
{
allow_delete( true ) ;
allow_convert( true ) ;
if ( fs .grow && ! fs .shrink && ! devices[ current_device ] .readonly )
{
allow_resize( true );
//only allow copying of real partitions
if ( selected_partition .status != GParted::STAT_NEW && selected_partition .status != GParted::STAT_COPY && fs .copy )
allow_copy( true ) ;
}
return;
}
//PRIMARY and LOGICAL
if ( selected_partition .type != GParted::EXTENDED )
if ( selected_partition .type == GParted::PRIMARY || selected_partition .type == GParted::LOGICAL )
{
fs = Get_FS( selected_partition .filesystem, gparted_core .get_fs( ) ) ;
allow_delete( true ) ;
allow_convert( true ) ;
@ -648,7 +628,7 @@ void Win_GParted::Set_Valid_Operations()
allow_resize( true ) ;
//only allow copying of real partitions
if ( selected_partition .status != GParted::STAT_NEW && selected_partition .status != GParted::STAT_COPY && fs .copy )
if ( selected_partition .status == GParted::STAT_REAL && fs .copy )
allow_copy( true ) ;
}
@ -872,9 +852,8 @@ void Win_GParted::activate_resize()
dialog .add_action_widget( button_resize_move, Gtk::RESPONSE_OK ) ;
dialog .show_all_children( ) ;
if ( dialog.run( ) == Gtk::RESPONSE_CANCEL )
if ( dialog .run( ) == Gtk::RESPONSE_CANCEL )
return ;
}
std::vector <Partition> partitions = devices[ current_device ] .device_partitions ;
@ -885,7 +864,7 @@ void Win_GParted::activate_resize()
operations[ t ] .Apply_Operation_To_Visual( partitions ) ;
Dialog_Partition_Resize_Move dialog( gparted_core .get_fs( ), devices[ current_device ] .heads * devices[ current_device ] .sectors ) ;
Dialog_Partition_Resize_Move dialog( gparted_core .get_fs( ), devices[ current_device ] .heads * devices[ current_device ] .sectors ) ;
if ( selected_partition .type == GParted::LOGICAL )
{
@ -898,30 +877,29 @@ void Win_GParted::activate_resize()
dialog .set_transient_for( *this ) ;
if ( dialog.run() == Gtk::RESPONSE_OK )
if ( dialog .run( ) == Gtk::RESPONSE_OK )
{
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)
//if selected_partition is NEW we simply remove the NEW operation from the list and add it again with the new size and position ( unless it's an EXTENDED )
if ( selected_partition .status == GParted::STAT_NEW && selected_partition.type != GParted::EXTENDED )
{
//remove operation which creates this partition
for ( unsigned int t=0;t<operations.size() ; t++ )
for ( unsigned int t = 0 ; t < operations .size( ) ; t++ )
{
if ( operations[t] .partition_new .partition == selected_partition .partition )
if ( operations[ t ] .partition_new .partition == selected_partition .partition )
{
operations.erase( operations .begin() + t ) ;
operations.erase( operations .begin( ) + t ) ;
//And add the new partition to the end of the operations list
Add_Operation( GParted::CREATE, dialog.Get_New_Partition() );
Add_Operation( GParted::CREATE, dialog .Get_New_Partition( ) );
break;
}
}
}
else//normal move/resize on existing partition
Add_Operation( GParted::RESIZE_MOVE, dialog.Get_New_Partition() );
Add_Operation( GParted::RESIZE_MOVE, dialog .Get_New_Partition( ) );
}
}

View File

@ -35,9 +35,14 @@ FS ext2::get_filesystem_support( )
if ( ! system( "which e2fsck 1>/dev/null 2>/dev/null" ) )
fs .check = true ;
//resizing is a delicate process which requires 3 commands..
if ( ! system( "which resize2fs 1>/dev/null 2>/dev/null" ) && fs .read && fs .check )
fs .grow = fs .shrink = true ;
//resizing is a delicate process ...
if ( ! system( "which resize2fs 1>/dev/null 2>/dev/null" ) && fs .check )
{
fs .grow = true ;
if ( fs .read ) //needed to determine a min filesystemsize..
fs .shrink = true ;
}
if ( ! system( "which dd 1>/dev/null 2>/dev/null" ) )
fs .copy = true ;

View File

@ -35,9 +35,14 @@ FS ext3::get_filesystem_support( )
if ( ! system( "which e2fsck 1>/dev/null 2>/dev/null" ) )
fs .check = true ;
//resizing is a delicate process which requires 3 commands..
if ( ! system( "which resize2fs 1>/dev/null 2>/dev/null" ) && fs .read && fs .check )
fs .grow = fs .shrink = true ;
//resizing is a delicate process ...
if ( ! system( "which resize2fs 1>/dev/null 2>/dev/null" ) && fs .check )
{
fs .grow = true ;
if ( fs .read ) //needed to determine a min filesystemsize..
fs .shrink = true ;
}
if ( ! system( "which dd 1>/dev/null 2>/dev/null" ) )
fs .copy = true ;

View File

@ -26,8 +26,7 @@ FS jfs::get_filesystem_support( )
FS fs ;
fs .filesystem = "jfs" ;
fs .grow_only = true ;
// if ( ! system( "which xfs_db 1>/dev/null 2>/dev/null" ) )
// fs .read = true ;

View File

@ -35,9 +35,14 @@ FS ntfs::get_filesystem_support( )
if ( ! system( "which ntfsfix 1>/dev/null 2>/dev/null" ) )
fs .check = true ;
//resizing is a delicate process which requires 3 commands..
if ( ! system( "which ntfsresize 1>/dev/null 2>/dev/null" ) && fs .read && fs .check )
fs .grow = fs .shrink = true ;
//resizing is a delicate process ...
if ( ! system( "which ntfsresize 1>/dev/null 2>/dev/null" ) && fs .check )
{
fs .grow = true ;
if ( fs .read ) //needed to determine a min filesystemsize..
fs .shrink = true ;
}
//we need ntfsresize to set correct used/unused after cloning
if ( ! system( "which ntfsclone 1>/dev/null 2>/dev/null" ) && fs .grow )

View File

@ -36,9 +36,14 @@ FS reiserfs::get_filesystem_support( )
if ( ! system( "which reiserfsck 1>/dev/null 2>/dev/null" ) )
fs .check = true ;
//resizing is a delicate process which requires 3 commands..
if ( ! system( "which resize_reiserfs 1>/dev/null 2>/dev/null" ) && fs .read && fs .check )
fs .grow = fs .shrink = true ;
//resizing is a delicate process ...
if ( ! system( "which resize_reiserfs 1>/dev/null 2>/dev/null" ) && fs .check )
{
fs .grow = true ;
if ( fs .read ) //needed to determine a min filesystemsize..
fs .shrink = true ;
}
//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 .grow )

View File

@ -26,8 +26,7 @@ FS xfs::get_filesystem_support( )
FS fs ;
fs .filesystem = "xfs" ;
fs .grow_only = true ;
if ( ! system( "which xfs_db 1>/dev/null 2>/dev/null" ) )
fs .read = true ;