Studying GRUB's `getroot` helpers ported to UNIX...
To check if a harddrive is a floppy disk it opens the corresponding device file (aided by GRUB's "kernel" subsystem) & checks the version numbers from `fstat()`.
There's a wrapper around the `vgs` commond with non-trivial reformatting, or it might be a noop depending on build flags.
Another helper retrieves & iterates over the mountpoints containing a filepath, querying those mounts' device files. It invokes a recursive support routine.
1/2