Subject: Re: emul vs. symlinks
To: None <tech-kern@NetBSD.org>
From: der Mouse <mouse@Rodents.Montreal.QC.CA>
List: tech-kern
Date: 07/09/2004 22:11:10
> 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.

Not enough.

/emul/xyzos/foo/bar -> /foo/pub
/foo/pub -> /oof/bup
/emul/xyzos/oof does not exist

try to open /foo/bar/baz.1.20

/emul/xyzos/foo/pub/baz.1.20 is the desired target file
/oof/bup/baz.1.20 exists but is not the desired target file

Clearing NOFOLLOW will not affect anything here, since none of the
baz.1.20 entities are symlinks.  You have to teach namei about
emulations at least enough to have it try within the emulation root
every time an absolute symlink follow is done, having it restart from
the real root whenever it runs into an ENOENT within the emulation
root.  (That still doesn't give a way for an emulation tree to provide
nonexistence of something that exists in the real root, but that may be
more bother than it's worth.  The whole /emul paradigm breaks
traditional semantics in other ways, too, though, such as allowing
chdir("/foo");open("bar"); to error out even when open("/foo/bar")
succeeds, so this additional oddity may be entirely tolerable.)

> I really think that you don't need to add your own namei() routine.
> Since you can tell namei() to not follow symlinks

Ah, but you can't.  All you can tell it is not to follow _terminal_
symlinks.

Of course, that may be good enough in practice even if examples like
the one above show it's not enough in all cases.

/~\ The ASCII				der Mouse
\ / Ribbon Campaign
 X  Against HTML	       mouse@rodents.montreal.qc.ca
/ \ Email!	     7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B