correct partitiontype of destination is now set while copying resizing now
* 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.
This commit is contained in:
parent
045edbbe95
commit
52dfb1c364
|
@ -1,3 +1,10 @@
|
||||||
|
2006-01-22 Bart Hakvoort <hakvoort@cvs.gnome.org>
|
||||||
|
|
||||||
|
* 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 <hakvoort@cvs.gnome.org>
|
2006-01-22 Bart Hakvoort <hakvoort@cvs.gnome.org>
|
||||||
|
|
||||||
* removed Execute_Command() and replaced it by execute_command().
|
* removed Execute_Command() and replaced it by execute_command().
|
||||||
|
|
|
@ -37,7 +37,7 @@ public:
|
||||||
long heads ;
|
long heads ;
|
||||||
long sectors ;
|
long sectors ;
|
||||||
long cylinders ;
|
long cylinders ;
|
||||||
long cylsize ;
|
long cylsize ;//FIXME we should store this one as a Sector
|
||||||
Glib::ustring model;
|
Glib::ustring model;
|
||||||
Glib::ustring path;
|
Glib::ustring path;
|
||||||
Glib::ustring realpath;
|
Glib::ustring realpath;
|
||||||
|
|
|
@ -44,7 +44,7 @@ public:
|
||||||
std::vector<OperationDetails> & operation_details ) = 0 ;
|
std::vector<OperationDetails> & operation_details ) = 0 ;
|
||||||
virtual bool Check_Repair( const Partition & partition, std::vector<OperationDetails> & operation_details ) = 0 ;
|
virtual bool Check_Repair( const Partition & partition, std::vector<OperationDetails> & operation_details ) = 0 ;
|
||||||
|
|
||||||
long cylinder_size ; //see GParted_Core::Resize()
|
Sector cylinder_size ; //see GParted_Core::resize()
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
int execute_command( std::vector<std::string> argv, std::vector<OperationDetails> & operation_details ) ;
|
int execute_command( std::vector<std::string> argv, std::vector<OperationDetails> & operation_details ) ;
|
||||||
|
|
|
@ -559,51 +559,48 @@ bool GParted_Core::resize( const Device & device,
|
||||||
const Partition & partition_new,
|
const Partition & partition_new,
|
||||||
std::vector<OperationDetails> & operation_details )
|
std::vector<OperationDetails> & operation_details )
|
||||||
{
|
{
|
||||||
|
//extended partition
|
||||||
if ( partition_old .type == GParted::TYPE_EXTENDED )
|
if ( partition_old .type == GParted::TYPE_EXTENDED )
|
||||||
return resize_container_partition( partition_old, partition_new, false, operation_details ) ;
|
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 )
|
if ( get_fs( partition_old .filesystem ) .grow == GParted::FS::LIBPARTED )
|
||||||
return resize_normal_using_libparted( partition_old, partition_new, operation_details ) ;
|
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 ) ;
|
succes = true ;
|
||||||
|
|
||||||
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 ) ;
|
|
||||||
|
|
||||||
|
|
||||||
p_filesystem ->Check_Repair( partition_new, operation_details ) ;
|
if ( partition_new .get_length() < partition_old .get_length() )
|
||||||
|
{
|
||||||
//expand filesystem to fit exactly in partition
|
p_filesystem ->cylinder_size = MEBIBYTE * device .cylsize ;
|
||||||
p_filesystem ->Resize( partition_new, operation_details, true ) ;
|
succes = p_filesystem ->Resize( partition_new, operation_details ) ;
|
||||||
|
|
||||||
return p_filesystem ->Check_Repair( 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,
|
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 ;
|
Partition src_partition ;
|
||||||
src_partition .partition = src_part_path ;
|
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 )
|
bool GParted_Core::Set_Disklabel( const Glib::ustring & device_path, const Glib::ustring & disklabel )
|
||||||
|
|
|
@ -30,7 +30,7 @@ Operation::Operation( const Device & device, const Partition & partition_origina
|
||||||
this ->partition_new = partition_new;
|
this ->partition_new = partition_new;
|
||||||
this ->operationtype = operationtype;
|
this ->operationtype = operationtype;
|
||||||
|
|
||||||
str_operation = Get_String( ) ;
|
str_operation = Get_String() ;
|
||||||
|
|
||||||
if ( operationtype == COPY )
|
if ( operationtype == COPY )
|
||||||
{
|
{
|
||||||
|
|
|
@ -1067,17 +1067,19 @@ void Win_GParted::activate_copy( )
|
||||||
|
|
||||||
void Win_GParted::activate_paste( )
|
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 ) ;
|
Dialog_Partition_Copy dialog( gparted_core .get_fs( copied_partition .filesystem ),
|
||||||
copied_partition .error .clear( ) ; //we don't need the errors of the source partition.
|
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_Data( selected_partition, copied_partition ) ;
|
||||||
dialog .set_transient_for( *this );
|
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() ;
|
||||||
Add_Operation( GParted::COPY, dialog .Get_New_Partition( ) );
|
Add_Operation( GParted::COPY, dialog .Get_New_Partition() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -107,7 +107,7 @@ bool ext2::Resize( const Partition & partition_new,
|
||||||
|
|
||||||
if ( ! fill_partition )
|
if ( ! fill_partition )
|
||||||
argv .push_back( Utils::num_to_str( Utils::Round( Utils::sector_to_unit(
|
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 ) )
|
if ( ! execute_command( argv, operation_details .back() .sub_details ) )
|
||||||
{
|
{
|
||||||
|
|
|
@ -108,7 +108,7 @@ bool ext3::Resize( const Partition & partition_new,
|
||||||
|
|
||||||
if ( ! fill_partition )
|
if ( ! fill_partition )
|
||||||
argv .push_back( Utils::num_to_str( Utils::Round( Utils::sector_to_unit(
|
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 ) )
|
if ( ! execute_command( argv, operation_details .back() .sub_details ) )
|
||||||
{
|
{
|
||||||
|
|
|
@ -143,7 +143,7 @@ bool fat16::Check_Repair( const Partition & partition, std::vector<OperationDeta
|
||||||
argv .push_back( "-v" ) ;
|
argv .push_back( "-v" ) ;
|
||||||
argv .push_back( partition .partition ) ;
|
argv .push_back( partition .partition ) ;
|
||||||
|
|
||||||
if ( ! execute_command( argv, operation_details .back() .sub_details ) )
|
if ( 1 >= execute_command( argv, operation_details .back() .sub_details ) >= 0 )
|
||||||
{
|
{
|
||||||
operation_details .back() .status = OperationDetails::SUCCES ;
|
operation_details .back() .status = OperationDetails::SUCCES ;
|
||||||
return true ;
|
return true ;
|
||||||
|
|
|
@ -142,7 +142,7 @@ bool fat32::Check_Repair( const Partition & partition, std::vector<OperationDeta
|
||||||
argv .push_back( "-v" ) ;
|
argv .push_back( "-v" ) ;
|
||||||
argv .push_back( partition .partition ) ;
|
argv .push_back( partition .partition ) ;
|
||||||
|
|
||||||
if ( ! execute_command( argv, operation_details .back() .sub_details ) )
|
if ( 1 >= execute_command( argv, operation_details .back() .sub_details ) >= 0 )
|
||||||
{
|
{
|
||||||
operation_details .back() .status = OperationDetails::SUCCES ;
|
operation_details .back() .status = OperationDetails::SUCCES ;
|
||||||
return true ;
|
return true ;
|
||||||
|
|
|
@ -106,7 +106,8 @@ bool ntfs::Resize( const Partition & partition_new,
|
||||||
if ( ! fill_partition )
|
if ( ! fill_partition )
|
||||||
{
|
{
|
||||||
str_temp += " -s " ;
|
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..
|
//simulation..
|
||||||
|
|
|
@ -110,15 +110,9 @@ bool reiserfs::Resize( const Partition & partition_new,
|
||||||
|
|
||||||
if ( ! fill_partition )
|
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 += " -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() ;
|
argv .clear() ;
|
||||||
|
|
Loading…
Reference in New Issue