Subject: Re: an emulation environment dilema...
To: NetBSD-current Discussion List <current-users@netbsd.org>
From: Greg A. Woods <woods@most.weird.com>
List: current-users
Date: 10/23/1998 11:09:27
[ On Fri, October 23, 1998 at 07:55:53 (-0400), Todd Vierling wrote: ]
> Subject: Re: an emulation environment dilema...
>
> On Thu, 22 Oct 1998, Greg A. Woods wrote:
> 
> : 	20:36 [279] $ ls -l /emul/sunos/usr/bin
> 
> : 	-rwxr-xr-x  1 woods  wheel    1010 Oct 22 13:40 arch
> 
> At 1010 bytes, this is obviously a shell script.

Well well well!  So it is.  Unfortunately I'd thought I'd already
checked that, but I must have missed it or mixed it up somehow.

The problem though is still the explicit path, and although the
suggestion you make of fixing the interpreter path at the top of this
script (also suggested by Andreas Wrede in another followup to your
message) is close, but it wouldn't quite work in this case because SunOS
make doesn't rely on #! exec() in this case.

Jaromir Dolecek also sent me some mail and suggested running ktrace to
find out whether or not the /emul/sunos paths were indeed being tried
first, or not.

I should have thought of ktrace, *and* I should have remembered that if
it's make it's also unlikely that it would be directly exec()ing anthing
but would instead be using system().  That's exactly the problem too.
It tries to run /emul/sunos/bin/sh but can't find it, switches back to
NetBSD emulation after finding /bin/sh, and of course then can't find
/bin/arch.

Simply putting SunOS sh in /emul/sunos/bin/ fixes the problem.

BTW, if #! interpreter file exec()s do fail in the emulated environment
I'd consider that a bug.  It should not be necessary to fix the path of
the interpreter.  The interpreter exec() should be tried in the
emulation environment first too.  Note that's not what this bug was
anyway.  In this case there is a /bin/sh interpreter in the
non-emulation environment, so if the script were ever found it should
have worked barring any incompatabilities in the script syntax.

Thanks everyone for helping me get past what seemed like an "obvious"
bug, but which was indeed very far from obvious.  Good old ktrace to the
rescue!  (Again!)

(BTW, the emulation environment does continue to work fine even with
symlinks at the top and within.  Oh, and after having read
compat_linux(8) I think compat_sunos(8) stinks, but unless I do find
some new reason to learn even more about how emulation works I think I'd
best leave fixing it up to someone who does know more.)

-- 
							Greg A. Woods

+1 416 218-0098      VE3TCP      <gwoods@acm.org>      <robohack!woods>
Planix, Inc. <woods@planix.com>; Secrets of the Weird <woods@weird.com>