Is it possible to get filename from file descriptor ?
    Dan Bernstein 
    brnstnd at kramden.acf.nyu.edu
       
    Sat Sep 15 20:15:53 AEST 1990
    
    
  
In article <870 at gtenmc.UUCP> kumar at gtenmc.UUCP (S.Kumar) writes:
>     A Unix question
>     Is there a way to get the filename in UNIX given the file descriptor.
>     (in a given process)
Not reliably. A file descriptor may be associated with several different
filenames, or none at all. The filenames may be hidden inside
directories that you can't read. They may change at any time.
>     I think the crash program provides a list of inodes for the filenames
>     which the process has opened. 
Filenames can change; how do you know it's the same file as when the
process was running? A root process can search the filesystem and
(unreliably, unless the disks are unmounted) find a file with a given
inode, but that's slow and really suitable only for administrative
duties.
---Dan
    
    
More information about the Comp.unix.internals
mailing list