The st_dev field returned by stat(2), called ID of device containing
file, is different across BTRFS subvolumes as well as across
filesystems. Using the command line, that is
if [ btrfs != "$(findmnt -noFSTYPE --target=.)" ]
then
echo "not btrfs"
elif findmnt . >/dev/null
then
echo "btrfs mountpoint"
elif [ "$(stat -c%Dc%d some.)" -filene "$(stat -c%d ..)" ]
then
echo "btrfs subvolume"
else
echo "btrfs directory"
fi