How do I filter out "useful" mounts from /etc/mtab or /proc/mounts

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:

  • '/'
  • '/boot'
  • '/run/media/[username]/0CA8-1F2D'
  • '/run/media/[username]/14E0-3E80'

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!

Replay

Category: mount Time: 2016-07-29 Views: 0
Tags: mount etc proc

Related post

iOS development

Android development

Python development

JAVA development

Development language

PHP development

Ruby development

search

Front-end development

Database

development tools

Open Platform

Javascript development

.NET development

cloud computing

server

Copyright (C) avrocks.com, All Rights Reserved.

processed in 0.119 (s). 12 q(s)