diff options
author | NeilBrown <neilb@suse.de> | 2013-09-03 00:47:57 +0200 |
---|---|---|
committer | NeilBrown <neilb@suse.de> | 2013-09-03 00:47:57 +0200 |
commit | 15af96928334a5a050bd12b3b3479f1b3afee140 (patch) | |
tree | b983d1303791552cf8eb1bd680ab39d54f2d370a /config.c | |
parent | mdmon: make sure we set safe_mode on SIGTERM. (diff) | |
download | mdadm-15af96928334a5a050bd12b3b3479f1b3afee140.tar.xz mdadm-15af96928334a5a050bd12b3b3479f1b3afee140.zip |
Config: factor reading of file out into separate function.
This will make it easier to read multiple files in a conf.d/
Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'config.c')
-rw-r--r-- | config.c | 77 |
1 files changed, 41 insertions, 36 deletions
@@ -686,44 +686,9 @@ void set_conffile(char *file) conffile = file; } -void load_conffile(void) +void conf_file(FILE *f) { - 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: @@ -761,6 +726,46 @@ void load_conffile(void) } free_line(line); } +} + +void load_conffile(void) +{ + FILE *f; + + 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; + conf_file(f); fclose(f); |