snapd icon indicating copy to clipboard operation
snapd copied to clipboard

osutil/disks: workaround to map mapper devices with their underlying disk

Open sespiros opened this issue 1 year ago • 0 comments

Trying to match a mountpoint with its underlying disk currently fails if the mountpoint is for a mapper virtual device. This happens because diskFromPartUDevProps is using the ID_PART_ENTRY_DISK udev property to retrieve the MINOR and MAJOR IDs of the partition and that field is not present for mapper devices.

The extra use case that this is needed for is for partitions mounted with verity by mount. When attempting to mount a disk under /dev with verity options, mount will create automatically a mapper device under /dev/mapper following the naming convention <partition_name> -> libmnt_. Rather than covering all the different cases (LVM, CRYPT partitions etc.), this workaround will simply translate a mapper device name to its physical device using the above naming convention.

These APIs are not meant to be called for tmpfs based mountpoints but they are excluded anyway from the workaround. This for example covers virtual devices that get auto-created by mount under i.e /dev/mapper/libmnt_tmpfs.

sespiros avatar Jul 12 '24 14:07 sespiros