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"
|
#define CONFFILE2 "/etc/mdadm/mdadm.conf"
|
||||||
#endif
|
#endif
|
||||||
char DefaultConfFile[] = CONFFILE;
|
char DefaultConfFile[] = CONFFILE;
|
||||||
|
char DefaultConfDir[] = CONFFILE ".d";
|
||||||
char DefaultAltConfFile[] = CONFFILE2;
|
char DefaultAltConfFile[] = CONFFILE2;
|
||||||
|
char DefaultAltConfDir[] = CONFFILE2 ".d";
|
||||||
|
|
||||||
enum linetype { Devices, Array, Mailaddr, Mailfrom, Program, CreateDev,
|
enum linetype { Devices, Array, Mailaddr, Mailfrom, Program, CreateDev,
|
||||||
Homehost, AutoMode, Policy, PartPolicy, LTEnd };
|
Homehost, AutoMode, Policy, PartPolicy, LTEnd };
|
||||||
|
@ -792,10 +794,13 @@ void conf_file_or_dir(FILE *f)
|
||||||
void load_conffile(void)
|
void load_conffile(void)
|
||||||
{
|
{
|
||||||
FILE *f;
|
FILE *f;
|
||||||
|
char *confdir = NULL;
|
||||||
|
|
||||||
if (loaded) return;
|
if (loaded) return;
|
||||||
if (conffile == NULL)
|
if (conffile == NULL) {
|
||||||
conffile = DefaultConfFile;
|
conffile = DefaultConfFile;
|
||||||
|
confdir = DefaultConfDir;
|
||||||
|
}
|
||||||
|
|
||||||
if (strcmp(conffile, "none") == 0) {
|
if (strcmp(conffile, "none") == 0) {
|
||||||
loaded = 1;
|
loaded = 1;
|
||||||
|
@ -819,18 +824,24 @@ void load_conffile(void)
|
||||||
if (f == NULL &&
|
if (f == NULL &&
|
||||||
conffile == DefaultConfFile) {
|
conffile == DefaultConfFile) {
|
||||||
f = fopen(DefaultAltConfFile, "r");
|
f = fopen(DefaultAltConfFile, "r");
|
||||||
if (f)
|
if (f) {
|
||||||
conffile = DefaultAltConfFile;
|
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)
|
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
|
.TP
|
||||||
.BR \-c ", " \-\-config=
|
.BR \-c ", " \-\-config=
|
||||||
Specify the config file. Default is to use
|
Specify the config file or directory. Default is to use
|
||||||
.BR /etc/mdadm.conf ,
|
.B /etc/mdadm.conf
|
||||||
or if that is missing then
|
and
|
||||||
.BR /etc/mdadm/mdadm.conf .
|
.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
|
If the config file given is
|
||||||
.B "partitions"
|
.B "partitions"
|
||||||
then nothing will be read, but
|
then nothing will be read, but
|
||||||
.I mdadm
|
.I mdadm
|
||||||
will act as though the config file contained exactly
|
will act as though the config file contained exactly
|
||||||
.B "DEVICE partitions containers"
|
.br
|
||||||
|
.B " DEVICE partitions containers"
|
||||||
|
.br
|
||||||
and will read
|
and will read
|
||||||
.B /proc/partitions
|
.B /proc/partitions
|
||||||
to find a list of devices to scan, and
|
to find a list of devices to scan, and
|
||||||
|
@ -284,6 +290,13 @@ is given for the config file, then
|
||||||
.I mdadm
|
.I mdadm
|
||||||
will act as though the config file were empty.
|
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
|
.TP
|
||||||
.BR \-s ", " \-\-scan
|
.BR \-s ", " \-\-scan
|
||||||
Scan config file or
|
Scan config file or
|
||||||
|
@ -2976,6 +2989,11 @@ they contain MD super block, and gives identifying information
|
||||||
.BR mdadm.conf (5)
|
.BR mdadm.conf (5)
|
||||||
for more details.
|
for more details.
|
||||||
|
|
||||||
|
.SS /etc/mdadm.conf.d
|
||||||
|
|
||||||
|
A directory containing configuration files which are read in lexical
|
||||||
|
order.
|
||||||
|
|
||||||
.SS {MAP_PATH}
|
.SS {MAP_PATH}
|
||||||
When
|
When
|
||||||
.B \-\-incremental
|
.B \-\-incremental
|
||||||
|
|
Loading…
Reference in New Issue