summaryrefslogtreecommitdiffstats
path: root/cmd
diff options
context:
space:
mode:
authorTurbo Fredriksson <[email protected]>2014-06-06 16:59:11 +0200
committerBrian Behlendorf <[email protected]>2014-06-06 12:30:35 -0700
commit480f62655d2a4c8fa9e3cf12f1245b455edac349 (patch)
treefe89e7aa49bdfb9398a787aec892820ba56c5953 /cmd
parent7a870db1b90db4ca31b67fbe856fd426431fa8b5 (diff)
Only automatically mount a clone when 'canmount == on'.
According to the man page, "When the noauto option is set, a dataset can only be mounted and unmounted explicitly. The dataset is not mounted automatically when the dataset is created or imported ...." When cloning a dataset the canmount property was not being honored. This patch adds the required check to achieve the behavior described in the man page. Signed-off-by: Turbo Fredriksson <[email protected]> Signed-off-by: Brian Behlendorf <[email protected]> Closes #2241
Diffstat (limited to 'cmd')
-rw-r--r--cmd/zfs/zfs_main.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/cmd/zfs/zfs_main.c b/cmd/zfs/zfs_main.c
index 7faab4734..4989b3b47 100644
--- a/cmd/zfs/zfs_main.c
+++ b/cmd/zfs/zfs_main.c
@@ -648,6 +648,7 @@ zfs_do_clone(int argc, char **argv)
/* create the mountpoint if necessary */
if (ret == 0) {
zfs_handle_t *clone;
+ int canmount = ZFS_CANMOUNT_OFF;
if (log_history) {
(void) zpool_log_history(g_zfs, history_str);
@@ -656,7 +657,17 @@ zfs_do_clone(int argc, char **argv)
clone = zfs_open(g_zfs, argv[1], ZFS_TYPE_DATASET);
if (clone != NULL) {
- if (zfs_get_type(clone) != ZFS_TYPE_VOLUME)
+ /*
+ * if the user doesn't want the dataset automatically
+ * mounted, then skip the mount/share step.
+ */
+ if (zfs_prop_valid_for_type(ZFS_PROP_CANMOUNT,
+ zfs_get_type(clone), B_FALSE))
+ canmount = zfs_prop_get_int(clone,
+ ZFS_PROP_CANMOUNT);
+
+ if (zfs_get_type(clone) != ZFS_TYPE_VOLUME &&
+ canmount == ZFS_CANMOUNT_ON)
if ((ret = zfs_mount(clone, NULL, 0)) == 0)
ret = zfs_share(clone);
zfs_close(clone);