#!/bin/bash -eu
# SPDX-License-Identifier: GPL-3.0-or-later

. guess-functions

devname="$1"; shift
fstype="$1"; shift

[ "$fstype" = 'btrfs' ] ||
	exit 0

uuid="$(sys_blkid -o value -s UUID -c /dev/null "$devname")"

for path in "$SYSFS_PATH/fs/btrfs/$uuid/devices"/*; do
	[ -e "$path" ] ||
		break
	guess_device "${path#$SYSFS_PATH}"
done

guess_feature 'btrfs'
