From owner-freebsd-hackers Sun Jan 18 14:06:57 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id OAA18038 for hackers-outgoing; Sun, 18 Jan 1998 14:06:57 -0800 (PST) (envelope-from owner-freebsd-hackers@FreeBSD.ORG) Received: from smtp02.primenet.com (smtp02.primenet.com [206.165.6.132]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id OAA18020 for ; Sun, 18 Jan 1998 14:06:49 -0800 (PST) (envelope-from tlambert@usr04.primenet.com) Received: (from daemon@localhost) by smtp02.primenet.com (8.8.8/8.8.8) id PAA10730; Sun, 18 Jan 1998 15:06:43 -0700 (MST) Received: from usr04.primenet.com(206.165.6.204) via SMTP by smtp02.primenet.com, id smtpd010694; Sun Jan 18 15:06:36 1998 Received: (from tlambert@localhost) by usr04.primenet.com (8.8.5/8.8.5) id PAA03832; Sun, 18 Jan 1998 15:06:34 -0700 (MST) From: Terry Lambert Message-Id: <199801182206.PAA03832@usr04.primenet.com> Subject: Re: dladdr hax To: dg@root.com Date: Sun, 18 Jan 1998 22:06:34 +0000 (GMT) Cc: jdp@polstra.com, hasty@rah.star-gate.com, hackers@FreeBSD.ORG In-Reply-To: <199801181553.HAA24836@implode.root.com> from "David Greenman" at Jan 18, 98 07:53:06 am X-Mailer: ELM [version 2.4 PL25] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk > 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.