linux emulation: cd /
Andriy Gapon
avg at icyb.net.ua
Wed Oct 20 10:56:21 PDT 2004
This is another bug-or-feature question:
doing cd / under linux emulation /linux_chdir("/")/ sets current
directory to real root rather than /compat/linux.
I see that this happens because of some check in linux_emul_convpath()
with the following comment:
/*
* We now compare the vnode of the linux_root to the one
* vnode asked. If they resolve to be the same, then we
* ignore the match so that the real root gets used.
* This avoids the problem of traversing "../.." to find the
* root directory and never finding it, because "/" resolves
* to the emulation root directory. This is expensive :-(
*/
I see where this is useful, but I think that explicit chdir to / should
be exempted from such check. One reason for my opinion is that currently
linux mkdir -p is broken bacause of this:
try mkdir -p /foo/bar/blah1/blah2/blah3
so that /compat/linux/foo/bar exist and you can write to it, but
/foo/bar doesn't exist (or exists but is not writable) and you can not
create it and blah1, blah2 and blah3 do not exist. mkdir will check if
/compat/linux/foo/bar/blah1/blah2 exists (it doesn't) and then will
chdir to root (which will be real root) and try to create foo, chdir to
foo, create bar etc - this will fail.
--
Andriy Gapon
More information about the freebsd-emulation
mailing list