diff options
author | NeilBrown <neilb@suse.de> | 2012-10-04 08:34:20 +0200 |
---|---|---|
committer | NeilBrown <neilb@suse.de> | 2012-10-04 08:34:20 +0200 |
commit | 7103b9b88d8c27989e17c80d7296eda97370dc1e (patch) | |
tree | 225ef68ca743ca2bdf6e70a7581ac82aebfa29db /mdopen.c | |
parent | imsm: Allow to specify controller for --detail-platform. (diff) | |
download | mdadm-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.c | 13 |
1 files changed, 11 insertions, 2 deletions
@@ -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 */ |