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 /sysfs.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 'sysfs.c')
-rw-r--r-- | sysfs.c | 9 |
1 files changed, 5 insertions, 4 deletions
@@ -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"); |