1 /*
2 * This file and its contents are supplied under the terms of the
3 * Common Development and Distribution License ("CDDL"), version 1.0.
4 * You may only use this file in accordance with the terms of version
5 * 1.0 of the CDDL.
6 *
7 * A full copy of the text of the CDDL should have accompanied this
8 * source. A copy of the CDDL is also available via the Internet at
9 * http://www.illumos.org/license/CDDL.
10 */
11
12 /*
13 * Copyright 2017 Nexenta Systems, Inc. All rights reserved.
14 */
15
16 /*
17 * Example using the "smb2" dtrace provider.
18 * Traces all SMB commands.
19 *
20 * All these probes provide:
21 * args[0] conninfo_t
22 * args[1] smb2opinfo_t
23 * Some also provide one of: (not used here)
24 * args[2] smb_open_args_t
25 * args[2] smb_rw_args_t
26 */
27
28 /*
29 * Unfortunately, trying to write this as:
30 * smb2:::op-*-start {}
31 * smb2:::op-*-done {}
32 * fails to compile with this complaint:
33 * dtrace: failed to compile script smb2-trace.d: line 41:
34 * args[ ] may not be referenced because probe description
35 * smb2:::op-*-start matches an unstable set of probes
36 *
37 * Not clear why listing them all is necessary,
38 * but that works.
39 */
40
41 smb2:::op-Cancel-start,
42 smb2:::op-ChangeNotify-start,
43 smb2:::op-Close-start,
44 smb2:::op-Create-start,
45 smb2:::op-Echo-start,
46 smb2:::op-Flush-start,
47 smb2:::op-Ioctl-start,
48 smb2:::op-Lock-start,
49 smb2:::op-Logoff-start,
50 smb2:::op-Negotiate-start,
51 smb2:::op-OplockBreak-start,
52 smb2:::op-QueryDirectory-start,
53 smb2:::op-QueryInfo-start,
54 smb2:::op-Read-start,
55 smb2:::op-SessionSetup-start,
56 smb2:::op-SetInfo-start,
57 smb2:::op-TreeConnect-start,
58 smb2:::op-TreeDisconnect-start,
59 smb2:::op-Write-start
60 {
61 printf("clnt=%s mid=0x%x uid=0x%x tid=0x%x\n",
62 args[0]->ci_remote,
63 args[1]->soi_mid,
64 args[1]->soi_uid,
65 args[1]->soi_tid);
66 }
67
68 smb2:::op-Cancel-done,
69 smb2:::op-ChangeNotify-done,
70 smb2:::op-Close-done,
71 smb2:::op-Create-done,
72 smb2:::op-Echo-done,
73 smb2:::op-Flush-done,
74 smb2:::op-Ioctl-done,
75 smb2:::op-Lock-done,
76 smb2:::op-Logoff-done,
77 smb2:::op-Negotiate-done,
78 smb2:::op-OplockBreak-done,
79 smb2:::op-QueryDirectory-done,
80 smb2:::op-QueryInfo-done,
81 smb2:::op-Read-done,
82 smb2:::op-SessionSetup-done,
83 smb2:::op-SetInfo-done,
84 smb2:::op-TreeConnect-done,
85 smb2:::op-TreeDisconnect-done,
86 smb2:::op-Write-done
87 {
88 printf("clnt=%s mid=0x%x status=0x%x\n",
89 args[0]->ci_remote,
90 args[1]->soi_mid,
91 args[1]->soi_status);
92 }