#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 };
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;
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)
.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
.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
.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