2017-08-23 00:29:34 +02:00
|
|
|
From b4decd517d90098bc2d17d3eddfe858d8b903920 Mon Sep 17 00:00:00 2001
|
2017-03-27 05:26:19 +02:00
|
|
|
From: NeilBrown <neilb@suse.com>
|
2017-08-23 00:29:34 +02:00
|
|
|
Date: Mon, 27 Mar 2017 14:36:56 +1100
|
2017-03-27 05:26:19 +02:00
|
|
|
Subject: [PATCH] Detail: handle non-existent arrays better.
|
2017-08-23 00:29:34 +02:00
|
|
|
References: bsc#966773
|
2017-03-27 05:26:19 +02:00
|
|
|
|
|
|
|
If you call "mdadm --detail" with a device file for an array which
|
|
|
|
doesn't exist, such as by
|
|
|
|
mknod /dev/md57 b 9 57
|
|
|
|
mdadm --detail /dev/md57
|
|
|
|
|
|
|
|
you get an unhelpful message about and inactive RAID0, and return
|
|
|
|
status is '0'. This is confusing.
|
|
|
|
|
|
|
|
So catch this possibility and print a more useful message, and
|
|
|
|
return a non-zero status.
|
|
|
|
|
|
|
|
Signed-off-by: NeilBrown <neilb@suse.com>
|
2017-08-23 00:29:34 +02:00
|
|
|
Signed-off-by: Jes Sorensen <Jes.Sorensen@gmail.com>
|
2017-03-27 05:26:19 +02:00
|
|
|
---
|
|
|
|
Detail.c | 8 ++++++++
|
|
|
|
1 file changed, 8 insertions(+)
|
|
|
|
|
|
|
|
diff --git a/Detail.c b/Detail.c
|
2017-08-23 00:29:34 +02:00
|
|
|
index cb33794..3d92855 100644
|
2017-03-27 05:26:19 +02:00
|
|
|
--- a/Detail.c
|
|
|
|
+++ b/Detail.c
|
|
|
|
@@ -110,6 +110,14 @@ int Detail(char *dev, struct context *c)
|
|
|
|
if (ioctl(fd, GET_ARRAY_INFO, &array) == 0) {
|
|
|
|
inactive = 0;
|
|
|
|
} else if (errno == ENODEV && sra) {
|
|
|
|
+ if (sra->array.major_version == -1 &&
|
|
|
|
+ sra->array.minor_version == -1 &&
|
|
|
|
+ sra->devs == NULL) {
|
|
|
|
+ pr_err("Array associated with md device %s does not exist.\n", dev);
|
|
|
|
+ close(fd);
|
|
|
|
+ sysfs_free(sra);
|
|
|
|
+ return rv;
|
|
|
|
+ }
|
|
|
|
array = sra->array;
|
|
|
|
inactive = 1;
|
|
|
|
} else {
|
|
|
|
--
|
2017-08-23 00:29:34 +02:00
|
|
|
2.10.2
|
2017-03-27 05:26:19 +02:00
|
|
|
|