gparted r847 - in trunk: . src
- From: gedakc svn gnome org
- To: svn-commits-list gnome org
- Subject: gparted r847 - in trunk: . src
- Date: Thu, 8 May 2008 17:25:43 +0100 (BST)
Author: gedakc
Date: Thu May 8 16:25:43 2008
New Revision: 847
URL: http://svn.gnome.org/viewvc/gparted?rev=847&view=rev
Log:
Added parse devices from /proc/partitions for "Scanning all devices..." code
Modified:
trunk/ChangeLog
trunk/src/GParted_Core.cc
Modified: trunk/src/GParted_Core.cc
==============================================================================
--- trunk/src/GParted_Core.cc (original)
+++ trunk/src/GParted_Core.cc Thu May 8 16:25:43 2008
@@ -39,7 +39,7 @@
#include "../include/ufs.h"
#include <cerrno>
-#include <sys/statvfs.h>
+#include <sys/statvfs.h>
std::vector<Glib::ustring> libparted_messages ; //see ped_exception_handler()
@@ -65,7 +65,7 @@
std::cout << "======================" << std::endl ;
std::cout << "libparted : " << ped_get_version() << std::endl ;
std::cout << "======================" << std::endl ;
-
+
//initialize filesystemlist
find_supported_filesystems() ;
}
@@ -135,9 +135,34 @@
if ( probe_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 @@
ped_device_close( lp_device ) ;
}
-
free( buf ) ;
}
-
lp_device = ped_device_get_next( lp_device ) ;
}
close_device_and_disk() ;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]