Monday, July 25, 2005

File Descriptors in DTrace

Starting with b16 of SX new useful feature has been added to DTrace - fds[] array.

"[...] returns information about the file descriptors associated with the process corresponding to the current thread. The array's base type is the fileinfo_t structure already used by DTrace's I/O provider, with a new member for the open(2) flags. Here's an example of fds[] in action:

$ dtrace -q -s /dev/stdin
/ execname == "ksh" && fds[arg0].fi_oflags & O_APPEND /
printf("ksh %d appending to %s\n", pid, fds[arg0].fi_pathname);

If I run this command on my desktop and start typing commands in another shell, I see output like this:

ksh 127453 appending to /home/mws/.sh_history
ksh 127453 appending to /home/mws/.sh_history


Well, this is going to be really useful!

btw: if you have a nfs server and want to use IO provider then I'm sure you will welcome bug id 6175304 which is RFE I submitted some time ago and is integrated in b17 - in practice it allows you to use IO provider on nfs server so observing nfsd will be much more friendly.

No comments: