]> CyberLeo.Net >> Repos - FreeBSD/stable/10.git/blob - cddl/contrib/dtracetoolkit/Snippits/fd2pathname.txt
MFC r368207,368607:
[FreeBSD/stable/10.git] / cddl / contrib / dtracetoolkit / Snippits / fd2pathname.txt
1 You have a file descriptor (probably from a syscall), and you want the
2 corresponding pathname.
3
4 If you are on newer versions of DTrace, there is the fds[] array,
5
6 # dtrace -n 'syscall::read:entry { @[fds[arg0].fi_pathname] = count(); }'
7 dtrace: description 'syscall::read:entry ' matched 1 probe
8 ^C
9
10   /etc/minor_perm                                                   2
11   /etc/mnttab                                                       2
12   /etc/motd                                                         2
13   /etc/magic                                                        4
14   /usr/sbin/clri                                                    5
15   /devices/pseudo/clone@0:ptm                                       6
16   /sbin/mount                                                       6
17   /dev/pts/28                                                       7
18   /devices/pseudo/consms@0:mouse                                   31
19   /devices/pseudo/conskbd@0:kbd                                    47
20   <unknown>                                                       351
21
22 easy.
23
24 but if you are on an older version of DTrace, try this to convert from
25 this->fd to self->vpath,
26
27         this->filep =
28             curthread->t_procp->p_user.u_finfo.fi_list[this->fd].uf_file;
29         this->vnodep = this->filep != 0 ? this->filep->f_vnode : 0;
30         self->vpath = this->vnodep ? (this->vnodep->v_path != 0 ?
31             cleanpath(this->vnodep->v_path) : "<unknown>") : "<unknown>";
32