summaryrefslogtreecommitdiffstats
path: root/mdopen.c
diff options
context:
space:
mode:
authorJes Sorensen <Jes.Sorensen@gmail.com>2017-04-05 21:44:20 +0200
committerJes Sorensen <Jes.Sorensen@gmail.com>2017-04-05 21:44:20 +0200
commit40b054e1dc9e334621fd2081bf6fc46b01dd7ef4 (patch)
treed316808bb50b44a94a8db5d802a586ab89f3bc8d /mdopen.c
parentmdmon: Stop bothering about md_get_version() (diff)
downloadmdadm-40b054e1dc9e334621fd2081bf6fc46b01dd7ef4.tar.xz
mdadm-40b054e1dc9e334621fd2081bf6fc46b01dd7ef4.zip
mdopen/open_mddev: Use md_get_array_info() to determine valid array
md_get_array_info() can be used instead of md_get_version() to determine this is in fact a valid array. Signed-off-by: Jes Sorensen <Jes.Sorensen@gmail.com>
Diffstat (limited to 'mdopen.c')
-rw-r--r--mdopen.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/mdopen.c b/mdopen.c
index 685ca328..fe240e5c 100644
--- a/mdopen.c
+++ b/mdopen.c
@@ -416,19 +416,23 @@ int create_mddev(char *dev, char *name, int autof, int trustworthy,
*/
int open_mddev(char *dev, int report_errors)
{
+ struct mdu_array_info_s array;
int mdfd = open(dev, O_RDONLY);
+
if (mdfd < 0) {
if (report_errors)
pr_err("error opening %s: %s\n",
dev, strerror(errno));
return -1;
}
- if (md_get_version(mdfd) <= 0) {
+
+ if (md_get_array_info(mdfd, &array) != 0) {
close(mdfd);
if (report_errors)
pr_err("%s does not appear to be an md device\n", dev);
return -2;
}
+
return mdfd;
}