tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: vnode_to_path()



On Mon, Feb 20, 2012 at 01:10:12PM +0100, Stephan wrote:
 > Hi folks,
 > 
 > I have a question regarding the vnode_to_path() function in
 > vfs_getcwd.c. This function should be called from kern_exec.c in order
 > to make $ORIGIN work in the dynamic linker, but for some reason is
 > commented out:

no it shouldn't...

 > #ifdef notyet
 >      /*
 >       * Although this works most of the time [since the entry was just
 >       * entered in the cache] we don't use it because it theoretically
 >       * can fail and it is not the cleanest interface, because there
 >       * could be races. When the namei cache is re-written, this can
 >       * be changed to use the appropriate function.
 >       */
 >      else if (!(error = vnode_to_path(dp, MAXPATHLEN, p->p_textvp, l, p)))
 >              data->ed_pack.ep_path = dp;
 > #endif
 > 
 > I don?t understand the issue from the short description. Can someone
 > explain what is exatly wrong?

The problem is that it works if and only if the entire chain of
pathname entries leading from the root directory to the vnode in
question is in the name cache. Sometimes it won't be, leading to
irregular and unpredictable failures.

The correct way to handle this is to call getcwd there instead, but
there's so far no agreement to accept the possible extra overhead on
every exec call. Also, there *are* race conditions and it's not at all
clear what the consequences might be.

$ORIGIN is a poorly conceived interface, unfortunately.

-- 
David A. Holland
dholland%netbsd.org@localhost


Home | Main Index | Thread Index | Old Index