Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.csd.uwm.edu!cs.utexas.edu!uunet!twwells!bill
From: bill@twwells.com (T. William Wells)
Newsgroups: comp.unix.wizards
Subject: Re: how can I get filename from file descriptor?
Message-ID: <1989Aug18.053151.2130@twwells.com>
Date: 18 Aug 89 05:31:51 GMT
References: <20613@adm.BRL.MIL>
Organization: None, Ft. Lauderdale, FL
Lines: 21

In article <20613@adm.BRL.MIL> Pabbisetty.henr@xerox.com (Nagesh Pabbisetty) writes:
: If I have a descriptor to a file, how can I find out the name of the file
: associated with it?

For most practical purposes, you don't.

1) A file descriptor may not have a path associated with it. Consider
   a file that is opened and then unlinked.

2) A file descriptor may have more than one path to it. Consider
   multiply linked files.

Assuming that neither of the above is true, the best you can do is to
get the device and inode number of the file and then search the
device's entire directory tree for the inode.

Ugh.

---
Bill                    { uunet | novavax | ankh | sunvice } !twwells!bill
bill@twwells.com