]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Create /dev/md if needed and it doesn't exist.
authorBill Nottingham <notting@redhat.com>
Mon, 5 May 2008 09:44:01 +0000 (19:44 +1000)
committerNeil Brown <neilb@suse.de>
Mon, 5 May 2008 09:44:01 +0000 (19:44 +1000)
From: Bill Nottingham <notting@redhat.com>

mdopen.c

index 55252dc10fcb36898f733ccd4319d5c02a02b353..ec34e916f8e9fdd996c88616e582f18f4aa55c2e 100644 (file)
--- a/mdopen.c
+++ b/mdopen.c
@@ -333,6 +333,20 @@ int open_mddev_devnum(char *devname, int devnum, char *name, char *chosen_name)
                        return -1;
                }
        } else {
+               /* special case: if --incremental is suggesting a 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");
+                               if (chmod("/dev/md", ci->mode|
+                                                 ((ci->mode>>2) & 0111)))
+                                       perror("chmod /dev/md");
+                       }
+               }
+
                if (mknod(chosen_name, S_IFBLK | 0600,
                          makedev(major_num, minor_num)) != 0) {
                        return -1;