comparison sbin/fzfs @ 527:b7d60802b25f

Use absolute paths for "mount" (all occurrences) and grep (some)
author Franz Glasner <fzglas.hg@dom66.de>
date Wed, 04 Sep 2024 18:29:42 +0200
parents c05ef1c86c9c
children 93b98803219b
comparison
equal deleted inserted replaced
526:e50ea2fd4b66 527:b7d60802b25f
207 echo "Would mount ${_name} on ${_real_mp}" 207 echo "Would mount ${_name} on ${_real_mp}"
208 else 208 else
209 mkdir -p "${_real_mp}" 1> /dev/null 2> /dev/null || \ 209 mkdir -p "${_real_mp}" 1> /dev/null 2> /dev/null || \
210 { echo "ERROR: cannot create mountpoint ${_real_mp}" >&2; _umount_datasets _mounted_datasets || true; return 1; } 210 { echo "ERROR: cannot create mountpoint ${_real_mp}" >&2; _umount_datasets _mounted_datasets || true; return 1; }
211 echo "Mounting ${_name} on ${_real_mp}" 211 echo "Mounting ${_name} on ${_real_mp}"
212 if mount -t zfs "${_name}" "${_real_mp}"; then 212 if /sbin/mount -t zfs "${_name}" "${_real_mp}"; then
213 array_append _mounted_datasets "${_name}" 213 array_append _mounted_datasets "${_name}"
214 else 214 else
215 if ! checkyes _opt_keep; then 215 if ! checkyes _opt_keep; then
216 _umount_datasets _mounted_datasets || true 216 _umount_datasets _mounted_datasets || true
217 fi 217 fi
289 [ -z "${_dsname}" ] && { echo "ERROR: no dataset given" 1>&2; return 2; } 289 [ -z "${_dsname}" ] && { echo "ERROR: no dataset given" 1>&2; return 2; }
290 290
291 # Just determine whether the given dataset name exists 291 # Just determine whether the given dataset name exists
292 _rootds_mountpoint="$(zfs list -H -o mountpoint -t filesystem "${_dsname}")" || { echo "ERROR: dataset not found" 1>&2; return 1; } 292 _rootds_mountpoint="$(zfs list -H -o mountpoint -t filesystem "${_dsname}")" || { echo "ERROR: dataset not found" 1>&2; return 1; }
293 293
294 mount -t zfs -p \ 294 /sbin/mount -t zfs -p \
295 | grep -E "^${_dsname}(/|\s)" \ 295 | LC_ALL=C GREP_OPTIONS="" /usr/bin/egrep "^${_dsname}(/|\s)" \
296 | sort -n -r \ 296 | /usr/bin/sort -n -r \
297 | { 297 | {
298 while IFS=' '$'\t' read -r _name _mp _rest ; do 298 while IFS=' '$'\t' read -r _name _mp _rest ; do
299 echo "Umounting ${_name} on ${_mp}" 299 echo "Umounting ${_name} on ${_mp}"
300 umount "${_mp}" || return 1 300 /sbin/umount "${_mp}" || return 1
301 done 301 done
302 } 302 }
303 return 0 303 return 0
304 } 304 }
305 305