diff options
author | pjd <pjd@FreeBSD.org> | 2012-04-24 13:44:46 +0000 |
---|---|---|
committer | pjd <pjd@FreeBSD.org> | 2012-04-24 13:44:46 +0000 |
commit | 35c58230e292775a694d189ff2b0bea2dcf6947d (patch) | |
tree | 6e4ca438c421f0489edbee609a801afb3b7e6722 /cddl | |
parent | 337d2f2292803bdbaab0250394ad681a3c599e5b (diff) | |
download | FreeBSD-src-35c58230e292775a694d189ff2b0bea2dcf6947d.zip FreeBSD-src-35c58230e292775a694d189ff2b0bea2dcf6947d.tar.gz |
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
Diffstat (limited to 'cddl')
-rw-r--r-- | cddl/contrib/opensolaris/cmd/zfs/zfs.8 | 6 | ||||
-rw-r--r-- | cddl/contrib/opensolaris/cmd/zfs/zfs_main.c | 19 |
2 files changed, 19 insertions, 6 deletions
diff --git a/cddl/contrib/opensolaris/cmd/zfs/zfs.8 b/cddl/contrib/opensolaris/cmd/zfs/zfs.8 index a60af75..fdbae4e 100644 --- a/cddl/contrib/opensolaris/cmd/zfs/zfs.8 +++ b/cddl/contrib/opensolaris/cmd/zfs/zfs.8 @@ -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 diff --git a/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c b/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c index 410246a..c322f08 100644 --- a/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c +++ b/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c @@ -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")); |