Deleted Added
full compact
io.d (236628) io.d (238366)
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE

--- 4 unchanged lines hidden (view full) ---

13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 *
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE

--- 4 unchanged lines hidden (view full) ---

13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 *
21 * $FreeBSD: head/cddl/lib/libdtrace/io.d 236628 2012-06-05 18:58:05Z gnn $
21 * $FreeBSD: head/cddl/lib/libdtrace/io.d 238366 2012-07-11 16:27:02Z gnn $
22 */
23/*
24 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
25 * Use is subject to license terms.
26 */
27
28#pragma ident "%Z%%M% %I% %E% SMI"
29
22 */
23/*
24 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
25 * Use is subject to license terms.
26 */
27
28#pragma ident "%Z%%M% %I% %E% SMI"
29
30#pragma D depends_on module unix
31#pragma D depends_on provider io
32
30#pragma D depends_on provider io
31
33inline int B_BUSY = B_BUSY;
34#pragma D binding "1.0" B_BUSY
35inline int B_DONE = 0x00000200;
36#pragma D binding "1.0" B_DONE
37inline int B_ERROR = B_ERROR;
38#pragma D binding "1.0" B_ERROR
39inline int B_PAGEIO = B_PAGEIO;
40#pragma D binding "1.0" B_PAGEIO
41inline int B_PHYS = B_PHYS;
42#pragma D binding "1.0" B_PHYS
43inline int B_READ = B_READ;
44#pragma D binding "1.0" B_READ
45inline int B_WRITE = B_WRITE;
46#pragma D binding "1.0" B_WRITE
47inline int B_ASYNC = 0x00000004;
48#pragma D binding "1.0" B_ASYNC
49
50typedef struct bufinfo {
51 int b_flags; /* buffer status */
52 size_t b_bcount; /* number of bytes */
53 caddr_t b_addr; /* buffer address */
54 uint64_t b_lblkno; /* block # on device */
55 uint64_t b_blkno; /* expanded block # on device */
56 size_t b_resid; /* # of bytes not transferred */
57 size_t b_bufsize; /* size of allocated buffer */
58 caddr_t b_iodone; /* I/O completion routine */
59 int b_error; /* expanded error field */
60 dev_t b_edev; /* extended device */
61} bufinfo_t;
62
63#pragma D binding "1.0" translator
64translator bufinfo_t < struct buf *B > {
65 b_flags = B->b_flags;
66 b_addr = B->b_un.b_addr;
67 b_bcount = B->b_bcount;
68 b_lblkno = B->_b_blkno._f;
69 b_blkno = sizeof (long) == 8 ? B->_b_blkno._f : B->_b_blkno._p._l;
70 b_resid = B->b_resid;
71 b_bufsize = B->b_bufsize;
72 b_iodone = (caddr_t)B->b_iodone;
73 b_error = B->b_error;
74 b_edev = B->b_edev;
75};
76
77typedef struct devinfo {
32typedef struct devinfo {
78 int dev_major; /* major number */
79 int dev_minor; /* minor number */
80 int dev_instance; /* instance number */
81 string dev_name; /* name of device */
82 string dev_statname; /* name of device + instance/minor */
83 string dev_pathname; /* pathname of device */
33 int dev_major; /* major number */
34 int dev_minor; /* minor number */
35 int dev_instance; /* instance number */
36 string dev_name; /* name of device */
37 string dev_statname; /* name of device + instance/minor */
38 string dev_pathname; /* pathname of device */
84} devinfo_t;
85
86#pragma D binding "1.0" translator
39} devinfo_t;
40
41#pragma D binding "1.0" translator
87translator devinfo_t < struct buf *B > {
88 dev_major = B->b_dip != NULL ? getmajor(B->b_edev) :
89 getmajor(B->b_file->v_vfsp->vfs_dev);
90 dev_minor = B->b_dip != NULL ? getminor(B->b_edev) :
91 getminor(B->b_file->v_vfsp->vfs_dev);
92 dev_instance = B->b_dip == NULL ?
93 getminor(B->b_file->v_vfsp->vfs_dev) :
94 ((struct dev_info *)B->b_dip)->devi_instance;
95 dev_name = B->b_dip == NULL ? "nfs" :
96 stringof(`devnamesp[getmajor(B->b_edev)].dn_name);
97 dev_statname = strjoin(B->b_dip == NULL ? "nfs" :
98 stringof(`devnamesp[getmajor(B->b_edev)].dn_name),
99 lltostr(B->b_dip == NULL ? getminor(B->b_file->v_vfsp->vfs_dev) :
100 ((struct dev_info *)B->b_dip)->devi_instance == 0 &&
101 ((struct dev_info *)B->b_dip)->devi_parent != NULL &&
102 ((struct dev_info *)B->b_dip)->devi_parent->devi_node_name ==
103 "pseudo" ? getminor(B->b_edev) :
104 ((struct dev_info *)B->b_dip)->devi_instance));
105 dev_pathname = B->b_dip == NULL ? "<nfs>" :
106 ddi_pathname(B->b_dip, getminor(B->b_edev));
42translator devinfo_t < struct devstat *D > {
43 dev_major = D->device_number;
44 dev_minor = D->unit_number;
45 dev_instance = 0;
46 dev_name = stringof(D->device_name);
47 dev_statname = stringof(D->device_name);
48 dev_pathname = stringof(D->device_name);
107};
108
49};
50
109typedef struct fileinfo {
110 string fi_name; /* name (basename of fi_pathname) */
111 string fi_dirname; /* directory (dirname of fi_pathname) */
112 string fi_pathname; /* full pathname */
113 offset_t fi_offset; /* offset within file */
114 string fi_fs; /* filesystem */
115 string fi_mount; /* mount point of file system */
116 int fi_oflags; /* open(2) flags for file descriptor */
117} fileinfo_t;
51typedef struct bufinfo {
52 int b_flags; /* flags */
53 long b_bcount; /* number of bytes */
54 caddr_t b_addr; /* buffer address */
55 uint64_t b_blkno; /* expanded block # on device */
56 uint64_t b_lblkno; /* block # on device */
57 size_t b_resid; /* # of bytes not transferred */
58 size_t b_bufsize; /* size of allocated buffer */
59/* caddr_t b_iodone; I/O completion routine */
60 int b_error; /* expanded error field */
61/* dev_t b_edev; extended device */
62} bufinfo_t;
118
119#pragma D binding "1.0" translator
63
64#pragma D binding "1.0" translator
120translator fileinfo_t < struct buf *B > {
121 fi_name = B->b_file == NULL ? "<none>" :
122 B->b_file->v_path == NULL ? "<unknown>" :
123 basename(cleanpath(B->b_file->v_path));
124 fi_dirname = B->b_file == NULL ? "<none>" :
125 B->b_file->v_path == NULL ? "<unknown>" :
126 dirname(cleanpath(B->b_file->v_path));
127 fi_pathname = B->b_file == NULL ? "<none>" :
128 B->b_file->v_path == NULL ? "<unknown>" :
129 cleanpath(B->b_file->v_path);
130 fi_offset = B->b_offset;
131 fi_fs = B->b_file == NULL ? "<none>" :
132 stringof(B->b_file->v_op->vnop_name);
133 fi_mount = B->b_file == NULL ? "<none>" :
134 B->b_file->v_vfsp->vfs_vnodecovered == NULL ? "/" :
135 B->b_file->v_vfsp->vfs_vnodecovered->v_path == NULL ? "<unknown>" :
136 cleanpath(B->b_file->v_vfsp->vfs_vnodecovered->v_path);
137 fi_oflags = 0;
65translator bufinfo_t < struct bio *B > {
66 b_flags = B->bio_flags;
67 b_bcount = B->bio_bcount;
68 b_addr = B->bio_data;
69 b_blkno = 0;
70 b_lblkno = 0;
71 b_resid = B->bio_resid;
72 b_bufsize = 0; /* XXX gnn */
73 b_error = B->bio_error;
138};
139
140/*
141 * The following inline constants can be used to examine fi_oflags when using
142 * the fds[] array or a translated fileinfo_t. Note that the various open
143 * flags behave as a bit-field *except* for O_RDONLY, O_WRONLY, and O_RDWR.
144 * To test the open mode, you write code similar to that used with the fcntl(2)
145 * F_GET[X]FL command, such as: if ((fi_oflags & O_ACCMODE) == O_WRONLY).

--- 7 unchanged lines hidden (view full) ---

153#pragma D binding "1.1" O_WRONLY
154inline int O_RDWR = 0x0002;
155#pragma D binding "1.1" O_RDWR
156
157inline int O_APPEND = 0x0008;
158#pragma D binding "1.1" O_APPEND
159inline int O_CREAT = 0x0200;
160#pragma D binding "1.1" O_CREAT
74};
75
76/*
77 * The following inline constants can be used to examine fi_oflags when using
78 * the fds[] array or a translated fileinfo_t. Note that the various open
79 * flags behave as a bit-field *except* for O_RDONLY, O_WRONLY, and O_RDWR.
80 * To test the open mode, you write code similar to that used with the fcntl(2)
81 * F_GET[X]FL command, such as: if ((fi_oflags & O_ACCMODE) == O_WRONLY).

--- 7 unchanged lines hidden (view full) ---

89#pragma D binding "1.1" O_WRONLY
90inline int O_RDWR = 0x0002;
91#pragma D binding "1.1" O_RDWR
92
93inline int O_APPEND = 0x0008;
94#pragma D binding "1.1" O_APPEND
95inline int O_CREAT = 0x0200;
96#pragma D binding "1.1" O_CREAT
161inline int O_DSYNC = O_DSYNC;
162#pragma D binding "1.1" O_DSYNC
163inline int O_EXCL = 0x0800;
164#pragma D binding "1.1" O_EXCL
97inline int O_EXCL = 0x0800;
98#pragma D binding "1.1" O_EXCL
165inline int O_LARGEFILE = O_LARGEFILE;
166#pragma D binding "1.1" O_LARGEFILE
167inline int O_NOCTTY = 0x8000;
168#pragma D binding "1.1" O_NOCTTY
169inline int O_NONBLOCK = 0x0004;
170#pragma D binding "1.1" O_NONBLOCK
171inline int O_NDELAY = 0x0004;
172#pragma D binding "1.1" O_NDELAY
99inline int O_NOCTTY = 0x8000;
100#pragma D binding "1.1" O_NOCTTY
101inline int O_NONBLOCK = 0x0004;
102#pragma D binding "1.1" O_NONBLOCK
103inline int O_NDELAY = 0x0004;
104#pragma D binding "1.1" O_NDELAY
173inline int O_RSYNC = O_RSYNC;
174#pragma D binding "1.1" O_RSYNC
175inline int O_SYNC = 0x0080;
176#pragma D binding "1.1" O_SYNC
177inline int O_TRUNC = 0x0400;
178#pragma D binding "1.1" O_TRUNC
105inline int O_SYNC = 0x0080;
106#pragma D binding "1.1" O_SYNC
107inline int O_TRUNC = 0x0400;
108#pragma D binding "1.1" O_TRUNC
179inline int O_XATTR = O_XATTR;
180#pragma D binding "1.1" O_XATTR
181
109
182#pragma D binding "1.1" translator
183translator fileinfo_t < struct file *F > {
184 fi_name = F == NULL ? "<none>" :
185 F->f_vnode->v_path == NULL ? "<unknown>" :
186 basename(cleanpath(F->f_vnode->v_path));
187 fi_dirname = F == NULL ? "<none>" :
188 F->f_vnode->v_path == NULL ? "<unknown>" :
189 dirname(cleanpath(F->f_vnode->v_path));
190 fi_pathname = F == NULL ? "<none>" :
191 F->f_vnode->v_path == NULL ? "<unknown>" :
192 cleanpath(F->f_vnode->v_path);
193 fi_offset = F == NULL ? 0 : F->f_offset;
194 fi_fs = F == NULL ? "<none>" : stringof(F->f_vnode->v_op->vnop_name);
195 fi_mount = F == NULL ? "<none>" :
196 F->f_vnode->v_vfsp->vfs_vnodecovered == NULL ? "/" :
197 F->f_vnode->v_vfsp->vfs_vnodecovered->v_path == NULL ? "<unknown>" :
198 cleanpath(F->f_vnode->v_vfsp->vfs_vnodecovered->v_path);
199 fi_oflags = F == NULL ? 0 : F->f_flag + (int)FOPEN;
200};
201
110
202inline fileinfo_t fds[int fd] = xlate <fileinfo_t> (
203 fd >= 0 && fd < curthread->t_procp->p_user.u_finfo.fi_nfiles ?
204 curthread->t_procp->p_user.u_finfo.fi_list[fd].uf_file : NULL);
205
206#pragma D attributes Stable/Stable/Common fds
207#pragma D binding "1.1" fds
208
209#pragma D binding "1.2" translator
210translator fileinfo_t < struct vnode *V > {
211 fi_name = V->v_path == NULL ? "<unknown>" :
212 basename(cleanpath(V->v_path));
213 fi_dirname = V->v_path == NULL ? "<unknown>" :
214 dirname(cleanpath(V->v_path));
215 fi_pathname = V->v_path == NULL ? "<unknown>" : cleanpath(V->v_path);
216 fi_fs = stringof(V->v_op->vnop_name);
217 fi_mount = V->v_vfsp->vfs_vnodecovered == NULL ? "/" :
218 V->v_vfsp->vfs_vnodecovered->v_path == NULL ? "<unknown>" :
219 cleanpath(V->v_vfsp->vfs_vnodecovered->v_path);
220};