From 023bbe6f017380f4a04c5060feb24dd8cdda9fce Mon Sep 17 00:00:00 2001 From: ilovezfs Date: Fri, 3 Oct 2014 22:20:43 -0700 Subject: [PATCH] Fix zpool create -t ENOENT bug. In userland we need to switch over to the temporary name once the pool has been created, otherwise the root dataset won't mount and the error "cannot open 'the_real_name': dataset does not exist" is printed. Signed-off-by: ilovezfs Signed-off-by: Brian Behlendorf Closes #2760 --- cmd/zpool/zpool_main.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cmd/zpool/zpool_main.c b/cmd/zpool/zpool_main.c index 3b5d2fc42..2b6ff4a65 100644 --- a/cmd/zpool/zpool_main.c +++ b/cmd/zpool/zpool_main.c @@ -814,6 +814,7 @@ zpool_do_create(int argc, char **argv) int c; nvlist_t *nvroot = NULL; char *poolname; + char *tname = NULL; int ret = 1; char *altroot = NULL; char *mountpoint = NULL; @@ -914,6 +915,7 @@ zpool_do_create(int argc, char **argv) if (add_prop_list_default(zpool_prop_to_name( ZPOOL_PROP_CACHEFILE), "none", &props, B_TRUE)) goto errout; + tname = optarg; break; case ':': (void) fprintf(stderr, gettext("missing argument for " @@ -1086,8 +1088,8 @@ zpool_do_create(int argc, char **argv) ret = 1; if (zpool_create(g_zfs, poolname, nvroot, props, fsprops) == 0) { - zfs_handle_t *pool = zfs_open(g_zfs, poolname, - ZFS_TYPE_FILESYSTEM); + zfs_handle_t *pool = zfs_open(g_zfs, + tname ? tname : poolname, ZFS_TYPE_FILESYSTEM); if (pool != NULL) { if (zfs_mount(pool, NULL, 0) == 0) ret = zfs_shareall(pool);