#!/bin/bash

REPRO_DIR=$(mktemp -d)
cd ${REPRO_DIR}

dd if=/dev/zero of=block bs=10240 count=1024
mkfs.btrfs block

mkdir filesystem
mount -t btrfs -o loop block filesystem

btrfs subvolume create filesystem/subvolume
mkdir filesystem/subvolume/{directory,bindsource}

mkdir binddest
mount --bind filesystem/subvolume/bindsource binddest

echo
echo
echo
echo "Begin unexpected output"
df filesystem/subvolume/directory
echo "Expected report for the main btrfs mount, not the bind-mount"
df -T | grep $PWD
echo "Expected only one btrfs filesystem"

umount binddest
umount filesystem
cd -
rm -r ${REPRO_DIR}
