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 Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD.

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 07:30 AM
$PWD shows absolute path vs path w/symbolic links kornshellmaven Shell Programming and Scripting 3 06-13-2007 01:15 PM
absolute path filedeliver High Level Programming 4 06-05-2007 06:18 PM
vi - replacing a relative path with absolute path in a file Yinzer955i UNIX for Dummies Questions & Answers 2 09-07-2006 12:47 PM
HOW to make absolute path???? HELP youngvet High Level Programming 1 11-01-2003 04:58 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-16-2007
vinp vinp is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 3
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.
  #2 (permalink)  
Old 11-16-2007
porter porter is offline Forum Advisor  
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.
  #3 (permalink)  
Old 11-16-2007
vinp vinp is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 3
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.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 01:50 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0