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 <pjd@FreeBSD.org>
FreeBSD-commit: freebsd/freebsd@35c58230e2

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Allan Jude <allan@klarasystems.com>
Ported-by: Ryan Moeller <ryan@iXsystems.com>
Signed-off-by: Ryan Moeller <ryan@iXsystems.com>
Closes #11254
This commit is contained in:
Ryan Moeller
2020-12-04 17:01:42 -05:00
committed by GitHub
parent 8f158ae6ad
commit 4b6e2a5a33
5 changed files with 80 additions and 7 deletions
+2 -1
View File
@@ -156,7 +156,8 @@ tests = ['zfs_create_001_pos', 'zfs_create_002_pos', 'zfs_create_003_pos',
'zfs_create_007_pos', 'zfs_create_008_neg', 'zfs_create_009_neg',
'zfs_create_010_neg', 'zfs_create_011_pos', 'zfs_create_012_pos',
'zfs_create_013_pos', 'zfs_create_014_pos', 'zfs_create_encrypted',
'zfs_create_crypt_combos', 'zfs_create_dryrun', 'zfs_create_verbose']
'zfs_create_crypt_combos', 'zfs_create_dryrun', 'zfs_create_nomount',
'zfs_create_verbose']
tags = ['functional', 'cli_root', 'zfs_create']
[tests/functional/cli_root/zfs_destroy]
@@ -19,6 +19,7 @@ dist_pkgdata_SCRIPTS = \
zfs_create_encrypted.ksh \
zfs_create_crypt_combos.ksh \
zfs_create_dryrun.ksh \
zfs_create_nomount.ksh \
zfs_create_verbose.ksh
dist_pkgdata_DATA = \
@@ -0,0 +1,51 @@
#!/bin/ksh -p
#
# This file and its contents are supplied under the terms of the
# Common Development and Distribution License ("CDDL"), version 1.0.
# You may only use this file in accordance with the terms of version
# 1.0 of the CDDL.
#
# A full copy of the text of the CDDL should have accompanied this
# source. A copy of the CDDL is also available via the Internet at
# http://www.illumos.org/license/CDDL.
#
#
# Copyright 2020 iXsystems, Inc.
#
. $STF_SUITE/include/libtest.shlib
#
# DESCRIPTION:
# zfs create -u should leave the new file system unmounted.
# It should not work for a volume.
#
# STRATEGY:
# 1. Create a file system using -u and make sure the file system is not mounted.
# 3. Do it for a volume to verify it fails.
#
verify_runnable "both"
function cleanup
{
local ds
for ds in "$fs" "$vol"; do
datasetexists "$ds" && destroy_dataset "$ds"
done
}
log_onexit cleanup
log_assert "zfs create -u leaves the new file system unmounted"
typeset fs="$TESTPOOL/$TESTFS1"
typeset vol="$TESTPOOL/$TESTVOL1"
log_must create_dataset "$fs" "-u"
log_mustnot ismounted "$fs"
log_mustnot zfs create -V $VOLSIZE -u "$vol"
log_pass "zfs create -u leaves the new file system unmounted"