Without being root (being able to look at kernel space), is it
possible to get a filename from an int file descriptor? I am trying
to find a file descriptor leak with a wrapper around open that would
list the types and names of all the open files. File type (reg,
socket, fifo, special...) is returned by fstat, but fstat does not
provide any info about the name of the file. I could maintain a table
of the names of all the open files when the are opened, but I would
prefer to do something like:
if ( open ( ... ) == -1 )
if ( errno == EMFILE )
for ( i = 0; i < getdtablesize ( ); i++ )
if ( !fstat ( i, &fstatus ) && S_ISREG ( fstatus.st_mode ) )
Get and print filename...
I could use a program like lsof, but I would really like to know
how to do this... Any ideas?
Thanks,
Clem Taylor