The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
Google UNIX.COM



View Single Post in UNIX Forums - Click on the Thread or Permalink to View Entire Thread -->
  #2 (permalink)  
Old 11-15-2007
porter porter is offline
Registered User
 

Join Date: Jan 2007
Posts: 2,965
Quote:
Originally Posted by vinp View Post
my question is whether it possible to get the complete path of a file from the file descriptor
Not elegantly. You have to get the device and inode, then start from the root of the device and enumerate the directories, do a stat on each entry until you find a match.

And you can get multiple matches for the same inode as a single file can have multiple names.

Also, a file does not *have* to have a name, for instance if you create a file then unlink it before you close it you have a valid file descriptor but no name in the file system.

So a single file can have zero or many names.
Reply With Quote