Subject: Re: emul vs. symlinks
To: Bill Studenmund <wrstuden@netbsd.org>
From: Quentin Garnier <cube@NetBSD.org>
List: tech-kern
Date: 07/10/2004 11:05:25
--Signature=_Sat__10_Jul_2004_11_05_25_+0200_kZ_WZxaUuko41bCZ
Content-Type: text/plain; charset=US-ASCII
Content-Disposition: inline
Content-Transfer-Encoding: 7bit

Le Fri, 9 Jul 2004 19:00:44 -0700
Bill Studenmund a ecrit :
> On Fri, Jul 09, 2004 at 11:33:20PM +0200, Quentin Garnier wrote:
> > Hi folks,
> > 
> > There is an issue with the way the emulation layer works with
> > symlinks. When opening a file or looking for an interpreter, the
> > emul_find() function is usually called, and its main purpose is to try
> > and find a file in the emulation root and failback on the real root if
> > it isn't found there.
> > 
> > It doesn't work well with symlinks since that part is completely
> > handled by namei(), which doesn't know, and therefore ignore, the
> > emulation root.
> 
> I think the thing to do is either teach namei about emulations or have 
> your lookup routine enforce NOFOLLOW (i.e. clear FOLLOW) and handle 
> symlinks yourself.

There is the issue der Mouse pointed out, but it's not that important in
the general case.

> Actually, since the emulation code already does the "/emul/foo/path"
> then "/path" stuff, you just need to put a symlink handling wrapper
> outside of that.

No.  emul_find() only looks up in the emulation root if the target exists,
and returns with the prefixed path in that case, and returns with the
non-prefixed path in the other case.  That's just that.

> I really think that you don't need to add your own namei() routine.
> Since you can tell namei() to not follow symlinks and the symlink
> following isn't hard, just do it yourself.

Well, what namei() does is exactly that:  call lookup() and handle
symlinks when it returns.  As ugly as it might be, it's easier to start
from namei() than from scratch.

-- 
Quentin Garnier - cube@NetBSD.org
The NetBSD Project - http://www.NetBSD.org/

--Signature=_Sat__10_Jul_2004_11_05_25_+0200_kZ_WZxaUuko41bCZ
Content-Type: application/pgp-signature

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (NetBSD)

iQEVAwUBQO+xW9goQloHrPnoAQIE9Qf7BXi6zPTvSAHmCpkaL7+2xpMF9na4apxd
m2EuafvNOq2J4MjupISJoPxq0Pjb31a4hwaWBfDaqCeF1sr4SeyMyX2PgOffSc4T
0tn8T2IfgB3GNtpZEcsl46spBYS3WoLjmoiO7e7Jd5l4DaCEQEzL9Srec4JQgrxX
dFkOb1/bQpG3gVWHXMB5l9XG+H7HPBprxU3yEfG0xQ31zjsw2670ljXIrNeMHncF
Rbod57I0e1GoXmLaZ7AW4Fcjx8CJTx0X4p1JBdhJQSXM/SL3jeNGgip3CXyLGRbN
p8zxPcxUFFav/NDoYz2/CxUB6r3bEgsie061MH82eK3/v+89hYilNw==
=UuvA
-----END PGP SIGNATURE-----

--Signature=_Sat__10_Jul_2004_11_05_25_+0200_kZ_WZxaUuko41bCZ--