Subject: Re: /emul/xxx for all/other /sys/compat/xxx?
To: None <tech-kern@NetBSD.ORG>
From: Frank van der Linden <frank@fwi.uva.nl>
List: tech-kern
Date: 03/06/1995 21:01:16
Quoting Christos Zoulas,

> The alternate root is provided as a means to programs to find and update
> their own configuration files, shared libraries etc. Creating files should
> work normally. Consider running the svr4 ksh and doing 'echo > foo' in /
> as Charles said. Notice that the ldconfig example will work properly,
> if the ld.so.cache already exists in /emul/linux/etc.

That's clearly a good point. However, my change for creating files was motivated
by the thought that there you can divide the system up into 2 sorts of
directories: the ones accessible by privileged users, and the home
directories. Writes and/or reads to the latter clearly shouldn't be
clobbered by alternate root handling. However, you also don't want any
'alien' binaries from other systems (over)writing your system files. So
that is why they should preferably be written under /emul/xxx, where
they will only be visible by the foreign binaries. The only thing that
you have to be certain about, is that the right directories exist
under /emul/xxx, and they will be used for both reading and writing.
For the other scheme to work, you would have to know each file that
would be used, and create empty versions of it under /emul/xxx.

Also, I expect that when you really want to write something in
a 'system' directory, you won't be doing that using a Linux
or any other binary. Unless, perhaps, you are bootstrapping
your system with binaries from another OS. But even that
might work.

My point about the Linux ldconfig was actually about the symbolic
links it tries to make to the shared libraries. What should be done
for them? I made symlink() follow the rule for creating new files:
if the directory it wanted to create the link in existed under /emul/linux,
it was created there (attempted anyway). This worked for ldconfig.

A chroot + union mount would indeed fix all this.. Well, if all the
emulation getdirentries() functions knew how to handle union mounted
dirs, which they don't currently.

- Frank