I need to know if there is a way to detect what block devices are currently available to be mounted, what block devices are currently mounted, and the type of block device (aka: is it a loop device? is it a phisical device (like a HDD/flash drive, etc...?)
I've searched for API documentation, but I could not find any on this particular topic.
I have delved into /sys/dev/block, but I feel like I shouldn't experiment if the API provides a way to gather this information.
So, I think I may have fiured it out. I was digging around, and found this:
/proc/partitions : has all the block partitions that can be mounted.
/proc/mounts : has all mounted devices, as well as their filesystem (if applicable) and permissions.
Both are updated in real-time.
I can get the size of any device from /sys/dev/block (following major:minor as given in /proc/partitions), but I really need to aqcuire the amoutn of free space available. Is there any better way to do this than calculating the size of used space?