[gparted] Populate member mount point with SWRaid array device (#756829)
- From: Curtis Gedak <gedakc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gparted] Populate member mount point with SWRaid array device (#756829)
- Date: Mon, 2 Nov 2015 19:20:52 +0000 (UTC)
commit f6c2f00df7858a7f4b97e699b9bcf1023bba850a
Author: Mike Fleetwood <mike fleetwood googlemail com>
Date: Thu Oct 22 12:37:57 2015 +0100
Populate member mount point with SWRaid array device (#756829)
Busy file systems are accessed via a mount point, LVM Physical Volumes
are activated via the Volume Group name and busy SWRaid members are
accessed via the array device, /dev entry. Therefore choose to show the
array device in the mount point field for busy SWRaid members.
The kernel device name for an SWRaid array (without leading "/dev/") is
the same as used in /proc/mdstat and /proc/partitions. Therefore the
array device (with leading "/dev/") displayed in GParted will match
between the mount point for busy SWRaid members and the array itself as
used in the device combo box.
# cat /proc/mdstat
Personalities : [raid1]
md1 : active raid1 sda1[2] sdb1[3]
524224 blocks super 1.0 [2/2] [UU]
...
# cat /proc/partitions
major minor #blocks name
8 0 33554432 sda
8 1 524288 sda1
...
8 16 33554432 sdb
8 17 524288 sdb1
...
9 1 524224 md1
...
Bug 756829 - SWRaid member detection enhancements
include/SWRaid_Info.h | 2 ++
src/GParted_Core.cc | 6 ++++++
src/SWRaid_Info.cc | 31 ++++++++++++++++++++++---------
3 files changed, 30 insertions(+), 9 deletions(-)
---
diff --git a/include/SWRaid_Info.h b/include/SWRaid_Info.h
index e2b70a7..a4d5fd6 100644
--- a/include/SWRaid_Info.h
+++ b/include/SWRaid_Info.h
@@ -33,6 +33,7 @@ namespace GParted
struct SWRaid_Member
{
Glib::ustring member;
+ Glib::ustring array;
Glib::ustring uuid;
Glib::ustring label;
bool active;
@@ -44,6 +45,7 @@ public:
static void load_cache();
static bool is_member( const Glib::ustring & member_path );
static bool is_member_active( const Glib::ustring & member_path );
+ static Glib::ustring get_array( const Glib::ustring & member_path );
static Glib::ustring get_uuid( const Glib::ustring & member_path );
static Glib::ustring get_label( const Glib::ustring & member_path );
diff --git a/src/GParted_Core.cc b/src/GParted_Core.cc
index 324d2d2..b9bb9e3 100644
--- a/src/GParted_Core.cc
+++ b/src/GParted_Core.cc
@@ -1817,6 +1817,12 @@ void GParted_Core::set_mountpoints( std::vector<Partition> & partitions )
if ( ! vgname .empty() )
partitions[ t ] .add_mountpoint( vgname ) ;
}
+ else if ( partitions[t].filesystem == FS_LINUX_SWRAID )
+ {
+ Glib::ustring array_path = SWRaid_Info::get_array( partitions[t].get_path() );
+ if ( ! array_path.empty() )
+ partitions[t].add_mountpoint( array_path );
+ }
}
}
diff --git a/src/SWRaid_Info.cc b/src/SWRaid_Info.cc
index 8bec78c..66ff23c 100644
--- a/src/SWRaid_Info.cc
+++ b/src/SWRaid_Info.cc
@@ -27,12 +27,13 @@ namespace GParted
// Data model:
// mdadm_found - Is the "mdadm" command available?
// swraid_info_cache - Vector of member information in Linux Software RAID arrays.
+// Only active arrays have /dev entries.
// E.g.
-// //member , uuid , label , active
-// [{"/dev/sda1", "15224a42-c25b-bcd9-15db-60004e5fe53a", "chimney:1", true },
-// {"/dev/sda2", "15224a42-c25b-bcd9-15db-60004e5fe53a", "chimney:1", true },
-// {"/dev/sda6", "8dc7483c-d74e-e0a8-b6a8-dc3ca57e43f8", "" , false},
-// {"/dev/sdb6", "8dc7483c-d74e-e0a8-b6a8-dc3ca57e43f8", "" , false}
+// //member , array , uuid , label , active
+// [{"/dev/sda1", "/dev/md1", "15224a42-c25b-bcd9-15db-60004e5fe53a", "chimney:1", true
},
+// {"/dev/sda2", "/dev/md1", "15224a42-c25b-bcd9-15db-60004e5fe53a", "chimney:1", true
},
+// {"/dev/sda6", "" , "8dc7483c-d74e-e0a8-b6a8-dc3ca57e43f8", "" ,
false},
+// {"/dev/sdb6", "" , "8dc7483c-d74e-e0a8-b6a8-dc3ca57e43f8", "" , false}
// ]
// Initialise static data elements
@@ -63,6 +64,14 @@ bool SWRaid_Info::is_member_active( const Glib::ustring & member_path )
return false; // No such member
}
+// Return array /dev entry (e.g. "/dev/md1") containing the specified member, or "" if the
+// array is not running or there is no such member.
+Glib::ustring SWRaid_Info::get_array( const Glib::ustring & member_path )
+{
+ const SWRaid_Member & memb = get_cache_entry_by_member( member_path );
+ return memb.array;
+}
+
// Return array UUID for the specified member, or "" when failed to parse the UUID or
// there is no such member.
Glib::ustring SWRaid_Info::get_uuid( const Glib::ustring & member_path )
@@ -159,6 +168,7 @@ void SWRaid_Info::load_swraid_info_cache()
{
SWRaid_Member memb;
memb.member = devices[j];
+ memb.array = "";
memb.uuid = uuid;
memb.label = label;
memb.active = false;
@@ -174,7 +184,7 @@ void SWRaid_Info::load_swraid_info_cache()
}
}
- // Set which SWRaid members are active.
+ // For active SWRaid members, set array and active flag.
std::string line;
std::ifstream input( "/proc/mdstat" );
if ( input )
@@ -197,13 +207,16 @@ void SWRaid_Info::load_swraid_info_cache()
if ( index != Glib::ustring::npos )
{
// Field contains an "[" so got a short
- // kernel device name of a member. Mark
- // as active.
+ // kernel device name of a member. Set
+ // array and active flag.
Glib::ustring mpath = "/dev/" +
fields[i].substr( 0, index );
SWRaid_Member & memb = get_cache_entry_by_member( mpath );
if ( memb.member == mpath )
+ {
+ memb.array = "/dev/" + fields[0];
memb.active = true;
+ }
}
}
}
@@ -221,7 +234,7 @@ SWRaid_Member & SWRaid_Info::get_cache_entry_by_member( const Glib::ustring & me
if ( member_path == swraid_info_cache[i].member )
return swraid_info_cache[i];
}
- static SWRaid_Member memb = {"", "", "", false};
+ static SWRaid_Member memb = {"", "", "", "", false};
return memb;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]