Re: Current Directory of a Process
Re: Current Directory of a Process
- Subject: Re: Current Directory of a Process
- From: Jim Magee <email@hidden>
- Date: Wed, 11 Jun 2003 11:49:33 -0400
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.