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:
Bart Hakvoort 2006-06-17 09:55:32 +00:00
parent 3094aeaabe
commit 20d5650188
12 changed files with 62 additions and 79 deletions

View File

@ -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()

View File

@ -92,7 +92,7 @@ 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,
bool resize_partition( const Partition & partition_old,
Partition & partition_new,
bool fixed_start,
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 ) ;

View File

@ -847,7 +847,7 @@ 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,
succes = resize_partition( partition_old,
partition_new,
false,
operation_details,
@ -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 )
@ -944,6 +943,8 @@ 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 )
{
case GParted::FS::GPARTED :
@ -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,7 +1266,7 @@ bool GParted_Core::create_filesystem( const Partition & partition, std::vector<O
}
}
bool GParted_Core::resize_container_partition( const Partition & partition_old,
bool GParted_Core::resize_partition( const Partition & partition_old,
Partition & partition_new,
bool fixed_start,
std::vector<OperationDetails> & operation_details,
@ -1556,6 +1557,26 @@ bool GParted_Core::copy_filesystem( const Partition & partition_src,
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 )
{
for ( unsigned int t = 0 ; t < flags .size() ; t++ )

View File

@ -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...

View File

@ -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...

View File

@ -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 ;

View File

@ -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 ;

View File

@ -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 ;

View File

@ -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 ;

View File

@ -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 ;

View File

@ -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 ;

View File

@ -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 ;