mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-22 18:40:43 +03:00
zfs_main: create, clone, rename: accept -pp for non-mountable parents
Teach `zfs {create,clone,rename}` to accept a doubled `-p` flag (`-pp`)
to create non-existing ancestor datasets with `canmount=off`.
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Rob Norris <robn@despairlabs.com>
Signed-off-by: Ivan Shapovalov <intelfx@intelfx.name>
Closes #17000
This commit is contained in:
committed by
Brian Behlendorf
parent
2f3f1ab1ba
commit
8531621aba
@@ -1171,6 +1171,22 @@ function datasetnonexists
|
||||
return 0
|
||||
}
|
||||
|
||||
# Check if the specified dataset property has the expected value or fail
|
||||
function dataset_has_prop # property expected_value dataset
|
||||
{
|
||||
typeset prop=$1
|
||||
typeset expected=$2
|
||||
typeset dataset=$3
|
||||
|
||||
typeset value=""
|
||||
|
||||
value="$(get_prop "$prop" "$dataset")"
|
||||
[[ "$value" == "$expected" ]] || {
|
||||
log_note "dataset $dataset: property $prop == $value (!= $expected)"
|
||||
return 1
|
||||
}
|
||||
}
|
||||
|
||||
# FreeBSD breaks exports(5) at whitespace and doesn't process escapes
|
||||
# Solaris just breaks
|
||||
#
|
||||
@@ -2629,11 +2645,16 @@ function verify_opt_p_ops
|
||||
typeset datatype=$2
|
||||
typeset dataset=$3
|
||||
typeset newdataset=$4
|
||||
typeset popt=$5
|
||||
|
||||
if [[ $datatype != "fs" && $datatype != "vol" ]]; then
|
||||
log_fail "$datatype is not supported."
|
||||
fi
|
||||
|
||||
if [[ -z "$popt" ]]; then
|
||||
popt=-p
|
||||
fi
|
||||
|
||||
# check parameters accordingly
|
||||
case $ops in
|
||||
create)
|
||||
@@ -2671,7 +2692,7 @@ function verify_opt_p_ops
|
||||
log_mustnot datasetexists $newdataset ${newdataset%/*}
|
||||
|
||||
# with -p option, operation should succeed
|
||||
log_must zfs $ops -p $dataset $newdataset
|
||||
log_must zfs $ops $popt $dataset $newdataset
|
||||
block_device_wait
|
||||
|
||||
if ! datasetexists $newdataset ; then
|
||||
@@ -2680,7 +2701,7 @@ function verify_opt_p_ops
|
||||
|
||||
# when $ops is create or clone, redo the operation still return zero
|
||||
if [[ $ops != "rename" ]]; then
|
||||
log_must zfs $ops -p $dataset $newdataset
|
||||
log_must zfs $ops $popt $dataset $newdataset
|
||||
fi
|
||||
|
||||
return 0
|
||||
|
||||
Reference in New Issue
Block a user