Re: Loopback (dir->dir) mounting (NOT -o loop)

From: Jamie Lokier (
Date: Sun Jun 04 2000 - 10:08:24 EST

Alexander Viro wrote:
> Umm... You know, I'ld rather have a way to determine whether <foo> is a
> mountpoint. That would be useful for things a-la tar(1), find(1), etc. -
> ->st_dev comparison is a kludge, after all the question is about one
> point in namespace, not two. OTOH bits in ->st_mode are scarce...

Detecting the same directory is usually done by comparing
(st_dev,st_ino). It is after all the only way to detect hard links.
find(1) does this to avoid following directory cycles

> As for the symlinks - you are missing another problem: .. handling. Shell
> somewhat hides it, but it makes things even uglier when you get
> $ ls ..
> bin dev home lost+found mnt proc sbin usr
> boot etc lib misc opt root tmp var
> $ cd ..
> $ ls bin
> ls: bin: No such file or directory
> IMO security-concerned stuff should treat mountpoints the same way it
> treats symlinks. Notice that bindings _are_ mountpoints in all respects
> and if you bind the root of filesystem tree you can't distinguish that
> from the case when you simply mounted that fs twice - it will give you
> exactly the same state. And treatment of mountpoints might be nicer, to
> put it mildly - rm -rf crossing the mountpoints hardly made anyone
> happy ;-/

It's ugly, but maybe they could appear as symlinks "mntpnt ->
mntpnt/:vfsmount_info"? .. works as you want and they're not followed
by security-conscious stuff.

-- Jamie

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
Please read the FAQ at

This archive was generated by hypermail 2b29 : Wed Jun 07 2000 - 21:00:18 EST