summaryrefslogtreecommitdiffstats
path: root/maps.c
diff options
context:
space:
mode:
authorJes Sorensen <jsorensen@fb.com>2017-04-20 05:27:58 +0200
committerJes Sorensen <jsorensen@fb.com>2017-04-20 06:12:27 +0200
commit5e4ca8bb82e98400c9258cb3d7e4d030576f21df (patch)
tree9c2f93c746d3a4264aa39ce1bb6505e12958d881 /maps.c
parentQuery: Use sysfs to obtain data if possible (diff)
downloadmdadm-5e4ca8bb82e98400c9258cb3d7e4d030576f21df.tar.xz
mdadm-5e4ca8bb82e98400c9258cb3d7e4d030576f21df.zip
sysfs: Parse array_state in sysfs_read()
Rather than copying in the array_state string, parse it and use an enum to indicate the state. Signed-off-by: Jes Sorensen <jsorensen@fb.com>
Diffstat (limited to 'maps.c')
-rw-r--r--maps.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/maps.c b/maps.c
index d9ee7de4..a8a4639a 100644
--- a/maps.c
+++ b/maps.c
@@ -139,6 +139,23 @@ mapping_t consistency_policies[] = {
{ NULL, 0}
};
+mapping_t sysfs_array_states[] = {
+ /*
+ * Beware map_name() uses strcmp() so active-idle must come before
+ * active, to be detected correctly.
+ */
+ { "active-idle", ARRAY_ACTIVE_IDLE },
+ { "active", ARRAY_ACTIVE },
+ { "clear", ARRAY_CLEAR },
+ { "inactive", ARRAY_INACTIVE },
+ { "suspended", ARRAY_SUSPENDED },
+ { "readonly", ARRAY_READONLY },
+ { "read-auto", ARRAY_READ_AUTO },
+ { "clean", ARRAY_CLEAN },
+ { "write-pending", ARRAY_WRITE_PENDING },
+ { NULL, 0 }
+};
+
char *map_num(mapping_t *map, int num)
{
while (map->name) {