Subject: Re: directory-scanning in linux emulation
To: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
From: David Maxwell <david@crlf.net>
List: current-users
Date: 07/06/2006 11:42:26
On Fri, 07 Jul 2006, Izumi Tsutsui wrote:
> smb@cs.columbia.edu wrote:
> 
> > When running firefox-linux (though I've heard the problem also happens
> > with gaim), it doesn't DTRT in the dialog box for selecting an application
> > to handle a particular file.  In particular, it seems to show only the
> > Linux emulation tree, rather than the whole system; this in turn means
> > that things in /usr/pkg/bin -- a likely source -- aren't visible.
> 
> Isn't it a design of compat_linux(8) implementation?
> 
> If you want to make linux binaries not to search /emul/linux
> shadow tree, you could use /../ prefix for file path.
> (undocumented but noted in sys/compat/common/compat_util.c)
> I.e. if you create a symlink "netbsd@ -> /.." under /emul,
> you could see whole NetBSD native tree under /emul/netbsd/
> even on any dialog box.

I didn't know about the /../ prefix. That's useful.

Another thing to note - some applications have counterintuitive behaviours.

Let's take Acroread7, for example.

1) Install acroread7.
2) run 'acroread7 /home/smb/foo.pdf' - works.
3) mkdir /emul/linux/home/smb
4) run 'acroread7 /home/smb/foo.pdf' - "There was an error opening this
      document. No such file or directory."

At first, it seems that acrobat isn't trying to open(2) the file you
specified, it is instead parsing the path, opening the directory,
(getting a handle to the one in /emul/linux, since it exists) and
deciding the file isn't there, after scanning it. From the ktrace, it
seems that it does a chdir to the directory - ending up in the /emul
version.

I suppose you could get reasonable behaviour for readonly files by
loopback mounting /home/smb to /emul/linux/home/smb, then union mounting
an fs on top of that, to hold your linux-specific files. Of course read-write
files will end up modified in the union, not in the underlying /home...

I think I've seen similar behaviour to acroread's from firefox as well.

In general I'd say avoid having a home directory in the /emul if you
can.

-- 
David Maxwell, david@vex.net|david@maxwell.net --> Unless you have a solution
when you tell them things like that, most people collapse into a gibbering, 
unthinking mass.  This is the same reason why you probably don't tell your 
boss about everything you read on BugTraq!    - Signal 11