Re: Current Directory of a Process
At 12:17 -0400 11/6/03, Robert Sandilands wrote: I am open to any suggestions. Lots of folks ask for this (vnode to path), but it's just not possible in the general case within the current architecture. As Jim said, there may not be a path, or there may be more than one. There are two really ugly options. 1. If the vnode is a directory, you can follow up the .. chain until you hit the root, at each stage iterating through the directory looking for your vnode. This is exactly the algorithm used by getcwd_physical in Libc. 2. If the vnode is a file, there's no general solution. The only feasible approach that I've seen is to get the CNID for the file and its parent, and then use volfs to look up the file and find its parent. This approach will only work on file systems that support volfs (HFS [Plus], AppleShare). You really have to stand back and look at the overall problem. How are you tapping into the kernel to generate your log points? Can you use that same mechanism to keep track of this information on a pre-process basis? Regardless, it's very likely that any approach you take will result in *serious* binary compatibility problems as we evolve the Mac OS X kernel. The kernel architecture just isn't set up to do this. S+E -- Quinn "The Eskimo!" <http://www.apple.com/developer/> Apple Developer Technical Support * Networking, Communications, Hardware _______________________________________________ darwin-kernel mailing list | darwin-kernel@lists.apple.com Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/darwin-kernel Do not post admin requests to the list. They will be ignored.
participants (1)
-
Quinn