Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Current Directory of a Process



On Wednesday, June 11, 2003, at 11:03 AM, Robert Sandilands wrote:
I can get the vnode pointing to the current directory, and that is good... Sort of. I need to be able to translate this vnode to a path name to be used in user space. I have poured through the kernel and not found a way to do that. In desperation I downloaded the code for Libc and looked at the getcwd code. Horror! If you want to spend some sleepless nights having nightmares look at Libc/gen/getcwd.c. Obviously that type of solution is not practical for the kernel.

Any ideas how to translate a vnode to a path?

It's the same issue trying to translate any other open file (directory) to a path. You can't! At least not reliably.

For one thing, there might not be a path anymore (the last link to the file/directory was deleted while you had an open reference to it). This is perfectly legal in BSD. For another, with hard-links, there may be MANY paths to the open file (not an issue with directories because of the inability to hard-link to a directory). Not all of which your application can use (because of permissions on intervening directories).

Again, we have to ask "what are you trying to accomplish?" It sounds like you may need to re-factor which parts of your application belong in user space and which parts belong in the kernel.

--Jim
_______________________________________________
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.

References: 
 >Re: Current Directory of a Process (From: Robert Sandilands <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.