Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!rutgers!mtune!io!granjon!packard!desoto!shz From: shz@desoto.UUCP Newsgroups: comp.unix.questions Subject: Re: A couple questions Message-ID: <314@desoto.UUCP> Date: Thu, 7-May-87 13:42:39 EDT Article-I.D.: desoto.314 Posted: Thu May 7 13:42:39 1987 Date-Received: Sat, 9-May-87 06:15:20 EDT References: <3164@jade.BERKELEY.EDU> <2382@ncoast.UUCP> Reply-To: shz@desoto.UUCP (S. Zirin) Organization: AT&T Bell Laboratories, Liberty Corner Lines: 29 In article <634@boulder.Colorado.EDU> cdash@boulder.Colorado.EDU (Charles Shub) writes: >In article <5835@brl-smoke.ARPA> gwyn@brl.arpa (Doug Gwyn (VLD/VMB) ) writes: >>In article <816@killer.UUCP> jfh@killer.UUCP (John Haugh) writes: >>>If you wanted to, you could even find out the name >>>of the file that was connected to the descriptor. (It is _not_ easy :-( ) >> >>I would think it's actually impossible. The kernel doesn't remember >>the name of the path you used to open an inode, and some descriptors >>(e.g. pipes) have no associated names. > >actually, it is possible. you know the inode associated with the descriptor >start at "/" and just keep looking for that i# keeping track of where you are. >Like the man said, it ain't easy, but it CAN be done. >-- Actually, it is even more difficult. I-numbers are only unique within a filesystem. You would first have to determine which filesystem your FD pointed to, and then start the search from the root of that filesystem. Even then it may not be possible to find the name of the file that was opened. Assuming the FD did reference a file (as opposed to an unnamed pipe or other 'magic' device), the last remaining name could have been unlinked. Which brings us to the last point: there may be multiple links to the file. The best you could hope for is to find the first name or all names, not necessarily the correct name. Check out the [usually undocumented] '-inum' option of FIND(1). Seth desoto!shz