how can I get filename from file descriptor?
Conor P. Cahill
cpcahil at virtech.UUCP
Wed Aug 16 11:51:49 AEST 1989
In article <20613 at adm.BRL.MIL>, Pabbisetty.henr at 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?
I'm not sure if this is the most efficient way, but it will work for any
standard file descriptors.
1. get the device and inode number using fstat(2).
2. Find the block special file that contains the file system that
contains the file (the device number will match).
3. Look up the device in /etc/mnttab (to find the mount point).
4. cd to the mount point
5. Search the indicated file system for a file with the same inode.
More information about the Comp.unix.wizards
mailing list