mirror of
https://gitlab.gnome.org/GNOME/gparted
synced 2024-08-27 11:40:03 +00:00
more cleanups in the core and the fs'es (these changelogs are getting
* more cleanups in the core and the fs'es (these changelogs are getting boring ;^) )
This commit is contained in:
parent
08245cd08c
commit
2d7fb5700b
|
@ -1,3 +1,8 @@
|
|||
2006-06-17 Bart Hakvoort <hakvoort@cvs.gnome.org>
|
||||
|
||||
* more cleanups in the core and the fs'es (these changelogs are
|
||||
getting boring ;^) )
|
||||
|
||||
2006-06-17 Bart Hakvoort <hakvoort@cvs.gnome.org>
|
||||
|
||||
* cleanups in the core and the fs'es (resize)
|
||||
|
|
|
@ -70,6 +70,8 @@ private:
|
|||
std::vector<OperationDetails> & operation_details,
|
||||
Sector cylinder_size = 0,
|
||||
bool fill_partition = false ) ;
|
||||
bool maximize_filesystem( const Partition & partition,
|
||||
std::vector<OperationDetails> & operation_details ) ;
|
||||
|
||||
bool copy( const Partition & partition_src,
|
||||
Partition & partition_dest,
|
||||
|
|
|
@ -908,7 +908,7 @@ bool GParted_Core::resize( const Device & device,
|
|||
succes = false ;
|
||||
|
||||
//expand filesystem to fit exactly in partition
|
||||
if ( ! resize_filesystem( partition_old, partition_new, operation_details, device .cylsize, true ) )
|
||||
if ( ! maximize_filesystem( partition_new, operation_details ) )
|
||||
succes = false ;
|
||||
|
||||
if ( ! check_repair( partition_new, operation_details ) )
|
||||
|
@ -926,15 +926,16 @@ bool GParted_Core::resize_filesystem( const Partition & partition_old,
|
|||
Sector cylinder_size,
|
||||
bool fill_partition )
|
||||
{
|
||||
if ( fill_partition )
|
||||
operation_details .push_back( OperationDetails( _("grow filesystem to fill the partition") ) ) ;
|
||||
else if ( partition_new .get_length() < partition_old .get_length() )
|
||||
if ( ! fill_partition )
|
||||
{
|
||||
if ( partition_new .get_length() < partition_old .get_length() )
|
||||
operation_details .push_back( OperationDetails( _("shrink filesystem") ) ) ;
|
||||
else if ( partition_new .get_length() > partition_old .get_length() )
|
||||
operation_details .push_back( OperationDetails( _("grow filesystem") ) ) ;
|
||||
else
|
||||
operation_details .push_back(
|
||||
OperationDetails( _("new and old partition have the same size. continuing anyway") ) ) ;
|
||||
}
|
||||
|
||||
set_proper_filesystem( partition_new .filesystem, cylinder_size ) ;
|
||||
if ( p_filesystem && p_filesystem ->Resize( partition_new, operation_details .back() .sub_details, fill_partition ) )
|
||||
|
@ -949,6 +950,14 @@ bool GParted_Core::resize_filesystem( const Partition & partition_old,
|
|||
}
|
||||
}
|
||||
|
||||
bool GParted_Core::maximize_filesystem( const Partition & partition,
|
||||
std::vector<OperationDetails> & operation_details )
|
||||
{
|
||||
operation_details .push_back( OperationDetails( _("grow filesystem to fill the partition") ) ) ;
|
||||
|
||||
return resize_filesystem( partition, partition, operation_details, 0, true ) ;
|
||||
}
|
||||
|
||||
bool GParted_Core::copy( const Partition & partition_src,
|
||||
Partition & partition_dest,
|
||||
Sector min_size,
|
||||
|
@ -968,7 +977,6 @@ bool GParted_Core::copy( const Partition & partition_src,
|
|||
partition_src .get_path(),
|
||||
partition_dest .get_path() ) ) ) ;
|
||||
|
||||
set_proper_filesystem( partition_dest .filesystem ) ;
|
||||
|
||||
switch ( get_fs( partition_dest .filesystem ) .copy )
|
||||
{
|
||||
|
@ -984,9 +992,11 @@ bool GParted_Core::copy( const Partition & partition_src,
|
|||
break ;
|
||||
|
||||
case GParted::FS::EXTERNAL :
|
||||
succes = p_filesystem ->Copy( partition_src .get_path(),
|
||||
set_proper_filesystem( partition_dest .filesystem ) ;
|
||||
succes = p_filesystem &&
|
||||
p_filesystem ->Copy( partition_src .get_path(),
|
||||
partition_dest .get_path(),
|
||||
operation_details ) ;
|
||||
operation_details .back() .sub_details ) ;
|
||||
break ;
|
||||
|
||||
default :
|
||||
|
@ -994,9 +1004,11 @@ bool GParted_Core::copy( const Partition & partition_src,
|
|||
break ;
|
||||
}
|
||||
|
||||
operation_details .back() .status = succes ? OperationDetails::SUCCES : OperationDetails::ERROR ;
|
||||
|
||||
return ( succes &&
|
||||
check_repair( partition_dest, operation_details ) &&
|
||||
p_filesystem ->Resize( partition_dest, operation_details, true ) &&
|
||||
maximize_filesystem( partition_dest, operation_details ) &&
|
||||
check_repair( partition_dest, operation_details ) ) ;
|
||||
}
|
||||
}
|
||||
|
|
33
src/ext2.cc
33
src/ext2.cc
|
@ -75,16 +75,7 @@ void ext2::Set_Used_Sectors( Partition & partition )
|
|||
|
||||
bool ext2::Create( const Partition & new_partition, std::vector<OperationDetails> & operation_details )
|
||||
{
|
||||
if ( ! execute_command( "mkfs.ext2 " + new_partition .get_path(), operation_details ) )
|
||||
{
|
||||
operation_details .back() .status = OperationDetails::SUCCES ;
|
||||
return true ;
|
||||
}
|
||||
else
|
||||
{
|
||||
operation_details .back() .status = OperationDetails::ERROR ;
|
||||
return false ;
|
||||
}
|
||||
return ! execute_command( "mkfs.ext2 " + new_partition .get_path(), operation_details ) ;
|
||||
}
|
||||
|
||||
bool ext2::Resize( const Partition & partition_new,
|
||||
|
@ -97,16 +88,7 @@ bool ext2::Resize( const Partition & partition_new,
|
|||
str_temp += " " + Utils::num_to_str( Utils::round( Utils::sector_to_unit(
|
||||
partition_new .get_length() - cylinder_size, GParted::UNIT_MIB ) ), true ) + "M" ;
|
||||
|
||||
if ( ! execute_command( str_temp, operation_details ) )
|
||||
{
|
||||
operation_details .back() .status = OperationDetails::SUCCES ;
|
||||
return true ;
|
||||
}
|
||||
else
|
||||
{
|
||||
operation_details .back() .status = OperationDetails::ERROR ;
|
||||
return false ;
|
||||
}
|
||||
return ! execute_command( str_temp, operation_details ) ;
|
||||
}
|
||||
|
||||
bool ext2::Copy( const Glib::ustring & src_part_path,
|
||||
|
@ -122,16 +104,7 @@ bool ext2::Check_Repair( const Partition & partition, std::vector<OperationDetai
|
|||
|
||||
//exitstatus 256 isn't documented, but it's returned when the 'FILESYSTEM IS MODIFIED'
|
||||
//this is quite normal (especially after a copy) so we let the function return true...
|
||||
if ( exit_status == 0 || exit_status == 1 || exit_status == 2 || exit_status == 256 )
|
||||
{
|
||||
operation_details .back() .status = OperationDetails::SUCCES ;
|
||||
return true ;
|
||||
}
|
||||
else
|
||||
{
|
||||
operation_details .back() .status = OperationDetails::ERROR ;
|
||||
return false ;
|
||||
}
|
||||
return ( exit_status == 0 || exit_status == 1 || exit_status == 2 || exit_status == 256 ) ;
|
||||
}
|
||||
|
||||
} //GParted
|
||||
|
|
33
src/ext3.cc
33
src/ext3.cc
|
@ -70,16 +70,7 @@ void ext3::Set_Used_Sectors( Partition & partition )
|
|||
|
||||
bool ext3::Create( const Partition & new_partition, std::vector<OperationDetails> & operation_details )
|
||||
{
|
||||
if ( ! execute_command( "mkfs.ext3 " + new_partition .get_path(), operation_details ) )
|
||||
{
|
||||
operation_details .back() .status = OperationDetails::SUCCES ;
|
||||
return true ;
|
||||
}
|
||||
else
|
||||
{
|
||||
operation_details .back() .status = OperationDetails::ERROR ;
|
||||
return false ;
|
||||
}
|
||||
return ! execute_command( "mkfs.ext3 " + new_partition .get_path(), operation_details ) ;
|
||||
}
|
||||
|
||||
bool ext3::Resize( const Partition & partition_new,
|
||||
|
@ -92,16 +83,7 @@ bool ext3::Resize( const Partition & partition_new,
|
|||
str_temp += " " + Utils::num_to_str( Utils::round( Utils::sector_to_unit(
|
||||
partition_new .get_length() - cylinder_size, GParted::UNIT_MIB ) ), true ) + "M" ;
|
||||
|
||||
if ( ! execute_command( str_temp, operation_details ) )
|
||||
{
|
||||
operation_details .back() .status = OperationDetails::SUCCES ;
|
||||
return true ;
|
||||
}
|
||||
else
|
||||
{
|
||||
operation_details .back() .status = OperationDetails::ERROR ;
|
||||
return false ;
|
||||
}
|
||||
return ! execute_command( str_temp, operation_details ) ;
|
||||
}
|
||||
|
||||
bool ext3::Copy( const Glib::ustring & src_part_path,
|
||||
|
@ -117,16 +99,7 @@ bool ext3::Check_Repair( const Partition & partition, std::vector<OperationDetai
|
|||
|
||||
//exitstatus 256 isn't documented, but it's returned when the 'FILESYSTEM IS MODIFIED'
|
||||
//this is quite normal (especially after a copy) so we let the function return true...
|
||||
if ( exit_status == 0 || exit_status == 1 || exit_status == 2 || exit_status == 256 )
|
||||
{
|
||||
operation_details .back() .status = OperationDetails::SUCCES ;
|
||||
return true ;
|
||||
}
|
||||
else
|
||||
{
|
||||
operation_details .back() .status = OperationDetails::ERROR ;
|
||||
return false ;
|
||||
}
|
||||
return ( exit_status == 0 || exit_status == 1 || exit_status == 2 || exit_status == 256 ) ;
|
||||
}
|
||||
|
||||
} //GParted
|
||||
|
|
23
src/fat16.cc
23
src/fat16.cc
|
@ -75,16 +75,7 @@ void fat16::Set_Used_Sectors( Partition & partition )
|
|||
|
||||
bool fat16::Create( const Partition & new_partition, std::vector<OperationDetails> & operation_details )
|
||||
{
|
||||
if ( ! execute_command( "mkdosfs -F16 -v " + new_partition .get_path(), operation_details ) )
|
||||
{
|
||||
operation_details .back() .status = OperationDetails::SUCCES ;
|
||||
return true ;
|
||||
}
|
||||
else
|
||||
{
|
||||
operation_details .back() .status = OperationDetails::ERROR ;
|
||||
return false ;
|
||||
}
|
||||
return ! execute_command( "mkdosfs -F16 -v " + new_partition .get_path(), operation_details ) ;
|
||||
}
|
||||
|
||||
bool fat16::Resize( const Partition & partition_new,
|
||||
|
@ -104,16 +95,8 @@ bool fat16::Copy( const Glib::ustring & src_part_path,
|
|||
bool fat16::Check_Repair( const Partition & partition, std::vector<OperationDetails> & operation_details )
|
||||
{
|
||||
exit_status = execute_command( "dosfsck -a -w -v " + partition .get_path(), operation_details ) ;
|
||||
if ( exit_status == 0 || exit_status == 1 )
|
||||
{
|
||||
operation_details .back() .status = OperationDetails::SUCCES ;
|
||||
return true ;
|
||||
}
|
||||
else
|
||||
{
|
||||
operation_details .back() .status = OperationDetails::ERROR ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
return ( exit_status == 0 || exit_status == 1 ) ;
|
||||
}
|
||||
|
||||
} //GParted
|
||||
|
|
23
src/fat32.cc
23
src/fat32.cc
|
@ -76,16 +76,7 @@ void fat32::Set_Used_Sectors( Partition & partition )
|
|||
|
||||
bool fat32::Create( const Partition & new_partition, std::vector<OperationDetails> & operation_details )
|
||||
{
|
||||
if ( ! execute_command( "mkdosfs -F32 -v " + new_partition .get_path(), operation_details ) )
|
||||
{
|
||||
operation_details .back() .status = OperationDetails::SUCCES ;
|
||||
return true ;
|
||||
}
|
||||
else
|
||||
{
|
||||
operation_details .back() .status = OperationDetails::ERROR ;
|
||||
return false ;
|
||||
}
|
||||
return ! execute_command( "mkdosfs -F32 -v " + new_partition .get_path(), operation_details ) ;
|
||||
}
|
||||
|
||||
bool fat32::Resize( const Partition & partition_new,
|
||||
|
@ -105,16 +96,8 @@ bool fat32::Copy( const Glib::ustring & src_part_path,
|
|||
bool fat32::Check_Repair( const Partition & partition, std::vector<OperationDetails> & operation_details )
|
||||
{
|
||||
exit_status = execute_command( "dosfsck -a -w -v " + partition .get_path(), operation_details ) ;
|
||||
if ( exit_status == 0 || exit_status == 1 )
|
||||
{
|
||||
operation_details .back() .status = OperationDetails::SUCCES ;
|
||||
return true ;
|
||||
}
|
||||
else
|
||||
{
|
||||
operation_details .back() .status = OperationDetails::ERROR ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
return ( exit_status == 0 || exit_status == 1 ) ;
|
||||
}
|
||||
|
||||
} //GParted
|
||||
|
|
11
src/hfs.cc
11
src/hfs.cc
|
@ -46,16 +46,7 @@ void hfs::Set_Used_Sectors( Partition & partition )
|
|||
|
||||
bool hfs::Create( const Partition & new_partition, std::vector<OperationDetails> & operation_details )
|
||||
{
|
||||
if ( ! execute_command( "hformat " + new_partition .get_path(), operation_details ) )
|
||||
{
|
||||
operation_details .back() .status = OperationDetails::SUCCES ;
|
||||
return true ;
|
||||
}
|
||||
else
|
||||
{
|
||||
operation_details .back() .status = OperationDetails::ERROR ;
|
||||
return false ;
|
||||
}
|
||||
return ! execute_command( "hformat " + new_partition .get_path(), operation_details ) ;
|
||||
}
|
||||
|
||||
bool hfs::Resize( const Partition & partition_new,
|
||||
|
|
23
src/jfs.cc
23
src/jfs.cc
|
@ -91,16 +91,7 @@ void jfs::Set_Used_Sectors( Partition & partition )
|
|||
|
||||
bool jfs::Create( const Partition & new_partition, std::vector<OperationDetails> & operation_details )
|
||||
{
|
||||
if ( ! execute_command( "mkfs.jfs -q " + new_partition .get_path(), operation_details ) )
|
||||
{
|
||||
operation_details .back() .status = OperationDetails::SUCCES ;
|
||||
return true ;
|
||||
}
|
||||
else
|
||||
{
|
||||
operation_details .back() .status = OperationDetails::ERROR ;
|
||||
return false ;
|
||||
}
|
||||
return ! execute_command( "mkfs.jfs -q " + new_partition .get_path(), operation_details ) ;
|
||||
}
|
||||
|
||||
bool jfs::Resize( const Partition & partition_new,
|
||||
|
@ -200,16 +191,8 @@ bool jfs::Copy( const Glib::ustring & src_part_path,
|
|||
bool jfs::Check_Repair( const Partition & partition, std::vector<OperationDetails> & operation_details )
|
||||
{
|
||||
exit_status = execute_command( "jfs_fsck -f " + partition .get_path(), operation_details ) ;
|
||||
if ( exit_status == 0 || exit_status == 1 )
|
||||
{
|
||||
operation_details .back() .status = OperationDetails::SUCCES ;
|
||||
return true ;
|
||||
}
|
||||
else
|
||||
{
|
||||
operation_details .back() .status = OperationDetails::ERROR ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
return ( exit_status == 0 || exit_status == 1 ) ;
|
||||
}
|
||||
|
||||
} //GParted
|
||||
|
|
|
@ -45,16 +45,7 @@ void linux_swap::Set_Used_Sectors( Partition & partition )
|
|||
|
||||
bool linux_swap::Create( const Partition & new_partition, std::vector<OperationDetails> & operation_details )
|
||||
{
|
||||
if ( ! execute_command( "mkswap " + new_partition .get_path(), operation_details ) )
|
||||
{
|
||||
operation_details .back() .status = OperationDetails::SUCCES ;
|
||||
return true ;
|
||||
}
|
||||
else
|
||||
{
|
||||
operation_details .back() .status = OperationDetails::ERROR ;
|
||||
return false ;
|
||||
}
|
||||
return ! execute_command( "mkswap " + new_partition .get_path(), operation_details ) ;
|
||||
}
|
||||
|
||||
bool linux_swap::Resize( const Partition & partition_new,
|
||||
|
|
34
src/ntfs.cc
34
src/ntfs.cc
|
@ -69,16 +69,7 @@ void ntfs::Set_Used_Sectors( Partition & partition )
|
|||
|
||||
bool ntfs::Create( const Partition & new_partition, std::vector<OperationDetails> & operation_details )
|
||||
{
|
||||
if ( ! execute_command( "mkntfs -Q -vv " + new_partition .get_path(), operation_details ) )
|
||||
{
|
||||
operation_details .back() .status = OperationDetails::SUCCES ;
|
||||
return true ;
|
||||
}
|
||||
else
|
||||
{
|
||||
operation_details .back() .status = OperationDetails::ERROR ;
|
||||
return false ;
|
||||
}
|
||||
return ! execute_command( "mkntfs -Q -vv " + new_partition .get_path(), operation_details ) ;
|
||||
}
|
||||
|
||||
bool ntfs::Resize( const Partition & partition_new,
|
||||
|
@ -127,31 +118,12 @@ bool ntfs::Copy( const Glib::ustring & src_part_path,
|
|||
const Glib::ustring & dest_part_path,
|
||||
std::vector<OperationDetails> & operation_details )
|
||||
{
|
||||
if ( ! execute_command( "ntfsclone -f --overwrite " + dest_part_path + " " + src_part_path,
|
||||
operation_details .back() .sub_details ) )
|
||||
{
|
||||
operation_details .back() .status = OperationDetails::SUCCES ;
|
||||
return true ;
|
||||
}
|
||||
else
|
||||
{
|
||||
operation_details .back() .status = OperationDetails::ERROR ;
|
||||
return false ;
|
||||
}
|
||||
return ! execute_command( "ntfsclone -f --overwrite " + dest_part_path + " " + src_part_path, operation_details ) ;
|
||||
}
|
||||
|
||||
bool ntfs::Check_Repair( const Partition & partition, std::vector<OperationDetails> & operation_details )
|
||||
{
|
||||
if ( ! execute_command( "ntfsresize -P -i -f -v " + partition .get_path(), operation_details ) )
|
||||
{
|
||||
operation_details .back() .status = OperationDetails::SUCCES ;
|
||||
return true ;
|
||||
}
|
||||
else
|
||||
{
|
||||
operation_details .back() .status = OperationDetails::ERROR ;
|
||||
return false ;
|
||||
}
|
||||
return ! execute_command( "ntfsresize -P -i -f -v " + partition .get_path(), operation_details ) ;
|
||||
}
|
||||
|
||||
} //GParted
|
||||
|
|
|
@ -68,16 +68,7 @@ void reiser4::Set_Used_Sectors( Partition & partition )
|
|||
|
||||
bool reiser4::Create( const Partition & new_partition, std::vector<OperationDetails> & operation_details )
|
||||
{
|
||||
if ( ! execute_command( "mkfs.reiser4 --yes " + new_partition .get_path(), operation_details ) )
|
||||
{
|
||||
operation_details .back() .status = OperationDetails::SUCCES ;
|
||||
return true ;
|
||||
}
|
||||
else
|
||||
{
|
||||
operation_details .back() .status = OperationDetails::ERROR ;
|
||||
return false ;
|
||||
}
|
||||
return ! execute_command( "mkfs.reiser4 --yes " + new_partition .get_path(), operation_details ) ;
|
||||
}
|
||||
|
||||
bool reiser4::Resize( const Partition & partition_new,
|
||||
|
@ -96,16 +87,7 @@ bool reiser4::Copy( const Glib::ustring & src_part_path,
|
|||
|
||||
bool reiser4::Check_Repair( const Partition & partition, std::vector<OperationDetails> & operation_details )
|
||||
{
|
||||
if ( ! execute_command( "fsck.reiser4 --yes --fix " + partition .get_path(), operation_details ) )
|
||||
{
|
||||
operation_details .back() .status = OperationDetails::SUCCES ;
|
||||
return true ;
|
||||
}
|
||||
else
|
||||
{
|
||||
operation_details .back() .status = OperationDetails::ERROR ;
|
||||
return false ;
|
||||
}
|
||||
return ! execute_command( "fsck.reiser4 --yes --fix " + partition .get_path(), operation_details ) ;
|
||||
}
|
||||
|
||||
} //GParted
|
||||
|
|
|
@ -73,16 +73,7 @@ void reiserfs::Set_Used_Sectors( Partition & partition )
|
|||
|
||||
bool reiserfs::Create( const Partition & new_partition, std::vector<OperationDetails> & operation_details )
|
||||
{
|
||||
if ( ! execute_command( "mkreiserfs -f " + new_partition .get_path(), operation_details ) )
|
||||
{
|
||||
operation_details .back() .status = OperationDetails::SUCCES ;
|
||||
return true ;
|
||||
}
|
||||
else
|
||||
{
|
||||
operation_details .back() .status = OperationDetails::ERROR ;
|
||||
return false ;
|
||||
}
|
||||
return ! execute_command( "mkreiserfs -f " + new_partition .get_path(), operation_details ) ;
|
||||
}
|
||||
|
||||
bool reiserfs::Resize( const Partition & partition_new,
|
||||
|
@ -99,16 +90,8 @@ bool reiserfs::Resize( const Partition & partition_new,
|
|||
}
|
||||
|
||||
exit_status = execute_command( str_temp, operation_details ) ;
|
||||
if ( exit_status == 0 || exit_status == 256 )
|
||||
{
|
||||
operation_details .back() .status = OperationDetails::SUCCES ;
|
||||
return true ;
|
||||
}
|
||||
else
|
||||
{
|
||||
operation_details .back() .status = OperationDetails::ERROR ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
return ( exit_status == 0 || exit_status == 256 ) ;
|
||||
}
|
||||
|
||||
bool reiserfs::Copy( const Glib::ustring & src_part_path,
|
||||
|
@ -121,16 +104,8 @@ bool reiserfs::Copy( const Glib::ustring & src_part_path,
|
|||
bool reiserfs::Check_Repair( const Partition & partition, std::vector<OperationDetails> & operation_details )
|
||||
{
|
||||
exit_status = execute_command( "reiserfsck --y --fix-fixable " + partition .get_path(), operation_details ) ;
|
||||
if ( exit_status == 0 || exit_status == 1 || exit_status == 256 )
|
||||
{
|
||||
operation_details .back() .status = OperationDetails::SUCCES ;
|
||||
return true ;
|
||||
}
|
||||
else
|
||||
{
|
||||
operation_details .back() .status = OperationDetails::ERROR ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
return ( exit_status == 0 || exit_status == 1 || exit_status == 256 ) ;
|
||||
}
|
||||
|
||||
} //GParted
|
||||
|
|
100
src/xfs.cc
100
src/xfs.cc
|
@ -93,16 +93,7 @@ void xfs::Set_Used_Sectors( Partition & partition )
|
|||
|
||||
bool xfs::Create( const Partition & new_partition, std::vector<OperationDetails> & operation_details )
|
||||
{
|
||||
if ( ! execute_command( "mkfs.xfs -f " + new_partition .get_path(), operation_details ) )
|
||||
{
|
||||
operation_details .back() .status = OperationDetails::SUCCES ;
|
||||
return true ;
|
||||
}
|
||||
else
|
||||
{
|
||||
operation_details .back() .status = OperationDetails::ERROR ;
|
||||
return false ;
|
||||
}
|
||||
return ! execute_command( "mkfs.xfs -f " + new_partition .get_path(), operation_details ) ;
|
||||
}
|
||||
|
||||
bool xfs::Resize( const Partition & partition_new,
|
||||
|
@ -200,106 +191,107 @@ bool xfs::Copy( const Glib::ustring & src_part_path,
|
|||
|
||||
//create xfs filesystem on destination..
|
||||
Partition partition( dest_part_path ) ;
|
||||
if ( Create( partition, operation_details .back() .sub_details ) )
|
||||
if ( Create( partition, operation_details ) )
|
||||
{
|
||||
//create source mountpoint...
|
||||
operation_details .back() .sub_details .push_back(
|
||||
operation_details .push_back(
|
||||
OperationDetails( String::ucompose( _("create temporary mountpoint (%1)"), SRC ) ) ) ;
|
||||
if ( ! mkdir( SRC .c_str(), 0 ) )
|
||||
{
|
||||
operation_details .back() .sub_details .back() .status = OperationDetails::SUCCES ;
|
||||
operation_details .back() .status = OperationDetails::SUCCES ;
|
||||
|
||||
//create destination mountpoint...
|
||||
operation_details .back() .sub_details .push_back(
|
||||
operation_details .push_back(
|
||||
OperationDetails( String::ucompose( _("create temporary mountpoint (%1)"), DST ) ) ) ;
|
||||
if ( ! mkdir( DST .c_str(), 0 ) )
|
||||
{
|
||||
operation_details .back() .sub_details .back() .status = OperationDetails::SUCCES ;
|
||||
operation_details .back() .status = OperationDetails::SUCCES ;
|
||||
|
||||
//mount source partition
|
||||
operation_details .back() .sub_details .push_back(
|
||||
operation_details .push_back(
|
||||
OperationDetails( String::ucompose( _("mount %1 on %2"), src_part_path, SRC ) ) ) ;
|
||||
|
||||
if ( ! execute_command( "mount -v -t xfs -o noatime,ro " + src_part_path + " " + SRC,
|
||||
operation_details .back() .sub_details .back() .sub_details ) )
|
||||
operation_details .back() .sub_details ) )
|
||||
{
|
||||
operation_details .back() .sub_details .back() .status = OperationDetails::SUCCES ;
|
||||
operation_details .back() .status = OperationDetails::SUCCES ;
|
||||
|
||||
//mount destination partition
|
||||
operation_details .back() .sub_details .push_back(
|
||||
operation_details .push_back(
|
||||
OperationDetails( String::ucompose( _("mount %1 on %2"), dest_part_path, DST ) ) ) ;
|
||||
|
||||
if ( ! execute_command( "mount -v -t xfs " + dest_part_path + " " + DST,
|
||||
operation_details .back() .sub_details .back() .sub_details ) )
|
||||
operation_details .back() .sub_details ) )
|
||||
{
|
||||
operation_details .back() .sub_details .back() .status = OperationDetails::SUCCES ;
|
||||
operation_details .back() .status = OperationDetails::SUCCES ;
|
||||
|
||||
//copy filesystem..
|
||||
operation_details .back() .sub_details .push_back( OperationDetails( _("copy filesystem") ) ) ;
|
||||
operation_details .push_back( OperationDetails( _("copy filesystem") ) ) ;
|
||||
|
||||
if ( ! execute_command(
|
||||
"xfsdump -J - " + SRC + " | xfsrestore -J - " + DST,
|
||||
operation_details .back() .sub_details .back() .sub_details ) )
|
||||
operation_details .back() .sub_details ) )
|
||||
{
|
||||
operation_details .back() .sub_details .back() .status = OperationDetails::SUCCES ;
|
||||
operation_details .back() .status = OperationDetails::SUCCES ;
|
||||
return_value = true ;
|
||||
}
|
||||
else
|
||||
{
|
||||
operation_details .back() .sub_details .back() .status = OperationDetails::ERROR ;
|
||||
operation_details .back() .status = OperationDetails::ERROR ;
|
||||
}
|
||||
|
||||
//unmount destination partition
|
||||
operation_details .back() .sub_details .push_back(
|
||||
OperationDetails( String::ucompose( _("unmount %1"), dest_part_path ) ) ) ;
|
||||
operation_details .push_back(
|
||||
OperationDetails( String::ucompose( _("unmount %1"),
|
||||
dest_part_path ) ) ) ;
|
||||
|
||||
if ( ! execute_command( "umount -v " + dest_part_path,
|
||||
operation_details .back() .sub_details .back() .sub_details ) )
|
||||
operation_details .back() .sub_details ) )
|
||||
{
|
||||
operation_details .back() .sub_details .back() .status = OperationDetails::SUCCES ;
|
||||
operation_details .back() .status = OperationDetails::SUCCES ;
|
||||
}
|
||||
else
|
||||
{
|
||||
operation_details .back() .sub_details .back() .status = OperationDetails::ERROR ;
|
||||
operation_details .back() .status = OperationDetails::ERROR ;
|
||||
return_value = false ;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
operation_details .back() .sub_details .back() .status = OperationDetails::ERROR ;
|
||||
operation_details .back() .status = OperationDetails::ERROR ;
|
||||
}
|
||||
|
||||
//unmount source partition
|
||||
operation_details .back() .sub_details .push_back(
|
||||
operation_details .push_back(
|
||||
OperationDetails( String::ucompose( _("unmount %1"), src_part_path ) ) ) ;
|
||||
|
||||
if ( ! execute_command( "umount -v " + src_part_path,
|
||||
operation_details .back() .sub_details .back() .sub_details ) )
|
||||
operation_details .back() .sub_details ) )
|
||||
{
|
||||
operation_details .back() .sub_details .back() .status = OperationDetails::SUCCES ;
|
||||
operation_details .back() .status = OperationDetails::SUCCES ;
|
||||
}
|
||||
else
|
||||
{
|
||||
operation_details .back() .sub_details .back() .status = OperationDetails::ERROR ;
|
||||
operation_details .back() .status = OperationDetails::ERROR ;
|
||||
return_value = false ;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
operation_details .back() .sub_details .back() .status = OperationDetails::ERROR ;
|
||||
operation_details .back() .status = OperationDetails::ERROR ;
|
||||
}
|
||||
|
||||
//remove destination mountpoint..
|
||||
operation_details .back() .sub_details .push_back(
|
||||
operation_details .push_back(
|
||||
OperationDetails( String::ucompose( _("remove temporary mountpoint (%1)"), DST ) ) ) ;
|
||||
if ( ! rmdir( DST .c_str() ) )
|
||||
{
|
||||
operation_details .back() .sub_details .back() .status = OperationDetails::SUCCES ;
|
||||
operation_details .back() .status = OperationDetails::SUCCES ;
|
||||
}
|
||||
else
|
||||
{
|
||||
operation_details .back() .sub_details .back() .status = OperationDetails::ERROR ;
|
||||
operation_details .back() .sub_details .back() .sub_details .push_back(
|
||||
operation_details .back() .status = OperationDetails::ERROR ;
|
||||
operation_details .back() .sub_details .push_back(
|
||||
OperationDetails( Glib::strerror( errno ), OperationDetails::NONE ) ) ;
|
||||
|
||||
return_value = false ;
|
||||
|
@ -307,22 +299,22 @@ bool xfs::Copy( const Glib::ustring & src_part_path,
|
|||
}
|
||||
else
|
||||
{
|
||||
operation_details .back() .sub_details .back() .status = OperationDetails::ERROR ;
|
||||
operation_details .back() .sub_details .back() .sub_details .push_back(
|
||||
operation_details .back() .status = OperationDetails::ERROR ;
|
||||
operation_details .back() .sub_details .push_back(
|
||||
OperationDetails( Glib::strerror( errno ), OperationDetails::NONE ) ) ;
|
||||
}
|
||||
|
||||
//remove source mountpoint..
|
||||
operation_details .back() .sub_details .push_back(
|
||||
operation_details .push_back(
|
||||
OperationDetails( String::ucompose( _("remove temporary mountpoint (%1)"), SRC ) ) ) ;
|
||||
if ( ! rmdir( SRC .c_str() ) )
|
||||
{
|
||||
operation_details .back() .sub_details .back() .status = OperationDetails::SUCCES ;
|
||||
operation_details .back() .status = OperationDetails::SUCCES ;
|
||||
}
|
||||
else
|
||||
{
|
||||
operation_details .back() .sub_details .back() .status = OperationDetails::ERROR ;
|
||||
operation_details .back() .sub_details .back() .sub_details .push_back(
|
||||
operation_details .back() .status = OperationDetails::ERROR ;
|
||||
operation_details .back() .sub_details .push_back(
|
||||
OperationDetails( Glib::strerror( errno ), OperationDetails::NONE ) ) ;
|
||||
|
||||
return_value = false ;
|
||||
|
@ -330,28 +322,18 @@ bool xfs::Copy( const Glib::ustring & src_part_path,
|
|||
}
|
||||
else
|
||||
{
|
||||
operation_details .back() .sub_details .back() .status = OperationDetails::ERROR ;
|
||||
operation_details .back() .sub_details .back() .sub_details .push_back(
|
||||
operation_details .back() .status = OperationDetails::ERROR ;
|
||||
operation_details .back() .sub_details .push_back(
|
||||
OperationDetails( Glib::strerror( errno ), OperationDetails::NONE ) ) ;
|
||||
}
|
||||
}
|
||||
|
||||
operation_details .back() .status = return_value ? OperationDetails::SUCCES : OperationDetails::ERROR ;
|
||||
return return_value ;
|
||||
}
|
||||
|
||||
bool xfs::Check_Repair( const Partition & partition, std::vector<OperationDetails> & operation_details )
|
||||
{
|
||||
if ( ! execute_command( "xfs_repair -v " + partition .get_path(), operation_details ) )
|
||||
{
|
||||
operation_details .back() .status = OperationDetails::SUCCES ;
|
||||
return true ;
|
||||
}
|
||||
else
|
||||
{
|
||||
operation_details .back() .status = OperationDetails::ERROR ;
|
||||
return false ;
|
||||
}
|
||||
return ! execute_command( "xfs_repair -v " + partition .get_path(), operation_details ) ;
|
||||
}
|
||||
|
||||
} //GParted
|
||||
|
|
Loading…
Reference in a new issue