diff options
author | NeilBrown <neilb@suse.de> | 2008-11-04 10:50:38 +0100 |
---|---|---|
committer | NeilBrown <neilb@suse.de> | 2008-11-04 10:50:38 +0100 |
commit | 215bb3f77627d818d5bc3eaca190212d491e1fcf (patch) | |
tree | eaf98beb68dc96c0a0d7114f42d7a0f0c98d0d62 /mdopen.c | |
parent | mdopen: Restore creation of partition devices and symlink. (diff) | |
download | mdadm-215bb3f77627d818d5bc3eaca190212d491e1fcf.tar.xz mdadm-215bb3f77627d818d5bc3eaca190212d491e1fcf.zip |
Incremental: adjust to the new naming scheme.
--incremental now uses exactly the same create_mddev that
other code uses.
Diffstat (limited to 'mdopen.c')
-rw-r--r-- | mdopen.c | 80 |
1 files changed, 0 insertions, 80 deletions
@@ -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; -} |