Skip to content

libtracker-miners-common: Get BTRFS subvolume ID through ioctl()

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 ff52970f 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.

(cherry-picked from commit 4083d3eb)

Merge request reports