diff --git a/ChangeLog b/ChangeLog index 7b4fd8fb..91474079 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2006-09-07 Bart Hakvoort + + * include/GParted_Core.h, + src/GParted_Core.cc: parse /proc/partitions to find devices instead + of using ped_device_probe_all() + 2006-09-06 Bart Hakvoort * configure.in: finally added a decent check for libparted (see also diff --git a/include/GParted_Core.h b/include/GParted_Core.h index 0495960b..586cca53 100644 --- a/include/GParted_Core.h +++ b/include/GParted_Core.h @@ -56,7 +56,6 @@ private: void init_maps() ; void read_mountpoints_from_file( const Glib::ustring & filename, std::map< Glib::ustring, std::vector > & map ) ; - bool check_device_path( const Glib::ustring & device_path ) ; std::vector get_alternate_paths( const Glib::ustring & path ) ; void set_device_partitions( Device & device ) ; GParted::FILESYSTEM get_filesystem() ; diff --git a/src/GParted_Core.cc b/src/GParted_Core.cc index b72e2dae..507672af 100644 --- a/src/GParted_Core.cc +++ b/src/GParted_Core.cc @@ -151,26 +151,27 @@ void GParted_Core::set_devices( std::vector & devices ) device_paths .clear() ; //try to find all available devices - ped_device_probe_all(); - //FIXME: since parted 1.7.1 i detect an unusable /dev/md/0 device (voyager), take a look at this and - //find out how to filter it from the list - lp_device = ped_device_get_next( NULL ); - while ( lp_device ) - { - device_paths .push_back( lp_device ->path ) ; + std::ifstream proc_partitions( "/proc/partitions" ) ; + if ( proc_partitions ) + { + std::string line ; + while ( getline( proc_partitions, line ) ) + { + int minor ; + char device[512] ; + if ( sscanf( line .c_str(), "%*d %d %*d %s", &minor, device ) == 2 && minor == 0 ) + device_paths .push_back( "/dev/" + Glib::ustring( device ) ) ; + } - lp_device = ped_device_get_next( lp_device ) ; - } - close_device_and_disk() ; + proc_partitions .close() ; + } std::sort( device_paths .begin(), device_paths .end() ) ; } for ( unsigned int t = 0 ; t < device_paths .size() ; t++ ) { - if ( check_device_path( device_paths[ t ] ) && - open_device_and_disk( device_paths[ t ], false ) && - lp_device ) + if ( open_device_and_disk( device_paths[ t ], false ) ) { temp_device .Reset() ; @@ -525,11 +526,6 @@ void GParted_Core::read_mountpoints_from_file( const Glib::ustring & filename, } } -bool GParted_Core::check_device_path( const Glib::ustring & device_path ) -{ - return ( device_path .length() > 6 && device_path .is_ascii() ) ; -} - std::vector GParted_Core::get_alternate_paths( const Glib::ustring & path ) { std::vector paths ;