dcavalca / rpms / mdadm

Forked from rpms/mdadm 3 years ago
Clone

Blame SOURCES/mdopen-open_mddev-Use-md_get_array_info-to-determine1.patch

2c1b57
From 40b054e1dc9e334621fd2081bf6fc46b01dd7ef4 Mon Sep 17 00:00:00 2001
2c1b57
From: Jes Sorensen <Jes.Sorensen@gmail.com>
2c1b57
Date: Wed, 5 Apr 2017 15:44:20 -0400
2c1b57
Subject: [RHEL7.5 PATCH 063/169] mdopen/open_mddev: Use
2c1b57
 md_get_array_info() to determine valid array
2c1b57
2c1b57
md_get_array_info() can be used instead of md_get_version() to
2c1b57
determine this is in fact a valid array.
2c1b57
2c1b57
Signed-off-by: Jes Sorensen <Jes.Sorensen@gmail.com>
2c1b57
---
2c1b57
 mdopen.c | 6 +++++-
2c1b57
 1 file changed, 5 insertions(+), 1 deletion(-)
2c1b57
2c1b57
diff --git a/mdopen.c b/mdopen.c
2c1b57
index 685ca32..fe240e5 100644
2c1b57
--- a/mdopen.c
2c1b57
+++ b/mdopen.c
2c1b57
@@ -416,19 +416,23 @@ int create_mddev(char *dev, char *name, int autof, int trustworthy,
2c1b57
  */
2c1b57
 int open_mddev(char *dev, int report_errors)
2c1b57
 {
2c1b57
+	struct mdu_array_info_s array;
2c1b57
 	int mdfd = open(dev, O_RDONLY);
2c1b57
+
2c1b57
 	if (mdfd < 0) {
2c1b57
 		if (report_errors)
2c1b57
 			pr_err("error opening %s: %s\n",
2c1b57
 				dev, strerror(errno));
2c1b57
 		return -1;
2c1b57
 	}
2c1b57
-	if (md_get_version(mdfd) <= 0) {
2c1b57
+
2c1b57
+	if (md_get_array_info(mdfd, &array) != 0) {
2c1b57
 		close(mdfd);
2c1b57
 		if (report_errors)
2c1b57
 			pr_err("%s does not appear to be an md device\n", dev);
2c1b57
 		return -2;
2c1b57
 	}
2c1b57
+
2c1b57
 	return mdfd;
2c1b57
 }
2c1b57
 
2c1b57
-- 
2c1b57
2.7.4
2c1b57