From owner-svn-src-all@FreeBSD.ORG Tue Apr 24 13:44:47 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5B1D51065677; Tue, 24 Apr 2012 13:44:47 +0000 (UTC) (envelope-from pjd@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 459AD8FC1D; Tue, 24 Apr 2012 13:44:47 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q3ODilSk051051; Tue, 24 Apr 2012 13:44:47 GMT (envelope-from pjd@svn.freebsd.org) Received: (from pjd@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3ODilS8051048; Tue, 24 Apr 2012 13:44:47 GMT (envelope-from pjd@svn.freebsd.org) Message-Id: <201204241344.q3ODilS8051048@svn.freebsd.org> From: Pawel Jakub Dawidek Date: Tue, 24 Apr 2012 13:44:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234654 - head/cddl/contrib/opensolaris/cmd/zfs X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 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: Tue, 24 Apr 2012 13:44:47 -0000 Author: pjd Date: Tue Apr 24 13:44:46 2012 New Revision: 234654 URL: http://svn.freebsd.org/changeset/base/234654 Log: Add -u option to 'zfs create' that prevents file system from being automatically mounted. This is similar to the 'zfs receive -u'. MFC after: 1 week Modified: head/cddl/contrib/opensolaris/cmd/zfs/zfs.8 head/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c Modified: head/cddl/contrib/opensolaris/cmd/zfs/zfs.8 ============================================================================== --- head/cddl/contrib/opensolaris/cmd/zfs/zfs.8 Tue Apr 24 13:37:43 2012 (r234653) +++ head/cddl/contrib/opensolaris/cmd/zfs/zfs.8 Tue Apr 24 13:44:46 2012 (r234654) @@ -35,7 +35,7 @@ .Op Fl \&? .Nm .Cm create -.Op Fl p +.Op Fl pu .Op Fl o Ar property Ns = Ns Ar value .Ar ... filesystem .Nm @@ -1354,7 +1354,7 @@ Displays a help message. .It Xo .Nm .Cm create -.Op Fl p +.Op Fl pu .Op Fl o Ar property Ns = Ns Ar value .Ar ... filesystem .Xc @@ -1374,6 +1374,8 @@ line using the .Fl o option is ignored. If the target filesystem already exists, the operation completes successfully. +.It Fl u +Newly created file system is not mounted. .It Fl o Ar property Ns = Ns Ar value Sets the specified property as if the command .Qq Nm Cm set Ar property Ns = Ns Ar value Modified: head/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c ============================================================================== --- head/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c Tue Apr 24 13:37:43 2012 (r234653) +++ head/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c Tue Apr 24 13:44:46 2012 (r234654) @@ -217,7 +217,7 @@ get_usage(zfs_help_t idx) return (gettext("\tclone [-p] [-o property=value] ... " " \n")); case HELP_CREATE: - return (gettext("\tcreate [-p] [-o property=value] ... " + return (gettext("\tcreate [-pu] [-o property=value] ... " "\n" "\tcreate [-ps] [-b blocksize] [-o property=value] ... " "-V \n")); @@ -681,7 +681,7 @@ usage: } /* - * zfs create [-p] [-o prop=value] ... fs + * zfs create [-pu] [-o prop=value] ... fs * zfs create [-ps] [-b blocksize] [-o prop=value] ... -V vol size * * Create a new dataset. This command can be used to create filesystems @@ -694,6 +694,8 @@ usage: * SPA_VERSION_REFRESERVATION, we set a refreservation instead. * * The '-p' flag creates all the non-existing ancestors of the target first. + * + * The '-u' flag prevents mounting of newly created file system. */ static int zfs_do_create(int argc, char **argv) @@ -705,6 +707,7 @@ zfs_do_create(int argc, char **argv) boolean_t noreserve = B_FALSE; boolean_t bflag = B_FALSE; boolean_t parents = B_FALSE; + boolean_t nomount = B_FALSE; int ret = 1; nvlist_t *props; uint64_t intval; @@ -714,7 +717,7 @@ zfs_do_create(int argc, char **argv) nomem(); /* check options */ - while ((c = getopt(argc, argv, ":V:b:so:p")) != -1) { + while ((c = getopt(argc, argv, ":V:b:so:pu")) != -1) { switch (c) { case 'V': type = ZFS_TYPE_VOLUME; @@ -754,6 +757,9 @@ zfs_do_create(int argc, char **argv) case 's': noreserve = B_TRUE; break; + case 'u': + nomount = B_TRUE; + break; case ':': (void) fprintf(stderr, gettext("missing size " "argument\n")); @@ -771,6 +777,11 @@ zfs_do_create(int argc, char **argv) "used when creating a volume\n")); goto badusage; } + if (nomount && type != ZFS_TYPE_FILESYSTEM) { + (void) fprintf(stderr, gettext("'-u' can only be " + "used when creating a file system\n")); + goto badusage; + } argc -= optind; argv += optind; @@ -853,7 +864,7 @@ zfs_do_create(int argc, char **argv) * 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 (canmount == ZFS_CANMOUNT_ON) { + if (!nomount && canmount == ZFS_CANMOUNT_ON) { if (zfs_mount(zhp, NULL, 0) != 0) { (void) fprintf(stderr, gettext("filesystem " "successfully created, but not mounted\n"));