xref: /titanic_41/usr/src/cmd/smbsrv/dtrace/cifs.d (revision 430b4c467020edf2445feb0c21db01c88b86243a)
1 #!/usr/sbin/dtrace -s
2 /*
3  * CDDL HEADER START
4  *
5  * The contents of this file are subject to the terms of the
6  * Common Development and Distribution License (the "License").
7  * You may not use this file except in compliance with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
24  */
25 
26 /*
27 #pragma D option flowindent
28 */
29 
30 /*
31  * Usage:	./cifs.d -p `pgrep smbd`
32  *
33  * On multi-processor systems, it may be easier to follow the output
34  * if run on a single processor: see psradm.  For example, to disable
35  * the second processor on a dual-processor system:	psradm -f 1
36  */
37 
38 BEGIN
39 {
40 	printf("CIFS Trace Started");
41 	printf("\n\n");
42 }
43 
44 END
45 {
46 	printf("CIFS Trace Ended");
47 	printf("\n\n");
48 }
49 
50 sdt:smbsrv::-smb_op*-start
51 {
52 	sr = (struct smb_request *)arg0;
53 
54 	printf("cmd=%d [uid=%d tid=%d]",
55 	    sr->smb_com, sr->smb_uid, sr->smb_tid);
56 
57 	self->status = 0;
58 }
59 
60 sdt:smbsrv::-smb_op*-done
61 {
62 	sr = (struct smb_request *)arg0;
63 
64 	printf("cmd[%d]: status=0x%08x (class=%d code=%d)",
65 	    sr->smb_com, sr->smb_error.status,
66 	    sr->smb_error.errcls, sr->smb_error.errcode);
67 
68 	self->status = sr->smb_error.status;
69 }
70 
71 sdt:smbsrv::-smb_op-Negotiate-done
72 {
73 	sr = (struct smb_request *)arg0;
74 	negprot = (smb_arg_negotiate_t *)arg1;
75 
76 	printf("dialect=%s index=%u caps=0x%08x maxmpx=%u tz=%d time=%u",
77 	    stringof(negprot->ni_name),
78 	    negprot->ni_index,
79 	    negprot->ni_capabilities,
80 	    negprot->ni_maxmpxcount,
81 	    negprot->ni_tzcorrection,
82 	    negprot->ni_servertime.tv_sec);
83 
84 	printf(" [status=0x%08x (class=%d code=%d)]",
85 	    sr->smb_error.status,
86 	    sr->smb_error.errcls, sr->smb_error.errcode);
87 
88 	self->status = sr->smb_error.status;
89 }
90 
91 sdt:smbsrv::-smb_op-SessionSetupX-start
92 {
93 	sr = (struct smb_request *)arg0;
94 	ssetup = (smb_arg_sessionsetup_t *)arg1;
95 
96 	printf("[%s] %s %s %s",
97 	    (sr->session->s_local_port == 139) ? "NBT" : "TCP",
98 	    (sr->session->s_local_port == 139) ?
99 	    stringof(sr->session->workstation) : "",
100 	    stringof(ssetup->ssi_domain),
101 	    stringof(ssetup->ssi_user));
102 
103 	printf(" maxmpx=%u vc=%u maxbuf=%u",
104 	    ssetup->ssi_maxmpxcount,
105 	    sr->session->vcnumber,
106 	    sr->session->smb_msg_size);
107 }
108 
109 sdt:smbsrv::-smb_op-SessionSetupX-done
110 {
111 	sr = (struct smb_request *)arg0;
112 	ssetup = (smb_arg_sessionsetup_t *)arg1;
113 
114 	printf("%s/%s: smbuid=%d (%s)",
115 	    stringof(sr->uid_user->u_domain),
116 	    stringof(sr->uid_user->u_name),
117 	    sr->smb_uid,
118 	    (ssetup->ssi_guest == 0) ? "user" : "guest");
119 
120 	printf(" [status=0x%08x (class=%d code=%d)]",
121 	    sr->smb_error.status,
122 	    sr->smb_error.errcls, sr->smb_error.errcode);
123 
124 	self->status = sr->smb_error.status;
125 }
126 
127 sdt:smbsrv::-smb_op-LogoffX-start
128 {
129 	sr = (struct smb_request *)arg0;
130 
131 	printf("uid %d: %s/%s", sr->smb_uid,
132 	    stringof(sr->uid_user->u_domain),
133 	    stringof(sr->uid_user->u_name));
134 }
135 
136 sdt:smbsrv::-smb_op-TreeConnectX-start
137 {
138 	tcon = (struct tcon *)arg1;
139 
140 	printf("[%s] %s",
141                 stringof(tcon->service),
142                 stringof(tcon->path));
143 }
144 
145 sdt:smbsrv::-smb_op-TreeConnectX-done
146 {
147 	sr = (struct smb_request *)arg0;
148 
149 	printf("tid %d: %s", sr->smb_tid,
150 	    (sr->smb_error.status == 0) ?
151 	    stringof(sr->tid_tree->t_sharename) : "");
152 
153 	printf(" [status=0x%08x (class=%d code=%d)]",
154 	    sr->smb_error.status,
155 	    sr->smb_error.errcls, sr->smb_error.errcode);
156 }
157 
158 sdt:smbsrv::-smb_op-TreeDisconnect-start
159 {
160 	sr = (struct smb_request *)arg0;
161 
162 	printf("tid %d: %s", sr->smb_tid,
163 	    stringof(sr->tid_tree->t_sharename));
164 	discard(self->status);
165 }
166 
167 sdt:smbsrv::-smb_op-Open-start,
168 sdt:smbsrv::-smb_op-OpenX-start,
169 sdt:smbsrv::-smb_op-Create-start,
170 sdt:smbsrv::-smb_op-CreateNew-start,
171 sdt:smbsrv::-smb_op-CreateTemporary-start,
172 sdt:smbsrv::-smb_op-CreateDirectory-start,
173 sdt:smbsrv::-smb_op-NtCreateX-start,
174 sdt:smbsrv::-smb_op-NtTransactCreate-start
175 {
176 	op =  (struct open_param *)arg1;
177 
178 	printf("%s", stringof(op->fqi.fq_path.pn_path));
179 }
180 
181 sdt:smbsrv::-smb_op-Open-done,
182 sdt:smbsrv::-smb_op-OpenX-done,
183 sdt:smbsrv::-smb_op-Create-done,
184 sdt:smbsrv::-smb_op-CreateNew-done,
185 sdt:smbsrv::-smb_op-CreateTemporary-done,
186 sdt:smbsrv::-smb_op-CreateDirectory-done,
187 sdt:smbsrv::-smb_op-NtCreateX-done,
188 sdt:smbsrv::-smb_op-NtTransactCreate-done
189 {
190 	sr = (struct smb_request *)arg0;
191 
192 	printf("%s: fid=%u",
193 	    stringof(sr->arg.open.fqi.fq_path.pn_path), sr->smb_fid);
194 }
195 
196 sdt:smbsrv::-smb_op-Read-start,
197 sdt:smbsrv::-smb_op-LockAndRead-start,
198 sdt:smbsrv::-smb_op-ReadX-start,
199 sdt:smbsrv::-smb_op-ReadRaw-start,
200 sdt:smbsrv::-smb_op-Write-start,
201 sdt:smbsrv::-smb_op-WriteAndClose-start,
202 sdt:smbsrv::-smb_op-WriteAndUnlock-start,
203 sdt:smbsrv::-smb_op-WriteX-start,
204 sdt:smbsrv::-smb_op-WriteRaw-start
205 {
206 	sr = (struct smb_request *)arg0;
207 	rw =  (smb_rw_param_t *)arg1;
208 
209 	printf("fid=%d: %u bytes at offset %u",
210 	    sr->smb_fid, rw->rw_count, rw->rw_offset);
211 }
212 
213 sdt:smbsrv::-smb_op-Read-done,
214 sdt:smbsrv::-smb_op-LockAndRead-done,
215 sdt:smbsrv::-smb_op-ReadX-done,
216 sdt:smbsrv::-smb_op-ReadRaw-done
217 /self->status == 0/
218 {
219 	sr = (struct smb_request *)arg0;
220 	rw =  (smb_rw_param_t *)arg1;
221 
222 	printf("fid=%d: %u bytes at offset %u",
223 	    sr->smb_fid, rw->rw_count, rw->rw_offset);
224 }
225 
226 sdt:smbsrv::-smb_op-Rename-start
227 {
228 	p = (struct dirop *)arg1;
229 
230 	printf("%s to %s",
231 	    stringof(p->fqi.fq_path.pn_path),
232 	    stringof(p->dst_fqi.fq_path.pn_path));
233 }
234 
235 sdt:smbsrv::-smb_op-CheckDirectory-start,
236 sdt:smbsrv::-smb_op-CreateDirectory-start,
237 sdt:smbsrv::-smb_op-DeleteDirectory-start,
238 sdt:smbsrv::-smb_op-Delete-start
239 {
240 	p = (struct dirop *)arg1;
241 
242 	printf("%s", stringof(p->fqi.fq_path.pn_path));
243 }
244 
245 /*
246 smb_dispatch_request:entry,
247 smb_dispatch_request:return,
248 smb_pre_*:return,
249 smb_com_*:return,
250 smb_post_*:return,
251 smbsr_status:return,
252 smbsr_errno:return
253 {
254 }
255 
256 smb_pre_*:entry,
257 smb_com_*:entry,
258 smb_post_*:entry
259 {
260 	sr = (struct smb_request *)arg0;
261 
262 	printf("cmd=%d [uid=%d tid=%d]",
263 	    sr->smb_com, sr->smb_uid, sr->smb_tid);
264 }
265 
266 smbsr_status:entry
267 {
268     printf("status=0x%08x class=%d, code=%d\n", arg1, arg2, arg3);
269 }
270 
271 smbsr_errno:entry
272 {
273     printf("errno=%d\n", arg1);
274 }
275 */
276