Added parse devices from /proc/partitions for "Scanning all devices..." code

svn path=/trunk/; revision=847
This commit is contained in:
Curtis Gedak 2008-05-08 16:25:43 +00:00
parent 85191346b3
commit 7bf6c422ff
2 changed files with 35 additions and 6 deletions

View File

@ -1,3 +1,9 @@
2008-05-08 Curtis Gedak <gedakc@gmail.com>
* src/GParted_Core.cc: Added parse devices from /proc/partitions
- If /proc/partitions doesn't exist then use ped_device_probe_all
- Closes GParted bugs #351753, and #453555
2008-05-06 Curtis Gedak <gedakc@gmail.com>
* gparted.in: Fixed problem with command line devices being ignored

View File

@ -137,7 +137,32 @@ void GParted_Core::set_devices( std::vector<Device> & devices )
device_paths .clear() ;
//try to find all available devices
ped_device_probe_all();
std::ifstream proc_partitions( "/proc/partitions" ) ;
if ( proc_partitions )
{
//parse device names from /proc/partitions
std::string line ;
std::string device ;
while ( getline( proc_partitions, line ) )
{
//Device names without a trailing digit refer to the whole disk.
//These whole disk devices are the ones we want.
device = Utils::regexp_label(line, "^[\t ]+[0-9]+[\t ]+[0-9]+[\t ]+[0-9]+[\t ]+([^0-9]+)$") ;
if ( device != "" )
{
//try to have libparted detect the device and add it to the list
device = "/dev/" + device;
ped_device_get( device .c_str() ) ;
}
}
proc_partitions .close() ;
}
else
{
//file /proc/partitions doesn't exist so use libparted to probe devices
ped_device_probe_all();
}
lp_device = ped_device_get_next( NULL );
while ( lp_device )
{
@ -152,10 +177,8 @@ void GParted_Core::set_devices( std::vector<Device> & devices )
ped_device_close( lp_device ) ;
}
free( buf ) ;
}
lp_device = ped_device_get_next( lp_device ) ;
}
close_device_and_disk() ;