From owner-freebsd-hackers Mon Apr 13 18:46:47 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id SAA15268 for freebsd-hackers-outgoing; Mon, 13 Apr 1998 18:46:47 -0700 (PDT) (envelope-from owner-freebsd-hackers@FreeBSD.ORG) Received: from smtp04.primenet.com (smtp04.primenet.com [206.165.6.134]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id BAA15252 for ; Tue, 14 Apr 1998 01:46:35 GMT (envelope-from tlambert@usr06.primenet.com) Received: (from daemon@localhost) by smtp04.primenet.com (8.8.8/8.8.8) id SAA28354; Mon, 13 Apr 1998 18:46:18 -0700 (MST) Received: from usr06.primenet.com(206.165.6.206) via SMTP by smtp04.primenet.com, id smtpd028289; Mon Apr 13 18:46:07 1998 Received: (from tlambert@localhost) by usr06.primenet.com (8.8.5/8.8.5) id SAA04924; Mon, 13 Apr 1998 18:46:03 -0700 (MST) From: Terry Lambert Message-Id: <199804140146.SAA04924@usr06.primenet.com> Subject: Re: filename from open file descriptor... To: stesin@gu.net Date: Tue, 14 Apr 1998 01:46:03 +0000 (GMT) Cc: tlambert@primenet.com, scrappy@hub.org, freebsd-hackers@FreeBSD.ORG In-Reply-To: from "Andrew Stesin" at Apr 13, 98 12:22:58 pm 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 X-Loop: FreeBSD.ORG > > > I'm trying to debug some code, and have an open file descriptor > > > that I want to find the file name that its associated with... > > > > > > is this possible? my first thought was fstat(), but that appears > > > to return everything but the name :( > > > > You remember the name when you open the file. > > How about rename()-ing the already opened file "on the fly"? > (Want to note that correct discovery of filename from the filedescriptor > seems to be theoretically impossible?) Not possible. You would have to search the entrire FS for the file, one directory at a time. If the file had a hard link, you could not know which of several valid directory entries was being renamed. You could add a VOP to the FS to allow you to link an already open file somewhere, but you would not be able to delete the previous name unless you changed the on disk structures and the in memory references for how hard links are managed (I've done this before, as an experiment; if you have a reference object that isn't the file itself, then you can always store the parent directory id in the reference object inode, and thus know the path used to open the file). Terry Lambert terry@lambert.org --- Any opinions in this posting are my own and not those of my present or previous employers. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message