From 649f26be9f9d01083f319c3956c4c30430247d1a Mon Sep 17 00:00:00 2001 From: Bart Hakvoort Date: Sun, 20 Aug 2006 11:47:17 +0000 Subject: [PATCH] fixed some issues with combi move+shrink on fat* and hfs* filesystems. * include/GParted_Core.h, src/GParted_Core.cc: fixed some issues with combi move+shrink on fat* and hfs* filesystems. Also call wait_for_node() from commit() if 'node' was provided. --- ChangeLog | 9 +++++++- include/GParted_Core.h | 2 +- src/GParted_Core.cc | 52 ++++++++++++++++-------------------------- 3 files changed, 29 insertions(+), 34 deletions(-) diff --git a/ChangeLog b/ChangeLog index eeb6573b..51cd98e3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,13 @@ 2006-08-20 Bart Hakvoort - * src/Dialog_Partition_Resize_Move.cc: due to some restrictions it as + * include/GParted_Core.h, + src/GParted_Core.cc: fixed some issues with combi move+shrink on + fat* and hfs* filesystems. + Also call wait_for_node() from commit() if 'node' was provided. + +2006-08-20 Bart Hakvoort + + * src/Dialog_Partition_Resize_Move.cc: due to some restrictions it was no longer possible to shrink swap filesystems. fixed. 2006-08-20 Bart Hakvoort diff --git a/include/GParted_Core.h b/include/GParted_Core.h index 53b37eb9..6d395489 100644 --- a/include/GParted_Core.h +++ b/include/GParted_Core.h @@ -162,7 +162,7 @@ private: bool open_device_and_disk( const Glib::ustring & device_path, bool strict = true ) ; void close_disk() ; void close_device_and_disk() ; - bool commit() ; + bool commit( const Glib::ustring & node = "" ) ; static PedExceptionOption ped_exception_handler( PedException * e ) ; diff --git a/src/GParted_Core.cc b/src/GParted_Core.cc index bc20833f..0b43e3db 100644 --- a/src/GParted_Core.cc +++ b/src/GParted_Core.cc @@ -972,7 +972,7 @@ bool GParted_Core::create_partition( Partition & new_partition, OperationDetail { if ( min_size > 0 ) constraint ->min_size = min_size ; - + if ( ped_disk_add_partition( lp_disk, lp_partition, constraint ) && commit() ) { //we have to free the result of ped_partition_get_path().. @@ -1002,25 +1002,16 @@ bool GParted_Core::create_partition( Partition & new_partition, OperationDetail close_device_and_disk() ; } - if ( new_partition .partition_number > 0 && - ( - new_partition .type == GParted::TYPE_EXTENDED || - ( - wait_for_node( new_partition .get_path() ) && - erase_filesystem_signatures( new_partition ) - ) - ) - ) + erase_filesystem_signatures( new_partition ) && + ( new_partition .type == GParted::TYPE_EXTENDED || wait_for_node( new_partition .get_path() ) ) ) { operationdetail .get_last_child() .set_status( STATUS_SUCCES ) ; - return true ; } else { operationdetail .get_last_child() .set_status( STATUS_ERROR ) ; - return false ; } } @@ -1071,7 +1062,6 @@ bool GParted_Core::Delete( const Partition & partition, OperationDetail & operat lp_partition = ped_disk_get_partition_by_sector( lp_disk, partition .get_sector() ) ; return_value = ped_disk_delete_partition( lp_disk, lp_partition ) && commit() ; - sleep( 1 ) ; //give the kernel some time to reread the partitiontable close_device_and_disk() ; } @@ -1223,8 +1213,9 @@ bool GParted_Core::resize_move_filesystem_using_libparted( const Partition & par partition_new .sector_start, partition_new .get_length() ) ; if ( lp_geom ) - return_value = ped_file_system_resize( fs, lp_geom, NULL ) && commit() ; - + return_value = ped_file_system_resize( fs, lp_geom, NULL ) && + commit( partition_new .get_path() ) ; + ped_file_system_close( fs ); } } @@ -1386,7 +1377,8 @@ bool GParted_Core::resize_move_partition( const Partition & partition_old, new_start = lp_partition ->geom .start ; new_end = lp_partition ->geom .end ; - return_value = commit() ; + return_value = commit( partition_new .type == TYPE_EXTENDED ? + "" : partition_new .get_path() ) ; } ped_constraint_destroy( constraint ); @@ -1409,18 +1401,9 @@ bool GParted_Core::resize_move_partition( const Partition & partition_old, FONT_ITALIC ) ) ; } - if ( partition_old .type == GParted::TYPE_EXTENDED ) - { - operationdetail .get_last_child() .set_status( return_value ? STATUS_SUCCES : STATUS_ERROR ) ; - return return_value ; - } - else - { - return_value &= wait_for_node( partition_new .get_path() ) ; - operationdetail .get_last_child() .set_status( return_value ? STATUS_SUCCES : STATUS_ERROR ) ; - - return return_value ; - } + operationdetail .get_last_child() .set_status( return_value ? STATUS_SUCCES : STATUS_ERROR ) ; + + return return_value ; } bool GParted_Core::resize_filesystem( const Partition & partition_old, @@ -1624,7 +1607,9 @@ bool GParted_Core::set_partition_type( const Partition & partition, OperationDet { lp_partition = ped_disk_get_partition_by_sector( lp_disk, partition .get_sector() ) ; - if ( lp_partition && ped_partition_set_system( lp_partition, fs_type ) && commit() ) + if ( lp_partition && + ped_partition_set_system( lp_partition, fs_type ) && + commit( partition .get_path() ) ) { operationdetail .get_last_child() .add_child( OperationDetail( String::ucompose( _("new partitiontype: %1"), @@ -1632,7 +1617,7 @@ bool GParted_Core::set_partition_type( const Partition & partition, OperationDet STATUS_NONE, FONT_ITALIC ) ) ; - return_value = wait_for_node( partition .get_path() ) ; + return_value = true ; } } @@ -2100,12 +2085,15 @@ void GParted_Core::close_device_and_disk() lp_device = NULL ; } -bool GParted_Core::commit() +bool GParted_Core::commit( const Glib::ustring & node ) { bool return_value = ped_disk_commit_to_dev( lp_disk ) ; ped_disk_commit_to_os( lp_disk ) ; - + + if ( ! node .empty() && return_value ) + return_value = wait_for_node( node ) ; + return return_value ; }