diff --git a/ChangeLog b/ChangeLog index ef85d4ec..e1d005e2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2004-12-20 Bart Hakvoort + + * src/Dialog_Partition_Copy.cc, + src/Win_GParted.cc, + src/xfs.cc: xfs copy now uses xfsdump and xfsrestore. icw some hacks in the other 2 files, it's now possible to shrink an xfs partition + while doing the copy. Although i'd rather preffered 'real' (in place) resizing i figured it's better then nothing. + Also the sourcefilesystem is now checked before the actual copy is performed. If damaged beyond repair, the copy won't start. + * src/Dialog_Partition_Resize_Move.cc: removed commented code. + 2004-12-18 Bart Hakvoort * include/Dialog_Filesystems.h, diff --git a/src/Dialog_Partition_Copy.cc b/src/Dialog_Partition_Copy.cc index 145bf4b5..ed7b4540 100644 --- a/src/Dialog_Partition_Copy.cc +++ b/src/Dialog_Partition_Copy.cc @@ -36,8 +36,6 @@ Dialog_Partition_Copy::Dialog_Partition_Copy( const FS & fs, Sector cylinder_siz void Dialog_Partition_Copy::Set_Data( const Partition & selected_partition, const Partition & copied_partition ) { - GRIP = true ; //prevents on spinbutton_changed from getting activated prematurely - this ->set_title( String::ucompose( _("Paste %1"), copied_partition .partition ) ) ; //set partition color @@ -48,27 +46,34 @@ void Dialog_Partition_Copy::Set_Data( const Partition & selected_partition, cons total_length = selected_partition .sector_end - selected_partition .sector_start ; TOTAL_MB = selected_partition .Get_Length_MB( ) ; MB_PER_PIXEL = (double) TOTAL_MB / 500 ; + long COPIED_LENGTH_MB = copied_partition .Get_Length_MB( ) ; //now calculate proportional length of partition frame_resizer_base ->set_x_start( 0 ) ; - frame_resizer_base ->set_x_end( ( Round( (double) (copied_partition .sector_end - copied_partition .sector_start) / ( (double)total_length/500) )) ) ; - frame_resizer_base ->set_used( Round( (double) copied_partition .sectors_used / ( (double)total_length/500) ) ) ; - + int x_end = Round( COPIED_LENGTH_MB / ( (double)TOTAL_MB/500 ) ) ; //> 500 px only possible with xfs... + frame_resizer_base ->set_x_end( x_end > 500 ? 500 : x_end ) ; + frame_resizer_base ->set_used( Round( copied_partition .Get_Used_MB( ) / ( (double)TOTAL_MB/500) ) ) ; + fs .MAX = ( ! fs .MAX || fs .MAX > TOTAL_MB ) ? TOTAL_MB : fs .MAX -= BUF ; - fs .MIN = copied_partition .Get_Length_MB( ) +1 ; + if ( fs .filesystem == "xfs" ) //bit hackisch, but most effective, since it's a unique situation + fs .MIN = copied_partition .Get_Used_MB( ) + (BUF * 2) ; + else + fs .MIN = COPIED_LENGTH_MB +1 ; + GRIP = true ; //set values of spinbutton_before spinbutton_before .set_range( 0, TOTAL_MB - fs .MIN ) ; spinbutton_before .set_value( 0 ) ; //set values of spinbutton_size spinbutton_size .set_range( fs .MIN, fs .MAX ) ; - spinbutton_size .set_value( fs .MIN ) ; + spinbutton_size .set_value( COPIED_LENGTH_MB ) ; //set values of spinbutton_after spinbutton_after .set_range( 0, TOTAL_MB - fs .MIN ) ; - spinbutton_after .set_value( TOTAL_MB - fs .MIN ) ; + spinbutton_after .set_value( TOTAL_MB - COPIED_LENGTH_MB ) ; + GRIP = false ; frame_resizer_base ->set_size_limits( (int) ( fs .MIN / MB_PER_PIXEL), (int) (fs .MAX / MB_PER_PIXEL) +1 ) ; @@ -79,8 +84,6 @@ void Dialog_Partition_Copy::Set_Data( const Partition & selected_partition, cons this ->selected_partition = copied_partition ; this ->selected_partition .inside_extended = selected_partition .inside_extended ; selected_partition .inside_extended ? this ->selected_partition .type = GParted::LOGICAL : this ->selected_partition .type = GParted::PRIMARY ; - - GRIP = false ; } Partition Dialog_Partition_Copy::Get_New_Partition() diff --git a/src/Dialog_Partition_Resize_Move.cc b/src/Dialog_Partition_Resize_Move.cc index 0b4edc13..4c278211 100644 --- a/src/Dialog_Partition_Resize_Move.cc +++ b/src/Dialog_Partition_Resize_Move.cc @@ -128,8 +128,6 @@ void Dialog_Partition_Resize_Move::Resize_Move_Normal( const std::vector TOTAL_MB ) - // fs .MAX = TOTAL_MB ; fs .MAX = ( ! fs .MAX || fs .MAX > TOTAL_MB ) ? TOTAL_MB : fs .MAX -= BUF/2 ; //set values of spinbutton_before diff --git a/src/GParted_Core.cc b/src/GParted_Core.cc index 301b9909..fd6675c5 100644 --- a/src/GParted_Core.cc +++ b/src/GParted_Core.cc @@ -431,12 +431,14 @@ bool GParted_Core::Resize( const Glib::ustring & device_path, const Partition & bool GParted_Core::Copy( const Glib::ustring & dest_device_path, const Glib::ustring & src_part_path, Partition & partition_dest ) { - if ( Create_Empty_Partition( dest_device_path, partition_dest, true ) > 0 ) - { - set_proper_filesystem( partition_dest .filesystem ) ; - - return p_filesystem ->Copy( src_part_path, partition_dest .partition ) ; - } + set_proper_filesystem( partition_dest .filesystem ) ; + + Partition src_partition ; + src_partition .partition = src_part_path ; + + if ( p_filesystem ->Check_Repair( src_partition ) ) + if ( Create_Empty_Partition( dest_device_path, partition_dest, true ) > 0 ) + return p_filesystem ->Copy( src_part_path, partition_dest .partition ) ; return false ; } diff --git a/src/Win_GParted.cc b/src/Win_GParted.cc index 100a327d..f4239be7 100644 --- a/src/Win_GParted.cc +++ b/src/Win_GParted.cc @@ -567,7 +567,9 @@ void Win_GParted::Set_Valid_Operations() if ( cylinder_size < 1 ) cylinder_size = 1 ; - if ( (copied_partition .Get_Length_MB( ) + cylinder_size) < selected_partition .Get_Length_MB( ) ) + if ( (copied_partition .Get_Length_MB( ) + cylinder_size) < selected_partition .Get_Length_MB( ) || + (copied_partition .filesystem == "xfs" && (copied_partition .Get_Used_MB( ) + cylinder_size) < selected_partition .Get_Length_MB( ) ) + ) allow_paste( true ) ; } diff --git a/src/xfs.cc b/src/xfs.cc index 9bd38a56..e7e6b500 100644 --- a/src/xfs.cc +++ b/src/xfs.cc @@ -51,7 +51,7 @@ FS xfs::get_filesystem_support( ) input .close( ) ; } - if ( ! system( "which dd 1>/dev/null 2>/dev/null" ) && fs .grow ) + if ( ! system( "which xfsdump xfsrestore mount umount 1>/dev/null 2>/dev/null" ) && fs .check && fs .create ) fs .copy = true ; fs .MIN = 32 ;//official minsize = 16MB, but the smallest xfs_repair can handle is 32MB... @@ -111,14 +111,20 @@ bool xfs::Resize( const Partition & partition_new, bool fill_partition ) bool xfs::Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest_part_path ) { - if ( ! Execute_Command( "LC_NUMERIC=C dd bs=8192 if=" + src_part_path + " of=" + dest_part_path ) ) - { - Partition partition ; - partition .partition = dest_part_path ; - return Resize( partition, true ) ; - } + bool return_value = false ; - return false ; + system( "mkdir /tmp/gparted_tmp_xfs_src_mountpoint /tmp/gparted_tmp_xfs_dest_mountpoint" ) ; + + if ( ! Execute_Command( "mkfs.xfs -f " + dest_part_path ) && + ! Execute_Command( "mount " + src_part_path + " /tmp/gparted_tmp_xfs_src_mountpoint" ) && + ! Execute_Command( "mount " + dest_part_path + " /tmp/gparted_tmp_xfs_dest_mountpoint" ) + ) + return_value = ! Execute_Command( "xfsdump -J - /tmp/gparted_tmp_xfs_src_mountpoint | xfsrestore -J - /tmp/gparted_tmp_xfs_dest_mountpoint" ) ; + + Execute_Command( "umount " + src_part_path + " " + dest_part_path ) ; + system( "rmdir /tmp/gparted_tmp_xfs_src_mountpoint /tmp/gparted_tmp_xfs_dest_mountpoint" ) ; + + return return_value ; } bool xfs::Check_Repair( const Partition & partition )