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/getmntent_r that allow to me to easily parse /etc/mtab and /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, parition 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 garenteed to be a physical device, parition or network share?
- Will I be leaving out anything paticularly important/useful?
- Is there a better/more precise way to do this?
Thanks for your time!