I'm currently writing a basic filesystem abstraction (in C++) and I need to get a list of "useful" mounted devices on linux.
I've found the function(s)
getmntent_r that allow to me to easily parse
/proc/mounts however many of the mounted devices aren't "useful" (such as:
/sys/fs/cgroup/net_cls). In particular I'm attempting to find mounts which related to a physical device, partition or network share/drive.
The closest I've found is checking if the
mnt_fsname (device name) starts with a
/, which in the case of my system narrows it down to:
Which appears to be what I want (the latter two being partitions on a usb stick). I haven't had a chance to try out a network share/device with it though.
Basically this is meant to be an approximation of windows-like 'drives', hence why I'm interested in physical devices etc., but doesn't prevent a library user navigating to unlisted devices if they so-desire.
So basically the question boils down too:
If the device name in a mount entry starts with a
/is it guarenteed to be a physical device, partition or network share?
Will I be leaving out anything particularly important/useful?
Is there a better/more precise way to do this?