I am enabling the syscall::write:entry probe on a running process. Within dtrace, I have easy access to the file descriptor. I can also easily cross-reference this using pfiles to determine the filename. I am interested in doing this from within dtrace. I started with curpsinfo and from there I was going to access the user struct and follow the trail to the vnode where I expected I would find the goods I am interested in. Once I include <sys/proc.h> I get error messages related to <sys/kstat.h>. I suspect that there is an easier way. I''m new to this, so I''ll appreciate whatever pointer you can give me. This is somewhat of a pointless exercise, as I have what I need, but I''m using this as an opportunity to learn. What is the dtrace way? Given that i didn''t have enabled probes when the file was opened, and I''m in the action clause with a file descriptor, how do I get the name of the file? Thanks, Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.opensolaris.org/pipermail/dtrace-discuss/attachments/20070213/95feeb71/attachment.html>
Jim Mauro
2007-Feb-14 03:16 UTC
[dtrace-discuss] How to get from file descriptor to file name
Check out this discussion thread:
http://www.opensolaris.org/jive/thread.jspa?messageID=72813𑱭
And Mike''s blog:
http://blogs.sun.com/mws/entry/dtrace_inlines_translators_and_file
Where he describes the fds[] array, with this example:
$ dtrace -q -s /dev/stdin
syscall::write:entry
/ execname == "ksh" && fds[arg0].fi_oflags & O_APPEND /
{
printf("ksh %d appending to %s\n", pid,
fds[arg0].fi_pathname);
}
This will accomplish what you wish...
/jim
MC wrote:>
> I am enabling the syscall::write:entry probe on a running process.
> Within dtrace, I have easy access to the file descriptor. I can also
> easily cross-reference this using pfiles to determine the filename. I
> am interested in doing this from within dtrace. I started with
> curpsinfo and from there I was going to access the user struct and
> follow the trail to the vnode where I expected I would find the goods
> I am interested in. Once I include <sys/proc.h> I get error messages
> related to <sys/kstat.h>.
>
> I suspect that there is an easier way. I''m new to this, so
I''ll
> appreciate whatever pointer you can give me.
>
> This is somewhat of a pointless exercise, as I have what I need, but
> I''m using this as an opportunity to learn. What is the dtrace
way?
>
> Given that i didn''t have enabled probes when the file was opened,
and
> I''m in the action clause with a file descriptor, how do I get the
name
> of the file?
>
> Thanks,
> Chris
> ------------------------------------------------------------------------
>
> _______________________________________________
> dtrace-discuss mailing list
> dtrace-discuss at opensolaris.org
>