From 215bb3f77627d818d5bc3eaca190212d491e1fcf Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Tue, 4 Nov 2008 20:50:38 +1100 Subject: Incremental: adjust to the new naming scheme. --incremental now uses exactly the same create_mddev that other code uses. --- mdopen.c | 80 ---------------------------------------------------------------- 1 file changed, 80 deletions(-) (limited to 'mdopen.c') diff --git a/mdopen.c b/mdopen.c index 4c0714d..ae3620a 100644 --- a/mdopen.c +++ b/mdopen.c @@ -360,83 +360,3 @@ int open_mddev(char *dev, int report_errors) } return mdfd; } - - -int create_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 - * the name into '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); - else if (name && *name && name[0] && strchr(name,'/') == NULL) { - char *n = strchr(name, ':'); - if (n) n++; else n = name; - if (isdigit(*n) && devnum < 0) - sprintf(chosen_name, "/dev/md/d%s", n); - else - sprintf(chosen_name, "/dev/md/%s", n); - } else { - if (devnum >= 0) - sprintf(chosen_name, "/dev/md%d", devnum); - else - sprintf(chosen_name, "/dev/md/d%d", -1-devnum); - } - if (devnum >= 0) { - major_num = MD_MAJOR; - minor_num = devnum; - } else { - major_num = get_mdp_major(); - minor_num = (-1-devnum) << 6; - } - if (stat(chosen_name, &stb) == 0) { - /* It already exists. Check it is right. */ - if ( ! S_ISBLK(stb.st_mode) || - stb.st_rdev != makedev(major_num, minor_num)) { - errno = EEXIST; - 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) { - 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; - } - /* FIXME chown/chmod ?? */ - } - - /* Simple locking to avoid --incr being called for the same - * array multiple times in parallel. - */ - for (i = 0; i < 25 ; i++) { - int fd; - - fd = open(chosen_name, O_RDWR|O_EXCL); - if (fd >= 0 || errno != EBUSY) { - if (devnum < 0) - make_parts(chosen_name, parts); - return fd; - } - usleep(200000); - } - return -1; -} -- cgit