Subject: Re: linux emul problem in 1.5R?
To: None <current-users@netbsd.org, jmarin@pyy.jmp.fi>
From: Ross Harvey <ross@ghs.com>
List: current-users
Date: 02/01/2001 17:31:48
> From: Jukka Marin <jmarin@pyy.jmp.fi>
>
> I just cvs updated my kernel sources and built a kernel (because of the
> panic I had with the older kernel).  So far, everything else looks OK,
> but Applixware no longer starts.  When I try to start it, it just prints
>
> Current directory: Success
>
> to stderr and exits.  This happens with Applixware, but not with linux
> Netscape (v4.76) or acroreader.
>
> All I did was install the new kernel and reboot.  Before that, Applixware
> was perfectly OK.
>
> Any ideas?
>
>   -jm

Some code was added recently that implemented a CHECK_ALT_SYMLINK() feature
to the common emulation code. It's probably what is responsible for your
failures; it certainly caused mine.

I believe it interferes with programs that do things like getcwd(3), because
it bypasses some special logic that deals with the real root vs the emulation
root. In any case, the problem it "fixed" was purely hypothetical ... AFAIK
there were no actual bugs reported, and although a PR is referenced in the
CVS log, I think that PR just described behavior predicted by reading the
code itself, not a problem with any real linux application.

It all has something to do with whether lstat(2) resolves symbolic links
under the emulation root that point nowhere.  While the new behavior might
be good in some cases, I can also imagine specific cases where the old
behavior was better, so I think we've absolutely nothing to lose by backing
out all those recent mods.

Here is a crude patch that will get your kernel going again:

Index: linux_file.c
===================================================================
RCS file: /cvsroot/syssrc/sys/compat/linux/common/linux_file.c,v
retrieving revision 1.37
diff -u -r1.37 linux_file.c
--- linux_file.c	2001/01/22 21:31:37	1.37
+++ linux_file.c	2001/02/02 00:54:43
@@ -479,6 +479,8 @@
 	return 0;
 }
 
+int enable_hrh = 0;
+
 static int
 linux_stat1(p, v, retval, dolstat)
 	struct proc *p;
@@ -495,7 +497,8 @@
 
 	sg = stackgap_init(p->p_emul);
 	st = stackgap_alloc(&sg, sizeof (struct stat));
-	if (dolstat)
+	
+	if (enable_hrh && dolstat)
 		CHECK_ALT_SYMLINK(p, &sg, SCARG(uap, path));
 	else
 		CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));