[dtrace-discuss] Re: Re: Re: How to get absolute path?
Dave Vasilevsky
djvasi at gmail.com
Sun Feb 11 03:00:16 PST 2007
All the current solutions on OS X are very suboptimal.
It does work to keep track of each process' cwd and prepend it to all relative paths. This isn't particularly easy though, especially because of fchdir. There isn't a reliable way to know what path a particular fd refers to--a table of fdpaths[pid, fd] will not work properly because not all fds are close-on-exec. With suitable post-processing by a more flexible language, one can make this work right. I'm working on some perl modules to deal with this for Fink, I'll release the code when the NDA no longer applies.
One interesting note is that on OS X, you can do [i]fcntl(fd, F_GETPATH, outpath);[/i] on a fd to get the real path. You usually have to do this for volfs paths, which are otherwise opaque. But if there's a way to trigger fcntls on arbitrary fds from dtrace, then that would solve our problem (subject to certain caveats about the wisdom of realpath when symlinks are around).
Note also that darwintrace (http://svn.macosforge.org/repository/darwinbuild/trunk/darwintrace/) already exists and allows tracing of open and other calls, with full paths. It needs some fixes for Leopard, but I'm sure kvv is on the ball. It also needs to use DYLD_FORCE_FLAT_NAMESPACE, which is a serious problem, but I've sent Apple a patch to fix that: http://10.0.1.201/trac/changeset/567. Hopefully that's a realistic workaround to dtrace for some of you.
This message posted from opensolaris.org
More information about the dtrace-discuss
mailing list