|
|
d922d5 |
From 27e39ad31cbdfe516f9f390cc860a4f681750ef0 Mon Sep 17 00:00:00 2001
|
|
|
d922d5 |
From: Xiao Ni <xni@redhat.com>
|
|
|
d922d5 |
Date: Wed, 30 May 2018 13:49:41 +0800
|
|
|
d922d5 |
Subject: [RHEL7.5 PATCH 23/26] Check major number of block device when
|
|
|
d922d5 |
querying md device
|
|
|
d922d5 |
|
|
|
d922d5 |
It give error message when query a non md device.
|
|
|
d922d5 |
mdadm /dev/null
|
|
|
d922d5 |
/dev/null: is an md device, but gives "Inappropriate ioctl for device" when queried
|
|
|
d922d5 |
|
|
|
d922d5 |
It's introduced by commit 5cb8599 and 8d0cd09
|
|
|
d922d5 |
At first it checks whether a block is md device by function md_get_version.
|
|
|
d922d5 |
In this function it does mainly two jobs:
|
|
|
d922d5 |
1. send request by ioctl. (now it can be replace by argument ioctlerr)
|
|
|
d922d5 |
2. check the block device major number which we don't do this.
|
|
|
d922d5 |
|
|
|
d922d5 |
We add the second judgement in this patch.
|
|
|
d922d5 |
|
|
|
d922d5 |
Fixes: 5cb8599 and 8d0cd09
|
|
|
d922d5 |
Reported-by: Karsten Weiss <karsten.weiss@atos.net>
|
|
|
d922d5 |
Signed-off-by: Xiao Ni <xni@redhat.com>
|
|
|
d922d5 |
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
|
|
|
d922d5 |
---
|
|
|
d922d5 |
Query.c | 5 ++---
|
|
|
d922d5 |
1 file changed, 2 insertions(+), 3 deletions(-)
|
|
|
d922d5 |
|
|
|
d922d5 |
diff --git a/Query.c b/Query.c
|
|
|
d922d5 |
index 2bd0e2a..23fbf8a 100644
|
|
|
d922d5 |
--- a/Query.c
|
|
|
d922d5 |
+++ b/Query.c
|
|
|
d922d5 |
@@ -85,12 +85,11 @@ int Query(char *dev)
|
|
|
d922d5 |
|
|
|
d922d5 |
if (ioctlerr == ENODEV)
|
|
|
d922d5 |
printf("%s: is an md device which is not active\n", dev);
|
|
|
d922d5 |
+ else if (ioctlerr && major(stb.st_rdev) != MD_MAJOR)
|
|
|
d922d5 |
+ printf("%s: is not an md array\n", dev);
|
|
|
d922d5 |
else if (ioctlerr)
|
|
|
d922d5 |
printf("%s: is an md device, but gives \"%s\" when queried\n",
|
|
|
d922d5 |
dev, strerror(ioctlerr));
|
|
|
d922d5 |
- else if (staterr)
|
|
|
d922d5 |
- printf("%s: is not a valid md device, returning %s\n",
|
|
|
d922d5 |
- dev, strerror(ioctlerr));
|
|
|
d922d5 |
else {
|
|
|
d922d5 |
printf("%s: %s %s %d devices, %d spare%s. Use mdadm --detail for more detail.\n",
|
|
|
d922d5 |
dev, human_size_brief(larray_size,IEC),
|
|
|
d922d5 |
--
|
|
|
d922d5 |
2.7.4
|
|
|
d922d5 |
|