Make device-special files for partitions when using --incremental
authorNeil Brown <neilb@suse.de>
Mon, 5 May 2008 11:55:39 +0000 (21:55 +1000)
committerNeil Brown <neilb@suse.de>
Mon, 5 May 2008 11:55:39 +0000 (21:55 +1000)
Incremental.c
mdadm.h
mdopen.c

index b54c4fc..0fb9afd 100644 (file)
@@ -259,7 +259,7 @@ int Incremental(char *devname, int verbose, int runstop,
        mdfd = open_mddev_devnum(match ? match->devname : NULL,
                                 devnum,
                                 info.name,
-                                chosen_name);
+                                chosen_name, autof >> 3);
        if (mdfd < 0) {
                fprintf(stderr, Name ": failed to open %s: %s.\n",
                        chosen_name, strerror(errno));
@@ -652,7 +652,8 @@ int IncrementalScan(int verbose)
                mdu_array_info_t array;
                mdu_bitmap_file_t bmf;
                struct mdinfo *sra;
-               int mdfd = open_mddev_devnum(me->path, me->devnum, NULL, path);
+               int mdfd = open_mddev_devnum(me->path, me->devnum,
+                                            NULL, path, 0);
                if (mdfd < 0)
                        continue;
                if (ioctl(mdfd, GET_ARRAY_INFO, &array) == 0 ||
diff --git a/mdadm.h b/mdadm.h
index 2f62c41..0d73c17 100644 (file)
--- a/mdadm.h
+++ b/mdadm.h
@@ -523,7 +523,7 @@ extern char DefaultConfFile[];
 
 extern int open_mddev(char *dev, int autof);
 extern int open_mddev_devnum(char *devname, int devnum, char *name,
-                            char *chosen_name);
+                            char *chosen_name, int parts);
 
 
 #define        LEVEL_MULTIPATH         (-4)
index fe98370..448a9eb 100644 (file)
--- a/mdopen.c
+++ b/mdopen.c
@@ -268,7 +268,8 @@ int open_mddev(char *dev, int autof)
 }
 
 
-int open_mddev_devnum(char *devname, int devnum, char *name, char *chosen_name)
+int open_mddev_devnum(char *devname, int devnum, char *name,
+                     char *chosen_name, int parts)
 {
        /* Open the md device with number 'devnum', possibly using 'devname',
         * possibly constructing a name with 'name', but in any case, copying
@@ -277,6 +278,7 @@ int open_mddev_devnum(char *devname, int devnum, char *name, char *chosen_name)
        int major_num, minor_num;
        struct stat stb;
        int i;
+       struct createinfo *ci = conf_get_create_info();
 
        if (devname)
                strcpy(chosen_name, devname);
@@ -312,7 +314,6 @@ int open_mddev_devnum(char *devname, int devnum, char *name, char *chosen_name)
                 * in /dev/md/, we make sure the directory exists.
                 */
                if (strncmp(chosen_name, "/dev/md/", 8) == 0) {
-                       struct createinfo *ci = conf_get_create_info();
                        if (mkdir("/dev/md",0700)==0) {
                                if (chown("/dev/md", ci->uid, ci->gid))
                                        perror("chown /dev/md");
@@ -336,8 +337,11 @@ int open_mddev_devnum(char *devname, int devnum, char *name, char *chosen_name)
                int fd;
 
                fd = open(chosen_name, O_RDWR|O_EXCL);
-               if (fd >= 0 || errno != EBUSY)
+               if (fd >= 0 || errno != EBUSY) {
+                       if (devnum < 0)
+                               make_parts(chosen_name, parts, ci->symlinks);
                        return fd;
+               }
                usleep(200000);
        }
        return -1;