diff options
author | Ryan Moeller <[email protected]> | 2020-12-04 17:01:42 -0500 |
---|---|---|
committer | GitHub <[email protected]> | 2020-12-04 14:01:42 -0800 |
commit | 4b6e2a5a33957af806b708723f32b83dbafce326 (patch) | |
tree | e7bb691c32e6992d2c197f600247dede9e8216f3 /cmd | |
parent | 8f158ae6ad98d7b4f4c583a77a44009580dee91c (diff) |
Add -u option to 'zfs create'
Add -u option to 'zfs create' that prevents file system from being
automatically mounted. This is similar to the 'zfs receive -u'.
Authored by: pjd <[email protected]>
FreeBSD-commit: freebsd/freebsd@35c58230e292775a694d189ff2b0bea2dcf6947d
Reviewed-by: Brian Behlendorf <[email protected]>
Reviewed-by: Allan Jude <[email protected]>
Ported-by: Ryan Moeller <[email protected]>
Signed-off-by: Ryan Moeller <[email protected]>
Closes #11254
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/zfs/zfs_main.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/cmd/zfs/zfs_main.c b/cmd/zfs/zfs_main.c index 340a7db96..8064f6363 100644 --- a/cmd/zfs/zfs_main.c +++ b/cmd/zfs/zfs_main.c @@ -270,7 +270,7 @@ get_usage(zfs_help_t idx) return (gettext("\tclone [-p] [-o property=value] ... " "<snapshot> <filesystem|volume>\n")); case HELP_CREATE: - return (gettext("\tcreate [-Pnpv] [-o property=value] ... " + return (gettext("\tcreate [-Pnpuv] [-o property=value] ... " "<filesystem>\n" "\tcreate [-Pnpsv] [-b blocksize] [-o property=value] ... " "-V <size> <volume>\n")); @@ -1012,6 +1012,8 @@ default_volblocksize(zpool_handle_t *zhp, nvlist_t *props) * check of arguments and properties, but does not check for permissions, * available space, etc. * + * The '-u' flag prevents the newly created file system from being mounted. + * * The '-v' flag is for verbose output. * * The '-P' flag is used for parseable output. It implies '-v'. @@ -1028,6 +1030,7 @@ zfs_do_create(int argc, char **argv) boolean_t bflag = B_FALSE; boolean_t parents = B_FALSE; boolean_t dryrun = B_FALSE; + boolean_t nomount = B_FALSE; boolean_t verbose = B_FALSE; boolean_t parseable = B_FALSE; int ret = 1; @@ -1039,7 +1042,7 @@ zfs_do_create(int argc, char **argv) nomem(); /* check options */ - while ((c = getopt(argc, argv, ":PV:b:nso:pv")) != -1) { + while ((c = getopt(argc, argv, ":PV:b:nso:puv")) != -1) { switch (c) { case 'V': type = ZFS_TYPE_VOLUME; @@ -1086,6 +1089,9 @@ zfs_do_create(int argc, char **argv) case 's': noreserve = B_TRUE; break; + case 'u': + nomount = B_TRUE; + break; case 'v': verbose = B_TRUE; break; @@ -1105,6 +1111,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 filesystem\n")); + goto badusage; + } argc -= optind; argv += optind; @@ -1265,6 +1276,11 @@ zfs_do_create(int argc, char **argv) log_history = B_FALSE; } + if (nomount) { + ret = 0; + goto error; + } + ret = zfs_mount_and_share(g_zfs, argv[0], ZFS_TYPE_DATASET); error: nvlist_free(props); |