Date: Tue, 24 Apr 2012 13:44:47 +0000 (UTC) From: Pawel Jakub Dawidek <pjd@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r234654 - head/cddl/contrib/opensolaris/cmd/zfs Message-ID: <201204241344.q3ODilS8051048@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
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] ... " "<snapshot> <filesystem|volume>\n")); case HELP_CREATE: - return (gettext("\tcreate [-p] [-o property=value] ... " + return (gettext("\tcreate [-pu] [-o property=value] ... " "<filesystem>\n" "\tcreate [-ps] [-b blocksize] [-o property=value] ... " "-V <size> <volume>\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"));
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201204241344.q3ODilS8051048>