parse /proc/partitions to find devices instead of using

* include/GParted_Core.h,
  src/GParted_Core.cc: parse /proc/partitions to find devices instead
  of using ped_device_probe_all()
This commit is contained in:
Bart Hakvoort 2006-09-07 18:40:15 +00:00
parent f87808853d
commit bd4d110fdb
3 changed files with 20 additions and 19 deletions

View File

@ -1,3 +1,9 @@
2006-09-07 Bart Hakvoort <hakvoort@cvs.gnome.org>
* 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 <hakvoort@cvs.gnome.org>
* configure.in: finally added a decent check for libparted (see also

View File

@ -56,7 +56,6 @@ private:
void init_maps() ;
void read_mountpoints_from_file( const Glib::ustring & filename,
std::map< Glib::ustring, std::vector<Glib::ustring> > & map ) ;
bool check_device_path( const Glib::ustring & device_path ) ;
std::vector<Glib::ustring> get_alternate_paths( const Glib::ustring & path ) ;
void set_device_partitions( Device & device ) ;
GParted::FILESYSTEM get_filesystem() ;

View File

@ -151,26 +151,27 @@ void GParted_Core::set_devices( std::vector<Device> & 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<Glib::ustring> GParted_Core::get_alternate_paths( const Glib::ustring & path )
{
std::vector<Glib::ustring> paths ;