improved errorhandling in Set_Used_Sectors() in the filesystemclasses

* improved errorhandling in Set_Used_Sectors() in the filesystemclasses
This commit is contained in:
Bart Hakvoort 2006-02-25 12:25:18 +00:00
parent 391ca32a2b
commit 29a7744fe2
12 changed files with 48 additions and 19 deletions

View File

@ -1,3 +1,7 @@
2006-02-25 Bart Hakvoort <hakvoort@cvs.gnome.org>
* improved errorhandling in Set_Used_Sectors() in the filesystemclasses
2006-02-25 Bart Hakvoort <hakvoort@cvs.gnome.org>
* in some places i still used MiB's instead of sectors to store sizes.

View File

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

View File

@ -420,9 +420,11 @@ void GParted_Core::set_used_sectors( std::vector<Partition> & 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<Partition> & partitions )
}
}
if ( partitions[ t ] .sectors_used == -1 )
if ( partitions[ t ] .sectors_used == -1 && partitions[ t ] .error .empty() )
partitions[ t ] .error = temp ;
}

View File

@ -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<OperationDetails> & operation_details )

View File

@ -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<OperationDetails> & operation_details )

View File

@ -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<OperationDetails> & operation_details )
@ -122,8 +124,9 @@ bool fat16::Check_Repair( const Partition & partition, std::vector<OperationDeta
{
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 ;

View File

@ -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<OperationDetails> & operation_details )
@ -120,8 +123,9 @@ bool fat32::Check_Repair( const Partition & partition, std::vector<OperationDeta
{
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 ;

View File

@ -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<OperationDetails> & operation_details )
@ -222,7 +224,8 @@ bool jfs::Check_Repair( const Partition & partition, std::vector<OperationDetail
{
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 ;

View File

@ -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<OperationDetails> & operation_details )

View File

@ -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<OperationDetails> & operation_details )

View File

@ -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<OperationDetails> & operation_details )
@ -145,7 +147,7 @@ bool reiserfs::Check_Repair( const Partition & partition, std::vector<OperationD
{
operation_details .push_back( OperationDetails( _("check filesystem for errors and (if possible) fix them") ) ) ;
int exit_status = execute_command( "reiserfsck --y --fix-fixable " + partition .partition,
exit_status = execute_command( "reiserfsck --y --fix-fixable " + partition .partition,
operation_details .back() .sub_details ) ;
if ( exit_status == 0 || exit_status == 1 || exit_status == 256 )
{

View File

@ -87,6 +87,8 @@ void xfs::Set_Used_Sectors( Partition & partition )
if ( N > -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<OperationDetails> & operation_details )