Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 18 Jan 1998 22:06:34 +0000 (GMT)
From:      Terry Lambert <tlambert@primenet.com>
To:        dg@root.com
Cc:        jdp@polstra.com, hasty@rah.star-gate.com, hackers@FreeBSD.ORG
Subject:   Re: dladdr hax
Message-ID:  <199801182206.PAA03832@usr04.primenet.com>
In-Reply-To: <199801181553.HAA24836@implode.root.com> from "David Greenman" at Jan 18, 98 07:53:06 am

next in thread | previous in thread | raw e-mail | index | archive | help
> Your
> suggestion is a good one and in fact we already save the vp of the image
> being execed; see p->p_textvp. If the directory vnode is also stored, then
> one could do the equivilent of 'getcwd' on that directory and yield the
> full path to the file. There may be directory reference count complications,
> however - you'd have to hold a reference to the directory vnode while the
> image was running, and this could be evil. Needs more thought.

You could do it byfile handle, and look it up that way; the FS
namespace code is not very good and can't support dev_t/ino_t based
lookup (you could get the dev_t from the vp for the image), but it
does support fhtovp().

Ideally, you'd want to store an FS opaque value to do this.  Directories
implcitly point to their parent in their data ("..").  There are issues
with mount point traversal, of course.  So you *could* getcwd() your
way up.

One *REAL* problem with doing this via vp instead of just doing what
Sun does is that it gives you a vnode for the parent directory (I know,
that's what you think you want 8-)).  This is a problem because of
chroot.  This is the same reason you can't export an inode namespace
very safely, unless inodes store parent pointers.

Really, hard links need to have an alias inode whose purpose is to
point to the real inode, and the real inode points to the alias as
a circular list.  This will let you delete the first link while
keeping the second, yet maintain correct parent pointers for hard
links.

Of course, that would make the implementation FS specific again; I
still think the best approach is to use the argv[ 0], and if your
program cares, start it with a wrapper that passes the absolute
path as argv[ 0].  Mostly, you care about libraries.  The java use
of this is a kludge anyway; really java should have an "ldconfig"
equivalent, then this dancing would not be necessary.


					Terry Lambert
					terry@lambert.org
---
Any opinions in this posting are my own and not those of my present
or previous employers.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199801182206.PAA03832>