summaryrefslogtreecommitdiffstats
path: root/Query.c
diff options
context:
space:
mode:
authorJes Sorensen <jsorensen@fb.com>2017-04-13 19:30:17 +0200
committerJes Sorensen <jsorensen@fb.com>2017-04-20 06:12:34 +0200
commit3ab8f4bf33d906cb1084f7b4036556bfb4bb73ec (patch)
treed868dedbd7309ab70ed2f48ad2d5e6f245578285 /Query.c
parentsysfs: Parse array_state in sysfs_read() (diff)
downloadmdadm-3ab8f4bf33d906cb1084f7b4036556bfb4bb73ec.tar.xz
mdadm-3ab8f4bf33d906cb1084f7b4036556bfb4bb73ec.zip
util: Introduce md_array_active() helper
Rather than querying md_get_array_info() to determine whether an array is valid, do the work in md_array_active() using sysfs, and fall back on md_get_array_info() if sysfs fails. Signed-off-by: Jes Sorensen <jsorensen@fb.com>
Diffstat (limited to 'Query.c')
-rw-r--r--Query.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/Query.c b/Query.c
index b761c470..4dec9f51 100644
--- a/Query.c
+++ b/Query.c
@@ -38,7 +38,6 @@ int Query(char *dev)
int level, raid_disks, spare_disks;
struct mdinfo info;
struct mdinfo *sra;
- mdu_array_info_t array;
struct supertype *st = NULL;
unsigned long long larray_size;
struct stat stb;
@@ -65,6 +64,8 @@ int Query(char *dev)
raid_disks = sra->array.raid_disks;
spare_disks = sra->array.spare_disks;
} else {
+ mdu_array_info_t array;
+
if (md_get_array_info(fd, &array) < 0) {
ioctlerr = errno;
} else {
@@ -111,7 +112,7 @@ int Query(char *dev)
disc.number = info.disk.number;
activity = "undetected";
if (mddev && (fd = open(mddev, O_RDONLY))>=0) {
- if (md_get_array_info(fd, &array) >= 0) {
+ if (md_array_active(fd)) {
if (md_get_disk_info(fd, &disc) >= 0 &&
makedev((unsigned)disc.major,(unsigned)disc.minor) == stb.st_rdev)
activity = "active";