I want to determine which subvolume a file or directory is on. For example, if I have a subvolume mount at /mnt/btrfs-subvol
and a directory /mnt/btrfs-subvol/some/dir
and I run something /mnt/btrfs-subvol/some/dir
it returns btrfs-subvol
.
The best I can think to do is to walk back, testing each directory with stat
as I go for an inode of 256, but I can't imagine that is the only way of doing this. Or maybe run maybe
until btrfs sub show `pwd`; cd ..;done; echo `pwd`
But I feel there should be a more elegant solution.