]> granicus.if.org Git - zfs/commitdiff
Only automatically mount a clone when 'canmount == on'.
authorTurbo Fredriksson <turbo@bayour.com>
Fri, 6 Jun 2014 14:59:11 +0000 (16:59 +0200)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Fri, 6 Jun 2014 19:30:35 +0000 (12:30 -0700)
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

cmd/zfs/zfs_main.c

index 7faab473414f3d8bede7474b11b81211de297abc..4989b3b47272ebd1dcad6846bf1562f95479e703 100644 (file)
@@ -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);