Skip to main content
added 278 characters in body
Source Link

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

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

stat -c%D some-file

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%d .)" -ne "$(stat -c%d ..)" ]
then
    echo "btrfs subvolume"
else
    echo "btrfs directory"
fi
Source Link

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

stat -c%D some-file