The UNIX and Linux Forums  

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


UNIX for Advanced & Expert Users Advanced UNIX and Linux questions go here. Expert-to-Expert.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
absolute path Kirichiko UNIX for Dummies Questions & Answers 2 10-03-2007 03:30 AM
$PWD shows absolute path vs path w/symbolic links kornshellmaven Shell Programming and Scripting 3 06-13-2007 09:15 AM
absolute path filedeliver High Level Programming 4 06-05-2007 02:18 PM
vi - replacing a relative path with absolute path in a file Yinzer955i UNIX for Dummies Questions & Answers 2 09-07-2006 08:47 AM
HOW to make absolute path???? HELP youngvet High Level Programming 1 11-01-2003 12:58 PM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 11-15-2007
Registered User
 

Join Date: Oct 2007
Posts: 3
Stumble this Post!
How to get Absolute path from file descriptors

Hello all,
my question is whether it possible to get the complete path of a file from the file descriptor iam going through some code for which i dont understood this statement
Code:
ifstream s((const byte*)fd);
what exactly this represents any idea.
which is not properly working is there any way that i can know to get its path to know whethrer that file is opened for writing. please help me.
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 11-15-2007
Registered User
 

Join Date: Jan 2007
Posts: 2,965
Stumble this Post!
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
  #3 (permalink)  
Old 11-15-2007
Registered User
 

Join Date: Oct 2007
Posts: 3
Stumble this Post!
thanks u porter,
for quick reply ya tried with the stat and fstat for which iam getting inode as 0, so how to proceed and also is there any alternate for this
line. please tell me
Code:
ifstream s((const byte*)fd);
because from the code iam fetching file descriptors only.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 01:49 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0