char DefaultConfFile[] = CONFFILE;
char DefaultAltConfFile[] = CONFFILE2;
-char *keywords[] = { "devices", "array",
- "mailaddr", "program", "mailfrom",
- "create",
- NULL };
+enum linetype { Devices, Array, Mailaddr, Mailfrom, Program, CreateDev, Homehost, LTEnd };
+char *keywords[] = {
+ [Devices] = "devices",
+ [Array] = "array",
+ [Mailaddr] = "mailaddr",
+ [Mailfrom] = "mailfrom",
+ [Program] = "program",
+ [CreateDev] = "create",
+ [Homehost] = "homehost",
+ [LTEnd] = NULL
+};
/*
* match_keyword returns an index into the keywords array, or -1 for no match
minor = strtoul(mp, NULL, 10);
name = map_dev(major, minor, 1);
-
+ if (!name)
+ continue;
d = malloc(sizeof(*d));
d->devname = strdup(name);
d->next = rv;
+ d->used = 0;
rv = d;
}
fclose(f);
}
createinfo.uid = strtoul(w+6, &ep, 10);
if (*ep != 0) {
-#ifndef STATIC
struct passwd *pw;
/* must be a name */
pw = getpwnam(w+6);
if (pw)
createinfo.uid = pw->pw_uid;
else
-#endif /* STATIC */
fprintf(stderr, Name ": CREATE user %s not found\n", w+6);
}
} else if (strncasecmp(w, "group=", 6) == 0) {
}
createinfo.gid = strtoul(w+6, &ep, 10);
if (*ep != 0) {
-#ifndef STATIC
struct group *gr;
/* must be a name */
gr = getgrnam(w+6);
if (gr)
createinfo.gid = gr->gr_gid;
else
-#endif /* STATIC */
fprintf(stderr, Name ": CREATE group %s not found\n", w+6);
}
} else if (strncasecmp(w, "mode=", 5) == 0) {
fprintf(stderr, Name ": unrecognised CREATE mode %s\n",
w+5);
}
+ } else if (strncasecmp(w, "metadata=", 9) == 0) {
+ /* style of metadata to use by default */
+ int i;
+ for (i=0; superlist[i] && !createinfo.supertype; i++)
+ createinfo.supertype =
+ superlist[i]->match_metadata_desc(w+9);
+ if (!createinfo.supertype)
+ fprintf(stderr, Name ": metadata format %s unknown, ignoring\n",
+ w+9);
+
} else {
fprintf(stderr, Name ": unrecognised word on CREATE line: %s\n",
w);
}
}
+static char *home_host = NULL;
+void homehostline(char *line)
+{
+ char *w;
+
+ for (w=dl_next(line); w != line ; w=dl_next(w)) {
+ if (home_host == NULL)
+ home_host = strdup(w);
+ else
+ fprintf(stderr, Name ": excess host name on HOMEHOST line: %s - ignored\n",
+ w);
+ }
+}
+
int loaded = 0;
loaded = 1;
while ((line=conf_line(f))) {
switch(match_keyword(line)) {
- case 0: /* DEVICE */
+ case Devices:
devline(line);
break;
- case 1: /* ARRAY */
+ case Array:
arrayline(line);
break;
- case 2: /* MAIL */
+ case Mailaddr:
mailline(line);
break;
- case 3: /* PROGRAM */
- programline(line);
- break;
- case 4: /* MAILFROM */
+ case Mailfrom:
mailfromline(line);
break;
- case 5: /* CREATE */
+ case Program:
+ programline(line);
+ break;
+ case CreateDev:
createline(line);
break;
+ case Homehost:
+ homehostline(line);
+ break;
default:
fprintf(stderr, Name ": Unknown keyword %s\n", line);
}
return alert_program;
}
+char *conf_get_homehost(char *conffile)
+{
+ load_conffile(conffile);
+ return home_host;
+}
+
struct createinfo *conf_get_create_info(char *conffile)
{
load_conffile(conffile);
mddev_dev_t t = malloc(sizeof(*t));
t->devname = strdup(globbuf.gl_pathv[i]);
t->next = dlist;
+ t->used = 0;
dlist = t;
/* printf("one dev is %s\n", t->devname);*/
}