File 0098-Assemble-extend-homehost-ignore-to-allow-name-to-ign.patch of Package mdadm.5365
From 86b77ddf87ee364c1092ae50c8efbd7fa71d5c34 Mon Sep 17 00:00:00 2001
From: NeilBrown <neilb@suse.com>
Date: Fri, 24 Jul 2015 12:50:54 +1000
Subject: [PATCH 144/359] Assemble: extend --homehost='<ignore>' to allow
--name= to ignore homehost
References: bsc#1081910
Also make --homehost='<ignore>' work properly.
Signed-off-by: NeilBrown <neilb@suse.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
Assemble.c | 16 ++++++++++------
mdadm.c | 2 +-
2 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/Assemble.c b/Assemble.c
index a3d020d..245e213 100644
--- a/Assemble.c
+++ b/Assemble.c
@@ -25,7 +25,7 @@
#include "mdadm.h"
#include <ctype.h>
-static int name_matches(char *found, char *required, char *homehost)
+static int name_matches(char *found, char *required, char *homehost, int require_homehost)
{
/* See if the name found matches the required name, possibly
* prefixed with 'homehost'
@@ -41,6 +41,7 @@ static int name_matches(char *found, char *required, char *homehost)
l = sep - found;
if (strncmp(found, "any:", 4) == 0 ||
(homehost && strcmp(homehost, "any") == 0) ||
+ !require_homehost ||
(homehost && strlen(homehost) == l &&
strncmp(found, homehost, l) == 0)) {
/* matching homehost */
@@ -78,7 +79,7 @@ static int is_member_busy(char *metadata_version)
static int ident_matches(struct mddev_ident *ident,
struct mdinfo *content,
struct supertype *tst,
- char *homehost,
+ char *homehost, int require_homehost,
char *update, char *devname)
{
@@ -90,7 +91,7 @@ static int ident_matches(struct mddev_ident *ident,
return 0;
}
if (ident->name[0] && (!update || strcmp(update, "name")!= 0) &&
- name_matches(content->name, ident->name, homehost)==0) {
+ name_matches(content->name, ident->name, homehost, require_homehost)==0) {
if (devname)
pr_err("%s has wrong name.\n", devname);
return 0;
@@ -330,7 +331,8 @@ static int select_devices(struct mddev_dev *devlist,
content = content->next) {
if (!ident_matches(ident, content, tst,
- c->homehost, c->update,
+ c->homehost, c->require_homehost,
+ c->update,
report_mismatch ? devname : NULL))
/* message already printed */;
else if (is_member_busy(content->text_version)) {
@@ -372,7 +374,8 @@ static int select_devices(struct mddev_dev *devlist,
tst->ss->getinfo_super(tst, content, NULL);
if (!ident_matches(ident, content, tst,
- c->homehost, c->update,
+ c->homehost, c->require_homehost,
+ c->update,
report_mismatch ? devname : NULL))
goto loop;
@@ -396,7 +399,8 @@ static int select_devices(struct mddev_dev *devlist,
goto loop;
}
if (match && !ident_matches(match, content, tst,
- c->homehost, c->update,
+ c->homehost, c->require_homehost,
+ c->update,
report_mismatch ? devname : NULL))
/* Array exists in mdadm.conf but some
* details don't match, so reject it
diff --git a/mdadm.c b/mdadm.c
index 3dd1bd2..93732a8 100644
--- a/mdadm.c
+++ b/mdadm.c
@@ -1247,7 +1247,7 @@ int main(int argc, char *argv[])
}
}
- if (c.homehost == NULL)
+ if (c.homehost == NULL && c.require_homehost)
c.homehost = conf_get_homehost(&c.require_homehost);
if (c.homehost == NULL || strcasecmp(c.homehost, "<system>")==0) {
if (gethostname(sys_hostname, sizeof(sys_hostname)) == 0) {
--
2.16.1