improved errorhandling in Set_Used_Sectors() in the filesystemclasses
* improved errorhandling in Set_Used_Sectors() in the filesystemclasses
This commit is contained in:
parent
391ca32a2b
commit
29a7744fe2
|
@ -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>
|
2006-02-25 Bart Hakvoort <hakvoort@cvs.gnome.org>
|
||||||
|
|
||||||
* in some places i still used MiB's instead of sectors to store sizes.
|
* in some places i still used MiB's instead of sectors to store sizes.
|
||||||
|
|
|
@ -52,6 +52,7 @@ protected:
|
||||||
//those are used in several places..
|
//those are used in several places..
|
||||||
Glib::ustring output, error ;
|
Glib::ustring output, error ;
|
||||||
Sector N, S ;
|
Sector N, S ;
|
||||||
|
int exit_status ;
|
||||||
unsigned int index ;
|
unsigned int index ;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -420,9 +420,11 @@ void GParted_Core::set_used_sectors( std::vector<Partition> & partitions )
|
||||||
|
|
||||||
for ( unsigned int t = 0 ; t < partitions .size() ; t++ )
|
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 )
|
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 ;
|
partitions[ t ] .error = temp ;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
namespace GParted
|
namespace GParted
|
||||||
{
|
{
|
||||||
|
|
||||||
FS ext2::get_filesystem_support( )
|
FS ext2::get_filesystem_support()
|
||||||
{
|
{
|
||||||
FS fs ;
|
FS fs ;
|
||||||
fs .filesystem = GParted::FS_EXT2 ;
|
fs .filesystem = GParted::FS_EXT2 ;
|
||||||
|
@ -66,6 +66,8 @@ void ext2::Set_Used_Sectors( Partition & partition )
|
||||||
if ( N > -1 && S > -1 )
|
if ( N > -1 && S > -1 )
|
||||||
partition .Set_Unused( Utils::Round( N * ( S / 512.0 ) ) ) ;
|
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 )
|
bool ext2::Create( const Partition & new_partition, std::vector<OperationDetails> & operation_details )
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
namespace GParted
|
namespace GParted
|
||||||
{
|
{
|
||||||
|
|
||||||
FS ext3::get_filesystem_support( )
|
FS ext3::get_filesystem_support()
|
||||||
{
|
{
|
||||||
FS fs ;
|
FS fs ;
|
||||||
fs .filesystem = GParted::FS_EXT3 ;
|
fs .filesystem = GParted::FS_EXT3 ;
|
||||||
|
@ -67,6 +67,8 @@ void ext3::Set_Used_Sectors( Partition & partition )
|
||||||
if ( N > -1 && S > -1 )
|
if ( N > -1 && S > -1 )
|
||||||
partition .Set_Unused( Utils::Round( N * ( S / 512.0 ) ) ) ;
|
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 )
|
bool ext3::Create( const Partition & new_partition, std::vector<OperationDetails> & operation_details )
|
||||||
|
|
13
src/fat16.cc
13
src/fat16.cc
|
@ -52,7 +52,8 @@ FS fat16::get_filesystem_support()
|
||||||
|
|
||||||
void fat16::Set_Used_Sectors( Partition & partition )
|
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
|
//free clusters
|
||||||
index = output .find( ",", output .find( partition .partition ) + partition .partition .length() ) +1 ;
|
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 )
|
if ( N > -1 && S > -1 )
|
||||||
partition .Set_Unused( Utils::Round( N * ( S / 512.0 ) ) ) ;
|
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 )
|
bool fat16::Create( const Partition & new_partition, std::vector<OperationDetails> & operation_details )
|
||||||
|
@ -121,9 +123,10 @@ bool fat16::Copy( const Glib::ustring & src_part_path,
|
||||||
bool fat16::Check_Repair( const Partition & partition, std::vector<OperationDetails> & operation_details )
|
bool fat16::Check_Repair( const Partition & partition, std::vector<OperationDetails> & operation_details )
|
||||||
{
|
{
|
||||||
operation_details .push_back( OperationDetails( _("check filesystem for errors and (if possible) fix them") ) ) ;
|
operation_details .push_back( OperationDetails( _("check filesystem for errors and (if possible) fix them") ) ) ;
|
||||||
|
|
||||||
if ( 1 >= execute_command( "dosfsck -a -w -v " + partition .partition,
|
exit_status = execute_command( "dosfsck -a -w -v " + partition .partition,
|
||||||
operation_details .back() .sub_details ) >= 0 )
|
operation_details .back() .sub_details ) ;
|
||||||
|
if ( exit_status == 0 || exit_status == 1 )
|
||||||
{
|
{
|
||||||
operation_details .back() .status = OperationDetails::SUCCES ;
|
operation_details .back() .status = OperationDetails::SUCCES ;
|
||||||
return true ;
|
return true ;
|
||||||
|
|
10
src/fat32.cc
10
src/fat32.cc
|
@ -51,7 +51,8 @@ FS fat32::get_filesystem_support( )
|
||||||
|
|
||||||
void fat32::Set_Used_Sectors( Partition & partition )
|
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
|
//free clusters
|
||||||
index = output .find( ",", output .find( partition .partition ) + partition .partition .length() ) +1 ;
|
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 )
|
if ( N > -1 && S > -1 )
|
||||||
partition .Set_Unused( Utils::Round( N * ( S / 512.0 ) ) ) ;
|
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 )
|
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") ) ) ;
|
operation_details .push_back( OperationDetails( _("check filesystem for errors and (if possible) fix them") ) ) ;
|
||||||
|
|
||||||
if ( 1 >= execute_command( "dosfsck -a -w -v " + partition .partition,
|
exit_status = execute_command( "dosfsck -a -w -v " + partition .partition,
|
||||||
operation_details .back() .sub_details ) >= 0 )
|
operation_details .back() .sub_details ) ;
|
||||||
|
if ( exit_status == 0 || exit_status == 1 )
|
||||||
{
|
{
|
||||||
operation_details .back() .status = OperationDetails::SUCCES ;
|
operation_details .back() .status = OperationDetails::SUCCES ;
|
||||||
return true ;
|
return true ;
|
||||||
|
|
|
@ -85,6 +85,8 @@ void jfs::Set_Used_Sectors( Partition & partition )
|
||||||
if ( S > -1 && N > -1 )
|
if ( S > -1 && N > -1 )
|
||||||
partition .Set_Unused( Utils::Round( N * ( S / 512.0 ) ) ) ;
|
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 )
|
bool jfs::Create( const Partition & new_partition, std::vector<OperationDetails> & operation_details )
|
||||||
|
@ -221,8 +223,9 @@ bool jfs::Copy( const Glib::ustring & src_part_path,
|
||||||
bool jfs::Check_Repair( const Partition & partition, std::vector<OperationDetails> & operation_details )
|
bool jfs::Check_Repair( const Partition & partition, std::vector<OperationDetails> & operation_details )
|
||||||
{
|
{
|
||||||
operation_details .push_back( OperationDetails( _("check filesystem for errors and (if possible) fix them") ) ) ;
|
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 ;
|
operation_details .back() .status = OperationDetails::SUCCES ;
|
||||||
return true ;
|
return true ;
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
namespace GParted
|
namespace GParted
|
||||||
{
|
{
|
||||||
|
|
||||||
FS ntfs::get_filesystem_support( )
|
FS ntfs::get_filesystem_support()
|
||||||
{
|
{
|
||||||
FS fs ;
|
FS fs ;
|
||||||
fs .filesystem = GParted::FS_NTFS ;
|
fs .filesystem = GParted::FS_NTFS ;
|
||||||
|
@ -63,6 +63,8 @@ void ntfs::Set_Used_Sectors( Partition & partition )
|
||||||
if ( N > -1 )
|
if ( N > -1 )
|
||||||
partition .Set_Unused( N ) ;
|
partition .Set_Unused( N ) ;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
partition .error = error ;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ntfs::Create( const Partition & new_partition, std::vector<OperationDetails> & operation_details )
|
bool ntfs::Create( const Partition & new_partition, std::vector<OperationDetails> & operation_details )
|
||||||
|
|
|
@ -60,6 +60,8 @@ void reiser4::Set_Used_Sectors( Partition & partition )
|
||||||
if ( N > -1 && S > -1 )
|
if ( N > -1 && S > -1 )
|
||||||
partition .Set_Unused( Utils::Round( N * ( S / 512.0 ) ) ) ;
|
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 )
|
bool reiser4::Create( const Partition & new_partition, std::vector<OperationDetails> & operation_details )
|
||||||
|
|
|
@ -70,6 +70,8 @@ void reiserfs::Set_Used_Sectors( Partition & partition )
|
||||||
if ( N > -1 && S > -1 )
|
if ( N > -1 && S > -1 )
|
||||||
partition .Set_Unused( Utils::Round( N * ( S / 512.0 ) ) ) ;
|
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 )
|
bool reiserfs::Create( const Partition & new_partition, std::vector<OperationDetails> & operation_details )
|
||||||
|
@ -145,8 +147,8 @@ bool reiserfs::Check_Repair( const Partition & partition, std::vector<OperationD
|
||||||
{
|
{
|
||||||
operation_details .push_back( OperationDetails( _("check filesystem for errors and (if possible) fix them") ) ) ;
|
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 ) ;
|
operation_details .back() .sub_details ) ;
|
||||||
if ( exit_status == 0 || exit_status == 1 || exit_status == 256 )
|
if ( exit_status == 0 || exit_status == 1 || exit_status == 256 )
|
||||||
{
|
{
|
||||||
operation_details .back() .status = OperationDetails::SUCCES ;
|
operation_details .back() .status = OperationDetails::SUCCES ;
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
namespace GParted
|
namespace GParted
|
||||||
{
|
{
|
||||||
|
|
||||||
FS xfs::get_filesystem_support( )
|
FS xfs::get_filesystem_support()
|
||||||
{
|
{
|
||||||
FS fs ;
|
FS fs ;
|
||||||
fs .filesystem = GParted::FS_XFS ;
|
fs .filesystem = GParted::FS_XFS ;
|
||||||
|
@ -87,6 +87,8 @@ void xfs::Set_Used_Sectors( Partition & partition )
|
||||||
if ( N > -1 && S > -1 )
|
if ( N > -1 && S > -1 )
|
||||||
partition .Set_Unused( Utils::Round( N * ( S / 512.0 ) ) ) ;
|
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 )
|
bool xfs::Create( const Partition & new_partition, std::vector<OperationDetails> & operation_details )
|
||||||
|
|
Loading…
Reference in New Issue