Re: one-line umount patch needed for am-utils

From: Alexander Viro (viro@math.psu.edu)
Date: Tue Oct 03 2000 - 18:06:36 EST


On Tue, 3 Oct 2000, Ion Badulescu wrote:

> Hi Alan,
>
> The patch included below allows the kernel to unmount a filesystem whose
> root entry is a symlink.
>
> Let me give you a bit of background. In addition to more common 2-level
> indirect mounts (also provided by autofs), amd allows for the so-called
> "direct mounts". They are implemented by mounting an amd-provided NFS
> filesystem with only one entry: the root "directory", which is in fact a
> symlink. Upon readlink, amd mounts the real (remote) NFS filesystem
> somewhere else and makes the symlink point to the real mountpoint.

        On 2.4 you can do them directly - no intermediate filesystem
needed. mount() with MS_BIND in flags will do the thing quite fine
(mount(old_dir,new_dir,NULL,MS_BIND,NULL); or mount --bind $old_dir
$new_dir; notices that old_dir doesn't have to be a root of any filesystem
- any existing directory will be fine). Essentially, that's "symlinks done
right".

> It's kind of silly and an abuse of the VFS, I agree. Unfortunately, it's
> been around for a while, it works on other systems and real people are
> using it. And they get a nasty surprise when they try it on Linux: the
> amd-provided NFS filesystems cannot be unmounted, because the VFS umount
> code follows the root symlink.

So fix amd and teach it not to do that.

> The patch fixes this by replacing the namei() in sys_umount with a
> lnamei() which doesn't follow symlinks at the end of the chain. It has
> been tested, and it does solve the amd problem. It does not break
> anything else, at least in my testing, and the change makes sense.
>
> Al, I'm cc:-ing you because this is basically your turf. Please let us
> know if you have any objections to the patch. The same change (different
> code though) is also needed for 2.4, by the way.

Last time I've touched 2.2 VFS was long ago. And 2.4 doesn't need that -
there's much better mechanism for the same thing. E.g. you get correct
behaviour of ".." in the root of bound subtree - it goes to parent
of new_dir, instead of the parent of old_dir (as it would be with
symlinks). See below:

# mkdir /tmp/foo
# mount --bind /usr/lib/gcc-lib /tmp/foo
# ln -sf /usr/lib/gcc/lib /tmp/bar
# ls -l /usr/lib/gcc-lib
total 1
drwxr-xr-x 4 root root 1024 Feb 23 2000 i386-linux
# ls -l /tmp/foo/
total 1
drwxr-xr-x 4 root root 1024 Feb 23 2000 i386-linux
# ls -l /tmp/foo
total 1
drwxr-xr-x 4 root root 1024 Feb 23 2000 i386-linux
# ls /tmp/foo/../..
bin cdrom etc home lib mnt root tmp var
boot dev floppy initrd lost+found proc sbin usr vmlinuz
# ls -l /tmp/bar/
total 1
drwxr-xr-x 4 root root 1024 Feb 23 2000 i386-linux
# ls -l /tmp/bar
lrwxrwxrwx 1 root root 17 Oct 3 21:45 /tmp/bar ->
/usr/lib/gcc-lib/
# ls /tmp/bar/../..
X11R6 doc include lib lost+found sbin src
bin games info local man share

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Sat Oct 07 2000 - 21:00:12 EST