summaryrefslogtreecommitdiff
path: root/config.c
diff options
context:
space:
mode:
authorLukasz Orlowski <lukasz.orlowski@intel.com>2011-11-07 12:20:34 +1100
committerNeilBrown <neilb@suse.de>2011-11-07 12:20:34 +1100
commit7c3367585ec04e249dca1d6e64afcb2be9723a9b (patch)
treecfcb56337396111fb6cfe62f6fdde590f8fe21da /config.c
parent4584621ab439f009d7f6a3e61b7cc91c0374065f (diff)
fix: Allowed to assemble 2 volumes with the same names from config file.
mdadm allowes to assemble 2 volumes with the same names based on the config file. The issue is fixed by iterating over the list of md device identifiers and comparing the names of md devices against each other, detecting identical names and blocking the assembly should the same names be found. Now having detected duplicate names, mdadm terminates without assembling the container, displaying appropriate prompt. Signed-off-by: Lukasz Orlowski <lukasz.orlowski@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'config.c')
-rw-r--r--config.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/config.c b/config.c
index 597e0460..6a398cfa 100644
--- a/config.c
+++ b/config.c
@@ -1096,3 +1096,36 @@ struct mddev_ident *conf_match(struct supertype *st,
}
return match;
}
+
+int conf_verify_devnames(struct mddev_ident *array_list)
+{
+ struct mddev_ident *a1, *a2;
+
+ for (a1 = array_list; a1; a1 = a1->next) {
+ if (!a1->devname)
+ continue;
+ for (a2 = a1->next; a2; a2 = a2->next) {
+ if (!a2->devname)
+ continue;
+ if (strcmp(a1->devname, a2->devname) != 0)
+ continue;
+
+ if (a1->uuid_set && a2->uuid_set) {
+ char nbuf[64];
+ __fname_from_uuid(a1->uuid, 0, nbuf, ':');
+ fprintf(stderr,
+ Name ": Devices %s and ",
+ nbuf);
+ __fname_from_uuid(a2->uuid, 0, nbuf, ':');
+ fprintf(stderr,
+ "%s have the same name: %s\n",
+ nbuf, a1->devname);
+ } else
+ fprintf(stderr, Name ": Device %s given twice"
+ " in config file\n", a1->devname);
+ return 1;
+ }
+ }
+
+ return 0;
+}