fn dev_root_is_on_device(device_name: &str, primary: &str) -> boolExpand description
Return true if /dev/root (a root-partition alias used by Ubuntu/AWS and
similar cloud images) belongs to device_name.
Two strategies, tried in order:
-
Symlink (
read_link): common on Debian and some Ubuntu builds. The symlink target (e.g.nvme0n1p1) is resolved and matched against the device prefix. -
/proc/self/mountinfo+ sysfs: when/dev/rootis a device node (not a symlink), we read themajor:minorstring from mountinfo field 3 for the/mount whose source is/dev/root, then scan/sys/block/<device>/<partition>/devfor a matching string. Both sources use the same"major:minor"text format, so no encoding ormakedev(3)arithmetic is needed.