Bug #521
closedHEAD: no rootfs in jail
0%
Description
Hello.
I don't remember when I started seeing this, but `df' doesn't show
the rootfs from inside jail, but any other mountpoints are visible.
- jls
JID Hostname Path IPs
1 j0 /home/j0 192.168.2.251 - jexec 1 df
(nothing shows up) - jexec 1 ls
l /2 root wheel 881 Aug 5 00:52 .cshrc
total 13946
-rw-r--r-rw-r--r-2 root wheel 914 Aug 5 00:53 .profiler--r--r-1 root wheel 6896 Jul 18 2006 COPYRIGHT
drwxr-xr-x 2 root wheel 1024 Jan 17 17:09 bin
drwxr-xr-x 3 root wheel 512 Jan 17 17:11 boot
drwxr-xr-x 3 root wheel 24064 Jul 18 2006 dev
drwxr-xr-x 17 root wheel 2048 Jan 18 16:23 etc
drwxr-xr-x 4 root wheel 512 Aug 5 00:37 home
drwxr-xr-x 2 root wheel 512 Jun 14 2005 mnt
dr-xr-xr-x 2 root wheel 512 Jun 14 2005 proc
drwxr-xr-x 3 root wheel 512 Jan 18 16:22 root
drwxr-xr-x 2 root wheel 2048 Jan 17 17:10 sbin
drwxr-xr-x 3 root wheel 512 Jul 18 2006 smp
lrwxr-xr-x 1 root wheel 11 Jan 17 17:09 sys -> usr/src/sys
drwxrwxrwt 2 root wheel 2048 Jan 19 03:01 tmp
drwxr-xr-x 4 root wheel 512 Jan 18 03:03 u
drwxr-xr-x 14 root wheel 512 Jan 18 03:03 usr
drwxr-xr-x 21 root wheel 512 Jun 14 2005 var
- jexec 1 md5 /bin/df ; md5 /bin/df
MD5 (/bin/df) = a0327cd000b1d85b83766557b79500b2
MD5 (/bin/df) = a0327cd000b1d85b83766557b79500b2
- mount -tnull /home/source /home/j0/home/source
- jexec 1 df
Filesystem 1K-blocks Used Avail Capacity Mounted on
/home/source 32350786 18819430 10943294 63% /home/source
I haven't noticed any other problem, just that rootfs doesn't show
the rootfs for the jail. I also tried setting up a faked /etc/fstab
in jail, but it had no effect.
Regards.
Updated by qhwt+dfly almost 18 years ago
Correction: this is NOT specific to jail, but the same goes for chroot'ed
environment.
Updated by qhwt+dfly almost 18 years ago
I still got no clue for this, but the getfsstat(2) behavior is
definitely wrong:
- chroot /j
- ls / /usr
/:
bin dev etc proc root sbin usr var
bin include libexec pkg share
freebsd_pkg lib local pkgsrc src
games libdata obj sbin
- df /
df: /: No such file or directory - df /usr
df: /usr: No such file or directory - mount
mount: getmntinfo: Unknown error: 0
At first I thought that chroot_visible_mnt() was to be blamed, but
the behavior doesn't change even if I changed it to always return 1.
Cheers.
Updated by joerg almost 18 years ago
It works fine in 1.4 and 1.6, just as a help.
Joerg
Updated by dillon almost 18 years ago
:> > I don't remember when I started seeing this, but `df' doesn't show
:> > the rootfs from inside jail, but any other mountpoints are visible.
:>
:> Correction: this is NOT specific to jail, but the same goes for chroot'ed
:> environment.
:
:I still got no clue for this, but the getfsstat(2) behavior is
:definitely wrong:
:
I'll fix it. It's the new namecache code. chroot_visible_mnt()
is not aware of the new way filesystems are glued together.
-Matt
Updated by dillon almost 18 years ago
:At first I thought that chroot_visible_mnt() was to be blamed, but
:the behavior doesn't change even if I changed it to always return 1.
:
:Cheers.
Hmm. Yes, you are right. chroot_visible_mnt() is working properly.
The problem is that the real mount point is not visible to the
chroot, because it is above the chroot.
chroot /home/root.jail /bin/csh
df /
/home/root.jail is not a mount point. The mount point for that directory
is /home (on my system) which is 'above' the jail, so cache_fullpath()
traverses from 'above' the jail and never locates the process's root.
We have to fake the root mount description in this case. I'll have to
think about this.
-Matt
Matthew Dillon
<dillon@backplane.com>