cmd/zfs: clone: accept -u to not mount newly created datasets

Signed-off-by: Ivan Shapovalov <intelfx@intelfx.name>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Reviewed-by: Alexander Motin <alexander.motin@TrueNAS.com>
Closes #18080
This commit is contained in:
Ivan Shapovalov
2026-01-05 18:21:56 +01:00
committed by Tony Hutter
parent cb1833023f
commit 6ab8f46c6c
5 changed files with 108 additions and 31 deletions
+1 -1
View File
@@ -196,7 +196,7 @@ tests = ['zfs_clone_001_neg', 'zfs_clone_002_pos', 'zfs_clone_003_pos',
'zfs_clone_004_pos', 'zfs_clone_005_pos', 'zfs_clone_006_pos',
'zfs_clone_007_pos', 'zfs_clone_008_neg', 'zfs_clone_009_neg',
'zfs_clone_010_pos', 'zfs_clone_encrypted', 'zfs_clone_deeply_nested',
'zfs_clone_rm_nested']
'zfs_clone_rm_nested', 'zfs_clone_nomount']
tags = ['functional', 'cli_root', 'zfs_clone']
[tests/functional/cli_root/zfs_copies]
+1
View File
@@ -677,6 +677,7 @@ nobase_dist_datadir_zfs_tests_tests_SCRIPTS += \
functional/cli_root/zfs_clone/zfs_clone_010_pos.ksh \
functional/cli_root/zfs_clone/zfs_clone_deeply_nested.ksh \
functional/cli_root/zfs_clone/zfs_clone_encrypted.ksh \
functional/cli_root/zfs_clone/zfs_clone_nomount.ksh \
functional/cli_root/zfs_clone/zfs_clone_rm_nested.ksh \
functional/cli_root/zfs_copies/cleanup.ksh \
functional/cli_root/zfs_copies/setup.ksh \
@@ -0,0 +1,66 @@
#!/bin/ksh -p
# shellcheck disable=SC2066
# SPDX-License-Identifier: CDDL-1.0
#
# 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 2025 Ivan Shapovalov <intelfx@intelfx.name>
#
. "$STF_SUITE/include/libtest.shlib"
#
# DESCRIPTION:
# `zfs clone -u` should leave the new file system unmounted.
#
# STRATEGY:
# 1. Prepare snapshots
# 2. Clone a snapshot using `-u` and make sure the clone is not mounted.
#
verify_runnable "both"
function setup_all
{
log_note "Creating snapshots..."
for snap in "$SNAPFS" ; do
if ! snapexists "$snap" ; then
log_must zfs snapshot "$snap"
fi
done
return 0
}
function cleanup_all
{
datasetexists "$fs" && destroy_dataset "$fs"
for snap in "$SNAPFS" ; do
snapexists "$snap" && destroy_dataset "$snap" -Rf
done
return 0
}
log_onexit cleanup_all
log_must setup_all
log_assert "zfs clone -u should leave the new file system unmounted"
typeset fs="$TESTPOOL/clonefs$$"
log_must zfs clone -u "$SNAPFS" "$fs"
log_mustnot ismounted "$fs"
log_pass "zfs clone -u leaves the new file system unmounted"