X-Git-Url: https://git.camperquake.de/gitweb.cgi?a=blobdiff_plain;f=cmd%2Fzpool%2Fzpool_vdev.c;h=bcfb02eedafa6ddcc339ae42b91a89db18cdaf16;hb=d4055aac3c4fdb6c1b5b1a7b73d20ff716e0a711;hp=d4838ad2dc5d0732742ff7db36a8cfd5426b21ff;hpb=5c1bad0013204d70c5b60713af977bdaa5df1302;p=zfs.git diff --git a/cmd/zpool/zpool_vdev.c b/cmd/zpool/zpool_vdev.c index d4838ad..bcfb02e 100644 --- a/cmd/zpool/zpool_vdev.c +++ b/cmd/zpool/zpool_vdev.c @@ -384,23 +384,9 @@ static int is_shorthand_path(const char *arg, char *path, struct stat64 *statbuf, boolean_t *wholedisk) { - char dirs[5][9] = {"by-id", "by-label", "by-path", "by-uuid", "zpool"}; - int i, err; - - /* /dev/ */ - (void) snprintf(path, MAXPATHLEN, "%s/%s", DISK_ROOT, arg); - *wholedisk = is_whole_disk(path); - err = stat64(path, statbuf); - if (*wholedisk || err == 0) - return (0); - - /* /dev/disk// */ - for (i = 0; i < 5; i++) { - (void) snprintf(path, MAXPATHLEN, "%s/%s/%s", - UDISK_ROOT, dirs[i], arg); + if (zfs_resolve_shortname(arg, path, MAXPATHLEN) == 0) { *wholedisk = is_whole_disk(path); - err = stat64(path, statbuf); - if (*wholedisk || err == 0) + if (*wholedisk || (stat64(path, statbuf) == 0)) return (0); } @@ -513,43 +499,6 @@ make_leaf_vdev(const char *arg, uint64_t is_log) verify(nvlist_add_uint64(vdev, ZPOOL_CONFIG_WHOLE_DISK, (uint64_t)wholedisk) == 0); -#if defined(__sun__) || defined(__sun) - /* - * For a whole disk, defer getting its devid until after labeling it. - */ - if (S_ISBLK(statbuf.st_mode) && !wholedisk) { - /* - * Get the devid for the device. - */ - int fd; - ddi_devid_t devid; - char *minor = NULL, *devid_str = NULL; - - if ((fd = open(path, O_RDONLY|O_EXCL)) < 0) { - (void) fprintf(stderr, gettext("cannot open '%s': " - "%s\n"), path, strerror(errno)); - nvlist_free(vdev); - return (NULL); - } - - if (devid_get(fd, &devid) == 0) { - if (devid_get_minor_name(fd, &minor) == 0 && - (devid_str = devid_str_encode(devid, minor)) != - NULL) { - verify(nvlist_add_string(vdev, - ZPOOL_CONFIG_DEVID, devid_str) == 0); - } - if (devid_str != NULL) - devid_str_free(devid_str); - if (minor != NULL) - devid_str_free(minor); - devid_free(devid); - } - - (void) close(fd); - } -#endif - return (vdev); } @@ -1009,13 +958,7 @@ make_disks(zpool_handle_t *zhp, nvlist_t *nv) * for *-part# to be created. Otherwise just use the normal * syntax for devices in /dev. */ - if (strncmp(path, UDISK_ROOT, strlen(UDISK_ROOT)) == 0) - (void) snprintf(buf, sizeof (buf), - "%s%s%s", path, "-part", FIRST_SLICE); - else - (void) snprintf(buf, sizeof (buf), - "%s%s%s", path, isdigit(path[strlen(path)-1]) ? - "p" : "", FIRST_SLICE); + zfs_append_partition(path, buf, sizeof (buf)); if ((ret = zpool_label_disk_wait(buf, 1000)) != 0) { (void) fprintf(stderr,