comparison sbin/fzfs @ 442:a2011285f054

Move "_get_local_zfs_properties_for_create()" into common.subr
author Franz Glasner <fzglas.hg@dom66.de>
date Fri, 03 May 2024 09:35:09 +0200
parents f06998866c01
children 312aebce590c
comparison
equal deleted inserted replaced
441:f06998866c01 442:a2011285f054
39 unmount 39 unmount
40 40
41 ' 41 '
42 42
43 43
44 #: 44 _p_datadir="$(dirname "$0")"/../share/local-bsdtools
45 #: Determine some important dataset properties that are set locally 45 . "${_p_datadir}/common.subr"
46 #:
47 #: Args:
48 #: $1: the dataset
49 #: $2 ...: the properties to check for
50 #:
51 #: Output (stdout):
52 #: An option string suited for use in "zfs create"
53 #:
54 _get_local_zfs_properties_for_create() {
55 local ds
56
57 local _res _prop _value _source
58
59 ds="${1}"
60 shift
61
62 _res=""
63
64 for _prop in "$@" ; do
65 IFS=$'\t' read -r _value _source <<EOF73GHASGJKKJ354
66 $(zfs get -H -p -o value,source "${_prop}" "${ds}")
67 EOF73GHASGJKKJ354
68 case "${_source}" in
69 local)
70 if [ -z "${_res}" ]; then
71 _res="-o ${_prop}=${_value}"
72 else
73 _res="${_res} -o ${_prop}=${_value}"
74 fi
75 ;;
76 *)
77 # VOID
78 ;;
79 esac
80 done
81 echo "${_res}"
82 }
83 46
84 47
85 # 48 #
86 #: Implementation of the "mount" command. 49 #: Implementation of the "mount" command.
87 #: 50 #: