From owner-svn-src-all@freebsd.org Wed Oct 21 12:08:32 2015 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 67344A1A844; Wed, 21 Oct 2015 12:08:32 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 28B8D327; Wed, 21 Oct 2015 12:08:32 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t9LC8VKo048665; Wed, 21 Oct 2015 12:08:31 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t9LC8VbD048664; Wed, 21 Oct 2015 12:08:31 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201510211208.t9LC8VbD048664@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Wed, 21 Oct 2015 12:08:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org Subject: svn commit: r289689 - vendor/illumos/dist/cmd/zfs X-SVN-Group: vendor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 21 Oct 2015 12:08:32 -0000 Author: mav Date: Wed Oct 21 12:08:31 2015 New Revision: 289689 URL: https://svnweb.freebsd.org/changeset/base/289689 Log: 5984 zfs clone should not mount the clone if canmount == noauto Reviewed by: Matthew Ahrens Reviewed by: Justin Gibbs Reviewed by: Richard Elling Approved by: Matthew Ahrens illumos/illumos-gate@780828c8aa1df2dc6f2066107a4aa8d045297972 Modified: vendor/illumos/dist/cmd/zfs/zfs_main.c Modified: vendor/illumos/dist/cmd/zfs/zfs_main.c ============================================================================== --- vendor/illumos/dist/cmd/zfs/zfs_main.c Wed Oct 21 11:43:18 2015 (r289688) +++ vendor/illumos/dist/cmd/zfs/zfs_main.c Wed Oct 21 12:08:31 2015 (r289689) @@ -582,6 +582,17 @@ finish_progress(char *done) } /* + * Check if the dataset is mountable and should be automatically mounted. + */ +static boolean_t +should_auto_mount(zfs_handle_t *zhp) +{ + if (!zfs_prop_valid_for_type(ZFS_PROP_CANMOUNT, zfs_get_type(zhp))) + return (B_FALSE); + return (zfs_prop_get_int(zhp, ZFS_PROP_CANMOUNT) == ZFS_CANMOUNT_ON); +} + +/* * zfs clone [-p] [-o prop=value] ... * * Given an existing dataset, create a writable copy whose initial contents @@ -666,9 +677,22 @@ 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 ((ret = zfs_mount(clone, NULL, 0)) == 0) - ret = zfs_share(clone); + /* + * If the user doesn't want the dataset + * automatically mounted, then skip the mount/share + * step. + */ + if (should_auto_mount(clone)) { + if ((ret = zfs_mount(clone, NULL, 0)) != 0) { + (void) fprintf(stderr, gettext("clone " + "successfully created, " + "but not mounted\n")); + } else if ((ret = zfs_share(clone)) != 0) { + (void) fprintf(stderr, gettext("clone " + "successfully created, " + "but not shared\n")); + } + } zfs_close(clone); } } @@ -714,7 +738,6 @@ zfs_do_create(int argc, char **argv) int ret = 1; nvlist_t *props; uint64_t intval; - int canmount = ZFS_CANMOUNT_OFF; if (nvlist_alloc(&props, NV_UNIQUE_NAME, 0) != 0) nomem(); @@ -858,19 +881,15 @@ zfs_do_create(int argc, char **argv) goto error; ret = 0; - /* - * 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, type)) - canmount = zfs_prop_get_int(zhp, ZFS_PROP_CANMOUNT); /* * Mount and/or share the new filesystem as appropriate. We provide a * verbose error message to let the user know that their filesystem was * in fact created, even if we failed to mount or share it. + * If the user doesn't want the dataset automatically mounted, + * then skip the mount/share step altogether. */ - if (canmount == ZFS_CANMOUNT_ON) { + if (should_auto_mount(zhp)) { if (zfs_mount(zhp, NULL, 0) != 0) { (void) fprintf(stderr, gettext("filesystem " "successfully created, but not mounted\n"));