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.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
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]
23 * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
24 * Copyright 2015 Nexenta Systems, Inc. All rights reserved.
27 #include <mdb/mdb_modapi.h>
28 #include <mdb/mdb_ks.h>
29 #include <sys/thread.h>
30 #include <sys/taskq.h>
31 #include <smbsrv/smb_vops.h>
32 #include <smbsrv/smb.h>
33 #include <smbsrv/smb_ktypes.h>
35 #define SMBSRV_OBJNAME "smbsrv"
37 #define SMB_DCMD_INDENT 2
38 #define ACE_TYPE_TABLEN (ACE_ALL_TYPES + 1)
39 #define ACE_TYPE_ENTRY(_v_) {_v_, #_v_}
40 #define SMB_COM_ENTRY(_v_, _x_) {#_v_, _x_}
42 #define SMB_MDB_MAX_OPTS 9
44 #define SMB_OPT_SERVER 0x00000001
45 #define SMB_OPT_SESSION 0x00000002
46 #define SMB_OPT_REQUEST 0x00000004
47 #define SMB_OPT_USER 0x00000008
48 #define SMB_OPT_TREE 0x00000010
49 #define SMB_OPT_OFILE 0x00000020
50 #define SMB_OPT_ODIR 0x00000040
51 #define SMB_OPT_WALK 0x00000100
52 #define SMB_OPT_VERBOSE 0x00000200
53 #define SMB_OPT_ALL_OBJ 0x000000FF
56 * Structure associating an ACE type to a string.
59 uint8_t ace_type_value
;
60 const char *ace_type_sting
;
64 * Structure containing strings describing an SMB command.
72 * Structure describing an object to be expanded (displayed).
82 * List of supported options. Ther order has the match the bits SMB_OPT_xxx.
84 typedef struct smb_mdb_opts
{
89 static smb_mdb_opts_t smb_opts
[SMB_MDB_MAX_OPTS
] =
91 { "-s", SMB_OPT_SERVER
},
92 { "-e", SMB_OPT_SESSION
},
93 { "-r", SMB_OPT_REQUEST
},
94 { "-u", SMB_OPT_USER
},
95 { "-t", SMB_OPT_TREE
},
96 { "-f", SMB_OPT_OFILE
},
97 { "-d", SMB_OPT_ODIR
},
98 { "-w", SMB_OPT_WALK
},
99 { "-v", SMB_OPT_VERBOSE
}
102 static smb_com_entry_t smb_com
[256] =
104 SMB_COM_ENTRY(SMB_COM_CREATE_DIRECTORY
, "No"),
105 SMB_COM_ENTRY(SMB_COM_DELETE_DIRECTORY
, "No"),
106 SMB_COM_ENTRY(SMB_COM_OPEN
, "No"),
107 SMB_COM_ENTRY(SMB_COM_CREATE
, "No"),
108 SMB_COM_ENTRY(SMB_COM_CLOSE
, "No"),
109 SMB_COM_ENTRY(SMB_COM_FLUSH
, "No"),
110 SMB_COM_ENTRY(SMB_COM_DELETE
, "No"),
111 SMB_COM_ENTRY(SMB_COM_RENAME
, "No"),
112 SMB_COM_ENTRY(SMB_COM_QUERY_INFORMATION
, "No"),
113 SMB_COM_ENTRY(SMB_COM_SET_INFORMATION
, "No"),
114 SMB_COM_ENTRY(SMB_COM_READ
, "No"),
115 SMB_COM_ENTRY(SMB_COM_WRITE
, "No"),
116 SMB_COM_ENTRY(SMB_COM_LOCK_BYTE_RANGE
, "No"),
117 SMB_COM_ENTRY(SMB_COM_UNLOCK_BYTE_RANGE
, "No"),
118 SMB_COM_ENTRY(SMB_COM_CREATE_TEMPORARY
, "No"),
119 SMB_COM_ENTRY(SMB_COM_CREATE_NEW
, "No"),
120 SMB_COM_ENTRY(SMB_COM_CHECK_DIRECTORY
, "No"),
121 SMB_COM_ENTRY(SMB_COM_PROCESS_EXIT
, "No"),
122 SMB_COM_ENTRY(SMB_COM_SEEK
, "No"),
123 SMB_COM_ENTRY(SMB_COM_LOCK_AND_READ
, "No"),
124 SMB_COM_ENTRY(SMB_COM_WRITE_AND_UNLOCK
, "No"),
125 SMB_COM_ENTRY(0x15, "?"),
126 SMB_COM_ENTRY(0x16, "?"),
127 SMB_COM_ENTRY(0x17, "?"),
128 SMB_COM_ENTRY(0x18, "?"),
129 SMB_COM_ENTRY(0x19, "?"),
130 SMB_COM_ENTRY(SMB_COM_READ_RAW
, "No"),
131 SMB_COM_ENTRY(SMB_COM_READ_MPX
, "No"),
132 SMB_COM_ENTRY(SMB_COM_READ_MPX_SECONDARY
, "No"),
133 SMB_COM_ENTRY(SMB_COM_WRITE_RAW
, "No"),
134 SMB_COM_ENTRY(SMB_COM_WRITE_MPX
, "No"),
135 SMB_COM_ENTRY(SMB_COM_WRITE_MPX_SECONDARY
, "No"),
136 SMB_COM_ENTRY(SMB_COM_WRITE_COMPLETE
, "No"),
137 SMB_COM_ENTRY(SMB_COM_QUERY_SERVER
, "No"),
138 SMB_COM_ENTRY(SMB_COM_SET_INFORMATION2
, "No"),
139 SMB_COM_ENTRY(SMB_COM_QUERY_INFORMATION2
, "No"),
140 SMB_COM_ENTRY(SMB_COM_LOCKING_ANDX
, "No"),
141 SMB_COM_ENTRY(SMB_COM_TRANSACTION
, "No"),
142 SMB_COM_ENTRY(SMB_COM_TRANSACTION_SECONDARY
, "No"),
143 SMB_COM_ENTRY(SMB_COM_IOCTL
, "No"),
144 SMB_COM_ENTRY(SMB_COM_IOCTL_SECONDARY
, "No"),
145 SMB_COM_ENTRY(SMB_COM_COPY
, "No"),
146 SMB_COM_ENTRY(SMB_COM_MOVE
, "No"),
147 SMB_COM_ENTRY(SMB_COM_ECHO
, "No"),
148 SMB_COM_ENTRY(SMB_COM_WRITE_AND_CLOSE
, "No"),
149 SMB_COM_ENTRY(SMB_COM_OPEN_ANDX
, "No"),
150 SMB_COM_ENTRY(SMB_COM_READ_ANDX
, "No"),
151 SMB_COM_ENTRY(SMB_COM_WRITE_ANDX
, "No"),
152 SMB_COM_ENTRY(SMB_COM_NEW_FILE_SIZE
, "No"),
153 SMB_COM_ENTRY(SMB_COM_CLOSE_AND_TREE_DISC
, "No"),
154 SMB_COM_ENTRY(SMB_COM_TRANSACTION2
, "No"),
155 SMB_COM_ENTRY(SMB_COM_TRANSACTION2_SECONDARY
, "No"),
156 SMB_COM_ENTRY(SMB_COM_FIND_CLOSE2
, "No"),
157 SMB_COM_ENTRY(SMB_COM_FIND_NOTIFY_CLOSE
, "No"),
158 SMB_COM_ENTRY(0x36, "?"),
159 SMB_COM_ENTRY(0x37, "?"),
160 SMB_COM_ENTRY(0x38, "?"),
161 SMB_COM_ENTRY(0x39, "?"),
162 SMB_COM_ENTRY(0x3A, "?"),
163 SMB_COM_ENTRY(0x3B, "?"),
164 SMB_COM_ENTRY(0x3C, "?"),
165 SMB_COM_ENTRY(0x3D, "?"),
166 SMB_COM_ENTRY(0x3E, "?"),
167 SMB_COM_ENTRY(0x3F, "?"),
168 SMB_COM_ENTRY(0x40, "?"),
169 SMB_COM_ENTRY(0x41, "?"),
170 SMB_COM_ENTRY(0x42, "?"),
171 SMB_COM_ENTRY(0x43, "?"),
172 SMB_COM_ENTRY(0x44, "?"),
173 SMB_COM_ENTRY(0x45, "?"),
174 SMB_COM_ENTRY(0x46, "?"),
175 SMB_COM_ENTRY(0x47, "?"),
176 SMB_COM_ENTRY(0x48, "?"),
177 SMB_COM_ENTRY(0x49, "?"),
178 SMB_COM_ENTRY(0x4A, "?"),
179 SMB_COM_ENTRY(0x4B, "?"),
180 SMB_COM_ENTRY(0x4C, "?"),
181 SMB_COM_ENTRY(0x4D, "?"),
182 SMB_COM_ENTRY(0x4E, "?"),
183 SMB_COM_ENTRY(0x4F, "?"),
184 SMB_COM_ENTRY(0x50, "?"),
185 SMB_COM_ENTRY(0x51, "?"),
186 SMB_COM_ENTRY(0x52, "?"),
187 SMB_COM_ENTRY(0x53, "?"),
188 SMB_COM_ENTRY(0x54, "?"),
189 SMB_COM_ENTRY(0x55, "?"),
190 SMB_COM_ENTRY(0x56, "?"),
191 SMB_COM_ENTRY(0x57, "?"),
192 SMB_COM_ENTRY(0x58, "?"),
193 SMB_COM_ENTRY(0x59, "?"),
194 SMB_COM_ENTRY(0x5A, "?"),
195 SMB_COM_ENTRY(0x5B, "?"),
196 SMB_COM_ENTRY(0x5C, "?"),
197 SMB_COM_ENTRY(0x5D, "?"),
198 SMB_COM_ENTRY(0x5E, "?"),
199 SMB_COM_ENTRY(0x5F, "?"),
200 SMB_COM_ENTRY(0x60, "?"),
201 SMB_COM_ENTRY(0x61, "?"),
202 SMB_COM_ENTRY(0x62, "?"),
203 SMB_COM_ENTRY(0x63, "?"),
204 SMB_COM_ENTRY(0x64, "?"),
205 SMB_COM_ENTRY(0x65, "?"),
206 SMB_COM_ENTRY(0x66, "?"),
207 SMB_COM_ENTRY(0x67, "?"),
208 SMB_COM_ENTRY(0x68, "?"),
209 SMB_COM_ENTRY(0x69, "?"),
210 SMB_COM_ENTRY(0x6A, "?"),
211 SMB_COM_ENTRY(0x6B, "?"),
212 SMB_COM_ENTRY(0x6C, "?"),
213 SMB_COM_ENTRY(0x6D, "?"),
214 SMB_COM_ENTRY(0x6E, "?"),
215 SMB_COM_ENTRY(0x6F, "?"),
216 SMB_COM_ENTRY(SMB_COM_TREE_CONNECT
, "No"),
217 SMB_COM_ENTRY(SMB_COM_TREE_DISCONNECT
, "No"),
218 SMB_COM_ENTRY(SMB_COM_NEGOTIATE
, "No"),
219 SMB_COM_ENTRY(SMB_COM_SESSION_SETUP_ANDX
, "No"),
220 SMB_COM_ENTRY(SMB_COM_LOGOFF_ANDX
, "No"),
221 SMB_COM_ENTRY(SMB_COM_TREE_CONNECT_ANDX
, "No"),
222 SMB_COM_ENTRY(0x76, "?"),
223 SMB_COM_ENTRY(0x77, "?"),
224 SMB_COM_ENTRY(0x78, "?"),
225 SMB_COM_ENTRY(0x79, "?"),
226 SMB_COM_ENTRY(0x7A, "?"),
227 SMB_COM_ENTRY(0x7B, "?"),
228 SMB_COM_ENTRY(0x7C, "?"),
229 SMB_COM_ENTRY(0x7D, "?"),
230 SMB_COM_ENTRY(0x7E, "?"),
231 SMB_COM_ENTRY(0x7F, "?"),
232 SMB_COM_ENTRY(SMB_COM_QUERY_INFORMATION_DISK
, "No"),
233 SMB_COM_ENTRY(SMB_COM_SEARCH
, "No"),
234 SMB_COM_ENTRY(SMB_COM_FIND
, "No"),
235 SMB_COM_ENTRY(SMB_COM_FIND_UNIQUE
, "No"),
236 SMB_COM_ENTRY(SMB_COM_FIND_CLOSE
, "No"),
237 SMB_COM_ENTRY(0x85, "?"),
238 SMB_COM_ENTRY(0x86, "?"),
239 SMB_COM_ENTRY(0x87, "?"),
240 SMB_COM_ENTRY(0x88, "?"),
241 SMB_COM_ENTRY(0x89, "?"),
242 SMB_COM_ENTRY(0x8A, "?"),
243 SMB_COM_ENTRY(0x8B, "?"),
244 SMB_COM_ENTRY(0x8C, "?"),
245 SMB_COM_ENTRY(0x8D, "?"),
246 SMB_COM_ENTRY(0x8E, "?"),
247 SMB_COM_ENTRY(0x8F, "?"),
248 SMB_COM_ENTRY(0x90, "?"),
249 SMB_COM_ENTRY(0x91, "?"),
250 SMB_COM_ENTRY(0x92, "?"),
251 SMB_COM_ENTRY(0x93, "?"),
252 SMB_COM_ENTRY(0x94, "?"),
253 SMB_COM_ENTRY(0x95, "?"),
254 SMB_COM_ENTRY(0x96, "?"),
255 SMB_COM_ENTRY(0x97, "?"),
256 SMB_COM_ENTRY(0x98, "?"),
257 SMB_COM_ENTRY(0x99, "?"),
258 SMB_COM_ENTRY(0x9A, "?"),
259 SMB_COM_ENTRY(0x9B, "?"),
260 SMB_COM_ENTRY(0x9C, "?"),
261 SMB_COM_ENTRY(0x9D, "?"),
262 SMB_COM_ENTRY(0x9E, "?"),
263 SMB_COM_ENTRY(0x9F, "?"),
264 SMB_COM_ENTRY(SMB_COM_NT_TRANSACT
, "No"),
265 SMB_COM_ENTRY(SMB_COM_NT_TRANSACT_SECONDARY
, "No"),
266 SMB_COM_ENTRY(SMB_COM_NT_CREATE_ANDX
, "No"),
267 SMB_COM_ENTRY(0xA3, "?"),
268 SMB_COM_ENTRY(SMB_COM_NT_CANCEL
, "No"),
269 SMB_COM_ENTRY(SMB_COM_NT_RENAME
, "No"),
270 SMB_COM_ENTRY(0xA6, "?"),
271 SMB_COM_ENTRY(0xA7, "?"),
272 SMB_COM_ENTRY(0xA8, "?"),
273 SMB_COM_ENTRY(0xA9, "?"),
274 SMB_COM_ENTRY(0xAA, "?"),
275 SMB_COM_ENTRY(0xAB, "?"),
276 SMB_COM_ENTRY(0xAC, "?"),
277 SMB_COM_ENTRY(0xAD, "?"),
278 SMB_COM_ENTRY(0xAE, "?"),
279 SMB_COM_ENTRY(0xAF, "?"),
280 SMB_COM_ENTRY(0xB0, "?"),
281 SMB_COM_ENTRY(0xB1, "?"),
282 SMB_COM_ENTRY(0xB2, "?"),
283 SMB_COM_ENTRY(0xB3, "?"),
284 SMB_COM_ENTRY(0xB4, "?"),
285 SMB_COM_ENTRY(0xB5, "?"),
286 SMB_COM_ENTRY(0xB6, "?"),
287 SMB_COM_ENTRY(0xB7, "?"),
288 SMB_COM_ENTRY(0xB8, "?"),
289 SMB_COM_ENTRY(0xB9, "?"),
290 SMB_COM_ENTRY(0xBA, "?"),
291 SMB_COM_ENTRY(0xBB, "?"),
292 SMB_COM_ENTRY(0xBC, "?"),
293 SMB_COM_ENTRY(0xBD, "?"),
294 SMB_COM_ENTRY(0xBE, "?"),
295 SMB_COM_ENTRY(0xBF, "?"),
296 SMB_COM_ENTRY(SMB_COM_OPEN_PRINT_FILE
, "No"),
297 SMB_COM_ENTRY(SMB_COM_WRITE_PRINT_FILE
, "No"),
298 SMB_COM_ENTRY(SMB_COM_CLOSE_PRINT_FILE
, "No"),
299 SMB_COM_ENTRY(SMB_COM_GET_PRINT_QUEUE
, "No"),
300 SMB_COM_ENTRY(0xC4, "?"),
301 SMB_COM_ENTRY(0xC5, "?"),
302 SMB_COM_ENTRY(0xC6, "?"),
303 SMB_COM_ENTRY(0xC7, "?"),
304 SMB_COM_ENTRY(0xC8, "?"),
305 SMB_COM_ENTRY(0xC9, "?"),
306 SMB_COM_ENTRY(0xCA, "?"),
307 SMB_COM_ENTRY(0xCB, "?"),
308 SMB_COM_ENTRY(0xCC, "?"),
309 SMB_COM_ENTRY(0xCD, "?"),
310 SMB_COM_ENTRY(0xCE, "?"),
311 SMB_COM_ENTRY(0xCF, "?"),
312 SMB_COM_ENTRY(0xD0, "?"),
313 SMB_COM_ENTRY(0xD1, "?"),
314 SMB_COM_ENTRY(0xD2, "?"),
315 SMB_COM_ENTRY(0xD3, "?"),
316 SMB_COM_ENTRY(0xD4, "?"),
317 SMB_COM_ENTRY(0xD5, "?"),
318 SMB_COM_ENTRY(0xD6, "?"),
319 SMB_COM_ENTRY(0xD7, "?"),
320 SMB_COM_ENTRY(SMB_COM_READ_BULK
, "No"),
321 SMB_COM_ENTRY(SMB_COM_WRITE_BULK
, "No"),
322 SMB_COM_ENTRY(SMB_COM_WRITE_BULK_DATA
, "No"),
323 SMB_COM_ENTRY(0xDB, "?"),
324 SMB_COM_ENTRY(0xDC, "?"),
325 SMB_COM_ENTRY(0xDD, "?"),
326 SMB_COM_ENTRY(0xDE, "?"),
327 SMB_COM_ENTRY(0xDF, "?"),
328 SMB_COM_ENTRY(0xE0, "?"),
329 SMB_COM_ENTRY(0xE1, "?"),
330 SMB_COM_ENTRY(0xE2, "?"),
331 SMB_COM_ENTRY(0xE3, "?"),
332 SMB_COM_ENTRY(0xE4, "?"),
333 SMB_COM_ENTRY(0xE5, "?"),
334 SMB_COM_ENTRY(0xE6, "?"),
335 SMB_COM_ENTRY(0xE7, "?"),
336 SMB_COM_ENTRY(0xE8, "?"),
337 SMB_COM_ENTRY(0xE9, "?"),
338 SMB_COM_ENTRY(0xEA, "?"),
339 SMB_COM_ENTRY(0xEB, "?"),
340 SMB_COM_ENTRY(0xEC, "?"),
341 SMB_COM_ENTRY(0xED, "?"),
342 SMB_COM_ENTRY(0xEE, "?"),
343 SMB_COM_ENTRY(0xEF, "?"),
344 SMB_COM_ENTRY(0xF0, "?"),
345 SMB_COM_ENTRY(0xF1, "?"),
346 SMB_COM_ENTRY(0xF2, "?"),
347 SMB_COM_ENTRY(0xF3, "?"),
348 SMB_COM_ENTRY(0xF4, "?"),
349 SMB_COM_ENTRY(0xF5, "?"),
350 SMB_COM_ENTRY(0xF6, "?"),
351 SMB_COM_ENTRY(0xF7, "?"),
352 SMB_COM_ENTRY(0xF8, "?"),
353 SMB_COM_ENTRY(0xF9, "?"),
354 SMB_COM_ENTRY(0xFA, "?"),
355 SMB_COM_ENTRY(0xFB, "?"),
356 SMB_COM_ENTRY(0xFC, "?"),
357 SMB_COM_ENTRY(0xFD, "?"),
358 SMB_COM_ENTRY(0xFE, "?"),
359 SMB_COM_ENTRY(0xFF, "?")
362 static const char *smb2_cmd_names
[SMB2__NCMDS
] = {
364 "smb2_session_setup",
378 "smb2_change_notify",
385 static int smb_dcmd_list(uintptr_t, uint_t
, int, const mdb_arg_t
*);
386 static void smb_dcmd_list_help(void);
387 static int smb_dcmd_server(uintptr_t, uint_t
, int, const mdb_arg_t
*);
388 static void smb_dcmd_session_help(void);
389 static int smb_dcmd_session(uintptr_t, uint_t
, int, const mdb_arg_t
*);
390 static int smb_dcmd_request(uintptr_t, uint_t
, int, const mdb_arg_t
*);
391 static void smb_dcmd_user_help(void);
392 static int smb_dcmd_user(uintptr_t, uint_t
, int, const mdb_arg_t
*);
393 static void smb_dcmd_tree_help(void);
394 static int smb_dcmd_tree(uintptr_t, uint_t
, int, const mdb_arg_t
*);
395 static int smb_dcmd_odir(uintptr_t, uint_t
, int, const mdb_arg_t
*);
396 static int smb_dcmd_ofile(uintptr_t, uint_t
, int, const mdb_arg_t
*);
397 static int smb_dcmd_kshare(uintptr_t, uint_t
, int, const mdb_arg_t
*);
398 static int smb_dcmd_vfs(uintptr_t, uint_t
, int, const mdb_arg_t
*);
399 static int smb_vfs_walk_init(mdb_walk_state_t
*);
400 static int smb_vfs_walk_step(mdb_walk_state_t
*);
401 static void smb_node_help(void);
402 static int smb_dcmd_node(uintptr_t, uint_t
, int, const mdb_arg_t
*);
403 static int smb_node_walk_init(mdb_walk_state_t
*);
404 static int smb_node_walk_step(mdb_walk_state_t
*);
405 static int smb_lock(uintptr_t, uint_t
, int, const mdb_arg_t
*);
406 static int smb_oplock(uintptr_t, uint_t
, int, const mdb_arg_t
*);
407 static int smb_oplock_grant(uintptr_t, uint_t
, int, const mdb_arg_t
*);
408 static int smb_ace(uintptr_t, uint_t
, int, const mdb_arg_t
*);
409 static int smb_ace_walk_init(mdb_walk_state_t
*);
410 static int smb_ace_walk_step(mdb_walk_state_t
*);
411 static int smb_acl(uintptr_t, uint_t
, int, const mdb_arg_t
*);
412 static int smb_sd(uintptr_t, uint_t
, int, const mdb_arg_t
*);
413 static int smb_sid(uintptr_t, uint_t
, int, const mdb_arg_t
*);
414 static int smb_sid_print(uintptr_t);
415 static int smb_fssd(uintptr_t, uint_t
, int, const mdb_arg_t
*);
416 static int smb_dcmd_getopt(uint_t
*, int, const mdb_arg_t
*);
417 static int smb_dcmd_setopt(uint_t
, int, mdb_arg_t
*);
418 static int smb_obj_expand(uintptr_t, uint_t
, const smb_exp_t
*, ulong_t
);
419 static int smb_obj_list(const char *, uint_t
, uint_t
);
420 static int smb_worker_findstack(uintptr_t);
421 static int smb_stats(uintptr_t, uint_t
, int, const mdb_arg_t
*);
424 * MDB module linkage information:
426 * We declare a list of structures describing our dcmds, a list of structures
427 * describing our walkers and a function named _mdb_init to return a pointer
428 * to our module information.
430 static const mdb_dcmd_t dcmds
[] = {
433 "print tree of SMB objects",
435 smb_dcmd_list_help
},
438 "print smb_server information",
442 "print smb_kshare_t information",
446 "print smb_vfs information",
450 "print smb_node_t information",
455 "print smb_session_t information",
457 smb_dcmd_session_help
},
460 "print smb_request_t information",
462 { "smblock", ":[-v]",
463 "print smb_lock_t information", smb_lock
},
466 "print smb_user_t information",
468 smb_dcmd_user_help
},
471 "print smb_tree_t information",
473 smb_dcmd_tree_help
},
476 "print smb_odir_t information",
480 "print smb_file_t information",
483 "print smb_oplock_t information", smb_oplock
},
484 { "smboplockgrant", NULL
,
485 "print smb_oplock_grant_t information", smb_oplock_grant
},
487 "print all smb dispatched requests statistics",
490 "print smb_ace_t information", smb_ace
},
492 "print smb_acl_t information", smb_acl
},
494 "print smb_sid_t information", smb_sid
},
496 "print smb_sd_t information", smb_sd
},
498 "print smb_fssd_t information", smb_fssd
},
502 static const mdb_walker_t walkers
[] = {
504 "walk list of smb_node_t structures",
510 "walk list of smb_vfs_t structures",
516 "walk list of smb_ace_t structures",
524 static const mdb_modinfo_t modinfo
= {
525 MDB_API_VERSION
, dcmds
, walkers
528 const mdb_modinfo_t
*
535 * *****************************************************************************
536 * ****************************** Top level DCMD *******************************
537 * *****************************************************************************
541 smb_dcmd_list_help(void)
544 "Displays the list of objects using an indented tree format.\n"
545 "If no option is specified the entire tree is displayed\n\n");
546 (void) mdb_dec_indent(2);
547 mdb_printf("%<b>OPTIONS%</b>\n");
548 (void) mdb_inc_indent(2);
550 "-v\tDisplay verbose information\n"
551 "-s\tDisplay the list of servers\n"
552 "-e\tDisplay the list of sessions\n"
553 "-r\tDisplay the list of smb requests\n"
554 "-u\tDisplay the list of users\n"
555 "-t\tDisplay the list of trees\n"
556 "-f\tDisplay the list of open files\n"
557 "-d\tDisplay the list of open searches\n");
563 * This function lists the objects specified on the command line. If no object
564 * is specified the entire tree (server through ofile and odir) is displayed.
569 smb_dcmd_list(uintptr_t addr
, uint_t flags
, int argc
, const mdb_arg_t
*argv
)
574 mdb_arg_t new_argv
[SMB_MDB_MAX_OPTS
];
576 if (smb_dcmd_getopt(&opts
, argc
, argv
))
579 if (!(opts
& ~(SMB_OPT_WALK
| SMB_OPT_VERBOSE
)))
580 opts
|= SMB_OPT_ALL_OBJ
;
582 opts
|= SMB_OPT_WALK
;
584 new_argc
= smb_dcmd_setopt(opts
, SMB_MDB_MAX_OPTS
, new_argv
);
586 if (mdb_lookup_by_obj(SMBSRV_OBJNAME
, "smb_servers", &sym
) == -1) {
587 mdb_warn("failed to find symbol smb_servers");
591 addr
= (uintptr_t)sym
.st_value
+ OFFSETOF(smb_llist_t
, ll_list
);
593 if (mdb_pwalk_dcmd("list", "smbsrv", new_argc
, new_argv
, addr
)) {
594 mdb_warn("cannot walk smb_server list");
601 * *****************************************************************************
602 * ***************************** smb_server_t **********************************
603 * *****************************************************************************
606 static const char *smb_server_state
[SMB_SERVER_STATE_SENTINEL
] =
616 * List of objects that can be expanded under a server structure.
618 static const smb_exp_t smb_server_exp
[] =
621 OFFSETOF(smb_server_t
, sv_nbt_daemon
.ld_session_list
.ll_list
),
622 "smbsess", "smb_session"},
624 OFFSETOF(smb_server_t
, sv_tcp_daemon
.ld_session_list
.ll_list
),
625 "smbsess", "smb_session"},
632 * smbsrv dcmd - Print out smb_server structures.
636 smb_dcmd_server(uintptr_t addr
, uint_t flags
, int argc
, const mdb_arg_t
*argv
)
641 if (smb_dcmd_getopt(&opts
, argc
, argv
))
644 if (!(flags
& DCMD_ADDRSPEC
))
645 return (smb_obj_list("smb_server", opts
| SMB_OPT_SERVER
,
648 if (((opts
& SMB_OPT_WALK
) && (opts
& SMB_OPT_SERVER
)) ||
649 !(opts
& SMB_OPT_WALK
)) {
653 sv
= mdb_alloc(sizeof (smb_server_t
), UM_SLEEP
| UM_GC
);
654 if (mdb_vread(sv
, sizeof (smb_server_t
), addr
) == -1) {
655 mdb_warn("failed to read smb_server at %p", addr
);
659 indent
= SMB_DCMD_INDENT
;
661 if (opts
& SMB_OPT_VERBOSE
) {
664 argv
.a_type
= MDB_TYPE_STRING
;
665 argv
.a_un
.a_str
= "smb_server_t";
666 if (mdb_call_dcmd("print", addr
, flags
, 1, &argv
))
669 if (DCMD_HDRSPEC(flags
))
675 "SERVER", "ZONE", "STATE");
677 if (sv
->sv_state
>= SMB_SERVER_STATE_SENTINEL
)
680 state
= smb_server_state
[sv
->sv_state
];
682 mdb_printf("%-?p %-4d %-32s \n",
683 addr
, sv
->sv_zid
, state
);
686 if (smb_obj_expand(addr
, opts
, smb_server_exp
, indent
))
692 * *****************************************************************************
693 * ***************************** smb_session_t *********************************
694 * *****************************************************************************
697 static const char *smb_session_state
[SMB_SESSION_STATE_SENTINEL
] =
708 * List of objects that can be expanded under a session structure.
710 static const smb_exp_t smb_session_exp
[] =
713 OFFSETOF(smb_session_t
, s_req_list
.sl_list
),
714 "smbreq", "smb_request"},
716 OFFSETOF(smb_session_t
, s_user_list
.ll_list
),
717 "smbuser", "smb_user"},
718 { SMB_OPT_TREE
| SMB_OPT_OFILE
| SMB_OPT_ODIR
,
719 OFFSETOF(smb_session_t
, s_tree_list
.ll_list
),
720 "smbtree", "smb_tree"},
725 smb_dcmd_session_help(void)
728 "Display the contents of smb_session_t, with optional"
730 (void) mdb_dec_indent(2);
731 mdb_printf("%<b>OPTIONS%</b>\n");
732 (void) mdb_inc_indent(2);
734 "-v\tDisplay verbose smb_session information\n"
735 "-r\tDisplay the list of smb requests attached\n"
736 "-u\tDisplay the list of users attached\n");
742 * smbsess dcmd - Print out the smb_session structure.
745 smb_dcmd_session(uintptr_t addr
, uint_t flags
, int argc
, const mdb_arg_t
*argv
)
750 if (smb_dcmd_getopt(&opts
, argc
, argv
))
753 if (!(flags
& DCMD_ADDRSPEC
)) {
754 opts
|= SMB_OPT_SESSION
;
755 opts
&= ~SMB_OPT_SERVER
;
756 return (smb_obj_list("smb_session", opts
, flags
));
759 if (((opts
& SMB_OPT_WALK
) && (opts
& SMB_OPT_SESSION
)) ||
760 !(opts
& SMB_OPT_WALK
)) {
761 char cipaddr
[INET6_ADDRSTRLEN
];
762 char lipaddr
[INET6_ADDRSTRLEN
];
767 indent
= SMB_DCMD_INDENT
;
769 se
= mdb_alloc(sizeof (*se
), UM_SLEEP
| UM_GC
);
770 if (mdb_vread(se
, sizeof (*se
), addr
) == -1) {
771 mdb_warn("failed to read smb_session at %p", addr
);
774 if (se
->s_state
>= SMB_SESSION_STATE_SENTINEL
)
777 state
= smb_session_state
[se
->s_state
];
779 switch (se
->ipaddr
.a_family
) {
781 ipaddrstrlen
= INET_ADDRSTRLEN
;
782 (void) mdb_snprintf(cipaddr
, sizeof (cipaddr
),
783 "%I", se
->ipaddr
.a_ipv4
);
784 (void) mdb_snprintf(lipaddr
, sizeof (lipaddr
),
785 "%I", se
->local_ipaddr
.a_ipv4
);
788 ipaddrstrlen
= INET6_ADDRSTRLEN
;
789 (void) mdb_snprintf(cipaddr
, sizeof (cipaddr
),
790 "%N", &(se
->ipaddr
.a_ipv6
));
791 (void) mdb_snprintf(lipaddr
, sizeof (lipaddr
),
792 "%N", &(se
->local_ipaddr
.a_ipv6
));
795 ipaddrstrlen
= INET_ADDRSTRLEN
;
796 (void) mdb_snprintf(cipaddr
, sizeof (cipaddr
),
798 (void) mdb_snprintf(lipaddr
, sizeof (lipaddr
),
802 if (opts
& SMB_OPT_VERBOSE
) {
803 mdb_printf("%<b>%<u>SMB session information "
804 "(%p): %</u>%</b>\n", addr
);
805 mdb_printf("Client IP address: %s %d\n",
806 cipaddr
, se
->s_remote_port
);
807 mdb_printf("Local IP Address: %s %d\n",
808 lipaddr
, se
->s_local_port
);
809 mdb_printf("Session KID: %u\n", se
->s_kid
);
810 mdb_printf("Workstation Name: %s\n",
812 mdb_printf("Session state: %u (%s)\n", se
->s_state
,
814 mdb_printf("Session dialect: %#x\n", se
->dialect
);
815 mdb_printf("Number of Users: %u\n",
816 se
->s_user_list
.ll_count
);
817 mdb_printf("Number of Trees: %u\n", se
->s_tree_cnt
);
818 mdb_printf("Number of Files: %u\n", se
->s_file_cnt
);
819 mdb_printf("Number of Shares: %u\n", se
->s_dir_cnt
);
820 mdb_printf("Number of active Transact.: %u\n\n",
821 se
->s_xa_list
.ll_count
);
823 if (DCMD_HDRSPEC(flags
)) {
825 "%<b>%<u>%-?s %-*s %-8s %-8s %-12s%</u>%</b>\n",
826 "SESSION", ipaddrstrlen
, "IP_ADDR",
827 "PORT", "DIALECT", "STATE");
829 mdb_printf("%-?p %-*s %-8d %-8#x %s\n",
830 addr
, ipaddrstrlen
, cipaddr
,
831 se
->s_remote_port
, se
->dialect
, state
);
834 if (smb_obj_expand(addr
, opts
, smb_session_exp
, indent
))
840 * *****************************************************************************
841 * **************************** smb_request_t **********************************
842 * *****************************************************************************
845 static const char *smb_request_state
[SMB_REQ_STATE_SENTINEL
] =
859 #define SMB_REQUEST_BANNER \
860 "%<b>%<u>%-?s %-?s %-14s %-14s %-16s %-32s%</u>%</b>\n"
861 #define SMB_REQUEST_FORMAT \
862 "%-?p %-?p %-14lld %-14lld %-16s %s\n"
865 smb_dcmd_request(uintptr_t addr
, uint_t flags
, int argc
, const mdb_arg_t
*argv
)
869 if (smb_dcmd_getopt(&opts
, argc
, argv
))
872 if (!(flags
& DCMD_ADDRSPEC
)) {
873 opts
|= SMB_OPT_REQUEST
;
874 opts
&= ~(SMB_OPT_SERVER
| SMB_OPT_SESSION
| SMB_OPT_USER
);
875 return (smb_obj_list("smb_request", opts
, flags
));
878 if (((opts
& SMB_OPT_WALK
) && (opts
& SMB_OPT_REQUEST
)) ||
879 !(opts
& SMB_OPT_WALK
)) {
882 const char *cur_cmd_name
;
887 sr
= mdb_alloc(sizeof (*sr
), UM_SLEEP
| UM_GC
);
888 if (mdb_vread(sr
, sizeof (*sr
), addr
) == -1) {
889 mdb_warn("failed to read smb_request at %p", addr
);
892 if (sr
->sr_magic
!= SMB_REQ_MAGIC
) {
893 mdb_warn("not an smb_request_t (%p)>", addr
);
899 * Note: mdb_gethrtime() is only available in kmdb
902 if (sr
->sr_time_submitted
!= 0) {
903 if (sr
->sr_time_active
!= 0) {
904 waiting
= sr
->sr_time_active
-
905 sr
->sr_time_submitted
;
906 running
= mdb_gethrtime() -
909 waiting
= mdb_gethrtime() -
910 sr
->sr_time_submitted
;
917 if (sr
->sr_state
>= SMB_REQ_STATE_SENTINEL
)
920 state
= smb_request_state
[sr
->sr_state
];
922 if (sr
->smb2_cmd_code
!= 0) {
924 cur_cmd_code
= sr
->smb2_cmd_code
;
925 if (cur_cmd_code
> SMB2_INVALID_CMD
)
926 cur_cmd_code
= SMB2_INVALID_CMD
;
927 cur_cmd_name
= smb2_cmd_names
[cur_cmd_code
];
930 cur_cmd_code
= sr
->smb_com
& 0xFF;
931 cur_cmd_name
= smb_com
[cur_cmd_code
].smb_com
;
934 if (opts
& SMB_OPT_VERBOSE
) {
936 "%</b>%</u>SMB request information (%p):"
937 "%</u>%</b>\n\n", addr
);
939 if (sr
->smb2_cmd_code
== 0) {
942 "first SMB COM: %u (%s)\n",
944 smb_com
[sr
->first_smb_com
].smb_com
);
948 "current SMB COM: %u (%s)\n",
949 cur_cmd_code
, cur_cmd_name
);
953 sr
->sr_state
, state
);
956 "TID(tree): %u (%p)\n",
957 sr
->smb_tid
, sr
->tid_tree
);
960 "UID(user): %u (%p)\n",
961 sr
->smb_uid
, sr
->uid_user
);
964 "FID(file): %u (%p)\n",
965 sr
->smb_fid
, sr
->fid_ofile
);
971 if (sr
->smb2_messageid
!= 0) {
982 "waiting time: %lld\n",
986 "running time: %lld\n",
990 "worker thread: %p\n",
992 smb_worker_findstack((uintptr_t)sr
->sr_worker
);
994 if (DCMD_HDRSPEC(flags
))
1018 * *****************************************************************************
1019 * ****************************** smb_user_t ***********************************
1020 * *****************************************************************************
1023 static const char *smb_user_state
[SMB_USER_STATE_SENTINEL
] =
1032 smb_dcmd_user_help(void)
1035 "Display the contents of smb_user_t, with optional filtering.\n\n");
1036 (void) mdb_dec_indent(2);
1037 mdb_printf("%<b>OPTIONS%</b>\n");
1038 (void) mdb_inc_indent(2);
1040 "-v\tDisplay verbose smb_user information\n");
1044 smb_dcmd_user(uintptr_t addr
, uint_t flags
, int argc
, const mdb_arg_t
*argv
)
1048 if (smb_dcmd_getopt(&opts
, argc
, argv
))
1049 return (DCMD_USAGE
);
1051 if (!(flags
& DCMD_ADDRSPEC
)) {
1052 opts
|= SMB_OPT_USER
;
1053 opts
&= ~(SMB_OPT_SERVER
| SMB_OPT_SESSION
| SMB_OPT_REQUEST
);
1054 return (smb_obj_list("smb_user", opts
, flags
));
1057 if (((opts
& SMB_OPT_WALK
) && (opts
& SMB_OPT_USER
)) ||
1058 !(opts
& SMB_OPT_WALK
)) {
1062 user
= mdb_alloc(sizeof (*user
), UM_SLEEP
| UM_GC
);
1063 if (mdb_vread(user
, sizeof (*user
), addr
) == -1) {
1064 mdb_warn("failed to read smb_user at %p", addr
);
1067 account
= mdb_zalloc(user
->u_domain_len
+ user
->u_name_len
+ 2,
1070 if (user
->u_domain_len
)
1071 (void) mdb_vread(account
, user
->u_domain_len
,
1072 (uintptr_t)user
->u_domain
);
1074 strcat(account
, "\\");
1076 if (user
->u_name_len
)
1077 (void) mdb_vread(account
+ strlen(account
),
1078 user
->u_name_len
, (uintptr_t)user
->u_name
);
1080 if (opts
& SMB_OPT_VERBOSE
) {
1083 if (user
->u_state
>= SMB_USER_STATE_SENTINEL
)
1086 state
= smb_user_state
[user
->u_state
];
1088 mdb_printf("%<b>%<u>SMB user information (%p):"
1089 "%</u>%</b>\n", addr
);
1090 mdb_printf("UID: %u\n", user
->u_uid
);
1091 mdb_printf("State: %d (%s)\n", user
->u_state
, state
);
1092 mdb_printf("Flags: 0x%08x\n", user
->u_flags
);
1093 mdb_printf("Privileges: 0x%08x\n", user
->u_privileges
);
1094 mdb_printf("Credential: %p\n", user
->u_cred
);
1095 mdb_printf("Reference Count: %d\n", user
->u_refcnt
);
1096 mdb_printf("User Account: %s\n\n", account
);
1098 if (DCMD_HDRSPEC(flags
))
1102 "%-32s%</u>%</b>\n",
1103 "USER", "UID", "ACCOUNT");
1105 mdb_printf("%-?p %-5u %-32s\n", addr
, user
->u_uid
,
1113 * *****************************************************************************
1114 * ****************************** smb_tree_t ***********************************
1115 * *****************************************************************************
1118 static const char *smb_tree_state
[SMB_TREE_STATE_SENTINEL
] =
1126 * List of objects that can be expanded under a tree structure.
1128 static const smb_exp_t smb_tree_exp
[] =
1131 OFFSETOF(smb_tree_t
, t_ofile_list
.ll_list
),
1132 "smbofile", "smb_ofile"},
1134 OFFSETOF(smb_tree_t
, t_odir_list
.ll_list
),
1135 "smbodir", "smb_odir"},
1140 smb_dcmd_tree_help(void)
1143 "Display the contents of smb_tree_t, with optional filtering.\n\n");
1144 (void) mdb_dec_indent(2);
1145 mdb_printf("%<b>OPTIONS%</b>\n");
1146 (void) mdb_inc_indent(2);
1148 "-v\tDisplay verbose smb_tree information\n"
1149 "-d\tDisplay the list of smb_odirs attached\n"
1150 "-f\tDisplay the list of smb_ofiles attached\n");
1154 smb_dcmd_tree(uintptr_t addr
, uint_t flags
, int argc
, const mdb_arg_t
*argv
)
1159 if (smb_dcmd_getopt(&opts
, argc
, argv
))
1160 return (DCMD_USAGE
);
1162 if (!(flags
& DCMD_ADDRSPEC
)) {
1163 opts
|= SMB_OPT_TREE
;
1164 opts
&= ~(SMB_OPT_SERVER
| SMB_OPT_SESSION
| SMB_OPT_REQUEST
|
1166 return (smb_obj_list("smb_tree", opts
, flags
));
1169 if (((opts
& SMB_OPT_WALK
) && (opts
& SMB_OPT_TREE
)) ||
1170 !(opts
& SMB_OPT_WALK
)) {
1173 indent
= SMB_DCMD_INDENT
;
1175 tree
= mdb_alloc(sizeof (*tree
), UM_SLEEP
| UM_GC
);
1176 if (mdb_vread(tree
, sizeof (*tree
), addr
) == -1) {
1177 mdb_warn("failed to read smb_tree at %p", addr
);
1180 if (opts
& SMB_OPT_VERBOSE
) {
1183 if (tree
->t_state
>= SMB_TREE_STATE_SENTINEL
)
1186 state
= smb_tree_state
[tree
->t_state
];
1188 mdb_printf("%<b>%<u>SMB tree information (%p):"
1189 "%</u>%</b>\n\n", addr
);
1190 mdb_printf("TID: %04x\n", tree
->t_tid
);
1191 mdb_printf("State: %d (%s)\n", tree
->t_state
, state
);
1192 mdb_printf("Share: %s\n", tree
->t_sharename
);
1193 mdb_printf("Resource: %s\n", tree
->t_resource
);
1194 mdb_printf("Type: %s\n", tree
->t_typename
);
1195 mdb_printf("Volume: %s\n", tree
->t_volume
);
1196 mdb_printf("Umask: %04x\n", tree
->t_umask
);
1197 mdb_printf("Flags: %08x\n", tree
->t_flags
);
1198 mdb_printf("SMB Node: %llx\n", tree
->t_snode
);
1199 mdb_printf("Reference Count: %d\n\n", tree
->t_refcnt
);
1201 if (DCMD_HDRSPEC(flags
))
1203 "%<b>%<u>%-?s %-5s %-16s %-32s%</u>%</b>\n",
1204 "TREE", "TID", "SHARE NAME", "RESOURCE");
1206 mdb_printf("%-?p %-5u %-16s %-32s\n", addr
,
1207 tree
->t_tid
, tree
->t_sharename
, tree
->t_resource
);
1210 if (smb_obj_expand(addr
, opts
, smb_tree_exp
, indent
))
1216 * *****************************************************************************
1217 * ****************************** smb_odir_t ***********************************
1218 * *****************************************************************************
1221 static const char *smb_odir_state
[SMB_ODIR_STATE_SENTINEL
] =
1230 smb_dcmd_odir(uintptr_t addr
, uint_t flags
, int argc
, const mdb_arg_t
*argv
)
1234 if (smb_dcmd_getopt(&opts
, argc
, argv
))
1235 return (DCMD_USAGE
);
1237 if (!(flags
& DCMD_ADDRSPEC
)) {
1238 opts
|= SMB_OPT_ODIR
;
1239 opts
&= ~(SMB_OPT_SERVER
| SMB_OPT_SESSION
| SMB_OPT_REQUEST
|
1240 SMB_OPT_USER
| SMB_OPT_TREE
| SMB_OPT_OFILE
);
1241 return (smb_obj_list("smb_odir", opts
, flags
));
1244 if (((opts
& SMB_OPT_WALK
) && (opts
& SMB_OPT_ODIR
)) ||
1245 !(opts
& SMB_OPT_WALK
)) {
1248 od
= mdb_alloc(sizeof (*od
), UM_SLEEP
| UM_GC
);
1249 if (mdb_vread(od
, sizeof (*od
), addr
) == -1) {
1250 mdb_warn("failed to read smb_odir at %p", addr
);
1253 if (opts
& SMB_OPT_VERBOSE
) {
1256 if (od
->d_state
>= SMB_ODIR_STATE_SENTINEL
)
1259 state
= smb_odir_state
[od
->d_state
];
1262 "%<b>%<u>SMB odir information (%p):%</u>%</b>\n\n",
1264 mdb_printf("State: %d (%s)\n", od
->d_state
, state
);
1265 mdb_printf("SID: %u\n", od
->d_odid
);
1266 mdb_printf("User: %p\n", od
->d_user
);
1267 mdb_printf("Tree: %p\n", od
->d_tree
);
1268 mdb_printf("Reference Count: %d\n", od
->d_refcnt
);
1269 mdb_printf("Pattern: %s\n", od
->d_pattern
);
1270 mdb_printf("SMB Node: %p\n\n", od
->d_dnode
);
1272 if (DCMD_HDRSPEC(flags
))
1277 "%-16s%</u>%</b>\n",
1278 "ODIR", "SID", "VNODE", "PATTERN");
1280 mdb_printf("%?p %-5u %-16p %s\n",
1281 addr
, od
->d_odid
, od
->d_dnode
, od
->d_pattern
);
1288 * *****************************************************************************
1289 * ****************************** smb_ofile_t **********************************
1290 * *****************************************************************************
1293 static const char *smb_ofile_state
[SMB_OFILE_STATE_SENTINEL
] =
1301 smb_dcmd_ofile(uintptr_t addr
, uint_t flags
, int argc
, const mdb_arg_t
*argv
)
1305 if (smb_dcmd_getopt(&opts
, argc
, argv
))
1306 return (DCMD_USAGE
);
1308 if (!(flags
& DCMD_ADDRSPEC
)) {
1309 opts
|= SMB_OPT_OFILE
;
1310 opts
&= ~(SMB_OPT_SERVER
| SMB_OPT_SESSION
| SMB_OPT_REQUEST
|
1311 SMB_OPT_USER
| SMB_OPT_TREE
| SMB_OPT_ODIR
);
1312 return (smb_obj_list("smb_ofile", opts
, flags
));
1315 if (((opts
& SMB_OPT_WALK
) && (opts
& SMB_OPT_OFILE
)) ||
1316 !(opts
& SMB_OPT_WALK
)) {
1319 of
= mdb_alloc(sizeof (*of
), UM_SLEEP
| UM_GC
);
1320 if (mdb_vread(of
, sizeof (*of
), addr
) == -1) {
1321 mdb_warn("failed to read smb_ofile at %p", addr
);
1324 if (opts
& SMB_OPT_VERBOSE
) {
1327 if (of
->f_state
>= SMB_OFILE_STATE_SENTINEL
)
1330 state
= smb_ofile_state
[of
->f_state
];
1333 "%<b>%<u>SMB ofile information (%p):%</u>%</b>\n\n",
1335 mdb_printf("FID: %u\n", of
->f_fid
);
1336 mdb_printf("State: %d (%s)\n", of
->f_state
, state
);
1337 mdb_printf("SMB Node: %p\n", of
->f_node
);
1338 mdb_printf("LLF Offset: 0x%llx (%s)\n",
1340 ((of
->f_flags
& SMB_OFLAGS_LLF_POS_VALID
) ?
1341 "Valid" : "Invalid"));
1342 mdb_printf("Flags: 0x%08x\n", of
->f_flags
);
1343 mdb_printf("User: %p\n", of
->f_user
);
1344 mdb_printf("Tree: %p\n", of
->f_tree
);
1345 mdb_printf("Credential: %p\n\n", of
->f_cr
);
1347 if (DCMD_HDRSPEC(flags
))
1353 "OFILE", "FID", "SMB NODE", "CRED");
1355 mdb_printf("%?p %-5u %-p %p\n", addr
,
1356 of
->f_fid
, of
->f_node
, of
->f_cr
);
1363 * *****************************************************************************
1364 * ******************************** smb_kshare_t *******************************
1365 * *****************************************************************************
1369 smb_kshare_cb(uintptr_t addr
, const void *data
, void *arg
)
1375 _NOTE(ARGUNUSED(data
));
1377 if (*opts
& SMB_OPT_VERBOSE
) {
1380 argv
.a_type
= MDB_TYPE_STRING
;
1381 argv
.a_un
.a_str
= "smb_kshare_t";
1382 /* Don't fail the walk if this fails. */
1383 mdb_call_dcmd("print", addr
, 0, 1, &argv
);
1386 * Summary line for a kshare
1387 * Don't fail the walk if any of these fail.
1389 ta
= addr
+ OFFSETOF(smb_kshare_t
, shr_name
);
1390 if (mdb_vread(&sa
, sizeof (sa
), ta
) < 0 ||
1391 mdb_readstr(name
, sizeof (name
), sa
) <= 0)
1394 ta
= addr
+ OFFSETOF(smb_kshare_t
, shr_path
);
1395 if (mdb_vread(&sa
, sizeof (sa
), ta
) < 0 ||
1396 mdb_readstr(path
, sizeof (path
), sa
) <= 0)
1399 mdb_printf("%-?p ", addr
); /* smb_kshare_t */
1400 mdb_printf("%-16s ", name
);
1401 mdb_printf("%-s", path
);
1411 * dcmd - Print out smb_kshare structures.
1412 * requires addr of an smb_server_t
1416 smb_dcmd_kshare(uintptr_t addr
, uint_t flags
, int argc
, const mdb_arg_t
*argv
)
1420 if (mdb_getopts(argc
, argv
,
1421 'v', MDB_OPT_SETBITS
, SMB_OPT_VERBOSE
, &opts
,
1423 return (DCMD_USAGE
);
1425 if (!(flags
& DCMD_ADDRSPEC
))
1426 return (DCMD_USAGE
);
1427 addr
+= OFFSETOF(smb_server_t
, sv_export
.e_share_avl
.avl_tree
);
1429 if (DCMD_HDRSPEC(flags
)) {
1436 "smb_kshare_t", "name", "path");
1439 if (mdb_pwalk("avl", smb_kshare_cb
, &opts
, addr
) == -1) {
1440 mdb_warn("cannot walk smb_kshare avl");
1448 * *****************************************************************************
1449 * ******************************** smb_vfs_t **********************************
1450 * *****************************************************************************
1456 * smbvfs dcmd - Prints out smb_vfs structures.
1460 smb_dcmd_vfs(uintptr_t addr
, uint_t flags
, int argc
, const mdb_arg_t
*argv
)
1462 int verbose
= FALSE
;
1467 if (mdb_getopts(argc
, argv
,
1468 'v', MDB_OPT_SETBITS
, TRUE
, &verbose
,
1470 return (DCMD_USAGE
);
1473 * If no smb_vfs address was specified on the command line, we can
1474 * print out all smb_vfs by invoking the smb_vfs walker, using
1475 * this dcmd itself as the callback.
1477 if (!(flags
& DCMD_ADDRSPEC
)) {
1478 if (mdb_walk_dcmd("smbvfs_walker", "smbvfs",
1479 argc
, argv
) == -1) {
1480 mdb_warn("failed to walk 'smb_vfs'");
1486 if (DCMD_HDRSPEC(flags
)) {
1495 "SMB_VFS", "REFCNT", "VFS", "VNODE", "ROOT");
1498 sf
= mdb_alloc(sizeof (*sf
), UM_SLEEP
| UM_GC
);
1499 if (mdb_vread(sf
, sizeof (*sf
), addr
) == -1) {
1500 mdb_warn("failed to read smb_vfs at %p", addr
);
1504 vn
= mdb_alloc(sizeof (*vn
), UM_SLEEP
| UM_GC
);
1505 if (mdb_vread(vn
, sizeof (*vn
),
1506 (uintptr_t)sf
->sv_rootvp
) == -1) {
1507 mdb_warn("failed to read vnode at %p", sf
->sv_rootvp
);
1511 path
= mdb_zalloc(MAXPATHLEN
, UM_SLEEP
| UM_GC
);
1512 (void) mdb_vread(path
, MAXPATHLEN
, (uintptr_t)vn
->v_path
);
1515 "%-?p %-10d %-?p %-?p %-s\n", addr
, sf
->sv_refcnt
,
1516 sf
->sv_vfsp
, sf
->sv_rootvp
, path
);
1522 * Initialize the smb_vfs_t walker to point to the smb_export
1523 * in the specified smb_server_t instance. (no global walks)
1526 smb_vfs_walk_init(mdb_walk_state_t
*wsp
)
1528 if (wsp
->walk_addr
== (uintptr_t)NULL
) {
1529 mdb_printf("require address of an smb_server_t\n");
1534 OFFSETOF(smb_server_t
, sv_export
.e_vfs_list
.ll_list
);
1536 if (mdb_layered_walk("list", wsp
) == -1) {
1537 mdb_warn("failed to walk list of VFS");
1545 smb_vfs_walk_step(mdb_walk_state_t
*wsp
)
1547 return (wsp
->walk_callback(wsp
->walk_addr
, wsp
->walk_layer
,
1552 * *****************************************************************************
1553 * ******************************* smb_node_t **********************************
1554 * *****************************************************************************
1561 "Display the contents of smb_node_t, with optional filtering.\n\n");
1562 (void) mdb_dec_indent(2);
1563 mdb_printf("%<b>OPTIONS%</b>\n");
1564 (void) mdb_inc_indent(2);
1566 "-v\tDisplay verbose smb_node information\n"
1567 "-p\tDisplay the full path of the vnode associated\n"
1568 "-s\tDisplay the stack of the last 16 calls that modified the "
1569 "reference\n\tcount\n");
1575 * smb_node dcmd - Print out smb_node structure.
1578 smb_dcmd_node(uintptr_t addr
, uint_t flags
, int argc
, const mdb_arg_t
*argv
)
1582 int verbose
= FALSE
;
1583 int print_full_path
= FALSE
;
1584 int stack_trace
= FALSE
;
1586 char od_name
[MAXNAMELEN
];
1587 char path_name
[1024];
1588 uintptr_t list_addr
, oplock_addr
;
1590 if (mdb_getopts(argc
, argv
,
1591 'v', MDB_OPT_SETBITS
, TRUE
, &verbose
,
1592 'p', MDB_OPT_SETBITS
, TRUE
, &print_full_path
,
1593 's', MDB_OPT_SETBITS
, TRUE
, &stack_trace
,
1595 return (DCMD_USAGE
);
1598 * If no smb_node address was specified on the command line, we can
1599 * print out all smb nodes by invoking the smb_node walker, using
1600 * this dcmd itself as the callback.
1602 if (!(flags
& DCMD_ADDRSPEC
)) {
1603 if (mdb_walk_dcmd("smbnode_walker", "smbnode",
1604 argc
, argv
) == -1) {
1605 mdb_warn("failed to walk 'smb_node'");
1612 * If this is the first invocation of the command, print a nice
1613 * header line for the output that will follow.
1615 if (DCMD_HDRSPEC(flags
)) {
1617 mdb_printf("%<b>%<u>SMB node information:%</u>%</b>\n");
1627 "ADDR", "VP", "NODE-NAME", "OFILES", "LOCKS",
1633 * For each smb_node, we just need to read the smb_node_t struct, read
1634 * and then print out the following fields.
1636 if (mdb_vread(&node
, sizeof (node
), addr
) == sizeof (node
)) {
1637 (void) mdb_snprintf(od_name
, sizeof (od_name
), "%s",
1639 if (print_full_path
) {
1640 if (mdb_vread(&vnode
, sizeof (vnode_t
),
1641 (uintptr_t)node
.vp
) == sizeof (vnode_t
)) {
1642 if (mdb_readstr(path_name
, sizeof (path_name
),
1643 (uintptr_t)vnode
.v_path
) != 0) {
1644 (void) mdb_snprintf(od_name
,
1645 sizeof (od_name
), "N/A");
1650 mdb_printf("VP: %p\n", node
.vp
);
1651 mdb_printf("Name: %s\n", od_name
);
1652 if (print_full_path
)
1653 mdb_printf("V-node Path: %s\n", path_name
);
1654 mdb_printf("Ofiles: %u\n", node
.n_ofile_list
.ll_count
);
1655 mdb_printf("Range Locks: %u\n",
1656 node
.n_lock_list
.ll_count
);
1657 if (node
.n_lock_list
.ll_count
!= 0) {
1658 (void) mdb_inc_indent(SMB_DCMD_INDENT
);
1660 OFFSETOF(smb_node_t
, n_lock_list
) +
1661 OFFSETOF(smb_llist_t
, ll_list
);
1662 if (mdb_pwalk_dcmd("list", "smblock", 0,
1664 mdb_warn("failed to walk node's active"
1667 (void) mdb_dec_indent(SMB_DCMD_INDENT
);
1669 if (node
.n_oplock
.ol_count
== 0) {
1670 mdb_printf("Opportunistic Locks: 0\n");
1673 addr
+ OFFSETOF(smb_node_t
, n_oplock
);
1674 mdb_printf("Opportunistic Lock: %p\n",
1676 rc
= mdb_call_dcmd("smboplock", oplock_addr
,
1681 mdb_printf("Reference Count: %u\n\n", node
.n_refcnt
);
1683 mdb_printf("%-?p %-?p %-18s %-6d %-6d %-8d %-6d ",
1684 addr
, node
.vp
, od_name
, node
.n_ofile_list
.ll_count
,
1685 node
.n_lock_list
.ll_count
,
1686 node
.n_oplock
.ol_count
, node
.n_refcnt
);
1688 if (print_full_path
)
1689 mdb_printf("\t%s\n", path_name
);
1691 if (stack_trace
&& node
.n_audit_buf
) {
1693 smb_audit_buf_node_t
*anb
;
1695 anb
= mdb_alloc(sizeof (smb_audit_buf_node_t
),
1698 if (mdb_vread(anb
, sizeof (*anb
),
1699 (uintptr_t)node
.n_audit_buf
) != sizeof (*anb
)) {
1700 mdb_warn("failed to read audit buffer");
1703 ctr
= anb
->anb_max_index
+ 1;
1705 anb
->anb_index
&= anb
->anb_max_index
;
1708 smb_audit_record_node_t
*anr
;
1710 anr
= anb
->anb_records
+ anb
->anb_index
;
1712 if (anr
->anr_depth
) {
1713 char c
[MDB_SYM_NAMLEN
];
1717 mdb_printf("\nRefCnt: %u\t",
1723 if (mdb_lookup_by_addr(
1730 mdb_printf("%s+0x%1x",
1733 (uintptr_t)sym
.st_value
);
1738 while (i
< anr
->anr_depth
) {
1739 if (mdb_lookup_by_addr(
1747 mdb_printf("\n\t\t%s+0x%1x",
1750 (uintptr_t)sym
.st_value
);
1756 anb
->anb_index
&= anb
->anb_max_index
;
1761 mdb_warn("failed to read struct smb_node at %p", addr
);
1769 * Initialize the smb_node_t walker by reading the value of smb_node_hash_table
1770 * in the kernel's symbol table. Only global walk supported.
1773 smb_node_walk_init(mdb_walk_state_t
*wsp
)
1777 uintptr_t node_hash_table_addr
;
1779 if (wsp
->walk_addr
== (uintptr_t)NULL
) {
1780 if (mdb_lookup_by_obj(SMBSRV_OBJNAME
, "smb_node_hash_table",
1782 mdb_warn("failed to find 'smb_node_hash_table'");
1785 node_hash_table_addr
= (uintptr_t)sym
.st_value
;
1787 mdb_printf("smb_node walk only supports global walks\n");
1791 for (i
= 0; i
< SMBND_HASH_MASK
+ 1; i
++) {
1792 wsp
->walk_addr
= node_hash_table_addr
+
1793 (i
* sizeof (smb_llist_t
)) + OFFSETOF(smb_llist_t
, ll_list
);
1794 if (mdb_layered_walk("list", wsp
) == -1) {
1795 mdb_warn("failed to walk 'list'");
1804 smb_node_walk_step(mdb_walk_state_t
*wsp
)
1806 return (wsp
->walk_callback(wsp
->walk_addr
, wsp
->walk_layer
,
1811 * *****************************************************************************
1812 * ****************************** smb_lock_t ***********************************
1813 * *****************************************************************************
1817 smb_lock(uintptr_t addr
, uint_t flags
, int argc
, const mdb_arg_t
*argv
)
1820 int verbose
= FALSE
;
1821 uintptr_t list_addr
;
1824 if (mdb_getopts(argc
, argv
,
1825 'v', MDB_OPT_SETBITS
, TRUE
, &verbose
,
1827 return (DCMD_USAGE
);
1830 * An smb_lock_t address must be specified.
1832 if (!(flags
& DCMD_ADDRSPEC
))
1833 return (DCMD_USAGE
);
1836 * If this is the first invocation of the command, print a nice
1837 * header line for the output that will follow.
1839 if (DCMD_HDRSPEC(flags
)) {
1841 mdb_printf("SMB lock information:\n\n");
1843 mdb_printf("%<u>%-?s %4s %16s %8s %9s%</u>\n",
1844 "Locks: ", "TYPE", "START", "LENGTH",
1848 if (mdb_vread(&lock
, sizeof (lock
), addr
) == sizeof (lock
)) {
1849 switch (lock
.l_type
) {
1850 case SMB_LOCK_TYPE_READWRITE
:
1853 case SMB_LOCK_TYPE_READONLY
:
1861 mdb_printf("Type :\t%s (%u)\n",
1862 lock_type
, lock
.l_type
);
1863 mdb_printf("Start :\t%llx\n",
1865 mdb_printf("Length :\t%lx\n",
1867 mdb_printf("Session :\t%p\n",
1869 mdb_printf("File :\t%p\n",
1871 mdb_printf("User ID :\t%u\n",
1873 mdb_printf("Process ID :\t%u\n",
1875 mdb_printf("Conflicts :\t%u\n",
1876 lock
.l_conflict_list
.sl_count
);
1877 if (lock
.l_conflict_list
.sl_count
!= 0) {
1878 (void) mdb_inc_indent(SMB_DCMD_INDENT
);
1880 OFFSETOF(smb_lock_t
, l_conflict_list
) +
1881 OFFSETOF(smb_slist_t
, sl_list
);
1882 if (mdb_pwalk_dcmd("list", "smb_lock",
1883 0, NULL
, list_addr
)) {
1884 mdb_warn("failed to walk conflict "
1887 (void) mdb_dec_indent(SMB_DCMD_INDENT
);
1889 mdb_printf("Blocked by :\t%p\n",
1891 mdb_printf("Flags :\t0x%x\n",
1895 mdb_printf("%?p %4s %16llx %08lx %9x", addr
,
1896 lock_type
, lock
.l_start
, lock
.l_length
,
1897 lock
.l_conflict_list
.sl_count
);
1900 mdb_warn("failed to read struct smb_request at %p", addr
);
1908 * *****************************************************************************
1909 * ************************** smb_oplock_grant_t *******************************
1910 * *****************************************************************************
1914 smb_oplock_grant(uintptr_t addr
, uint_t flags
, int argc
, const mdb_arg_t
*argv
)
1916 smb_oplock_grant_t grant
;
1919 if (!(flags
& DCMD_ADDRSPEC
))
1920 return (DCMD_USAGE
);
1923 * If this is the first invocation of the command, print a nice
1924 * header line for the output that will follow.
1926 if (DCMD_HDRSPEC(flags
)) {
1927 mdb_printf("%<u>%-16s %-10s %-16s%</u>\n",
1928 "Grants:", "LEVEL", "OFILE");
1931 if (mdb_vread(&grant
, sizeof (grant
), addr
) == sizeof (grant
)) {
1932 switch (grant
.og_level
) {
1933 case SMB_OPLOCK_EXCLUSIVE
:
1934 level
= "EXCLUSIVE";
1936 case SMB_OPLOCK_BATCH
:
1939 case SMB_OPLOCK_LEVEL_II
:
1947 mdb_printf("%-16p %-10s %-16p", addr
, level
, grant
.og_ofile
);
1953 * *****************************************************************************
1954 * ***************************** smb_oplock_t **********************************
1955 * *****************************************************************************
1959 smb_oplock(uintptr_t addr
, uint_t flags
, int argc
, const mdb_arg_t
*argv
)
1961 smb_oplock_t oplock
;
1962 uintptr_t list_addr
;
1964 if (!(flags
& DCMD_ADDRSPEC
))
1965 return (DCMD_USAGE
);
1967 if (mdb_vread(&oplock
, sizeof (oplock
), addr
) != sizeof (oplock
)) {
1968 mdb_warn("failed to read struct smb_oplock at %p", addr
);
1972 if (oplock
.ol_count
== 0)
1975 (void) mdb_inc_indent(SMB_DCMD_INDENT
);
1976 switch (oplock
.ol_break
) {
1977 case SMB_OPLOCK_BREAK_TO_NONE
:
1978 mdb_printf("Break Pending: BREAK_TO_NONE\n");
1980 case SMB_OPLOCK_BREAK_TO_LEVEL_II
:
1982 "Break Pending: BREAK_TO_LEVEL_II\n");
1988 list_addr
= addr
+ OFFSETOF(smb_oplock_t
, ol_grants
);
1990 if (mdb_pwalk_dcmd("list", "smboplockgrant",
1991 argc
, argv
, list_addr
)) {
1992 mdb_warn("failed to walk oplock grants");
1995 (void) mdb_dec_indent(SMB_DCMD_INDENT
);
2003 * Prints SMB requests statistics.
2007 smb_stats(uintptr_t addr
, uint_t flags
, int argc
, const mdb_arg_t
*argv
)
2011 if (!(flags
& DCMD_ADDRSPEC
))
2012 return (DCMD_USAGE
);
2014 sv
= mdb_alloc(sizeof (*sv
), UM_SLEEP
| UM_GC
);
2015 if (mdb_vread(sv
, sizeof (*sv
), addr
) == -1) {
2016 mdb_warn("failed to read server object at %p", addr
);
2019 if (sv
->sv_magic
!= SMB_SERVER_MAGIC
) {
2020 mdb_warn("not an smb_server_t (%p)>", addr
);
2024 "\n%<b> nbt tcp users trees files pipes%</b>\n"
2025 "%5d %5d %5d %5d %5d %5d\n",
2037 * *****************************************************************************
2038 * ******************************** smb_ace_t **********************************
2039 * *****************************************************************************
2041 static const ace_type_entry_t ace_types
[ACE_TYPE_TABLEN
] =
2043 ACE_TYPE_ENTRY(ACE_ACCESS_ALLOWED_ACE_TYPE
),
2044 ACE_TYPE_ENTRY(ACE_ACCESS_DENIED_ACE_TYPE
),
2045 ACE_TYPE_ENTRY(ACE_SYSTEM_AUDIT_ACE_TYPE
),
2046 ACE_TYPE_ENTRY(ACE_SYSTEM_ALARM_ACE_TYPE
),
2047 ACE_TYPE_ENTRY(ACE_ACCESS_ALLOWED_COMPOUND_ACE_TYPE
),
2048 ACE_TYPE_ENTRY(ACE_ACCESS_ALLOWED_OBJECT_ACE_TYPE
),
2049 ACE_TYPE_ENTRY(ACE_ACCESS_DENIED_OBJECT_ACE_TYPE
),
2050 ACE_TYPE_ENTRY(ACE_SYSTEM_AUDIT_OBJECT_ACE_TYPE
),
2051 ACE_TYPE_ENTRY(ACE_SYSTEM_ALARM_OBJECT_ACE_TYPE
),
2052 ACE_TYPE_ENTRY(ACE_ACCESS_ALLOWED_CALLBACK_ACE_TYPE
),
2053 ACE_TYPE_ENTRY(ACE_ACCESS_DENIED_CALLBACK_ACE_TYPE
),
2054 ACE_TYPE_ENTRY(ACE_ACCESS_ALLOWED_CALLBACK_OBJECT_ACE_TYPE
),
2055 ACE_TYPE_ENTRY(ACE_ACCESS_DENIED_CALLBACK_OBJECT_ACE_TYPE
),
2056 ACE_TYPE_ENTRY(ACE_SYSTEM_AUDIT_CALLBACK_ACE_TYPE
),
2057 ACE_TYPE_ENTRY(ACE_SYSTEM_ALARM_CALLBACK_ACE_TYPE
),
2058 ACE_TYPE_ENTRY(ACE_SYSTEM_AUDIT_CALLBACK_OBJECT_ACE_TYPE
),
2059 ACE_TYPE_ENTRY(ACE_SYSTEM_ALARM_CALLBACK_OBJECT_ACE_TYPE
),
2060 ACE_TYPE_ENTRY(0x11),
2061 ACE_TYPE_ENTRY(0x12),
2062 ACE_TYPE_ENTRY(0x13),
2063 ACE_TYPE_ENTRY(0x14),
2064 ACE_TYPE_ENTRY(0x15),
2065 ACE_TYPE_ENTRY(0x16),
2066 ACE_TYPE_ENTRY(0x17),
2067 ACE_TYPE_ENTRY(0x18),
2068 ACE_TYPE_ENTRY(0x19),
2069 ACE_TYPE_ENTRY(0x1A),
2070 ACE_TYPE_ENTRY(0x1B),
2071 ACE_TYPE_ENTRY(0x1C),
2072 ACE_TYPE_ENTRY(0x1D),
2073 ACE_TYPE_ENTRY(0x1E),
2074 ACE_TYPE_ENTRY(0x1F)
2077 static const mdb_bitmask_t ace_flag_bits
[] = {
2078 { "OBJECT_INHERIT_ACE", OBJECT_INHERIT_ACE
, OBJECT_INHERIT_ACE
},
2079 { "CONTAINER_INHERIT_ACE", CONTAINER_INHERIT_ACE
,
2080 CONTAINER_INHERIT_ACE
},
2081 { "NO_PROPOGATE_INHERIT_ACE", NO_PROPOGATE_INHERIT_ACE
,
2082 NO_PROPOGATE_INHERIT_ACE
},
2083 { "INHERIT_ONLY_ACE", INHERIT_ONLY_ACE
, INHERIT_ONLY_ACE
},
2084 { "INHERITED_ACE", INHERITED_ACE
, INHERITED_ACE
},
2085 { "SUCCESSFUL_ACCESS_ACE_FLAG", SUCCESSFUL_ACCESS_ACE_FLAG
,
2086 SUCCESSFUL_ACCESS_ACE_FLAG
},
2087 { "FAILED_ACCESS_ACE_FLAG", FAILED_ACCESS_ACE_FLAG
,
2088 FAILED_ACCESS_ACE_FLAG
},
2096 smb_ace(uintptr_t addr
, uint_t flags
, int argc
, const mdb_arg_t
*argv
)
2099 int verbose
= FALSE
;
2103 if (mdb_getopts(argc
, argv
, 'v', MDB_OPT_SETBITS
, TRUE
, &verbose
,
2105 return (DCMD_USAGE
);
2108 * An smb_ace address is required.
2110 if (!(flags
& DCMD_ADDRSPEC
))
2111 return (DCMD_USAGE
);
2113 if (mdb_vread(&ace
, sizeof (ace
), addr
) != sizeof (ace
)) {
2114 mdb_warn("failed to read struct smb_ace at %p", addr
);
2119 if (ace
.se_hdr
.se_type
< ACE_TYPE_TABLEN
)
2120 ptr
= ace_types
[ace
.se_hdr
.se_type
].ace_type_sting
;
2124 mdb_printf("ACE Type: 0x%02x (%s)\n", ace
.se_hdr
.se_type
, ptr
);
2125 mdb_printf("ACE Flags: %b\n", (int)ace
.se_hdr
.se_flags
,
2127 mdb_printf("ACE Wire Size: 0x%04x\n", ace
.se_hdr
.se_bsize
);
2128 mdb_printf("ACE Mask: 0x%08x\n", ace
.se_mask
);
2129 mdb_printf("ACE SID: ");
2131 if (DCMD_HDRSPEC(flags
))
2133 "%<b>%<u>%?-s %-4s %-4s %-8s %s%</u>%</b>\n",
2134 "ACE", "TYPE", "FLAGS", "MASK", "SID");
2135 mdb_printf("%?p 0x%02x 0x%02x 0x%08x ", addr
,
2136 ace
.se_hdr
.se_type
, ace
.se_hdr
.se_flags
, ace
.se_mask
);
2138 rc
= smb_sid_print((uintptr_t)ace
.se_sid
);
2144 smb_ace_walk_init(mdb_walk_state_t
*wsp
)
2146 if (wsp
->walk_addr
== (uintptr_t)NULL
) {
2147 mdb_printf("smb_ace walk only supports local walks\n");
2151 wsp
->walk_addr
+= OFFSETOF(smb_acl_t
, sl_sorted
);
2153 if (mdb_layered_walk("list", wsp
) == -1) {
2154 mdb_warn("failed to walk list of ACEs");
2162 smb_ace_walk_step(mdb_walk_state_t
*wsp
)
2164 return (wsp
->walk_callback(wsp
->walk_addr
, wsp
->walk_layer
,
2169 * *****************************************************************************
2170 * ******************************** smb_acl_t **********************************
2171 * *****************************************************************************
2178 smb_acl(uintptr_t addr
, uint_t flags
, int argc
, const mdb_arg_t
*argv
)
2182 /* An smb_acl address is required. */
2183 if (!(flags
& DCMD_ADDRSPEC
))
2184 return (DCMD_USAGE
);
2186 if (mdb_vread(&acl
, sizeof (acl
), addr
) != sizeof (acl
)) {
2187 mdb_warn("failed to read struct smb_acl at %p", addr
);
2191 mdb_printf("ACL Revision: %d\n", acl
.sl_revision
);
2192 mdb_printf("ACL Size on Wire: %d\n", acl
.sl_bsize
);
2193 mdb_printf("ACL Number of ACEs: %d\n", acl
.sl_acecnt
);
2195 (void) mdb_inc_indent(SMB_DCMD_INDENT
);
2196 if (mdb_pwalk_dcmd("smbace_walker", "smbace", argc
, argv
, addr
)) {
2197 (void) mdb_dec_indent(SMB_DCMD_INDENT
);
2198 mdb_warn("failed to walk list of ACEs for ACL %p", addr
);
2201 (void) mdb_dec_indent(SMB_DCMD_INDENT
);
2206 * *****************************************************************************
2207 * ********************************* smb_sd_t **********************************
2208 * *****************************************************************************
2215 smb_sd(uintptr_t addr
, uint_t flags
, int argc
, const mdb_arg_t
*argv
)
2221 * An smb_sid address is required.
2223 if (!(flags
& DCMD_ADDRSPEC
))
2224 return (DCMD_USAGE
);
2226 if (mdb_vread(&sd
, sizeof (sd
), addr
) != sizeof (sd
)) {
2227 mdb_warn("failed to read struct smb_sd at %p", addr
);
2231 mdb_printf("SD Revision: %d\n", sd
.sd_revision
);
2232 mdb_printf("SD Control: %04x\n", sd
.sd_control
);
2233 if (sd
.sd_control
& SE_OWNER_DEFAULTED
)
2234 mdb_printf("\t SE_OWNER_DEFAULTED\n");
2235 if (sd
.sd_control
& SE_GROUP_DEFAULTED
)
2236 mdb_printf("\t SE_GROUP_DEFAULTED\n");
2237 if (sd
.sd_control
& SE_DACL_PRESENT
)
2238 mdb_printf("\t SE_DACL_PRESENT\n");
2239 if (sd
.sd_control
& SE_DACL_DEFAULTED
)
2240 mdb_printf("\t SE_DACL_DEFAULTED\n");
2241 if (sd
.sd_control
& SE_SACL_PRESENT
)
2242 mdb_printf("\t SE_SACL_PRESENT\n");
2243 if (sd
.sd_control
& SE_SACL_DEFAULTED
)
2244 mdb_printf("\t SE_SACL_DEFAULTED\n");
2245 if (sd
.sd_control
& SE_DACL_AUTO_INHERIT_REQ
)
2246 mdb_printf("\t SE_DACL_AUTO_INHERIT_REQ\n");
2247 if (sd
.sd_control
& SE_SACL_AUTO_INHERIT_REQ
)
2248 mdb_printf("\t SE_SACL_AUTO_INHERIT_REQ\n");
2249 if (sd
.sd_control
& SE_DACL_AUTO_INHERITED
)
2250 mdb_printf("\t SE_DACL_AUTO_INHERITED\n");
2251 if (sd
.sd_control
& SE_SACL_AUTO_INHERITED
)
2252 mdb_printf("\t SE_SACL_AUTO_INHERITED\n");
2253 if (sd
.sd_control
& SE_DACL_PROTECTED
)
2254 mdb_printf("\t SE_DACL_PROTECTED\n");
2255 if (sd
.sd_control
& SE_SACL_PROTECTED
)
2256 mdb_printf("\t SE_SACL_PROTECTED\n");
2257 if (sd
.sd_control
& SE_SELF_RELATIVE
)
2258 mdb_printf("\t SE_SELF_RELATIVE\n");
2260 mdb_printf("SID of Owner: ");
2261 rc
= smb_sid_print((uintptr_t)sd
.sd_owner
);
2264 mdb_printf("\nSID of Group: ");
2265 rc
= smb_sid_print((uintptr_t)sd
.sd_group
);
2270 if (sd
.sd_control
& SE_SACL_PRESENT
&& sd
.sd_sacl
) {
2271 mdb_printf("%<b>%<u>System ACL%</u>%</b>\n");
2272 (void) mdb_inc_indent(SMB_DCMD_INDENT
);
2273 rc
= mdb_call_dcmd("smbacl", (uintptr_t)sd
.sd_sacl
, flags
,
2275 (void) mdb_dec_indent(SMB_DCMD_INDENT
);
2279 if (sd
.sd_control
& SE_DACL_PRESENT
&& sd
.sd_dacl
) {
2280 mdb_printf("%<b>%<u>Discretionary ACL%</u>%</b>\n");
2281 (void) mdb_inc_indent(SMB_DCMD_INDENT
);
2282 rc
= mdb_call_dcmd("smbacl", (uintptr_t)sd
.sd_dacl
, flags
,
2284 (void) mdb_dec_indent(SMB_DCMD_INDENT
);
2293 * *****************************************************************************
2294 * ********************************* smb_sid_t *********************************
2295 * *****************************************************************************
2303 smb_sid(uintptr_t addr
, uint_t flags
, int argc
, const mdb_arg_t
*argv
)
2306 * An smb_sid address is required.
2308 if (!(flags
& DCMD_ADDRSPEC
))
2309 return (DCMD_USAGE
);
2311 return (smb_sid_print(addr
));
2318 smb_sid_print(uintptr_t addr
)
2326 sid_size
= OFFSETOF(smb_sid_t
, sid_subauth
);
2328 if (mdb_vread(&sid
, sid_size
, addr
) != sid_size
) {
2329 mdb_warn("failed to read struct smb_sid at %p", addr
);
2333 sid_size
+= sid
.sid_subauthcnt
* sizeof (sid
.sid_subauth
[0]);
2335 psid
= mdb_zalloc(sid_size
, UM_SLEEP
| UM_GC
);
2336 if (mdb_vread(psid
, sid_size
, addr
) != sid_size
) {
2337 mdb_warn("failed to read struct smb_sid at %p", addr
);
2341 mdb_printf("S-%d", psid
->sid_revision
);
2343 for (i
= 0; i
< NT_SID_AUTH_MAX
; i
++) {
2344 authority
+= ((uint64_t)psid
->sid_authority
[i
]) <<
2345 (8 * (NT_SID_AUTH_MAX
- 1) - i
);
2347 mdb_printf("-%ll", authority
);
2349 for (i
= 0; i
< psid
->sid_subauthcnt
; i
++)
2350 mdb_printf("-%d", psid
->sid_subauth
[i
]);
2356 * *****************************************************************************
2357 * ********************************* smb_fssd_t ********************************
2358 * *****************************************************************************
2365 smb_fssd(uintptr_t addr
, uint_t flags
, int argc
, const mdb_arg_t
*argv
)
2371 * An smb_fssd address is required.
2373 if (!(flags
& DCMD_ADDRSPEC
))
2374 return (DCMD_USAGE
);
2376 if (mdb_vread(&fssd
, sizeof (fssd
), addr
) != sizeof (fssd
)) {
2377 mdb_warn("failed to read struct smb_fssd at %p", addr
);
2381 mdb_printf("FSSD secinfo: 0x%x\n", fssd
.sd_secinfo
);
2382 if (fssd
.sd_secinfo
& SMB_OWNER_SECINFO
)
2383 mdb_printf("FSSD uid: %d\n", fssd
.sd_uid
);
2384 if (fssd
.sd_secinfo
& SMB_GROUP_SECINFO
)
2385 mdb_printf("FSSD gid: %d\n", fssd
.sd_gid
);
2386 if (fssd
.sd_secinfo
& SMB_SACL_SECINFO
&& fssd
.sd_zsacl
) {
2387 mdb_printf("%<b>%<u>System ACL%</u>%</b>\n");
2388 (void) mdb_inc_indent(SMB_DCMD_INDENT
);
2389 rc
= mdb_call_dcmd("smbacl", (uintptr_t)fssd
.sd_zsacl
, flags
,
2391 (void) mdb_dec_indent(SMB_DCMD_INDENT
);
2395 if (fssd
.sd_secinfo
& SMB_DACL_SECINFO
&& fssd
.sd_zdacl
) {
2396 mdb_printf("%<b>%<u>Discretionary ACL%</u>%</b>\n");
2397 (void) mdb_inc_indent(SMB_DCMD_INDENT
);
2398 rc
= mdb_call_dcmd("smbacl", (uintptr_t)fssd
.sd_zdacl
, flags
,
2400 (void) mdb_dec_indent(SMB_DCMD_INDENT
);
2409 * *****************************************************************************
2410 * **************************** Utility Funcions *******************************
2411 * *****************************************************************************
2417 * This function analyzes the arguments passed in and sets the bit corresponding
2418 * to the options found in the opts variable.
2422 * -1 An error occured during the decoding
2423 * 0 The decoding was successful
2426 smb_dcmd_getopt(uint_t
*opts
, int argc
, const mdb_arg_t
*argv
)
2430 if (mdb_getopts(argc
, argv
,
2431 's', MDB_OPT_SETBITS
, SMB_OPT_SERVER
, opts
,
2432 'e', MDB_OPT_SETBITS
, SMB_OPT_SESSION
, opts
,
2433 'r', MDB_OPT_SETBITS
, SMB_OPT_REQUEST
, opts
,
2434 'u', MDB_OPT_SETBITS
, SMB_OPT_USER
, opts
,
2435 't', MDB_OPT_SETBITS
, SMB_OPT_TREE
, opts
,
2436 'f', MDB_OPT_SETBITS
, SMB_OPT_OFILE
, opts
,
2437 'd', MDB_OPT_SETBITS
, SMB_OPT_ODIR
, opts
,
2438 'w', MDB_OPT_SETBITS
, SMB_OPT_WALK
, opts
,
2439 'v', MDB_OPT_SETBITS
, SMB_OPT_VERBOSE
, opts
,
2449 * This function set the arguments corresponding to the bits set in opts.
2453 * Number of arguments set.
2456 smb_dcmd_setopt(uint_t opts
, int max_argc
, mdb_arg_t
*argv
)
2461 for (i
= 0; i
< SMB_MDB_MAX_OPTS
; i
++) {
2462 if ((opts
& smb_opts
[i
].o_value
) && (argc
< max_argc
)) {
2463 argv
->a_type
= MDB_TYPE_STRING
;
2464 argv
->a_un
.a_str
= smb_opts
[i
].o_name
;
2476 smb_obj_expand(uintptr_t addr
, uint_t opts
, const smb_exp_t
*x
, ulong_t indent
)
2480 mdb_arg_t argv
[SMB_MDB_MAX_OPTS
];
2482 argc
= smb_dcmd_setopt(opts
| SMB_OPT_WALK
, SMB_MDB_MAX_OPTS
, argv
);
2484 (void) mdb_inc_indent(indent
);
2485 while (x
->ex_dcmd
) {
2486 if (x
->ex_mask
& opts
) {
2487 rc
= mdb_pwalk_dcmd("list", x
->ex_dcmd
, argc
, argv
,
2488 addr
+ x
->ex_offset
);
2491 mdb_warn("failed to walk the list of %s in %p",
2492 x
->ex_name
, addr
+ x
->ex_offset
);
2498 (void) mdb_dec_indent(indent
);
2505 * Function called by the DCMDs when no address is provided. It expands the
2506 * tree under the object type associated with the calling DCMD (based on the
2515 smb_obj_list(const char *name
, uint_t opts
, uint_t flags
)
2518 mdb_arg_t argv
[SMB_MDB_MAX_OPTS
];
2520 argc
= smb_dcmd_setopt(opts
, SMB_MDB_MAX_OPTS
, argv
);
2522 if (mdb_call_dcmd("smblist", 0, flags
, argc
, argv
)) {
2523 mdb_warn("failed to list %s", name
);
2530 smb_worker_findstack(uintptr_t addr
)
2536 mdb_snprintf(cmd
, sizeof (cmd
), "<.$c%d", 16);
2537 cmdarg
.a_type
= MDB_TYPE_STRING
;
2538 cmdarg
.a_un
.a_str
= cmd
;
2539 (void) mdb_call_dcmd("findstack", addr
, DCMD_ADDRSPEC
, 1, &cmdarg
);