Skip to main content

device_source_prefixes

Function device_source_prefixes 

Source
fn device_source_prefixes(device_name: &str) -> Vec<String>
Expand description

Build the list of source-path prefixes to look for in /proc/mounts for a given block device.

Most devices map 1-to-1: /dev/sda["/dev/sda"] (matches sda1, sda2 …).

Two special cases add extra prefixes:

  • Device-mapper (dm-*): /proc/mounts uses /dev/mapper/<name>, not /dev/dm-N. The canonical name is read from /sys/block/<dev>/dm/name.

  • /dev/root: some distros (Ubuntu/AWS, cloud-init images) expose the root partition under this alias in /proc/mounts instead of the real device path. Resolution is attempted first via read_link (covers distros that make it a symlink) and then via a major:minor comparison between /proc/self/mountinfo and /sys/block/<dev>/<part>/dev (covers distros where it is a plain device node). See dev_root_is_on_device.