void conf_file(FILE *f) { char *line; while ((line=conf_line(f))) { switch(match_keyword(line)) { case Devices: devline(line); break; case Array: arrayline(line); break; case Mailaddr: mailline(line); break; case Mailfrom: mailfromline(line); break; case Program: programline(line); break; case CreateDev: createline(line); break; case Homehost: homehostline(line); break; case AutoMode: autoline(line); break; case Policy: policyline(line, rule_policy); break; case PartPolicy: policyline(line, rule_part); break; default: pr_err("Unknown keyword %s\n", line); } free_line(line); } }
void load_conffile(char *conffile) { FILE *f; char *line; if (loaded) return; if (conffile == NULL) conffile = DefaultConfFile; if (strcmp(conffile, "none") == 0) { loaded = 1; return; } if (strcmp(conffile, "partitions")==0) { char *list = dl_strdup("DEV"); dl_init(list); dl_add(list, dl_strdup("partitions")); devline(list); free_line(list); loaded = 1; return; } f = fopen(conffile, "r"); /* Debian chose to relocate mdadm.conf into /etc/mdadm/. * To allow Debian users to compile from clean source and still * have a working mdadm, we read /etc/mdadm/mdadm.conf * if /etc/mdadm.conf doesn't exist */ if (f == NULL && conffile == DefaultConfFile) { f = fopen(DefaultAltConfFile, "r"); if (f) conffile = DefaultAltConfFile; } if (f == NULL) return; loaded = 1; while ((line=conf_line(f))) { switch(match_keyword(line)) { case 0: /* DEVICE */ devline(line); break; case 1: /* ARRAY */ arrayline(line); break; case 2: /* MAIL */ mailline(line); break; case 3: /* PROGRAM */ programline(line); break; default: fprintf(stderr, Name ": Unknown keyword %s\n", line); } free_line(line); } fclose(f); /* printf("got file\n"); */ }
void load_conffile(void) { FILE *f; char *line; if (loaded) return; if (conffile == NULL) conffile = DefaultConfFile; if (strcmp(conffile, "none") == 0) { loaded = 1; return; } if (strcmp(conffile, "partitions")==0) { char *list = dl_strdup("DEV"); dl_init(list); dl_add(list, dl_strdup("partitions")); devline(list); free_line(list); loaded = 1; return; } f = fopen(conffile, "r"); /* Debian chose to relocate mdadm.conf into /etc/mdadm/. * To allow Debian users to compile from clean source and still * have a working mdadm, we read /etc/mdadm/mdadm.conf * if /etc/mdadm.conf doesn't exist */ if (f == NULL && conffile == DefaultConfFile) { f = fopen(DefaultAltConfFile, "r"); if (f) conffile = DefaultAltConfFile; } if (f == NULL) return; loaded = 1; while ((line=conf_line(f))) { switch(match_keyword(line)) { case Devices: devline(line); break; case Array: arrayline(line); break; case Mailaddr: mailline(line); break; case Mailfrom: mailfromline(line); break; case Program: programline(line); break; case CreateDev: createline(line); break; case Homehost: homehostline(line); break; default: fprintf(stderr, Name ": Unknown keyword %s\n", line); } free_line(line); } fclose(f); /* printf("got file\n"); */ }