summaryrefslogtreecommitdiffstats
path: root/config.c
diff options
context:
space:
mode:
authorNeil Brown <neilb@suse.de>2006-05-16 09:35:06 +0200
committerNeil Brown <neilb@suse.de>2006-05-16 09:35:06 +0200
commitf1ae21c411252787089618fc4a36bd5f06cc8917 (patch)
treecb0f7d3c0c78be1815a9fb9b7537363621a4d753 /config.c
parentWhen updating uuid, update the bitmap as well - external bitmaps (diff)
downloadmdadm-f1ae21c411252787089618fc4a36bd5f06cc8917.tar.xz
mdadm-f1ae21c411252787089618fc4a36bd5f06cc8917.zip
Arrange the 'auto' setting in mdadm.conf can choose default type.
So when you say auto=md or auto=part in mdadm.conf, it give a preference for type of array, but standard name will override. But --auto=md is more insistant. FIXME I'm not at all happy about handling of names that already exist. I don't think that should be removed if the device is active. Signed-off-by: Neil Brown <neilb@suse.de>
Diffstat (limited to 'config.c')
-rw-r--r--config.c29
1 files changed, 17 insertions, 12 deletions
diff --git a/config.c b/config.c
index c48f88e2..269eb11c 100644
--- a/config.c
+++ b/config.c
@@ -254,17 +254,17 @@ struct createinfo createinfo = {
#endif
};
-int parse_auto(char *str, char *msg)
+int parse_auto(char *str, char *msg, int config)
{
int autof;
if (str == NULL || *str == 0)
- autof = -2;
+ autof = 2;
else if (strcasecmp(str,"no")==0)
- autof = -3;
+ autof = 1;
else if (strcasecmp(str,"yes")==0)
- autof = -2;
+ autof = 2;
else if (strcasecmp(str,"md")==0)
- autof = -1;
+ autof = config?5:3;
else {
/* There might be digits, and maybe a hypen, at the end */
char *e = str + strlen(str);
@@ -279,19 +279,24 @@ int parse_auto(char *str, char *msg)
if (e > str && e[-1] == '-')
e--;
len = e - str;
- if ((len == 3 && strncasecmp(str,"mdp",3)==0) ||
- (len == 1 && strncasecmp(str,"p",1)==0) ||
- (len >= 4 && strncasecmp(str,"part",4)==0))
- autof = num;
- else {
+ if ((len == 2 && strncasecmp(str,"md",2)==0)) {
+ autof = config ? 5 : 3;
+ } else if ((len == 3 && strncasecmp(str,"mdp",3)==0)) {
+ autof = config ? 6 : 4;
+ } else if ((len == 1 && strncasecmp(str,"p",1)==0) ||
+ (len >= 4 && strncasecmp(str,"part",4)==0)) {
+ autof = 6;
+ } else {
fprintf(stderr, Name ": %s arg of \"%s\" unrecognised: use no,yes,md,mdp,part\n"
" optionally followed by a number.\n",
msg, str);
exit(2);
}
+ autof |= num << 3;
}
return autof;
}
+
static void createline(char *line)
{
char *w;
@@ -299,7 +304,7 @@ static void createline(char *line)
for (w=dl_next(line); w!=line; w=dl_next(w)) {
if (strncasecmp(w, "auto=", 5) == 0)
- createinfo.autof = parse_auto(w+5, "auto=");
+ createinfo.autof = parse_auto(w+5, "auto=", 1);
else if (strncasecmp(w, "owner=", 6) == 0) {
if (w[6] == 0) {
fprintf(stderr, Name ": missing owner name\n");
@@ -475,7 +480,7 @@ void arrayline(char *line)
fprintf(stderr, Name ": metadata format %s unknown, ignored.\n", w+9);
} else if (strncasecmp(w, "auto=", 5) == 0 ) {
/* whether to create device special files as needed */
- mis.autof = parse_auto(w+5, "auto type");
+ mis.autof = parse_auto(w+5, "auto type", 0);
} else {
fprintf(stderr, Name ": unrecognised word on ARRAY line: %s\n",
w);