Bill Nottingham: Create /dev/md if needed and it doesn't exist.

Martin F. Krafft madduck at alioth.debian.org
Tue Jun 24 22:02:09 UTC 2008


Module: mdadm
Branch: master
Commit: 62552fdfccf7db17edb136e504703e6b18cec72a
URL:    http://git.debian.org/?p=pkg-mdadm/mdadm.git;a=commit;h=62552fdfccf7db17edb136e504703e6b18cec72a

Author: Bill Nottingham <notting at redhat.com>
Date:   Mon May  5 19:44:01 2008 +1000

Create /dev/md if needed and it doesn't exist.

From: Bill Nottingham <notting at redhat.com>

---

 mdopen.c |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/mdopen.c b/mdopen.c
index 55252dc..ec34e91 100644
--- 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;




More information about the pkg-mdadm-commits mailing list