summaryrefslogtreecommitdiff
path: root/config.c
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2009-05-11 15:18:35 +1000
committerNeilBrown <neilb@suse.de>2009-05-11 15:18:35 +1000
commitdb2d001cee64cd330cc2ab24ddefed48eb67fc7b (patch)
treefc0b9dc7a4bfac82f6a823d8e70b59df8a0eac8b /config.c
parentaa7c284c06ba046039f60ceb4e3fb422967d354f (diff)
config: allow Array line to contain array name without /dev/md/ prefix.
For consistency with --create and --assemble, allow the array name given in mdadm.conf to exclude the "/dev/md/" prefix. So e.g. ARRAY home uuid=whatever is treated like ARRAY /dev/md/home uuid=whatever Also exclude names which create_mddev will reject. Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'config.c')
-rw-r--r--config.c45
1 files changed, 40 insertions, 5 deletions
diff --git a/config.c b/config.c
index fd757ad0..41428ae9 100644
--- a/config.c
+++ b/config.c
@@ -448,6 +448,17 @@ void devline(char *line)
mddev_ident_t mddevlist = NULL;
mddev_ident_t *mddevlp = &mddevlist;
+static int is_number(char *w)
+{
+ /* check if there are 1 or more digits and nothing else */
+ int digits = 0;
+ while (*w && isdigit(*w)) {
+ digits++;
+ w++;
+ }
+ return (digits && ! *w);
+}
+
void arrayline(char *line)
{
char *w;
@@ -473,11 +484,35 @@ void arrayline(char *line)
mis.member = NULL;
for (w=dl_next(line); w!=line; w=dl_next(w)) {
- if (w[0] == '/' || strcasecmp(w, "<ignore>") == 0) {
- if (mis.devname)
- fprintf(stderr, Name ": only give one device per ARRAY line: %s and %s\n",
- mis.devname, w);
- else mis.devname = w;
+ if (w[0] == '/' || strchr(w, '=') == NULL) {
+ /* This names the device, or is '<ignore>'.
+ * The rules match those in create_mddev.
+ * 'w' must be:
+ * /dev/md/{anything}
+ * /dev/mdNN
+ * /dev/md_dNN
+ * <ignore>
+ * or anything that doesn't start '/' or '<'
+ */
+ if (strcasecmp(w, "<ignore>") == 0 ||
+ strncmp(w, "/dev/md/", 8) == 0 ||
+ (w[0] != '/' && w[0] != '<') ||
+ (strncmp(w, "/dev/md", 7) == 0 &&
+ is_number(w+7)) ||
+ (strncmp(w, "/dev/md_d", 9) == 0 &&
+ is_number(w+9))
+ ) {
+ /* This is acceptable */;
+ if (mis.devname)
+ fprintf(stderr, Name ": only give one "
+ "device per ARRAY line: %s and %s\n",
+ mis.devname, w);
+ else
+ mis.devname = w;
+ }else {
+ fprintf(stderr, Name ": %s is an invalid name for "
+ "an md device - ignored.\n", w);
+ }
} else if (strncasecmp(w, "uuid=", 5)==0 ) {
if (mis.uuid_set)
fprintf(stderr, Name ": only specify uuid once, %s ignored.\n",