diff options
author | Jes Sorensen <jsorensen@fb.com> | 2017-04-20 05:27:58 +0200 |
---|---|---|
committer | Jes Sorensen <jsorensen@fb.com> | 2017-04-20 06:12:27 +0200 |
commit | 5e4ca8bb82e98400c9258cb3d7e4d030576f21df (patch) | |
tree | 9c2f93c746d3a4264aa39ce1bb6505e12958d881 /maps.c | |
parent | Query: Use sysfs to obtain data if possible (diff) | |
download | mdadm-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.c | 17 |
1 files changed, 17 insertions, 0 deletions
@@ -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) { |