dtrace filename lookups from fd (Serg Slobodyanyuk)

Sergey Slobodyanyuk ssv.lkml at gmail.com
Mon Jun 4 07:48:19 UTC 2012


>
>
> Date: Fri, 1 Jun 2012 17:00:20 +0100
> From: "Steven Hartland" <killing at multiplay.co.uk>
>
> As a first foray into dtrace I wanted to create a little
> script which shows the amount of disk read / write activity.
>
> Now the DtraceToolkit includes rwsnoop but this uses Solaris
> specific requests and on looking around it seems like
> using rwsnoop vn_fullpath may be the way to go.
>
> Has anyone done anything similar to this before or has any
> tips on going about this?
>
>    Regards
>    Steve
>


HI,
Some times ago I decided to do the same - port rwsnoop to FreeBSD(8.2 R).
FreeBSD vfs code quiet different from solaris code so I asked for help
Kostik and he directed me to vn_fullpath() routine after that I wrote
working port of rwsnoop.
But script generate alot of errors like "invalid address (0x....) in
action" even on data that should be there(from my point of view). After
several tries to debug it I left it as is.
You can run it with "| grep -v invalid" or direct STDERR to /dev/null.

Maybe Hackers could look at it and say what's wrong :-)

Changed part of code:

        this->fp = &(curthread->td_proc->p_fd->fd_ofiles[self->fd]);
this->vp = (struct vnode *)((*(this->fp))->f_vnode);
this->cache_dst = &((this->vp)->v_cache_dst);
this->ncp = (&((this->vp)->v_cache_dst)) != NULL ?
(&((this->vp)->v_cache_dst))->tqh_first : 0;
self->ncname = this->ncp ? (this->ncp->nc_name != 0 ?
 stringof(this->ncp->nc_name) : "<unknown>") : "<unknown>"

Link to script:
https://docs.google.com/open?id=0B7olr28SbDyNZktLMG51UHVxNW8


//Br. Serg


More information about the freebsd-hackers mailing list