1 #!/usr/sbin/dtrace -s 2 3 /* 4 * CDDL HEADER START 5 * 6 * The contents of this file are subject to the terms of the 7 * Common Development and Distribution License (the "License"). 8 * You may not use this file except in compliance with the License. 9 * 10 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 11 * or http://www.opensolaris.org/os/licensing. 12 * See the License for the specific language governing permissions 13 * and limitations under the License. 14 * 15 * When distributing Covered Code, include this CDDL HEADER in each 16 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 17 * If applicable, add the following below this CDDL HEADER, with the 18 * fields enclosed by brackets "[]" replaced with your own identifying 19 * information: Portions Copyright [yyyy] [name of copyright owner] 20 * 21 * CDDL HEADER END 22 */ 23 24 /* 25 * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. 26 */ 27 28 #pragma D option flowindent 29 30 /* 31 * Usage: ./stype.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-SessionSetupX-start 51 { 52 sr = (struct smb_request *)arg0; 53 ssetup = (smb_arg_sessionsetup_t *)arg1; 54 55 printf("[%s] %s %s %s", 56 (sr->session->s_local_port == 139) ? "NBT" : "TCP", 57 (sr->session->s_local_port == 139) ? 58 stringof(sr->session->workstation) : "", 59 stringof(ssetup->ssi_domain), 60 stringof(ssetup->ssi_user)); 61 62 printf(" maxmpx=%u vc=%u maxbuf=%u", 63 ssetup->ssi_maxmpxcount, 64 sr->session->vcnumber, 65 sr->session->smb_msg_size); 66 } 67 68 sdt:smbsrv::-smb_op-SessionSetupX-done 69 { 70 sr = (struct smb_request *)arg0; 71 ssetup = (smb_arg_sessionsetup_t *)arg1; 72 73 printf("%s/%s: smbuid=%d (%s)", 74 stringof(sr->uid_user->u_domain), 75 stringof(sr->uid_user->u_name), 76 sr->smb_uid, 77 (ssetup->ssi_guest == 0) ? "user" : "guest"); 78 79 printf(" [status=0x%08x (class=%d code=%d)]", 80 sr->smb_error.status, 81 sr->smb_error.errcls, sr->smb_error.errcode); 82 } 83 84 sdt:smbsrv::-smb_op-LogoffX-start 85 { 86 sr = (struct smb_request *)arg0; 87 88 printf("uid %d: %s/%s", sr->smb_uid, 89 stringof(sr->uid_user->u_domain), 90 stringof(sr->uid_user->u_name)); 91 } 92 93 sdt:smbsrv::-smb_op-TreeConnectX-start 94 { 95 tcon = (struct tcon *)arg1; 96 97 printf("[%s] %s", 98 stringof(tcon->service), 99 stringof(tcon->path)); 100 } 101 102 sdt:smbsrv::-smb_op-TreeConnectX-done 103 { 104 sr = (struct smb_request *)arg0; 105 106 printf("tid %d: %s", sr->smb_tid, 107 (sr->smb_error.status == 0) ? 108 stringof(sr->tid_tree->t_sharename) : ""); 109 110 printf(" [status=0x%08x (class=%d code=%d)]", 111 sr->smb_error.status, 112 sr->smb_error.errcls, sr->smb_error.errcode); 113 } 114 115 sdt:smbsrv::-smb_op-TreeDisconnect-start 116 { 117 sr = (struct smb_request *)arg0; 118 119 printf("tid %d: %s", sr->smb_tid, 120 (sr->tid_tree == 0) ? "" : 121 stringof(sr->tid_tree->t_sharename)); 122 } 123 124 /* 125 * Error functions 126 */ 127 smbsr_status:entry 128 { 129 printf("status=0x%08x class=%d, code=%d", arg1, arg2, arg3); 130 } 131 132 smbsr_errno:entry 133 { 134 printf("errno=%d", arg1); 135 } 136 137 smbsr_status:return, 138 smbsr_errno:return 139 { 140 } 141 142 /* 143 * Share/tree connect. 144 */ 145 smb_tree_connect:entry 146 { 147 } 148 149 smb_tree_get_sharename:entry 150 { 151 printf("uncpath=%s", stringof(arg0)); 152 } 153 154 smb_tree_connect_disk:entry 155 { 156 printf("sharename=%s", stringof(arg1)); 157 self->stype = 0; 158 } 159 160 smb_tree_connect_printq:entry 161 { 162 printf("sharename=%s", stringof(arg1)); 163 self->stype = 1; 164 } 165 166 smb_tree_connect_ipc:entry 167 { 168 printf("sharename=%s", stringof(arg1)); 169 self->stype = 3; 170 } 171 172 smb_tree_connect:return, 173 smb_tree_get_sharename:return, 174 smb_tree_connect_disk:return, 175 smb_tree_connect_ipc:return 176 { 177 printf("rc=0x%08x", arg1); 178 } 179 180 smb_tree_alloc:entry 181 /self->stype == 0/ 182 { 183 printf("share=%s service=%s", stringof(arg1), stringof(arg2)); 184 } 185 186 smb_tree_alloc:return 187 /self->stype == 0/ 188 { 189 printf("FS=%s flags=0x%08x", 190 stringof(((smb_tree_t *)arg1)->t_typename), 191 ((smb_tree_t *)arg1)->t_flags); 192 } 193 194 smb_tree_disconnect:entry, 195 smb_tree_disconnect:return 196 { 197 } 198 199 smb_tree_log:entry 200 { 201 printf("%s: %s", stringof(arg1), stringof(arg2)); 202 } 203