/etc/mtab vs. /proc/mounts

Alan Bateman Alan.Bateman at oracle.com
Thu Feb 3 04:37:21 PST 2011


Thanks for all the replies, I've been about thinking about what to do 
with this.

On FileSystem.getFileStores then it might be a bit confusing to 
developers if it enumerated underlying file systems that aren't normally 
shown by df and mount. For that reason it may be more consistent to just 
use /etc/mtab as it is doing now (and perhaps with some additional 
filtering, say to exclude entries that the automounter may have added).

If getFileStores is using /etc/mtab then it's probably best if 
getFileStore also uses /etc/mtab. If not found then it could fallback to 
/proc/mounts if it is different file (we can use the st_dev/st_ino to 
check that).

The overlaid mounts issue does seem tricky. I don't know how "df -T 
file..." does this but I suspect it's the first match. If so, then 
having getFileStore work this way is probably best. Worse case is that 
the for-informational purposes name and type aren't as expected.  I 
should mention this code is simpler in the Solaris implementation 
because the extmnttab structure returned by getextmntent gives us the 
device major/minor number so we can match that up to the st_dev of the 
file.  While looking into this I see that the Linux 2.6.26 kernel added 
/proc/self/mountinfo and that seems to have the information we need, 
including an ID for the mount and its parent, and the device major/minor 
number.

-Alan







More information about the nio-dev mailing list