diff --git a/ChangeLog b/ChangeLog index 89a8e154..eac917a3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2006-02-25 Bart Hakvoort + + * improved errorhandling in Set_Used_Sectors() in the filesystemclasses + 2006-02-25 Bart Hakvoort * in some places i still used MiB's instead of sectors to store sizes. diff --git a/include/FileSystem.h b/include/FileSystem.h index 16fae2bd..684f9a74 100644 --- a/include/FileSystem.h +++ b/include/FileSystem.h @@ -52,6 +52,7 @@ protected: //those are used in several places.. Glib::ustring output, error ; Sector N, S ; + int exit_status ; unsigned int index ; private: diff --git a/src/GParted_Core.cc b/src/GParted_Core.cc index 82ce9fe5..fc787745 100644 --- a/src/GParted_Core.cc +++ b/src/GParted_Core.cc @@ -420,9 +420,11 @@ void GParted_Core::set_used_sectors( std::vector & partitions ) for ( unsigned int t = 0 ; t < partitions .size() ; t++ ) { - if ( partitions[ t ] .filesystem != GParted::FS_LINUX_SWAP && partitions[ t ] .filesystem != GParted::FS_UNKNOWN ) + if ( partitions[ t ] .filesystem != GParted::FS_LINUX_SWAP && + partitions[ t ] .filesystem != GParted::FS_UNKNOWN ) { - if ( partitions[ t ] .type == GParted::TYPE_PRIMARY || partitions[ t ] .type == GParted::TYPE_LOGICAL ) + if ( partitions[ t ] .type == GParted::TYPE_PRIMARY || + partitions[ t ] .type == GParted::TYPE_LOGICAL ) { if ( partitions[ t ] .busy ) { @@ -446,7 +448,7 @@ void GParted_Core::set_used_sectors( std::vector & partitions ) } } - if ( partitions[ t ] .sectors_used == -1 ) + if ( partitions[ t ] .sectors_used == -1 && partitions[ t ] .error .empty() ) partitions[ t ] .error = temp ; } diff --git a/src/ext2.cc b/src/ext2.cc index 1bfe6e0f..00346839 100644 --- a/src/ext2.cc +++ b/src/ext2.cc @@ -20,7 +20,7 @@ namespace GParted { -FS ext2::get_filesystem_support( ) +FS ext2::get_filesystem_support() { FS fs ; fs .filesystem = GParted::FS_EXT2 ; @@ -66,6 +66,8 @@ void ext2::Set_Used_Sectors( Partition & partition ) if ( N > -1 && S > -1 ) partition .Set_Unused( Utils::Round( N * ( S / 512.0 ) ) ) ; } + else + partition .error = error ; } bool ext2::Create( const Partition & new_partition, std::vector & operation_details ) diff --git a/src/ext3.cc b/src/ext3.cc index 2e3a5c68..af8f816b 100644 --- a/src/ext3.cc +++ b/src/ext3.cc @@ -21,7 +21,7 @@ namespace GParted { -FS ext3::get_filesystem_support( ) +FS ext3::get_filesystem_support() { FS fs ; fs .filesystem = GParted::FS_EXT3 ; @@ -67,6 +67,8 @@ void ext3::Set_Used_Sectors( Partition & partition ) if ( N > -1 && S > -1 ) partition .Set_Unused( Utils::Round( N * ( S / 512.0 ) ) ) ; } + else + partition .error = error ; } bool ext3::Create( const Partition & new_partition, std::vector & operation_details ) diff --git a/src/fat16.cc b/src/fat16.cc index 6d173d02..d9079b78 100644 --- a/src/fat16.cc +++ b/src/fat16.cc @@ -52,7 +52,8 @@ FS fat16::get_filesystem_support() void fat16::Set_Used_Sectors( Partition & partition ) { - if ( 1 >= Utils::execute_command( "dosfsck -a -v " + partition .partition, output, error, true ) >= 0 ) + exit_status = Utils::execute_command( "dosfsck -a -v " + partition .partition, output, error, true ) ; + if ( exit_status == 0 || exit_status == 1 ) { //free clusters index = output .find( ",", output .find( partition .partition ) + partition .partition .length() ) +1 ; @@ -69,7 +70,8 @@ void fat16::Set_Used_Sectors( Partition & partition ) if ( N > -1 && S > -1 ) partition .Set_Unused( Utils::Round( N * ( S / 512.0 ) ) ) ; } - //FIXME: all fs classes should send 'error' to stdout here. + else + partition .error = error ; } bool fat16::Create( const Partition & new_partition, std::vector & operation_details ) @@ -121,9 +123,10 @@ bool fat16::Copy( const Glib::ustring & src_part_path, bool fat16::Check_Repair( const Partition & partition, std::vector & operation_details ) { operation_details .push_back( OperationDetails( _("check filesystem for errors and (if possible) fix them") ) ) ; - - if ( 1 >= execute_command( "dosfsck -a -w -v " + partition .partition, - operation_details .back() .sub_details ) >= 0 ) + + exit_status = execute_command( "dosfsck -a -w -v " + partition .partition, + operation_details .back() .sub_details ) ; + if ( exit_status == 0 || exit_status == 1 ) { operation_details .back() .status = OperationDetails::SUCCES ; return true ; diff --git a/src/fat32.cc b/src/fat32.cc index cc17bc2d..bb543342 100644 --- a/src/fat32.cc +++ b/src/fat32.cc @@ -51,7 +51,8 @@ FS fat32::get_filesystem_support( ) void fat32::Set_Used_Sectors( Partition & partition ) { - if ( 1 >= Utils::execute_command( "dosfsck -a -v " + partition .partition, output, error, true ) >= 0 ) + exit_status = Utils::execute_command( "dosfsck -a -v " + partition .partition, output, error, true ) ; + if ( exit_status == 0 || exit_status == 1 ) { //free clusters index = output .find( ",", output .find( partition .partition ) + partition .partition .length() ) +1 ; @@ -68,6 +69,8 @@ void fat32::Set_Used_Sectors( Partition & partition ) if ( N > -1 && S > -1 ) partition .Set_Unused( Utils::Round( N * ( S / 512.0 ) ) ) ; } + else + partition .error = error ; } bool fat32::Create( const Partition & new_partition, std::vector & operation_details ) @@ -120,8 +123,9 @@ bool fat32::Check_Repair( const Partition & partition, std::vector= execute_command( "dosfsck -a -w -v " + partition .partition, - operation_details .back() .sub_details ) >= 0 ) + exit_status = execute_command( "dosfsck -a -w -v " + partition .partition, + operation_details .back() .sub_details ) ; + if ( exit_status == 0 || exit_status == 1 ) { operation_details .back() .status = OperationDetails::SUCCES ; return true ; diff --git a/src/jfs.cc b/src/jfs.cc index cd1e5ff2..8c16abf6 100644 --- a/src/jfs.cc +++ b/src/jfs.cc @@ -85,6 +85,8 @@ void jfs::Set_Used_Sectors( Partition & partition ) if ( S > -1 && N > -1 ) partition .Set_Unused( Utils::Round( N * ( S / 512.0 ) ) ) ; } + else + partition .error = error ; } bool jfs::Create( const Partition & new_partition, std::vector & operation_details ) @@ -221,8 +223,9 @@ bool jfs::Copy( const Glib::ustring & src_part_path, bool jfs::Check_Repair( const Partition & partition, std::vector & operation_details ) { operation_details .push_back( OperationDetails( _("check filesystem for errors and (if possible) fix them") ) ) ; - - if ( 1 >= execute_command( "jfs_fsck -f " + partition .partition, operation_details .back() .sub_details ) >= 0 ) + + exit_status = execute_command( "jfs_fsck -f " + partition .partition, operation_details .back() .sub_details ) ; + if ( exit_status == 0 || exit_status == 1 ) { operation_details .back() .status = OperationDetails::SUCCES ; return true ; diff --git a/src/ntfs.cc b/src/ntfs.cc index e94204db..40a506f3 100644 --- a/src/ntfs.cc +++ b/src/ntfs.cc @@ -21,7 +21,7 @@ namespace GParted { -FS ntfs::get_filesystem_support( ) +FS ntfs::get_filesystem_support() { FS fs ; fs .filesystem = GParted::FS_NTFS ; @@ -63,6 +63,8 @@ void ntfs::Set_Used_Sectors( Partition & partition ) if ( N > -1 ) partition .Set_Unused( N ) ; } + else + partition .error = error ; } bool ntfs::Create( const Partition & new_partition, std::vector & operation_details ) diff --git a/src/reiser4.cc b/src/reiser4.cc index 0fc5ea49..d14b40d5 100644 --- a/src/reiser4.cc +++ b/src/reiser4.cc @@ -60,6 +60,8 @@ void reiser4::Set_Used_Sectors( Partition & partition ) if ( N > -1 && S > -1 ) partition .Set_Unused( Utils::Round( N * ( S / 512.0 ) ) ) ; } + else + partition .error = error ; } bool reiser4::Create( const Partition & new_partition, std::vector & operation_details ) diff --git a/src/reiserfs.cc b/src/reiserfs.cc index 4bc3cd65..2d3dcdc1 100644 --- a/src/reiserfs.cc +++ b/src/reiserfs.cc @@ -70,6 +70,8 @@ void reiserfs::Set_Used_Sectors( Partition & partition ) if ( N > -1 && S > -1 ) partition .Set_Unused( Utils::Round( N * ( S / 512.0 ) ) ) ; } + else + partition .error = error ; } bool reiserfs::Create( const Partition & new_partition, std::vector & operation_details ) @@ -145,8 +147,8 @@ bool reiserfs::Check_Repair( const Partition & partition, std::vector -1 && S > -1 ) partition .Set_Unused( Utils::Round( N * ( S / 512.0 ) ) ) ; } + else + partition .error = error ; } bool xfs::Create( const Partition & new_partition, std::vector & operation_details )