config: read /etc/mdadm.conf.d as well as /etc/mdadm.conf
If a configfile is explicitly given, just that file or directory is read. Otherwise we now read both a file /etc/mdadm.conf and a directory /etc/mdadm.conf.d This allows a transition to directory based config, which in turn allows easy control from scripts. Signed-off-by: NeilBrown <neilb@suse.de>
This commit is contained in:
parent
343b7e75e8
commit
9dc70cbc54
33
config.c
33
config.c
|
@ -72,7 +72,9 @@
|
|||
#define CONFFILE2 "/etc/mdadm/mdadm.conf"
|
||||
#endif
|
||||
char DefaultConfFile[] = CONFFILE;
|
||||
char DefaultConfDir[] = CONFFILE ".d";
|
||||
char DefaultAltConfFile[] = CONFFILE2;
|
||||
char DefaultAltConfDir[] = CONFFILE2 ".d";
|
||||
|
||||
enum linetype { Devices, Array, Mailaddr, Mailfrom, Program, CreateDev,
|
||||
Homehost, AutoMode, Policy, PartPolicy, LTEnd };
|
||||
|
@ -792,10 +794,13 @@ void conf_file_or_dir(FILE *f)
|
|||
void load_conffile(void)
|
||||
{
|
||||
FILE *f;
|
||||
char *confdir = NULL;
|
||||
|
||||
if (loaded) return;
|
||||
if (conffile == NULL)
|
||||
if (conffile == NULL) {
|
||||
conffile = DefaultConfFile;
|
||||
confdir = DefaultConfDir;
|
||||
}
|
||||
|
||||
if (strcmp(conffile, "none") == 0) {
|
||||
loaded = 1;
|
||||
|
@ -819,18 +824,24 @@ void load_conffile(void)
|
|||
if (f == NULL &&
|
||||
conffile == DefaultConfFile) {
|
||||
f = fopen(DefaultAltConfFile, "r");
|
||||
if (f)
|
||||
if (f) {
|
||||
conffile = DefaultAltConfFile;
|
||||
confdir = DefaultAltConfDir;
|
||||
}
|
||||
}
|
||||
if (f) {
|
||||
loaded = 1;
|
||||
conf_file_or_dir(f);
|
||||
fclose(f);
|
||||
}
|
||||
if (confdir) {
|
||||
f = fopen(confdir, "r");
|
||||
if (f) {
|
||||
loaded = 1;
|
||||
conf_file_or_dir(f);
|
||||
fclose(f);
|
||||
}
|
||||
}
|
||||
if (f == NULL)
|
||||
return;
|
||||
|
||||
loaded = 1;
|
||||
conf_file_or_dir(f);
|
||||
|
||||
fclose(f);
|
||||
|
||||
/* printf("got file\n"); */
|
||||
}
|
||||
|
||||
char *conf_get_mailaddr(void)
|
||||
|
|
28
mdadm.8.in
28
mdadm.8.in
|
@ -263,16 +263,22 @@ the exact meaning of this option in different contexts.
|
|||
|
||||
.TP
|
||||
.BR \-c ", " \-\-config=
|
||||
Specify the config file. Default is to use
|
||||
.BR /etc/mdadm.conf ,
|
||||
or if that is missing then
|
||||
.BR /etc/mdadm/mdadm.conf .
|
||||
Specify the config file or directory. Default is to use
|
||||
.B /etc/mdadm.conf
|
||||
and
|
||||
.BR /etc/mdadm.conf.d ,
|
||||
or if those are missing then
|
||||
.B /etc/mdadm/mdadm.conf
|
||||
and
|
||||
.BR /etc/mdadm/mdadm.conf.d .
|
||||
If the config file given is
|
||||
.B "partitions"
|
||||
then nothing will be read, but
|
||||
.I mdadm
|
||||
will act as though the config file contained exactly
|
||||
.B "DEVICE partitions containers"
|
||||
.br
|
||||
.B " DEVICE partitions containers"
|
||||
.br
|
||||
and will read
|
||||
.B /proc/partitions
|
||||
to find a list of devices to scan, and
|
||||
|
@ -284,6 +290,13 @@ is given for the config file, then
|
|||
.I mdadm
|
||||
will act as though the config file were empty.
|
||||
|
||||
If the name given is of a directory, then
|
||||
.I mdadm
|
||||
will collect all the files contained in the directory with a name ending
|
||||
in
|
||||
.BR .conf ,
|
||||
sort them lexically, and process all of those files as config files.
|
||||
|
||||
.TP
|
||||
.BR \-s ", " \-\-scan
|
||||
Scan config file or
|
||||
|
@ -2976,6 +2989,11 @@ they contain MD super block, and gives identifying information
|
|||
.BR mdadm.conf (5)
|
||||
for more details.
|
||||
|
||||
.SS /etc/mdadm.conf.d
|
||||
|
||||
A directory containing configuration files which are read in lexical
|
||||
order.
|
||||
|
||||
.SS {MAP_PATH}
|
||||
When
|
||||
.B \-\-incremental
|
||||
|
|
Loading…
Reference in New Issue