]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - config.c
Use O_DIRECT to read bitmap files.
[thirdparty/mdadm.git] / config.c
index a5d5edd2a61691d1f7a2bfa1d593cb8fbb649710..70b798eb86535c5127f9d205b82ab7bfcfe23b54 100644 (file)
--- a/config.c
+++ b/config.c
 #ifndef CONFFILE
 #define CONFFILE "/etc/mdadm.conf"
 #endif
+#ifndef CONFFILE2
+/* for Debian compatibility .... */
+#define CONFFILE2 "/etc/mdadm/mdadm.conf"
+#endif
 char DefaultConfFile[] = CONFFILE;
+char DefaultAltConfFile[] = CONFFILE2;
 
 char *keywords[] = { "device", "array", "mailaddr", "program", NULL };
 
@@ -214,6 +219,8 @@ mddev_dev_t load_partitions(void)
        while (fgets(buf, 1024, f)) {
                int major, minor;
                char *name, *mp;
+               mddev_dev_t d;
+
                buf[1023] = '\0';
                if (buf[0] != ' ')
                        continue;
@@ -222,15 +229,12 @@ mddev_dev_t load_partitions(void)
                        continue;
                minor = strtoul(mp, NULL, 10);
 
-               name = map_dev(major, minor);
-               if (name) {
-                       mddev_dev_t d;
+               name = map_dev(major, minor, 1);
 
-                       d = malloc(sizeof(*d));
-                       d->devname = strdup(name);
-                       d->next = rv;
-                       rv = d;
-               }
+               d = malloc(sizeof(*d));
+               d->devname = strdup(name);
+               d->next = rv;
+               rv = d;
        }
        fclose(f);
        return rv;
@@ -269,7 +273,7 @@ void arrayline(char *line)
        mis.super_minor = UnSet;
        mis.level = UnSet;
        mis.raid_disks = UnSet;
-       mis.spare_disks = UnSet;
+       mis.spare_disks = 0;
        mis.devices = NULL;
        mis.devname = NULL;
        mis.spare_group = NULL;
@@ -277,6 +281,7 @@ void arrayline(char *line)
        mis.next = NULL;
        mis.st = NULL;
        mis.bitmap_fd = -1;
+       mis.bitmap_file = NULL;
        mis.name[0] = 0;
 
        for (w=dl_next(line); w!=line; w=dl_next(w)) {
@@ -317,6 +322,13 @@ void arrayline(char *line)
                        else
                                strcpy(mis.name, w+5);
 
+               } else if (strncasecmp(w, "bitmap=", 7) == 0) {
+                       if (mis.bitmap_file)
+                               fprintf(stderr, Name ": only specify bitmap file once. %s ignored\n",
+                                       w);
+                       else
+                               mis.bitmap_file = w+7;
+
                } else if (strncasecmp(w, "devices=", 8 ) == 0 ) {
                        if (mis.devices)
                                fprintf(stderr, Name ": only specify devices once (use a comma separated list). %s ignored\n",
@@ -452,7 +464,18 @@ void load_conffile(char *conffile)
                return;
        }
        f = fopen(conffile, "r");
-       if (f ==NULL)
+       /* 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;