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

From: Andries Brouwer (aeb@veritas.com)
Date: Fri Jun 02 2000 - 06:54:59 EST


On Fri, Jun 02, 2000 at 10:07:49AM +1200, Chris Wedgwood wrote:
> On Thu, Jun 01, 2000 at 12:50:48PM +0200, Oystein Viggen wrote:
>
> Is it possible to do something similar with just one file? The
> ability to mount /dev/log inside a chroot jail would be nice, as
> this can not easily be solved by filesystem links.
>
> No, it's not possible and in this instance not desirable.

Why do you say so?

# touch /tmp/pw
# mount -t bind /etc/passwd /tmp/pw
# head -1 /tmp/pw
root:x:0:0:root:/root:/bin/bash
# tail -1 /proc/mounts
/dev/root /tmp/pw ext2 rw 0 0
# mount | tail -1
/etc/passwd on /tmp/pw type bind (rw)
#

The file-bind has succeeded. But /proc/mounts contains misleading information.

# ls -l /tmp/pw /etc/passwd
-rw-r--r-- 1 root root 2751 Apr 29 21:45 /tmp/pw
-rw-r--r-- 1 root root 2751 Apr 29 21:45 /etc/passwd
# echo "fake::0:0:fake:/:" >> /tmp/pw
# ls -l /tmp/pw
-rw-r--r-- 1 root root 2751 Apr 29 21:45 /tmp/pw
#

Funny - the file is unchanged. Where did the echoed stuff go?
Answer: it went to the underlying /tmp/pw, the unmounted one.

# rm /tmp/pw
# umount /tmp/pw
umount: /etc/passwd: not mounted
umount: /tmp/pw: not found
# tail -1 /proc/mounts
/dev/root /tmp/pw ext2 rw 0 0
#

Hmm. umount cannot umount this anymore, but the kernel still
lists it in /proc/mounts.

Andries

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



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