Re: Getting the full path for a file
Re: Getting the full path for a file
- Subject: Re: Getting the full path for a file
- From: Quinn <email@hidden>
- Date: Mon, 12 Jul 2004 10:53:24 +0100
At 9:48 -0700 23/6/04, Krishna Monian wrote:
Hi All,
I was looking at the MoreFiles samples on the Apple
site and the FullPath code in particular. I am trying
to modify the fs_usage system call so that it reports
the full path.
However I am not sure how exactly I should go about
using the getFullPath function.
I would really appreciate it if someone could guide me
on this.
I sent the following to Krishna on a private email, but I'm posting
it here because I thought others could benefit from the information
as well.
-------------------------------------------------------------------------
o vnode to full path -- In Mac OS X 10.3 and later, we record the
path that the user traversed to access a vnode. You can get this
information from user space using the F_GETPATH fcntl. You can get
this information from the kernel using the vn_getpath routine.
o full path problems -- Even with the above, there are numerous
problems associated with using full paths. For example:
- race conditions -- There's no guarantee that the full path you get
is still valid. Between the time that it's recorded (as the file
is being looked up) and the time you see it, someone could have
renamed the file, or one of its parents.
- uniqueness -- There's no guarantee that the full path is unique.
A file with multiple hard links can have multiple valid full paths.
The path you get back is the path that the user used to look up
the file, which may not be the path you were looking for.
- existence -- A common Unix practice is to open a temporary
file and then delete the file on disk. The file disappears from
the catalogue but is still accessible via the file descriptor.
In this case there is *no* valid full path to the file.
- volfs -- The Core Services File Manager (which is used by most
Carbon applications) does most file access via volfs. You
can read about volfs in DTS Q&A 1113 "The '/.vol' directory and 'volfs'".
<
http://developer.apple.com/qa/qa2001/qa1113.html>
As mentioned in the Q&A, Apple explicitly warns against you
constructing or interpreting volfs paths; this is an area that's
subject to change in the future. Furthermore, there's no efficient
way to map from a volfs path to the corresponding Posix path.
-------------------------------------------------------------------------
S+E
--
Quinn "The Eskimo!" <
http://www.apple.com/developer/>
Apple Developer Technical Support * Networking, Communications, Hardware
_______________________________________________
darwin-kernel mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/darwin-kernel
Do not post admin requests to the list. They will be ignored.