diff --git a/ChangeLog b/ChangeLog index 0a94f407..2edf90db 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2006-01-22 Bart Hakvoort + + * correct partitiontype of destination is now set while copying + * resizing now return correct status (sometimes it would report + succes even when some of the suboperationes failed) + * fixed some issues with resizing and cylindersizes. + 2006-01-22 Bart Hakvoort * removed Execute_Command() and replaced it by execute_command(). diff --git a/include/Device.h b/include/Device.h index 3bd98626..536b7ce0 100644 --- a/include/Device.h +++ b/include/Device.h @@ -37,7 +37,7 @@ public: long heads ; long sectors ; long cylinders ; - long cylsize ; + long cylsize ;//FIXME we should store this one as a Sector Glib::ustring model; Glib::ustring path; Glib::ustring realpath; diff --git a/include/FileSystem.h b/include/FileSystem.h index aabe6471..5170500f 100644 --- a/include/FileSystem.h +++ b/include/FileSystem.h @@ -44,7 +44,7 @@ public: std::vector & operation_details ) = 0 ; virtual bool Check_Repair( const Partition & partition, std::vector & operation_details ) = 0 ; - long cylinder_size ; //see GParted_Core::Resize() + Sector cylinder_size ; //see GParted_Core::resize() protected: int execute_command( std::vector argv, std::vector & operation_details ) ; diff --git a/src/GParted_Core.cc b/src/GParted_Core.cc index 1bbf48eb..a2427a88 100644 --- a/src/GParted_Core.cc +++ b/src/GParted_Core.cc @@ -559,51 +559,48 @@ bool GParted_Core::resize( const Device & device, const Partition & partition_new, std::vector & operation_details ) { + //extended partition if ( partition_old .type == GParted::TYPE_EXTENDED ) return resize_container_partition( partition_old, partition_new, false, operation_details ) ; - //lazy check (only grow). it's possbile one day this should be separated in checks for grow,shrink,move .. + //resize using libparted.. if ( get_fs( partition_old .filesystem ) .grow == GParted::FS::LIBPARTED ) return resize_normal_using_libparted( partition_old, partition_new, operation_details ) ; - else //use custom resize tools.. + + //use custom resize tools.. + bool succes = false ; + set_proper_filesystem( partition_new .filesystem ) ; + + if ( p_filesystem && p_filesystem ->Check_Repair( partition_new, operation_details ) ) { - set_proper_filesystem( partition_new .filesystem ) ; - - if ( p_filesystem ->Check_Repair( partition_new, operation_details ) ) - {//FIXME hier moet betere errorchecking!! momenteel kan er iets fout gaan en wordt de operatie toch - //als geslaagd gerapporteerd. ik ben er groot voorstander van om alles weer te fixen mbv resize e.d. - //maar de status moet wel correct zijn! - //shrinking - if ( partition_new .Get_Length_MB() < partition_old .Get_Length_MB() ) - { - p_filesystem ->cylinder_size = device .cylsize ; - - if ( p_filesystem ->Resize( partition_new, operation_details ) ) - resize_container_partition( - partition_old, - partition_new, - ! get_fs( partition_new .filesystem ) .move, - operation_details ) ; - } - //growing/moving - else - resize_container_partition( - partition_old, - partition_new, - ! get_fs( partition_new .filesystem ) .move, - operation_details ) ; - + succes = true ; - p_filesystem ->Check_Repair( partition_new, operation_details ) ; - - //expand filesystem to fit exactly in partition - p_filesystem ->Resize( partition_new, operation_details, true ) ; - - return p_filesystem ->Check_Repair( partition_new, operation_details ) ; + if ( partition_new .get_length() < partition_old .get_length() ) + { + p_filesystem ->cylinder_size = MEBIBYTE * device .cylsize ; + succes = p_filesystem ->Resize( partition_new, operation_details ) ; } + + if ( succes ) + succes = resize_container_partition( + partition_old, + partition_new, + ! get_fs( partition_new .filesystem ) .move, + operation_details ) ; + + //these 3 are always executed, however, if 1 of them fails the whole operation fails + if ( ! p_filesystem ->Check_Repair( partition_new, operation_details ) ) + succes = false ; + + //expand filesystem to fit exactly in partition + if ( ! p_filesystem ->Resize( partition_new, operation_details, true ) ) + succes = false ; + + if ( ! p_filesystem ->Check_Repair( partition_new, operation_details ) ) + succes = false ; } - - return false ; + + return succes ; } bool GParted_Core::copy( const Glib::ustring & src_part_path, @@ -614,12 +611,13 @@ bool GParted_Core::copy( const Glib::ustring & src_part_path, Partition src_partition ; src_partition .partition = src_part_path ; -//FIXME set correct type of dest partition - if ( p_filesystem ->Check_Repair( src_partition, operation_details ) ) - if ( create_empty_partition( partition_dest, operation_details, true ) > 0 ) - return p_filesystem ->Copy( src_part_path, partition_dest .partition, operation_details ) ; - return false ; + return ( p_filesystem && + p_filesystem ->Check_Repair( src_partition, operation_details ) && + create_empty_partition( partition_dest, operation_details, true ) > 0 && + set_partition_type( partition_dest, operation_details ) && + p_filesystem ->Copy( src_part_path, partition_dest .partition, operation_details ) && + p_filesystem ->Check_Repair( partition_dest, operation_details ) ) ; } bool GParted_Core::Set_Disklabel( const Glib::ustring & device_path, const Glib::ustring & disklabel ) diff --git a/src/Operation.cc b/src/Operation.cc index d3bbb6c5..2e2ca236 100644 --- a/src/Operation.cc +++ b/src/Operation.cc @@ -30,7 +30,7 @@ Operation::Operation( const Device & device, const Partition & partition_origina this ->partition_new = partition_new; this ->operationtype = operationtype; - str_operation = Get_String( ) ; + str_operation = Get_String() ; if ( operationtype == COPY ) { diff --git a/src/Win_GParted.cc b/src/Win_GParted.cc index 497a3a2e..c4b082bf 100644 --- a/src/Win_GParted.cc +++ b/src/Win_GParted.cc @@ -1067,17 +1067,19 @@ void Win_GParted::activate_copy( ) void Win_GParted::activate_paste( ) { - if ( ! max_amount_prim_reached( ) ) + if ( ! max_amount_prim_reached() ) { - Dialog_Partition_Copy dialog( gparted_core .get_fs( copied_partition .filesystem ), devices[ current_device ] .cylsize ) ; - copied_partition .error .clear( ) ; //we don't need the errors of the source partition. + Dialog_Partition_Copy dialog( gparted_core .get_fs( copied_partition .filesystem ), + devices[ current_device ] .cylsize ) ; + //we don't need the errors of the source partition. + copied_partition .error .clear() ; dialog .Set_Data( selected_partition, copied_partition ) ; 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) - Add_Operation( GParted::COPY, dialog .Get_New_Partition( ) ); + dialog .hide() ; + Add_Operation( GParted::COPY, dialog .Get_New_Partition() ); } } } diff --git a/src/ext2.cc b/src/ext2.cc index ba05a71b..0b47c8f7 100644 --- a/src/ext2.cc +++ b/src/ext2.cc @@ -107,7 +107,7 @@ bool ext2::Resize( const Partition & partition_new, if ( ! fill_partition ) argv .push_back( Utils::num_to_str( Utils::Round( Utils::sector_to_unit( - partition_new .get_length(), GParted::UNIT_MIB ) ) - cylinder_size, true ) + "M" ) ; + partition_new .get_length() - cylinder_size, GParted::UNIT_MIB ) ), true ) + "M" ) ; if ( ! execute_command( argv, operation_details .back() .sub_details ) ) { diff --git a/src/ext3.cc b/src/ext3.cc index 15b2cea2..ac63ffbd 100644 --- a/src/ext3.cc +++ b/src/ext3.cc @@ -108,7 +108,7 @@ bool ext3::Resize( const Partition & partition_new, if ( ! fill_partition ) argv .push_back( Utils::num_to_str( Utils::Round( Utils::sector_to_unit( - partition_new .get_length(), GParted::UNIT_MIB ) ) - cylinder_size, true ) + "M" ) ; + partition_new .get_length() - cylinder_size, GParted::UNIT_MIB ) ), true ) + "M" ) ; if ( ! execute_command( argv, operation_details .back() .sub_details ) ) { diff --git a/src/fat16.cc b/src/fat16.cc index d443e86c..a5fafce6 100644 --- a/src/fat16.cc +++ b/src/fat16.cc @@ -143,7 +143,7 @@ bool fat16::Check_Repair( const Partition & partition, std::vector= execute_command( argv, operation_details .back() .sub_details ) >= 0 ) { operation_details .back() .status = OperationDetails::SUCCES ; return true ; diff --git a/src/fat32.cc b/src/fat32.cc index 25613c58..42acbaec 100644 --- a/src/fat32.cc +++ b/src/fat32.cc @@ -142,7 +142,7 @@ bool fat32::Check_Repair( const Partition & partition, std::vector= execute_command( argv, operation_details .back() .sub_details ) >= 0 ) { operation_details .back() .status = OperationDetails::SUCCES ; return true ; diff --git a/src/ntfs.cc b/src/ntfs.cc index 7135f91e..a7d469bd 100644 --- a/src/ntfs.cc +++ b/src/ntfs.cc @@ -106,7 +106,8 @@ bool ntfs::Resize( const Partition & partition_new, if ( ! fill_partition ) { str_temp += " -s " ; - str_temp += Utils::num_to_str( Utils::Round( Utils::sector_to_unit( partition_new .get_length(), GParted::UNIT_BYTE ) ), true ) ; + str_temp += Utils::num_to_str( Utils::Round( Utils::sector_to_unit( + partition_new .get_length() - cylinder_size, GParted::UNIT_BYTE ) ), true ) ; } //simulation.. diff --git a/src/reiserfs.cc b/src/reiserfs.cc index 5d02957b..f00bf05b 100644 --- a/src/reiserfs.cc +++ b/src/reiserfs.cc @@ -110,15 +110,9 @@ bool reiserfs::Resize( const Partition & partition_new, if ( ! fill_partition ) { - /* FIXME:i need to find a better solution for this 'cylinder problem' - * till then we do it the 'dirty way' - * (this only matters while shrinking a filesystem, so maybe we should solve this - * in the resizedialog...) - */ - long bytes = Utils::Round( Utils::sector_to_unit( cylinder_size * MEBIBYTE, GParted::UNIT_BYTE ) ) ; - str_temp += " -s " ; - str_temp += Utils::num_to_str( Utils::Round( Utils::sector_to_unit( partition_new .get_length(), GParted::UNIT_BYTE ) ) - bytes, true ) ; + str_temp += Utils::num_to_str( Utils::Round( Utils::sector_to_unit( + partition_new .get_length() - cylinder_size, GParted::UNIT_BYTE ) ), true ) ; } argv .clear() ;