We have to find them with "btrfs usage", which is cumbersome.
strglobin() { [[ $1 = *$2* ]]; }
# Generic glob matching function. If glob pattern $2 matches all of $1, OK
strglob() { [[ $1 = $2 ]]; }
+# returns OK if $1 contains literal string $2 at the beginning, and isn't empty
+str_starts() { [ "${1#"$2"*}" != "$1" ]; }
+# returns OK if $1 contains literal string $2 at the end, and isn't empty
+str_ends() { [ "${1%*"$2"}" != "$1" ]; }
# helper function for check() in module-setup.sh
# to check for required installed binaries
[[ ${DM_LV_LAYER} ]] || [[ ! -L /dev/${DM_VG_NAME}/${DM_LV_NAME} ]]
}
+btrfs_devs() {
+ local _mp="$1"
+ btrfs device usage "$_mp" \
+ | while read _dev _rest; do
+ str_starts "$_dev" "/" || continue
+ _dev=${_dev%,}
+ printf -- "%s\n" "$_dev"
+ done
+}
;;
esac
[ -z "$dev" ] && dwarn "Bad fstab entry $@" && continue
+ if [[ "$3" == btrfs ]]; then
+ for i in $(btrfs_devs "$2"); do
+ push_host_devs "$i"
+ done
+ fi
push_host_devs "$dev"
host_fs_types["$dev"]="$3"
done
_bdev=$(readlink -f "/dev/block/$_dev")
[[ -b $_bdev ]] && _dev=$_bdev
push_host_devs $_dev
- [[ "$mp" == "/" ]] && root_dev="$_dev"
+ [[ "$mp" == "/" ]] && push root_devs "$_dev"
push_host_devs "$_dev"
+ if [[ $(find_mp_fstype "$mp") == btrfs ]]; then
+ for i in $(btrfs_devs "$mp"); do
+ [[ "$mp" == "/" ]] && push root_devs "$i"
+ push_host_devs "$i"
+ done
+ fi
done
if [[ -f /proc/swaps ]] && [[ -f /etc/fstab ]]; then
[[ "$_o" != *x-initrd.mount* ]] && continue
_dev=$(expand_persistent_dev "$_d")
_dev="$(readlink -f "$_dev")"
- [[ -b $_dev ]] && push_host_devs "$_dev"
+ [[ -b $_dev ]] || continue
+
+ push_host_devs "$_dev"
+ if [[ "$_t" == btrfs ]]; then
+ for i in $(find_btrfs_devs "$_m"); do
+ push_host_devs "$i"
+ done
+ fi
done < /etc/fstab
fi
. "$moddir/dracut-lib.sh"
for _dev in ${host_devs[@]}; do
- [[ "$_dev" == "$root_dev" ]] && continue
+ for _dev2 in ${root_devs[@]}; do
+ [[ "$_dev" == "$_dev2" ]] && continue 2
+ done
# We only actually wait for real devs - swap is only needed
# for resume and udev rules generated when parsing resume=