From: Bill Nottingham Date: Mon, 5 May 2008 09:44:01 +0000 (+1000) Subject: Create /dev/md if needed and it doesn't exist. X-Git-Tag: mdadm-2.6.5~15 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=62552fdfccf7db17edb136e504703e6b18cec72a;p=thirdparty%2Fmdadm.git Create /dev/md if needed and it doesn't exist. From: Bill Nottingham --- diff --git a/mdopen.c b/mdopen.c index 55252dc1..ec34e916 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;