# HG changeset patch # User Franz Glasner # Date 1725887761 -7200 # Node ID f6dc405ddd58c80792dd88b336110d5b134abb7b # Parent 9f8f3e9b3d84e61d633247044365609831435f80 fzfs: switch to farray.sh diff -r 9f8f3e9b3d84 -r f6dc405ddd58 sbin/fzfs --- a/sbin/fzfs Mon Sep 09 14:39:16 2024 +0200 +++ b/sbin/fzfs Mon Sep 09 15:16:01 2024 +0200 @@ -45,7 +45,7 @@ _p_datadir="$(dirname "$0")"/../share/local-bsdtools . "${_p_datadir}/common.subr" -. "${_p_datadir}/array.sh" +. "${_p_datadir}/farray.sh" # @@ -59,6 +59,7 @@ local _opt_mount_children_only _opt_keep local _name _mp _canmount _mounted _rootds_mountpoint _rootds_mountpoint_prefix _relative_mp _real_mp + local _mounted_datasets _opt_dry_run="" _opt_keep="" @@ -136,7 +137,7 @@ # mounted by this routine and should be unmounted on errors # -- if possible. # - array_create _mounted_datasets + farray_create _mounted_datasets while IFS=$'\t' read -r _name _mp _canmount _mounted ; do # Skip filesystems that are already mounted @@ -210,7 +211,7 @@ { echo "ERROR: cannot create mountpoint ${_real_mp}" >&2; _umount_datasets _mounted_datasets || true; return 1; } echo "Mounting ${_name} on ${_real_mp}" if /sbin/mount -t zfs "${_name}" "${_real_mp}"; then - array_append _mounted_datasets "${_name}" + farray_append _mounted_datasets "${_name}" else if ! checkyes _opt_keep; then _umount_datasets _mounted_datasets || true @@ -226,7 +227,7 @@ else echo "Mounting ${_name} on configured ZFS dataset mountpoint ${_mp}" if zfs mount "${_name}"; then - array_append _mounted_datasets "${_name}" + farray_append _mounted_datasets "${_name}" else if ! checkyes _opt_keep; then _umount_datasets _mounted_datasets || true @@ -240,7 +241,7 @@ ;; esac done - array_destroy _mounted_datasets + farray_destroy _mounted_datasets return 0 } } @@ -259,7 +260,7 @@ #: Unmounting is done in the reverse order. #: _umount_datasets() { - array_reversed_for_each "$1" _umount_datasets_umount + farray_reversed_for_each "$1" _umount_datasets_umount } @@ -489,6 +490,7 @@ local _ds_canmount _ds_mountpoint local _clone_props _arg_canmount _arg_other_clone_props local _opt _idx _idx_lp _prop _propval + local _ds_tree _cloned_datasets _local_props _opt_dry_run="" _opt_keep="" @@ -532,17 +534,17 @@ return 1 fi - array_create _ds_tree + farray_create _ds_tree while IFS=$'\n' read -r _ds; do - array_append _ds_tree "${_ds}" + farray_append _ds_tree "${_ds}" done </dev/null 2>&1; then err "child dataset (snapshot) does not exist: ${_ds}@${_snapshot_name}" 1>&2 return 1 @@ -550,24 +552,24 @@ _idx=$((${_idx} + 1)) done - array_create _cloned_datasets - alist_create _local_props + farray_create _cloned_datasets + falist_create _local_props # # 1. Clone with "safe" canmount settings # _idx=1 - while array_tryget _ds _ds_tree ${_idx}; do + while farray_tryget _ds _ds_tree ${_idx}; do # Determine the relative name of the dataset _ds_relname="${_ds#${_ds_source_base}}" # Need to determine in *every* case (local, default, received, ...) _ds_canmount="$(zfs get -H -o value canmount "${_ds}")" - alist_clear _local_props + falist_clear _local_props while IFS=$'\t' read -r _prop _propval ; do - alist_set _local_props "${_prop}" "${_propval}" + falist_set _local_props "${_prop}" "${_propval}" done <