Skip to content

Commit

Permalink
Only automatically mount a clone when 'canmount == on'.
Browse files Browse the repository at this point in the history
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 <turbo@bayour.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #2241
  • Loading branch information
FransUrbo authored and behlendorf committed Jun 6, 2014
1 parent 7a870db commit 480f626
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion cmd/zfs/zfs_main.c
Expand Up @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit 480f626

Please sign in to comment.