diff --git a/ChangeLog b/ChangeLog index 554b26a6..f1eac865 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2006-04-03 Bart Hakvoort + + * include/Dialog_Filesystems.h, + src/Dialog_Filesystems.cc: added column 'check' + * include/GParted_Core.h, + src/GParted_Core.cc: use halproperty + 'storage.automount_enabled_hint' instead of pmount to disable + automounting. + 2006-04-02 Bart Hakvoort * include/GParted_Core.h, diff --git a/include/Dialog_Filesystems.h b/include/Dialog_Filesystems.h index 7327acb6..e9a97255 100644 --- a/include/Dialog_Filesystems.h +++ b/include/Dialog_Filesystems.h @@ -51,6 +51,7 @@ private: Gtk::TreeModelColumn< Glib::RefPtr > shrink ; Gtk::TreeModelColumn< Glib::RefPtr > move ; Gtk::TreeModelColumn< Glib::RefPtr > copy ; + Gtk::TreeModelColumn< Glib::RefPtr > check ; treeview_filesystems_Columns() { @@ -62,6 +63,7 @@ private: add( shrink ) ; add( move ) ; add( copy ) ; + add( check ) ; } }; diff --git a/include/GParted_Core.h b/include/GParted_Core.h index b35b6f95..7c92af25 100644 --- a/include/GParted_Core.h +++ b/include/GParted_Core.h @@ -66,7 +66,7 @@ private: GParted::FILESYSTEM get_filesystem() ; bool check_device_path( const Glib::ustring & device_path ) ; void set_device_partitions( Device & device ) ; - void disable_automount( const std::vector & partitions ) ; + void disable_automount( const Device & device ) ; void read_mountpoints_from_file( const Glib::ustring & filename, std::map< Glib::ustring, std::vector > & map ) ; void init_maps() ; @@ -94,7 +94,7 @@ private: void set_proper_filesystem( const FILESYSTEM & filesystem ) ; bool set_partition_type( const Partition & partition, std::vector & operation_details ) ; - bool wait_for_node( const Glib::ustring & node, bool disable_automount = false ) ; + bool wait_for_node( const Glib::ustring & node ) ; bool erase_filesystem_signatures( const Partition & partition ) ; bool open_device( const Glib::ustring & device_path ) ; @@ -119,8 +119,9 @@ private: std::map< Glib::ustring, Glib::ustring >::iterator iter ; std::map< Glib::ustring, std::vector >::iterator iter_mp ; - std::vector pmount_locked_partitions ; - Glib::ustring PID ; + //disabling automount stuff + bool DISABLE_AUTOMOUNT ; + std::map disabled_automount_devices ; PedDevice *lp_device ; PedDisk *lp_disk ; diff --git a/src/Dialog_Filesystems.cc b/src/Dialog_Filesystems.cc index 703ce864..40aaa44f 100644 --- a/src/Dialog_Filesystems.cc +++ b/src/Dialog_Filesystems.cc @@ -38,6 +38,7 @@ Dialog_Filesystems::Dialog_Filesystems() treeview_filesystems .append_column( _("Shrink"), treeview_filesystems_columns .shrink ); treeview_filesystems .append_column( _("Move"), treeview_filesystems_columns .move ); treeview_filesystems .append_column( _("Copy"), treeview_filesystems_columns .copy ); + treeview_filesystems .append_column( _("Check"), treeview_filesystems_columns .check ); treeview_filesystems .get_selection() ->set_mode( Gtk::SELECTION_NONE ); get_vbox() ->pack_start( treeview_filesystems ) ; @@ -46,7 +47,7 @@ Dialog_Filesystems::Dialog_Filesystems() icon_yes = render_icon( Gtk::Stock::APPLY, Gtk::ICON_SIZE_LARGE_TOOLBAR ) ; icon_no = render_icon( Gtk::Stock::CANCEL, Gtk::ICON_SIZE_LARGE_TOOLBAR ) ; - add_button( Gtk::Stock::REFRESH, Gtk::RESPONSE_OK ); + add_button( Gtk::Stock::REFRESH, Gtk::RESPONSE_OK ) ; add_button( Gtk::Stock::CLOSE, Gtk::RESPONSE_CLOSE ) ->grab_focus() ; show_all_children() ; } @@ -71,6 +72,7 @@ void Dialog_Filesystems::Show_Filesystem( const FS & fs ) treerow[ treeview_filesystems_columns .shrink ] = fs .shrink ? icon_yes : icon_no ; treerow[ treeview_filesystems_columns .move ] = fs .move ? icon_yes : icon_no ; treerow[ treeview_filesystems_columns .copy ] = fs .copy ? icon_yes : icon_no ; + treerow[ treeview_filesystems_columns .check ] = fs .check ? icon_yes : icon_no ; } Dialog_Filesystems::~Dialog_Filesystems() diff --git a/src/GParted_Core.cc b/src/GParted_Core.cc index 8bc74827..458cb598 100644 --- a/src/GParted_Core.cc +++ b/src/GParted_Core.cc @@ -51,8 +51,7 @@ GParted_Core::GParted_Core() lp_disk = NULL ; lp_partition = NULL ; p_filesystem = NULL ; - - PID = Utils::num_to_str( getpid() ) ; + DISABLE_AUTOMOUNT = false ; ped_exception_set_handler( ped_exception_handler ) ; @@ -65,6 +64,15 @@ GParted_Core::GParted_Core() //throw libpartedversion to the stdout to see which version is actually used. std::cout << "======================" << std::endl ; std::cout << "libparted : " << ped_get_version() << std::endl ; + + //see if we can disable automounting + if ( ! Glib::find_program_in_path( "hal-find-by-property" ) .empty() && + ! Glib::find_program_in_path( "hal-set-property" ) .empty() ) + { + DISABLE_AUTOMOUNT = true ; + std::cout << "automounting disabled" << std::endl ; + } + std::cout << "======================" << std::endl ; //initialize filesystemlist @@ -156,7 +164,9 @@ void GParted_Core::get_devices( std::vector & devices ) std::sort( device_paths .begin(), device_paths .end() ) ; } - +//FIXME: i guess this is the correct place to remove devices from disabled_automount_devices.. +//this is necessary for people who remove and replug their usbdevice without restarting gparted +//all devices not in device_paths yet availabl in disable_automount_devices should be removed.. for ( unsigned int t = 0 ; t < device_paths .size() ; t++ ) { if ( check_device_path( device_paths[ t ] ) && @@ -186,11 +196,8 @@ void GParted_Core::get_devices( std::vector & devices ) temp_device .disktype = lp_disk ->type ->name ; temp_device .max_prims = ped_disk_get_max_primary_partition_count( lp_disk ) ; + disable_automount( temp_device ) ; set_device_partitions( temp_device ) ; - - if ( ! Glib::find_program_in_path( "pmount" ) .empty() ) - disable_automount( temp_device .partitions ) ; - set_mountpoints( temp_device .partitions ) ; set_used_sectors( temp_device .partitions ) ; @@ -439,21 +446,34 @@ void GParted_Core::set_device_partitions( Device & device ) insert_unallocated( device .get_path(), device .partitions, 0, device .length -1, false ) ; } -void GParted_Core::disable_automount( const std::vector & partitions ) +void GParted_Core::disable_automount( const Device & device ) { - for ( unsigned int t = 0 ; t < partitions .size() ; t++ ) + if ( DISABLE_AUTOMOUNT ) { - if ( partitions[ t ] .type == GParted::TYPE_EXTENDED ) - disable_automount( partitions[ t ] .logicals ) ; - - if ( partitions[ t ] .type != GParted::TYPE_UNALLOCATED && - std::find( pmount_locked_partitions .begin(), - pmount_locked_partitions .end(), - partitions[ t ] .get_path() ) == pmount_locked_partitions .end() ) + if ( disabled_automount_devices .find( device .get_path() ) == disabled_automount_devices .end() ) { - Utils::execute_command( "pmount --lock " + partitions[ t ] .get_path() + " " + PID ) ; + //get HAL device-id + Glib::ustring hal_id, error ; + bool found = false ; - pmount_locked_partitions .push_back( partitions[ t ] .get_path() ) ; + for ( unsigned int t = 0 ; t < device .get_paths() .size() && ! found ; t++ ) + found = ! Utils::execute_command( + "hal-find-by-property --key 'block.device' --string '" + + device .get_paths()[ t ] + "'", + hal_id, + error ) ; + + if ( found ) + { + if ( ! hal_id .empty() && hal_id[ hal_id .length() -1 ] == '\n' ) + hal_id .erase( hal_id .length() -1, 1 ) ; + + Utils::execute_command( "hal-set-property --udi '" + hal_id + + "' --key 'storage.automount_enabled_hint' --bool false" ) ; + } + + //found or not found.. we're done with this device.. + disabled_automount_devices[ device. get_path() ] = hal_id ; } } } @@ -686,10 +706,6 @@ bool GParted_Core::Delete( const Partition & partition, std::vector