From: NeilBrown Date: Tue, 30 Nov 2010 22:55:35 +0000 (+1100) Subject: ddf: fail creation of new subarray with same name as old. X-Git-Tag: mdadm-3.2~208 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=97c9c10014f5c1392edcbd8da1870a4a68270ece;p=thirdparty%2Fmdadm.git ddf: fail creation of new subarray with same name as old. Signed-off-by: NeilBrown --- diff --git a/super-ddf.c b/super-ddf.c index 1ff7e545..b3890aae 100644 --- a/super-ddf.c +++ b/super-ddf.c @@ -1961,6 +1961,19 @@ static int init_super_ddf_bvd(struct supertype *st, return 0; } + if (name) + for (venum = 0; venum < __be16_to_cpu(ddf->virt->max_vdes); venum++) + if (!all_ff(ddf->virt->entries[venum].guid)) { + char *n = ddf->virt->entries[venum].name; + + if (strncmp(name, n, 16) == 0) { + fprintf(stderr, Name ": This ddf already" + " has an array called %s\n", + name); + return 0; + } + } + for (venum = 0; venum < __be16_to_cpu(ddf->virt->max_vdes); venum++) if (all_ff(ddf->virt->entries[venum].guid)) break; diff --git a/tests/10ddf-create b/tests/10ddf-create index 12c38208..d8dca58b 100644 --- a/tests/10ddf-create +++ b/tests/10ddf-create @@ -10,6 +10,9 @@ mdadm -CR /dev/md/ddf0 -e ddf -n 5 $dev8 $dev9 $dev10 $dev11 $dev12 mdadm -CR r0 -l0 -n5 /dev/md/ddf0 -z 5000 +if mdadm -CR r0 -l1 -n2 /dev/md/ddf0 -z 5000 +then echo >&2 create with same name should fail ; exit 1 +fi mdadm -CR r1 -l1 -n2 /dev/md/ddf0 mdadm -CR r5 -l5 -n3 /dev/md/ddf0 testdev /dev/md/r0 5 5000 512