diff --git a/ChangeLog b/ChangeLog index 6d00108a..a720b008 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2006-08-01 Bart Hakvoort + + * src/Dialog_Partition_Copy.cc, + src/GParted_Core.cc, + src/Win_GParted.cc: fixed some issues when manipulating a just + copied partition. (see also #349513) + 2006-07-30 Bart Hakvoort * improved errorhandling a bit. At the initialscan we store diff --git a/src/Dialog_Partition_Copy.cc b/src/Dialog_Partition_Copy.cc index 9f7ffc6f..a79b8b52 100644 --- a/src/Dialog_Partition_Copy.cc +++ b/src/Dialog_Partition_Copy.cc @@ -116,7 +116,7 @@ Partition Dialog_Partition_Copy::Get_New_Partition() selected_partition = Dialog_Base_Partition::Get_New_Partition() ; //set proper name and status for partition - selected_partition .status = GParted::STAT_NEW ; + selected_partition .status = GParted::STAT_COPY ; return selected_partition ; } diff --git a/src/GParted_Core.cc b/src/GParted_Core.cc index 71bd5117..410868fd 100644 --- a/src/GParted_Core.cc +++ b/src/GParted_Core.cc @@ -283,38 +283,78 @@ bool GParted_Core::snap_to_cylinder( const Device & device, Partition & partitio bool GParted_Core::apply_operation_to_disk( Operation * operation ) { - bool succes = false ; + bool succes = true ; libparted_messages .clear() ; + + if ( operation ->partition_original .status == GParted::STAT_COPY ) + { + succes = false ; + operation ->operation_detail .sub_details .push_back( + OperationDetail( String::ucompose( _("find real path of %1"), + operation ->partition_original .get_path() ) ) ) ; - switch ( operation ->type ) - { - case OPERATION_DELETE: - succes = Delete( operation ->partition_original, operation ->operation_detail .sub_details ) ; - break ; - case OPERATION_CREATE: - succes = create( operation ->device, - operation ->partition_new, - operation ->operation_detail .sub_details ) ; - break ; - case OPERATION_RESIZE_MOVE: - succes = resize_move( operation ->device, - operation ->partition_original, - operation ->partition_new, - operation ->operation_detail .sub_details ) ; - break ; - case OPERATION_FORMAT: - succes = format( operation ->partition_new, operation ->operation_detail .sub_details ) ; - break ; - case OPERATION_COPY: - operation ->partition_new .add_path( operation ->partition_original .get_path(), true ) ; - succes = copy( static_cast( operation ) ->partition_copied, - operation ->partition_new, - static_cast( operation ) ->partition_copied .get_length(), - static_cast( operation ) ->block_size, - operation ->operation_detail .sub_details ) ; - break ; + if ( open_device_and_disk( operation ->partition_original .device_path ) ) + { + lp_partition = ped_disk_get_partition_by_sector( + lp_disk, + (operation ->partition_original .sector_end + operation ->partition_original .sector_start) / 2 ) ; + + if ( lp_partition ) + { + char * lp_path = ped_partition_get_path( lp_partition ) ; + + operation ->partition_original .add_path( lp_path, true ) ; + operation ->partition_new .add_path( lp_path, true ) ; + + free( lp_path ) ; + succes = true ; + + operation ->operation_detail .sub_details .back() .sub_details .push_back( + OperationDetail( String::ucompose( _("path: %1"), + operation ->partition_new .get_path() ), + STATUS_NONE, + FONT_ITALIC ) ) ; + } + + close_device_and_disk() ; + } + + operation ->operation_detail .sub_details .back() .status = succes ? STATUS_SUCCES : STATUS_ERROR ; } + if ( succes ) + switch ( operation ->type ) + { + case OPERATION_DELETE: + succes = Delete( operation ->partition_original, + operation ->operation_detail .sub_details ) ; + break ; + case OPERATION_CREATE: + succes = create( operation ->device, + operation ->partition_new, + operation ->operation_detail .sub_details ) ; + break ; + case OPERATION_RESIZE_MOVE: + succes = resize_move( operation ->device, + operation ->partition_original, + operation ->partition_new, + operation ->operation_detail .sub_details ) ; + break ; + case OPERATION_FORMAT: + succes = format( operation ->partition_new, + operation ->operation_detail .sub_details ) ; + break ; + case OPERATION_COPY: + //when copying to an existing partition we have to change the 'copy of..' to a valid path + operation ->partition_new .add_path( operation ->partition_original .get_path(), true ) ; + succes = copy( static_cast( operation ) ->partition_copied, + operation ->partition_new, + static_cast( operation ) ->partition_copied .get_length(), + static_cast( operation ) ->block_size, + operation ->operation_detail .sub_details ) ; + break ; + } + if ( ! succes && libparted_messages .size() > 0 ) { operation ->operation_detail .sub_details .push_back( @@ -1615,7 +1655,7 @@ bool GParted_Core::copy( const Partition & partition_src, if ( check_repair( partition_src, operation_details ) ) { bool succes = true ; - if ( partition_dest .status == GParted::STAT_NEW ) + if ( partition_dest .status == GParted::STAT_COPY ) succes = create_partition( partition_dest, operation_details, min_size ) ; if ( succes && set_partition_type( partition_dest, operation_details ) ) @@ -1675,8 +1715,7 @@ bool GParted_Core::copy_filesystem( const Partition & partition_src, bool succes = false ; PedDevice *lp_device_src, *lp_device_dest ; -//FIXME: adapt open_device() so we don't have to call ped_device_get() here -//(same goes for close_device() and ped_device_destroy() + lp_device_src = ped_device_get( partition_src .device_path .c_str() ); if ( partition_src .device_path != partition_dest .device_path ) @@ -1801,7 +1840,7 @@ bool GParted_Core::set_partition_type( const Partition & partition, std::vector & operation_details ) { operation_details .push_back( OperationDetail( _("set partitiontype") ) ) ; - +//FIXME: be a little bit more verbose.. bool return_value = false ; if ( open_device_and_disk( partition .device_path ) ) @@ -2012,8 +2051,6 @@ bool GParted_Core::erase_filesystem_signatures( const Partition & partition ) return return_value ; } -//FIXME open_device( _and_disk) and the close functions should take an PedDevice * and PedDisk * as argument -//basicly we should get rid of these global lp_device and lp_disk bool GParted_Core::open_device( const Glib::ustring & device_path ) { lp_device = ped_device_get( device_path .c_str() ); diff --git a/src/Win_GParted.cc b/src/Win_GParted.cc index 9bd529e1..1f8a3138 100644 --- a/src/Win_GParted.cc +++ b/src/Win_GParted.cc @@ -1309,7 +1309,6 @@ void Win_GParted::activate_paste() partition_new .color = copied_partition .color ; partition_new .set_used( copied_partition .sectors_used ) ; partition_new .messages .clear() ; - partition_new .status = GParted::STAT_COPY ; //FIXME: in this case there's no window presented to the user, so he cannot choose the blocksize //i guess this means we have to present a window with the choice (maybe the copydialog, with everything