diff options
-rw-r--r-- | cmd/zpool/zpool_main.c | 5 | ||||
-rw-r--r-- | lib/libzfs/libzfs_pool.c | 11 |
2 files changed, 12 insertions, 4 deletions
diff --git a/cmd/zpool/zpool_main.c b/cmd/zpool/zpool_main.c index b6b6f0cf4..d23903aec 100644 --- a/cmd/zpool/zpool_main.c +++ b/cmd/zpool/zpool_main.c @@ -2216,7 +2216,8 @@ show_import(nvlist_t *config) (void) printf(gettext(" config:\n\n")); - cb.cb_namewidth = max_width(NULL, nvroot, 0, 0, VDEV_NAME_TYPE_ID); + cb.cb_namewidth = max_width(NULL, nvroot, 0, strlen(name), + VDEV_NAME_TYPE_ID); if (cb.cb_namewidth < 10) cb.cb_namewidth = 10; @@ -3925,7 +3926,7 @@ get_namewidth(zpool_handle_t *zhp, void *data) &nvroot) == 0); unsigned int poolname_len = strlen(zpool_get_name(zhp)); if (!cb->cb_verbose) - cb->cb_namewidth = poolname_len; + cb->cb_namewidth = MAX(poolname_len, cb->cb_namewidth); else cb->cb_namewidth = MAX(poolname_len, max_width(zhp, nvroot, 0, cb->cb_namewidth, diff --git a/lib/libzfs/libzfs_pool.c b/lib/libzfs/libzfs_pool.c index aa77b547a..46fb99aff 100644 --- a/lib/libzfs/libzfs_pool.c +++ b/lib/libzfs/libzfs_pool.c @@ -3588,6 +3588,14 @@ zpool_vdev_name(libzfs_handle_t *hdl, zpool_handle_t *zhp, nvlist_t *nv, char buf[PATH_BUF_LEN]; char tmpbuf[PATH_BUF_LEN]; + /* + * vdev_name will be "root"/"root-0" for the root vdev, but it is the + * zpool name that will be displayed to the user. + */ + verify(nvlist_lookup_string(nv, ZPOOL_CONFIG_TYPE, &type) == 0); + if (zhp != NULL && strcmp(type, "root") == 0) + return (zfs_strdup(hdl, zpool_get_name(zhp))); + env = getenv("ZPOOL_VDEV_NAME_PATH"); if (env && (strtoul(env, NULL, 0) > 0 || !strncasecmp(env, "YES", 3) || !strncasecmp(env, "ON", 2))) @@ -3669,7 +3677,6 @@ zpool_vdev_name(libzfs_handle_t *hdl, zpool_handle_t *zhp, nvlist_t *nv, /* * For a block device only use the name. */ - verify(nvlist_lookup_string(nv, ZPOOL_CONFIG_TYPE, &type) == 0); if ((strcmp(type, VDEV_TYPE_DISK) == 0) && !(name_flags & VDEV_NAME_PATH)) { path = strrchr(path, '/'); @@ -3684,7 +3691,7 @@ zpool_vdev_name(libzfs_handle_t *hdl, zpool_handle_t *zhp, nvlist_t *nv, return (zfs_strip_partition(path)); } } else { - verify(nvlist_lookup_string(nv, ZPOOL_CONFIG_TYPE, &path) == 0); + path = type; /* * If it's a raidz device, we need to stick in the parity level. |