[gparted] Simplify whole device matching in load_proc_partitions_Info_cache()
- From: Curtis Gedak <gedakc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gparted] Simplify whole device matching in load_proc_partitions_Info_cache()
- Date: Sun, 7 Aug 2016 20:54:30 +0000 (UTC)
commit 5055c0b638ca236ea9457eaf151c3bc54a872065
Author: Mike Fleetwood <mike fleetwood googlemail com>
Date: Tue Jul 12 19:49:56 2016 +0100
Simplify whole device matching in load_proc_partitions_Info_cache()
Following earlier commit "Pre-populate BlockSpecial cache while reading
/proc/partitions (#767842)" load_proc_partitions_info_cache() has
extracted just the name field from each line of /proc/partitions.
Therefore simplify the regular expressions matching each type of whole
disk device to just matching in the name field rather than matching in
the whole line.
src/Proc_Partitions_Info.cc | 16 +++++++++-------
1 files changed, 9 insertions(+), 7 deletions(-)
---
diff --git a/src/Proc_Partitions_Info.cc b/src/Proc_Partitions_Info.cc
index 4262ba3..ea1cd38 100644
--- a/src/Proc_Partitions_Info.cc
+++ b/src/Proc_Partitions_Info.cc
@@ -82,22 +82,24 @@ void Proc_Partitions_Info::load_proc_partitions_info_cache()
//Whole disk devices are the ones we want.
//Device names without a trailing digit refer to the whole disk.
- device = Utils::regexp_label(line, "^[\t ]+[0-9]+[\t ]+[0-9]+[\t ]+[0-9]+[\t
]+([^0-9]+)$") ;
+ device = Utils::regexp_label( name, "^([^0-9]+)$" );
+
//Recognize /dev/md* devices (Linux software RAID - mdadm).
//E.g., device = /dev/md127, partition = /dev/md127p1
if ( device == "" )
- device = Utils::regexp_label(line, "^[\t ]+[0-9]+[\t ]+[0-9]+[\t ]+[0-9]+[\t
]+(md[0-9]+)$") ;
+ device = Utils::regexp_label( name, "^(md[0-9]+)$" );
+
//Recognize /dev/mmcblk* devices.
//E.g., device = /dev/mmcblk0, partition = /dev/mmcblk0p1
if ( device == "" )
- device = Utils::regexp_label(line, "^[\t ]+[0-9]+[\t ]+[0-9]+[\t ]+[0-9]+[\t
]+(mmcblk[0-9]+)$") ;
+ device = Utils::regexp_label( name, "^(mmcblk[0-9]+)$" );
// Recognise /dev/nvme*n* devices
// (Non-Volatile Memory Express devices. SSD type devices which
// plug directly into PCIe sockets).
// E.g., device = /dev/nvme0n1, partition = /dev/nvme0n1p1
if ( device == "" )
- device = Utils::regexp_label(line, "^[\t ]+[0-9]+[\t ]+[0-9]+[\t ]+[0-9]+[\t
]+(nvme[0-9]+n[0-9]+)$");
+ device = Utils::regexp_label( name, "^(nvme[0-9]+n[0-9]+)$" );
//Device names that end with a #[^p]# are HP Smart Array Devices (disks)
// E.g., device = /dev/cciss/c0d0, partition = /dev/cciss/c0d0p1
@@ -109,12 +111,12 @@ void Proc_Partitions_Info::load_proc_partitions_info_cache()
// E.g., device = /dev/rd/c0d0, partition = /dev/rd/c0d0p1
// (linux-x.y.z/Documentation/blockdev/README.DAC960)
if ( device == "" )
- device = Utils::regexp_label(line, "^[\t ]+[0-9]+[\t ]+[0-9]+[\t ]+[0-9]+[\t
]+([a-z]+/c[0-9]+d[0-9]+)$") ;
+ device = Utils::regexp_label( name, "^([a-z]+/c[0-9]+d[0-9]+)$" );
+
if ( device != "" )
{
//add potential device to the list
- device = "/dev/" + device;
- device_paths_cache .push_back( device ) ;
+ device_paths_cache.push_back( "/dev/" + device );
}
}
proc_partitions .close() ;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]