Execute_Command() now returns exit status of executed command returnvalue

* include/FileSystem.h,
  src/FileSystem.cc: Execute_Command() now returns exit status of executed command
* the filesystemclasses: returnvalue (bool) is now set according to the return status of the command
This commit is contained in:
Bart Hakvoort 2004-11-30 21:05:48 +00:00
parent 4fef62dea1
commit f0eb17b8db
10 changed files with 41 additions and 30 deletions

View File

@ -1,3 +1,9 @@
2004-11-30 Bart Hakvoort <gparted@users.sf.net>
* include/FileSystem.h,
src/FileSystem.cc: Execute_Command() now returns exit status of executed command
* the filesystemclasses: returnvalue (bool) is now set according to the return status of the command
2004-11-29 Bart Hakvoort <gparted@users.sf.net> 2004-11-29 Bart Hakvoort <gparted@users.sf.net>
* src/GParted_Core.cc: It seemed some kernels remove and re-add blockdevicepaths after the commit_to_os. This caused trouble at some points * src/GParted_Core.cc: It seemed some kernels remove and re-add blockdevicepaths after the commit_to_os. This caused trouble at some points

View File

@ -95,7 +95,7 @@ public:
long cylinder_size ; //see GParted_Core::Resize() long cylinder_size ; //see GParted_Core::Resize()
protected: protected:
bool Execute_Command( Glib::ustring command ) ; int Execute_Command( Glib::ustring command ) ;
PedDevice *device ; PedDevice *device ;

View File

@ -27,7 +27,7 @@ FileSystem::FileSystem( )
cylinder_size = 0 ; cylinder_size = 0 ;
} }
bool FileSystem::Execute_Command( Glib::ustring command ) int FileSystem::Execute_Command( Glib::ustring command )
{ {
Glib::Dispatcher dispatcher; Glib::Dispatcher dispatcher;
sigc::connection conn = dispatcher .connect( sigc::mem_fun(*this, &FileSystem::Update_Textview) ); sigc::connection conn = dispatcher .connect( sigc::mem_fun(*this, &FileSystem::Update_Textview) );
@ -48,13 +48,10 @@ bool FileSystem::Execute_Command( Glib::ustring command )
//dispatcher ( ) ;disabled for the moment. Hier moet ik nog eens fris naar kijken. (anjuta had zo'n ingebouwde terminal, hoe deed die dat?? !!! //dispatcher ( ) ;disabled for the moment. Hier moet ik nog eens fris naar kijken. (anjuta had zo'n ingebouwde terminal, hoe deed die dat?? !!!
} }
pclose( f ) ;
output = "" ; output = "" ;
dispatcher ( ) ; dispatcher( ) ;
return pclose( f ) ;
return true ;
} }
void FileSystem::Update_Textview( ) void FileSystem::Update_Textview( )

View File

@ -76,7 +76,7 @@ void ext2::Set_Used_Sectors( Partition & partition )
bool ext2::Create( const Glib::ustring device_path, const Partition & new_partition ) bool ext2::Create( const Glib::ustring device_path, const Partition & new_partition )
{ {
return Execute_Command( "mkfs.ext2 " + new_partition .partition ) ; return ! Execute_Command( "mkfs.ext2 " + new_partition .partition ) ;
} }
bool ext2::Resize( const Partition & partition_new, bool fill_partition ) bool ext2::Resize( const Partition & partition_new, bool fill_partition )
@ -86,17 +86,17 @@ bool ext2::Resize( const Partition & partition_new, bool fill_partition )
if ( ! fill_partition ) if ( ! fill_partition )
str_temp += " " + num_to_str( partition_new .Get_Length_MB( ) - cylinder_size ) + "M" ; str_temp += " " + num_to_str( partition_new .Get_Length_MB( ) - cylinder_size ) + "M" ;
return Execute_Command( str_temp ) ; return ! Execute_Command( str_temp ) ;
} }
bool ext2::Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest_part_path ) bool ext2::Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest_part_path )
{ {
return Execute_Command( "dd bs=8192 if=" + src_part_path + " of=" + dest_part_path ) ; return ! Execute_Command( "dd bs=8192 if=" + src_part_path + " of=" + dest_part_path ) ;
} }
bool ext2::Check_Repair( const Partition & partition ) bool ext2::Check_Repair( const Partition & partition )
{ {
return Execute_Command( "e2fsck -fy " + partition .partition ) ; return Execute_Command( "e2fsck -fy " + partition .partition ) <= 1 ;
} }
int ext2::get_estimated_time( long MB_to_Consider ) int ext2::get_estimated_time( long MB_to_Consider )

View File

@ -76,7 +76,7 @@ void ext3::Set_Used_Sectors( Partition & partition )
bool ext3::Create( const Glib::ustring device_path, const Partition & new_partition ) bool ext3::Create( const Glib::ustring device_path, const Partition & new_partition )
{ {
return Execute_Command( "mkfs.ext3 " + new_partition .partition ) ; return ! Execute_Command( "mkfs.ext3 " + new_partition .partition ) ;
} }
bool ext3::Resize( const Partition & partition_new, bool fill_partition ) bool ext3::Resize( const Partition & partition_new, bool fill_partition )
@ -86,17 +86,17 @@ bool ext3::Resize( const Partition & partition_new, bool fill_partition )
if ( ! fill_partition ) if ( ! fill_partition )
str_temp += " " + num_to_str( partition_new .Get_Length_MB( ) - cylinder_size ) + "M" ; str_temp += " " + num_to_str( partition_new .Get_Length_MB( ) - cylinder_size ) + "M" ;
return Execute_Command( str_temp ) ; return ! Execute_Command( str_temp ) ;
} }
bool ext3::Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest_part_path ) bool ext3::Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest_part_path )
{ {
return Execute_Command( "dd bs=8192 if=" + src_part_path + " of=" + dest_part_path ) ; return ! Execute_Command( "dd bs=8192 if=" + src_part_path + " of=" + dest_part_path ) ;
} }
bool ext3::Check_Repair( const Partition & partition ) bool ext3::Check_Repair( const Partition & partition )
{ {
return Execute_Command( "e2fsck -fy " + partition .partition ) ; return Execute_Command( "e2fsck -fy " + partition .partition ) <= 1 ;
} }
int ext3::get_estimated_time( long MB_to_Consider ) int ext3::get_estimated_time( long MB_to_Consider )

View File

@ -107,7 +107,7 @@ bool fat16::Resize( const Partition & partition_new, bool fill_partition )
bool fat16::Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest_part_path ) bool fat16::Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest_part_path )
{ {
return Execute_Command( "dd bs=8192 if=" + src_part_path + " of=" + dest_part_path ) ; return ! Execute_Command( "dd bs=8192 if=" + src_part_path + " of=" + dest_part_path ) ;
} }
bool fat16::Check_Repair( const Partition & partition ) bool fat16::Check_Repair( const Partition & partition )

View File

@ -73,7 +73,7 @@ void fat32::Set_Used_Sectors( Partition & partition )
bool fat32::Create( const Glib::ustring device_path, const Partition & new_partition ) bool fat32::Create( const Glib::ustring device_path, const Partition & new_partition )
{ {
return Execute_Command( "mkdosfs -F32 " + new_partition .partition ) ; return ! Execute_Command( "mkdosfs -F32 " + new_partition .partition ) ;
} }
bool fat32::Resize( const Partition & partition_new, bool fill_partition ) bool fat32::Resize( const Partition & partition_new, bool fill_partition )
@ -84,7 +84,7 @@ bool fat32::Resize( const Partition & partition_new, bool fill_partition )
bool fat32::Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest_part_path ) bool fat32::Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest_part_path )
{ {
return Execute_Command( "dd bs=8192 if=" + src_part_path + " of=" + dest_part_path ) ; return ! Execute_Command( "dd bs=8192 if=" + src_part_path + " of=" + dest_part_path ) ;
} }
bool fat32::Check_Repair( const Partition & partition ) bool fat32::Check_Repair( const Partition & partition )

View File

@ -82,7 +82,7 @@ bool linux_swap::Resize( const Partition & partition_new, bool fill_partition )
bool linux_swap::Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest_part_path ) bool linux_swap::Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest_part_path )
{ {
return Execute_Command( "dd bs=8192 if=" + src_part_path + " of=" + dest_part_path ) ; return ! Execute_Command( "dd bs=8192 if=" + src_part_path + " of=" + dest_part_path ) ;
} }
bool linux_swap::Check_Repair( const Partition & partition ) bool linux_swap::Check_Repair( const Partition & partition )

View File

@ -72,7 +72,7 @@ void ntfs::Set_Used_Sectors( Partition & partition )
bool ntfs::Create( const Glib::ustring device_path, const Partition & new_partition ) bool ntfs::Create( const Glib::ustring device_path, const Partition & new_partition )
{ {
return Execute_Command( "mkntfs -Q " + new_partition .partition ) ; return ! Execute_Command( "mkntfs -Q " + new_partition .partition ) ;
} }
bool ntfs::Resize( const Partition & partition_new, bool fill_partition ) bool ntfs::Resize( const Partition & partition_new, bool fill_partition )
@ -82,22 +82,24 @@ bool ntfs::Resize( const Partition & partition_new, bool fill_partition )
if ( ! fill_partition ) if ( ! fill_partition )
str_temp += " -s " + num_to_str( partition_new .Get_Length_MB( ) - cylinder_size ) + "M" ; str_temp += " -s " + num_to_str( partition_new .Get_Length_MB( ) - cylinder_size ) + "M" ;
return Execute_Command( str_temp ) ; return ! Execute_Command( str_temp ) ;
} }
bool ntfs::Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest_part_path ) bool ntfs::Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest_part_path )
{ {
Execute_Command( "ntfsclone -f --overwrite " + dest_part_path + " " + src_part_path ) ; bool ret_val = ! Execute_Command( "ntfsclone -f --overwrite " + dest_part_path + " " + src_part_path ) ;
//resize to full to set correct used/unused //resize to full to set correct used/unused
return Execute_Command( "echo y | ntfsresize -f " + dest_part_path ) ; Execute_Command( "echo y | ntfsresize -f " + dest_part_path ) ;
return ret_val ;
} }
bool ntfs::Check_Repair( const Partition & partition ) bool ntfs::Check_Repair( const Partition & partition )
{ {
//according to Szaka it's best to use ntfsresize to check the partition for errors //according to Szaka it's best to use ntfsresize to check the partition for errors
//since --info is read-only i'll leave it out. just calling ntfsresize --force has also a tendency of fixing stuff :) //since --info is read-only i'll leave it out. just calling ntfsresize --force has also a tendency of fixing stuff :)
return Execute_Command( "echo y | ntfsresize -f " + partition .partition ) ; return ! Execute_Command( "echo y | ntfsresize -f " + partition .partition ) ;
} }
int ntfs::get_estimated_time( long MB_to_Consider ) int ntfs::get_estimated_time( long MB_to_Consider )

View File

@ -77,7 +77,7 @@ void reiserfs::Set_Used_Sectors( Partition & partition )
bool reiserfs::Create( const Glib::ustring device_path, const Partition & new_partition ) bool reiserfs::Create( const Glib::ustring device_path, const Partition & new_partition )
{ {
return Execute_Command( "mkreiserfs -q " + new_partition .partition ) ; return ! Execute_Command( "mkreiserfs -q " + new_partition .partition ) ;
} }
bool reiserfs::Resize( const Partition & partition_new, bool fill_partition ) bool reiserfs::Resize( const Partition & partition_new, bool fill_partition )
@ -87,21 +87,27 @@ bool reiserfs::Resize( const Partition & partition_new, bool fill_partition )
if ( ! fill_partition ) if ( ! fill_partition )
str_temp += " -s " + num_to_str( partition_new .Get_Length_MB( ) - cylinder_size ) + "M" ; str_temp += " -s " + num_to_str( partition_new .Get_Length_MB( ) - cylinder_size ) + "M" ;
return Execute_Command( str_temp ) ; return ! Execute_Command( str_temp ) ;
} }
bool reiserfs::Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest_part_path ) bool reiserfs::Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest_part_path )
{ {
//copy partition //copy partition
Execute_Command( "dd bs=8192 if=" + src_part_path + " of=" + dest_part_path ) ; bool ret_val = ! Execute_Command( "dd bs=8192 if=" + src_part_path + " of=" + dest_part_path ) ;
//and set proper used/unused //and set proper used/unused
return Execute_Command( "resize_reiserfs " + dest_part_path ) ; Execute_Command( "resize_reiserfs " + dest_part_path ) ;
return ret_val ;
} }
bool reiserfs::Check_Repair( const Partition & partition ) bool reiserfs::Check_Repair( const Partition & partition )
{ {
return Execute_Command( "reiserfsck -y --fix-fixable " + partition .partition ) ; //according to the manpage it should return 0 or 1 on succes, instead it returns 256 on succes..
//blah, don't have time for this. Just check for both options, we'll fix this in 0.0.8 with our much improved errorhandling
int t = Execute_Command( "reiserfsck -y --fix-fixable " + partition .partition ) ;
return ( t <=1 || t == 256 ) ;
} }
int reiserfs::get_estimated_time( long MB_to_Consider ) int reiserfs::get_estimated_time( long MB_to_Consider )