cleanups in the core and the fs'es (check/repair)
* cleanups in the core and the fs'es (check/repair)
This commit is contained in:
parent
3094aeaabe
commit
20d5650188
|
@ -1,3 +1,7 @@
|
|||
2006-06-17 Bart Hakvoort <hakvoort@cvs.gnome.org>
|
||||
|
||||
* cleanups in the core and the fs'es (check/repair)
|
||||
|
||||
2006-06-17 Bart Hakvoort <hakvoort@cvs.gnome.org>
|
||||
|
||||
* src/GParted_Core.cc: use new create_filesystem() in format()
|
||||
|
|
|
@ -92,11 +92,11 @@ private:
|
|||
std::vector<OperationDetails> & operation_details,
|
||||
Sector min_size = 0 ) ;
|
||||
bool create_filesystem( const Partition & partition, std::vector<OperationDetails> & operation_details ) ;
|
||||
bool resize_container_partition( const Partition & partition_old,
|
||||
Partition & partition_new,
|
||||
bool fixed_start,
|
||||
std::vector<OperationDetails> & operation_details,
|
||||
Sector min_size = 0 ) ;
|
||||
bool resize_partition( const Partition & partition_old,
|
||||
Partition & partition_new,
|
||||
bool fixed_start,
|
||||
std::vector<OperationDetails> & operation_details,
|
||||
Sector min_size = 0 ) ;
|
||||
bool resize_normal_using_libparted( const Partition & partition_old,
|
||||
Partition & partition_new,
|
||||
std::vector<OperationDetails> & operation_details ) ;
|
||||
|
@ -104,6 +104,7 @@ private:
|
|||
const Partition & partition_dest,
|
||||
std::vector<OperationDetails> & operation_details,
|
||||
Sector block_size ) ;
|
||||
bool check_repair( const Partition & partition, std::vector<OperationDetails> & operation_details ) ;
|
||||
void set_proper_filesystem( const FILESYSTEM & filesystem ) ;
|
||||
bool set_partition_type( const Partition & partition,
|
||||
std::vector<OperationDetails> & operation_details ) ;
|
||||
|
|
|
@ -847,11 +847,11 @@ bool GParted_Core::move_partition( const Partition & partition_old,
|
|||
|
||||
ped_device_close( lp_device );
|
||||
//FIXME: errorhandling needs to be improved!
|
||||
succes = resize_container_partition( partition_old,
|
||||
partition_new,
|
||||
false,
|
||||
operation_details,
|
||||
partition_old .get_length() ) ;
|
||||
succes = resize_partition( partition_old,
|
||||
partition_new,
|
||||
false,
|
||||
operation_details,
|
||||
partition_old .get_length() ) ;
|
||||
}
|
||||
|
||||
close_device_and_disk() ;
|
||||
|
@ -867,22 +867,21 @@ bool GParted_Core::resize( const Device & device,
|
|||
{
|
||||
//extended partition
|
||||
if ( partition_old .type == GParted::TYPE_EXTENDED )
|
||||
return resize_container_partition( partition_old, partition_new, false, operation_details ) ;
|
||||
return resize_partition( partition_old, partition_new, false, operation_details ) ;
|
||||
|
||||
bool succes = false ;
|
||||
set_proper_filesystem( partition_new .filesystem ) ;
|
||||
|
||||
//resize using libparted..
|
||||
if ( get_fs( partition_old .filesystem ) .grow == GParted::FS::LIBPARTED ||
|
||||
get_fs( partition_old .filesystem ) .shrink == GParted::FS::LIBPARTED ||
|
||||
get_fs( partition_old .filesystem ) .move == GParted::FS::LIBPARTED )
|
||||
{
|
||||
if ( p_filesystem && p_filesystem ->Check_Repair( partition_new, operation_details ) )
|
||||
if ( check_repair( partition_new, operation_details ) )
|
||||
{
|
||||
succes = resize_normal_using_libparted( partition_old, partition_new, operation_details ) ;
|
||||
|
||||
//always check after a resize, but if it failes the whole operation failes
|
||||
if ( ! p_filesystem ->Check_Repair( partition_new, operation_details ) )
|
||||
if ( ! check_repair( partition_new, operation_details ) )
|
||||
succes = false ;
|
||||
}
|
||||
|
||||
|
@ -890,9 +889,10 @@ bool GParted_Core::resize( const Device & device,
|
|||
}
|
||||
|
||||
//use custom resize tools..
|
||||
if ( p_filesystem && p_filesystem ->Check_Repair( partition_new, operation_details ) )
|
||||
if ( check_repair( partition_new, operation_details ) )
|
||||
{
|
||||
succes = true ;
|
||||
set_proper_filesystem( partition_new .filesystem ) ;
|
||||
|
||||
if ( partition_new .get_length() < partition_old .get_length() )
|
||||
{
|
||||
|
@ -901,21 +901,21 @@ bool GParted_Core::resize( const Device & device,
|
|||
}
|
||||
|
||||
if ( succes )
|
||||
succes = resize_container_partition(
|
||||
succes = resize_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 ) )
|
||||
if ( ! 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 ) )
|
||||
if ( ! check_repair( partition_new, operation_details ) )
|
||||
succes = false ;
|
||||
|
||||
return succes ;
|
||||
|
@ -930,8 +930,7 @@ bool GParted_Core::copy( const Partition & partition_src,
|
|||
Sector block_size,
|
||||
std::vector<OperationDetails> & operation_details )
|
||||
{
|
||||
set_proper_filesystem( partition_dest .filesystem ) ;
|
||||
if ( p_filesystem && p_filesystem ->Check_Repair( partition_src, operation_details ) )
|
||||
if ( check_repair( partition_src, operation_details ) )
|
||||
{
|
||||
bool succes = true ;
|
||||
if ( partition_dest .status == GParted::STAT_NEW )
|
||||
|
@ -943,6 +942,8 @@ bool GParted_Core::copy( const Partition & partition_src,
|
|||
String::ucompose( _("copy filesystem of %1 to %2"),
|
||||
partition_src .get_path(),
|
||||
partition_dest .get_path() ) ) ) ;
|
||||
|
||||
set_proper_filesystem( partition_dest .filesystem ) ;
|
||||
|
||||
switch ( get_fs( partition_dest .filesystem ) .copy )
|
||||
{
|
||||
|
@ -969,9 +970,9 @@ bool GParted_Core::copy( const Partition & partition_src,
|
|||
}
|
||||
|
||||
return ( succes &&
|
||||
p_filesystem ->Check_Repair( partition_dest, operation_details ) &&
|
||||
check_repair( partition_dest, operation_details ) &&
|
||||
p_filesystem ->Resize( partition_dest, operation_details, true ) &&
|
||||
p_filesystem ->Check_Repair( partition_dest, operation_details ) ) ;
|
||||
check_repair( partition_dest, operation_details ) ) ;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1265,11 +1266,11 @@ bool GParted_Core::create_filesystem( const Partition & partition, std::vector<O
|
|||
}
|
||||
}
|
||||
|
||||
bool GParted_Core::resize_container_partition( const Partition & partition_old,
|
||||
Partition & partition_new,
|
||||
bool fixed_start,
|
||||
std::vector<OperationDetails> & operation_details,
|
||||
Sector min_size )
|
||||
bool GParted_Core::resize_partition( const Partition & partition_old,
|
||||
Partition & partition_new,
|
||||
bool fixed_start,
|
||||
std::vector<OperationDetails> & operation_details,
|
||||
Sector min_size )
|
||||
{
|
||||
operation_details .push_back( OperationDetails( _("resize partition") ) ) ;
|
||||
|
||||
|
@ -1555,6 +1556,26 @@ bool GParted_Core::copy_filesystem( const Partition & partition_src,
|
|||
operation_details .back() .status = succes ? OperationDetails::SUCCES : OperationDetails::ERROR ;
|
||||
return succes ;
|
||||
}
|
||||
|
||||
bool GParted_Core::check_repair( const Partition & partition, std::vector<OperationDetails> & operation_details )
|
||||
{
|
||||
operation_details .push_back( OperationDetails(
|
||||
String::ucompose( _("check filesystem on %1 for errors and (if possible) fix them"),
|
||||
partition .get_path() ) ) ) ;
|
||||
|
||||
set_proper_filesystem( partition .filesystem ) ;
|
||||
|
||||
if ( p_filesystem && p_filesystem ->Check_Repair( partition, operation_details .back() .sub_details ) )
|
||||
{
|
||||
operation_details .back() .status = OperationDetails::SUCCES ;
|
||||
return true ;
|
||||
}
|
||||
else
|
||||
{
|
||||
operation_details .back() .status = OperationDetails::ERROR ;
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
|
||||
void GParted_Core::set_flags( Partition & partition )
|
||||
{
|
||||
|
|
|
@ -123,12 +123,7 @@ bool ext2::Copy( const Glib::ustring & src_part_path,
|
|||
|
||||
bool ext2::Check_Repair( const Partition & partition, std::vector<OperationDetails> & operation_details )
|
||||
{
|
||||
operation_details .push_back( OperationDetails(
|
||||
String::ucompose( _("check filesystem on %1 for errors and (if possible) fix them"),
|
||||
partition .get_path() ) ) ) ;
|
||||
|
||||
exit_status = execute_command( "e2fsck -f -y -v " + partition .get_path(),
|
||||
operation_details .back() .sub_details ) ;
|
||||
exit_status = execute_command( "e2fsck -f -y -v " + partition .get_path(), operation_details ) ;
|
||||
|
||||
//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...
|
||||
|
|
|
@ -118,12 +118,7 @@ bool ext3::Copy( const Glib::ustring & src_part_path,
|
|||
|
||||
bool ext3::Check_Repair( const Partition & partition, std::vector<OperationDetails> & operation_details )
|
||||
{
|
||||
operation_details .push_back( OperationDetails(
|
||||
String::ucompose( _("check filesystem on %1 for errors and (if possible) fix them"),
|
||||
partition .get_path() ) ) ) ;
|
||||
|
||||
exit_status = execute_command( "e2fsck -f -y -v " + partition .get_path(),
|
||||
operation_details .back() .sub_details ) ;
|
||||
exit_status = execute_command( "e2fsck -f -y -v " + partition .get_path(), operation_details ) ;
|
||||
|
||||
//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...
|
||||
|
|
|
@ -103,12 +103,7 @@ bool fat16::Copy( const Glib::ustring & src_part_path,
|
|||
|
||||
bool fat16::Check_Repair( const Partition & partition, std::vector<OperationDetails> & operation_details )
|
||||
{
|
||||
operation_details .push_back( OperationDetails(
|
||||
String::ucompose( _("check filesystem on %1 for errors and (if possible) fix them"),
|
||||
partition .get_path() ) ) ) ;
|
||||
|
||||
exit_status = execute_command( "dosfsck -a -w -v " + partition .get_path(),
|
||||
operation_details .back() .sub_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 ;
|
||||
|
|
|
@ -104,12 +104,7 @@ bool fat32::Copy( const Glib::ustring & src_part_path,
|
|||
|
||||
bool fat32::Check_Repair( const Partition & partition, std::vector<OperationDetails> & operation_details )
|
||||
{
|
||||
operation_details .push_back( OperationDetails(
|
||||
String::ucompose( _("check filesystem on %1 for errors and (if possible) fix them"),
|
||||
partition .get_path() ) ) ) ;
|
||||
|
||||
exit_status = execute_command( "dosfsck -a -w -v " + partition .get_path(),
|
||||
operation_details .back() .sub_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 ;
|
||||
|
|
|
@ -204,11 +204,7 @@ bool jfs::Copy( const Glib::ustring & src_part_path,
|
|||
|
||||
bool jfs::Check_Repair( const Partition & partition, std::vector<OperationDetails> & operation_details )
|
||||
{
|
||||
operation_details .push_back( OperationDetails(
|
||||
String::ucompose( _("check filesystem on %1 for errors and (if possible) fix them"),
|
||||
partition .get_path() ) ) ) ;
|
||||
|
||||
exit_status = execute_command( "jfs_fsck -f " + partition .get_path(), operation_details .back() .sub_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 ;
|
||||
|
|
|
@ -149,12 +149,7 @@ bool ntfs::Copy( const Glib::ustring & src_part_path,
|
|||
|
||||
bool ntfs::Check_Repair( const Partition & partition, std::vector<OperationDetails> & operation_details )
|
||||
{
|
||||
operation_details .push_back( OperationDetails(
|
||||
String::ucompose( _("check filesystem on %1 for errors and (if possible) fix them"),
|
||||
partition .get_path() ) ) ) ;
|
||||
|
||||
if ( ! execute_command( "ntfsresize -P -i -f -v " + partition .get_path(),
|
||||
operation_details .back() .sub_details ) )
|
||||
if ( ! execute_command( "ntfsresize -P -i -f -v " + partition .get_path(), operation_details ) )
|
||||
{
|
||||
operation_details .back() .status = OperationDetails::SUCCES ;
|
||||
return true ;
|
||||
|
|
|
@ -96,12 +96,7 @@ bool reiser4::Copy( const Glib::ustring & src_part_path,
|
|||
|
||||
bool reiser4::Check_Repair( const Partition & partition, std::vector<OperationDetails> & operation_details )
|
||||
{
|
||||
operation_details .push_back( OperationDetails(
|
||||
String::ucompose( _("check filesystem on %1 for errors and (if possible) fix them"),
|
||||
partition .get_path() ) ) ) ;
|
||||
|
||||
if ( ! execute_command( "fsck.reiser4 --yes --fix " + partition .get_path(),
|
||||
operation_details .back() .sub_details ) )
|
||||
if ( ! execute_command( "fsck.reiser4 --yes --fix " + partition .get_path(), operation_details ) )
|
||||
{
|
||||
operation_details .back() .status = OperationDetails::SUCCES ;
|
||||
return true ;
|
||||
|
|
|
@ -125,12 +125,7 @@ bool reiserfs::Copy( const Glib::ustring & src_part_path,
|
|||
|
||||
bool reiserfs::Check_Repair( const Partition & partition, std::vector<OperationDetails> & operation_details )
|
||||
{
|
||||
operation_details .push_back( OperationDetails(
|
||||
String::ucompose( _("check filesystem on %1 for errors and (if possible) fix them"),
|
||||
partition .get_path() ) ) ) ;
|
||||
|
||||
exit_status = execute_command( "reiserfsck --y --fix-fixable " + partition .get_path(),
|
||||
operation_details .back() .sub_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 ;
|
||||
|
|
|
@ -348,11 +348,7 @@ bool xfs::Copy( const Glib::ustring & src_part_path,
|
|||
|
||||
bool xfs::Check_Repair( const Partition & partition, std::vector<OperationDetails> & operation_details )
|
||||
{
|
||||
operation_details .push_back( OperationDetails(
|
||||
String::ucompose( _("check filesystem on %1 for errors and (if possible) fix them"),
|
||||
partition .get_path() ) ) ) ;
|
||||
|
||||
if ( ! execute_command( "xfs_repair -v " + partition .get_path(), operation_details .back() .sub_details ) )
|
||||
if ( ! execute_command( "xfs_repair -v " + partition .get_path(), operation_details ) )
|
||||
{
|
||||
operation_details .back() .status = OperationDetails::SUCCES ;
|
||||
return true ;
|
||||
|
|
Loading…
Reference in New Issue