Skip to content

Use BTRFS_IOC_INO_LOOKUP ioctl to get btrfs subvolume ID

From the main commit:

Use the BTRFS_IOC_INO_LOOKUP ioctl on a file FD, in order to fetch
its BTRFS subvolume ID. According to BTRFS documentation this is
necessary to get a filesystem-wide unique identifier as we expect:
https://btrfs.readthedocs.io/en/latest/Subvolumes.html#inode-numbers

Commit ff52970f997e only handled subvolumes that are known through
mountpoint info, this in addition works for subvolumes that are
known only to btrfs (e.g. `btrfs subvolume create ...` with no
mount bound to it), with the small drawback that we have to poke
every file for their subvolume through ioctl(), these kernel/fs
queries should be fast though.

Since subvolumes as mounts are also indirectly handled through
the ioctl(), it is not necessary anymore to track the "subvol"
option in mtab.

Fixes: ff52970f997 ("libtracker-miners-common: Include btrfs subvolume in stable identifiers")

Closes: #266 (closed)

Merge request reports