diff --git a/ChangeLog b/ChangeLog index 021c985f..dc18519f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2006-01-21 Bart Hakvoort + + * src/main.cc: cleanups + * src/ntfs.cc: use ntfsfix for scanning. + run a simulation before performing an actual resize. more detailed + feedback. + 2006-01-20 Bart Hakvoort * src/xfs.cc: updated copy to provide detailed feedback. diff --git a/src/main.cc b/src/main.cc index d3d6732e..5b31bad5 100644 --- a/src/main.cc +++ b/src/main.cc @@ -19,30 +19,32 @@ #include -int main( int argc, char *argv[ ] ) +int main( int argc, char *argv[] ) { //initialize thread system - Glib::thread_init( ); + Glib::thread_init() ; - Gtk::Main kit( argc, argv ); + Gtk::Main kit( argc, argv ) ; //i18n - bindtextdomain( GETTEXT_PACKAGE, GNOMELOCALEDIR ); - bind_textdomain_codeset( GETTEXT_PACKAGE, "UTF-8" ); - textdomain( GETTEXT_PACKAGE ); + bindtextdomain( GETTEXT_PACKAGE, GNOMELOCALEDIR ) ; + bind_textdomain_codeset( GETTEXT_PACKAGE, "UTF-8" ) ; + textdomain( GETTEXT_PACKAGE ) ; //check UID - if ( getuid( ) != 0 ) + if ( getuid() != 0 ) { - Gtk::MessageDialog dialog( "" + (Glib::ustring) _( "Root privileges are required for running GParted" ) + "\n\n" + (Glib::ustring) _( "Since GParted can be a weapon of mass destruction only root may run it.") ,true, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true); - dialog .run( ) ; - exit( 0 ); + Gtk::MessageDialog dialog( _("Root privileges are required for running GParted"), false, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK ) ; + dialog .set_secondary_text( _( "Since GParted can be a weapon of mass destruction only root may run it.") ) ; + + dialog .run() ; + exit( 0 ) ; } - GParted::Win_GParted win_gparted; - Gtk::Main::run( win_gparted ); + GParted::Win_GParted win_gparted ; + Gtk::Main::run( win_gparted ) ; - return 0; + return 0 ; } diff --git a/src/ntfs.cc b/src/ntfs.cc index d3c63f12..9031e60a 100644 --- a/src/ntfs.cc +++ b/src/ntfs.cc @@ -102,29 +102,52 @@ bool ntfs::Create( const Partition & new_partition, std::vector & operation_details, bool fill_partition ) -{//FIXME probeer dmv piping y the echoen in ntfsresize - //-contact szaka en probeer een --yes oid in de API te krijgen - //-perform eerst testruns e.d. in ntfsresize te bouwen.. +{ if ( fill_partition ) operation_details .push_back( OperationDetails( _("grow filesystem to fill the partition") ) ) ; else operation_details .push_back( OperationDetails( _("resize the filesystem") ) ) ; - Glib::ustring str_temp = "echo y | ntfsresize -f " + partition_new .partition ; + bool return_value = false ; + Glib::ustring str_temp = "echo y | ntfsresize -P --force " + partition_new .partition ; if ( ! fill_partition ) - str_temp += " -s " + Utils::num_to_str( partition_new .Get_Length_MB( ) - cylinder_size, true ) + "M" ; + str_temp += " -s " + Utils::num_to_str( partition_new .Get_Length_MB() - cylinder_size, true ) + "M" ; - if ( ! Execute_Command( str_temp ) ) + //simulation.. + operation_details .back() .sub_details .push_back( OperationDetails( _("run simulation") ) ) ; + + argv .clear() ; + argv .push_back( "sh" ) ; + argv .push_back( "-c" ) ; + argv .push_back( str_temp + " --no-action" ) ; + if ( ! execute_command( argv, operation_details .back() .sub_details .back() .sub_details ) ) { - operation_details .back() .status = OperationDetails::SUCCES ; - return true ; + operation_details .back() .sub_details .back() .status = OperationDetails::SUCCES ; + + //real resize (use description from 'main' operation) + operation_details .back() .sub_details .push_back( + OperationDetails( operation_details .back() .description ) ) ; + + argv .erase( argv .end() ) ; + argv .push_back( str_temp ) ; + if ( ! execute_command( argv, operation_details .back() .sub_details .back() .sub_details ) ) + { + operation_details .back() .sub_details .back() .status = OperationDetails::SUCCES ; + return_value = true ; + } + else + { + operation_details .back() .sub_details .back() .status = OperationDetails::ERROR ; + } } else { - operation_details .back() .status = OperationDetails::ERROR ; - return false ; + operation_details .back() .sub_details .back() .status = OperationDetails::ERROR ; } + + operation_details .back() .status = return_value ? OperationDetails::SUCCES : OperationDetails::ERROR ; + return return_value ; } bool ntfs::Copy( const Glib::ustring & src_part_path, @@ -140,7 +163,6 @@ bool ntfs::Copy( const Glib::ustring & src_part_path, argv .push_back( "--overwrite" ) ; argv .push_back( dest_part_path ) ; argv .push_back( src_part_path ) ; - if ( ! execute_command( argv, operation_details .back() .sub_details ) ) { operation_details .back() .status = OperationDetails::SUCCES ; @@ -156,11 +178,12 @@ bool ntfs::Copy( const Glib::ustring & src_part_path, bool ntfs::Check_Repair( const Partition & partition, std::vector & operation_details ) { - //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 :) operation_details .push_back( OperationDetails( _("check filesystem for errors and (if possible) fix them") ) ) ; -//FIXME.. ook hier kan eea verbeterd/verduidelijkt.. - if ( Resize( partition, operation_details .back() .sub_details, true ) ) + + argv .clear() ; + argv .push_back( "ntfsfix" ) ; + argv .push_back( partition .partition ) ; + if ( ! execute_command( argv, operation_details .back() .sub_details ) ) { operation_details .back() .status = OperationDetails::SUCCES ; return true ;