comparison sbin/fjail @ 206:92e5db34eb2b

Implent a "-O" flag for mounts that allows to mount also datasets with configured mountpoints outside their "natural" mountpoints within the dataset hierarchy
author Franz Glasner <fzglas.hg@dom66.de>
date Sun, 21 Aug 2022 14:38:05 +0200
parents fcfa674c8444
children a19acddb4662
comparison
equal deleted inserted replaced
205:fcfa674c8444 206:92e5db34eb2b
38 -s Also create a dataset for freebsd-update data files 38 -s Also create a dataset for freebsd-update data files
39 -t Create a more tiny set of datasets 39 -t Create a more tiny set of datasets
40 -T Create only an extra tiny set of datasets 40 -T Create only an extra tiny set of datasets
41 -u Do not automatically mount newly created datasets 41 -u Do not automatically mount newly created datasets
42 42
43 mount [-u] [-n] DATASET MOUNTPOINT 43 mount [-O] [-u] [-n] DATASET MOUNTPOINT
44 44
45 Mount the ZFS dataset DATASET and all its children to mountpoint 45 Mount the ZFS dataset DATASET and all its children to mountpoint
46 MOUNTPOINT 46 MOUNTPOINT
47 47
48 -O Also mount datasets at mountpoints outside of their natural
49 and inherited mountpoints
48 -n Do not really mount but show what would be mounted where 50 -n Do not really mount but show what would be mounted where
49 -u Alias of -n 51 -u Alias of -n
50 52
51 umount DATASET 53 umount DATASET
52 54
362 # 364 #
363 command_mount() { 365 command_mount() {
364 local _dsname _mountpoint 366 local _dsname _mountpoint
365 local _name _mp _canmount _mounted 367 local _name _mp _canmount _mounted
366 local _rootds_mountpoint _relative_mp _real_mp 368 local _rootds_mountpoint _relative_mp _real_mp
367 local _dry_run 369 local _dry_run _mount_outside
368 370
369 _dry_run="" 371 _dry_run=""
370 while getopts "nu" _opt ; do 372 _mount_outside=""
373 while getopts "Onu" _opt ; do
371 case ${_opt} in 374 case ${_opt} in
375 O)
376 _mount_outside="yes"
377 ;;
372 n|u) 378 n|u)
373 _dry_run="yes" 379 _dry_run="yes"
374 ;; 380 ;;
375 \?|:) 381 \?|:)
376 return 2; 382 return 2;
431 echo "Mounting ${_name} on ${_real_mp}" 437 echo "Mounting ${_name} on ${_real_mp}"
432 mount -t zfs "${_name}" "${_real_mp}" || return 1 438 mount -t zfs "${_name}" "${_real_mp}" || return 1
433 fi 439 fi
434 ;; 440 ;;
435 *) 441 *)
436 # XXX FIXME Option to do a zfs mount $_name ??? 442 if [ "${_mount_outside}" = "yes" ]; then
437 echo "Skipping ${_name} because its configured mountpoint is not relative to given root dataset" 2>&1 443 if [ "${_dry_run}" = "yes" ]; then
444 echo "Would mount ${_name} on configured dataset mountpoint ${_mp}"
445 else
446 echo "Mounting ${_name} on configured dataset mountpoint ${_mp}"
447 zfs mount "${_name}" || return 1
448 fi
449 else
450 echo "Skipping ${_name} because its configured mountpoint is not relative to given root dataset" 2>&1
451 fi
438 ;; 452 ;;
439 esac 453 esac
440 done 454 done
441 455
442 return 0 456 return 0