summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWill Andrews <will@firepipe.net>2013-06-11 09:13:47 -0800
committerChristopher Siden <chris.siden@delphix.com>2013-06-11 10:13:47 -0700
commit8b713775314bbbf24edd503b4869342d8711ce95 (patch)
tree29608e1b202e1f81737ebfe71817068f5f415b44
parentfc7a6e3fefc649cb65c8e2a35d194781445008b0 (diff)
downloadillumos-joyent-8b713775314bbbf24edd503b4869342d8711ce95.tar.gz
3745 zpool create should treat -O mountpoint and -m the same
3811 zpool create -o altroot=/xyz -O mountpoint=/mnt ignores the mountpoint option Reviewed by: Matthew Ahrens <mahrens@delphix.com> Approved by: Christopher Siden <christopher.siden@delphix.com>
-rw-r--r--usr/src/cmd/zpool/zpool_main.c37
-rw-r--r--usr/src/lib/libzfs/common/libzfs_pool.c16
-rwxr-xr-x[-rw-r--r--]usr/src/test/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_005_pos.ksh8
3 files changed, 35 insertions, 26 deletions
diff --git a/usr/src/cmd/zpool/zpool_main.c b/usr/src/cmd/zpool/zpool_main.c
index b1326e962f..833aabcde7 100644
--- a/usr/src/cmd/zpool/zpool_main.c
+++ b/usr/src/cmd/zpool/zpool_main.c
@@ -677,6 +677,7 @@ zpool_do_create(int argc, char **argv)
goto errout;
break;
case 'm':
+ /* Equivalent to -O mountpoint=optarg */
mountpoint = optarg;
break;
case 'o':
@@ -715,8 +716,18 @@ zpool_do_create(int argc, char **argv)
*propval = '\0';
propval++;
- if (add_prop_list(optarg, propval, &fsprops, B_FALSE))
+ /*
+ * Mountpoints are checked and then added later.
+ * Uniquely among properties, they can be specified
+ * more than once, to avoid conflict with -m.
+ */
+ if (0 == strcmp(optarg,
+ zfs_prop_to_name(ZFS_PROP_MOUNTPOINT))) {
+ mountpoint = propval;
+ } else if (add_prop_list(optarg, propval, &fsprops,
+ B_FALSE)) {
goto errout;
+ }
break;
case ':':
(void) fprintf(stderr, gettext("missing argument for "
@@ -833,6 +844,18 @@ zpool_do_create(int argc, char **argv)
}
}
+ /*
+ * Now that the mountpoint's validity has been checked, ensure that
+ * the property is set appropriately prior to creating the pool.
+ */
+ if (mountpoint != NULL) {
+ ret = add_prop_list(zfs_prop_to_name(ZFS_PROP_MOUNTPOINT),
+ mountpoint, &fsprops, B_FALSE);
+ if (ret != 0)
+ goto errout;
+ }
+
+ ret = 1;
if (dryrun) {
/*
* For a dry run invocation, print out a basic message and run
@@ -867,21 +890,19 @@ zpool_do_create(int argc, char **argv)
if (nvlist_exists(props, propname))
continue;
- if (add_prop_list(propname, ZFS_FEATURE_ENABLED,
- &props, B_TRUE) != 0)
+ ret = add_prop_list(propname,
+ ZFS_FEATURE_ENABLED, &props, B_TRUE);
+ if (ret != 0)
goto errout;
}
}
+
+ ret = 1;
if (zpool_create(g_zfs, poolname,
nvroot, props, fsprops) == 0) {
zfs_handle_t *pool = zfs_open(g_zfs, poolname,
ZFS_TYPE_FILESYSTEM);
if (pool != NULL) {
- if (mountpoint != NULL)
- verify(zfs_prop_set(pool,
- zfs_prop_to_name(
- ZFS_PROP_MOUNTPOINT),
- mountpoint) == 0);
if (zfs_mount(pool, NULL, 0) == 0)
ret = zfs_shareall(pool);
zfs_close(pool);
diff --git a/usr/src/lib/libzfs/common/libzfs_pool.c b/usr/src/lib/libzfs/common/libzfs_pool.c
index 1c6fb371e3..19d1ff7bdb 100644
--- a/usr/src/lib/libzfs/common/libzfs_pool.c
+++ b/usr/src/lib/libzfs/common/libzfs_pool.c
@@ -1080,7 +1080,6 @@ zpool_create(libzfs_handle_t *hdl, const char *pool, nvlist_t *nvroot,
nvlist_t *zc_fsprops = NULL;
nvlist_t *zc_props = NULL;
char msg[1024];
- char *altroot;
int ret = -1;
(void) snprintf(msg, sizeof (msg), dgettext(TEXT_DOMAIN,
@@ -1179,21 +1178,6 @@ zpool_create(libzfs_handle_t *hdl, const char *pool, nvlist_t *nvroot,
}
}
- /*
- * If this is an alternate root pool, then we automatically set the
- * mountpoint of the root dataset to be '/'.
- */
- if (nvlist_lookup_string(props, zpool_prop_to_name(ZPOOL_PROP_ALTROOT),
- &altroot) == 0) {
- zfs_handle_t *zhp;
-
- verify((zhp = zfs_open(hdl, pool, ZFS_TYPE_DATASET)) != NULL);
- verify(zfs_prop_set(zhp, zfs_prop_to_name(ZFS_PROP_MOUNTPOINT),
- "/") == 0);
-
- zfs_close(zhp);
- }
-
create_failed:
zcmd_free_nvlists(&zc);
nvlist_free(zc_props);
diff --git a/usr/src/test/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_005_pos.ksh b/usr/src/test/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_005_pos.ksh
index 2458cf350c..c2f3789891 100644..100755
--- a/usr/src/test/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_005_pos.ksh
+++ b/usr/src/test/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_005_pos.ksh
@@ -103,12 +103,16 @@ do
[[ "$mpt" != "$mpt_val" ]] && \
log_fail "The value of mountpoint property is different\
from the output of zfs mount"
- if [[ "$opt" == "-R $TESTDIR1" ]] || [[ "$opt" == "-m $TESTDIR1" ]];
- then
+ if [[ "$opt" == "-m $TESTDIR1" ]]; then
[[ ! -d $TESTDIR1 ]] && \
log_fail "$TESTDIR1 is not created auotmatically."
[[ "$mpt" != "$TESTDIR1" ]] && \
log_fail "$TESTPOOL is not mounted on $TESTDIR1."
+ elif [[ "$opt" == "-R $TESTDIR1" ]]; then
+ [[ ! -d $TESTDIR1/$TESTPOOL ]] && \
+ log_fail "$TESTDIR1/$TESTPOOL is not created auotmatically."
+ [[ "$mpt" != "$TESTDIR1/$TESTPOOL" ]] && \
+ log_fail "$TESTPOOL is not mounted on $TESTDIR1/$TESTPOOL."
else
[[ ! -d ${TESTDIR1}$TESTDIR1 ]] && \
log_fail "${TESTDIR1}$TESTDIR1 is not created automatically."