I am looking for a way to determine if a given path is a bind mount point (on linux). The standard techniques for detecting regular mount points don't seem to work. Even the mountpoint command fails to detect bind mounts.
I'm not sure there is supposed to be a way to do that (except perhaps thru
/etc/fstab) because I understand that bind mounts are sort-of "hard links" in the mount space (not the file hierarchy), and there is no way (once the bind mount happened) to distinguish the source and the target mount points.
And why are asking that? Bind mounts are (IMHO) mostly useful to hide such things from the application's point of view (otherwise you would use symlinks -or even hard links, in the rare cases they are possible- for directories)
mountpoint which I just discovered thanks to your question seems to see something:
% grep /home /etc/fstab UUID=000008-0003-000c-9ecd-0f1a /home ext3 defaults 0 2 % grep /usr/src /etc/fstab /home/Src /usr/src none bind 0 0 % mountpoint /usr/src /usr/src is a mountpoint % mountpoint /home/Src /home/Src is not a mountpoint
mountpoint I find that it is doing
fstat syscalls on directories like
(added in november 2016:)
/proc/mounts e.g. proc(5)