summaryrefslogtreecommitdiffstats
path: root/mdopen.c
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2012-10-04 08:34:20 +0200
committerNeilBrown <neilb@suse.de>2012-10-04 08:34:20 +0200
commit7103b9b88d8c27989e17c80d7296eda97370dc1e (patch)
tree225ef68ca743ca2bdf6e70a7581ac82aebfa29db /mdopen.c
parentimsm: Allow to specify controller for --detail-platform. (diff)
downloadmdadm-7103b9b88d8c27989e17c80d7296eda97370dc1e.tar.xz
mdadm-7103b9b88d8c27989e17c80d7296eda97370dc1e.zip
Handles spaces in array names better.
1/ When printing the "name=" entry for --brief output, enclose name in quotes if it contains spaces etc. Quotes are already supported for reading mdadm.conf 2/ When a name is used as a device name, translate spaces and tabs to '_', as well as the current translation of '/' to '-'. Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'mdopen.c')
-rw-r--r--mdopen.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/mdopen.c b/mdopen.c
index 58e359aa..61eda812 100644
--- a/mdopen.c
+++ b/mdopen.c
@@ -286,8 +286,17 @@ int create_mddev(char *dev, char *name, int autof, int trustworthy,
int cnlen;
strncpy(cname, name, 200);
cname[200] = 0;
- while ((cp = strchr(cname, '/')) != NULL)
- *cp = '-';
+ for (cp = cname; *cp ; cp++)
+ switch (*cp) {
+ case '/':
+ *cp = '-';
+ break;
+ case ' ':
+ case '\t':
+ *cp = '_';
+ break;
+ }
+
if (trustworthy == LOCAL ||
(trustworthy == FOREIGN && strchr(cname, ':') != NULL)) {
/* Only need suffix if there is a conflict */