summaryrefslogtreecommitdiffstats
path: root/sysfs.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 /sysfs.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 'sysfs.c')
-rw-r--r--sysfs.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/sysfs.c b/sysfs.c
index 51deb237..c6df9b06 100644
--- a/sysfs.c
+++ b/sysfs.c
@@ -247,11 +247,12 @@ struct mdinfo *sysfs_read(int fd, char *devnm, unsigned long options)
if (options & GET_ARRAY_STATE) {
strcpy(base, "array_state");
- if (load_sys(fname, sra->sysfs_array_state,
- sizeof(sra->sysfs_array_state)))
+ if (load_sys(fname, buf, sizeof(buf)))
goto abort;
- } else
- sra->sysfs_array_state[0] = 0;
+ sra->array_state = map_name(sysfs_array_states, buf);
+ if (sra->array_state == UnSet)
+ sra->array_state = ARRAY_UNKNOWN_STATE;
+ }
if (options & GET_CONSISTENCY_POLICY) {
strcpy(base, "consistency_policy");