changeset 21326:db8ec8447779

10961 want mdb "shares" walker for smbsrv Reviewed by: Bayard Bell <bayard.bell@nexenta.com> Reviewed by: Kevin Crowe <kevin.crowe@nexenta.com> Reviewed by: Matt Barden <Matt.Barden@nexenta.com> Approved by: Joshua M. Clulow <josh@sysmgr.org>
author Gordon Ross <gwr@nexenta.com>
date Mon, 20 Apr 2015 23:02:00 -0400
parents dde8fe698626
children a99734b8cddf
files usr/src/cmd/mdb/common/modules/smbsrv/smbsrv.c
diffstat 1 files changed, 294 insertions(+), 250 deletions(-) [+]
line wrap: on
line diff
--- a/usr/src/cmd/mdb/common/modules/smbsrv/smbsrv.c	Wed Apr 10 14:27:20 2019 -0400
+++ b/usr/src/cmd/mdb/common/modules/smbsrv/smbsrv.c	Mon Apr 20 23:02:00 2015 -0400
@@ -386,154 +386,12 @@
 	"smb2_invalid_cmd"
 };
 
-static int smb_dcmd_list(uintptr_t, uint_t, int, const mdb_arg_t *);
-static void smb_dcmd_list_help(void);
-static int smb_dcmd_server(uintptr_t, uint_t, int, const mdb_arg_t *);
-static void smb_dcmd_session_help(void);
-static int smb_dcmd_session(uintptr_t, uint_t, int, const mdb_arg_t *);
-static int smb_dcmd_request(uintptr_t, uint_t, int, const mdb_arg_t *);
-static void smb_dcmd_user_help(void);
-static int smb_dcmd_user(uintptr_t, uint_t, int, const mdb_arg_t *);
-static void smb_dcmd_tree_help(void);
-static int smb_dcmd_tree(uintptr_t, uint_t, int, const mdb_arg_t *);
-static int smb_dcmd_odir(uintptr_t, uint_t, int, const mdb_arg_t *);
-static int smb_dcmd_ofile(uintptr_t, uint_t, int, const mdb_arg_t *);
-static int smb_dcmd_kshare(uintptr_t, uint_t, int, const mdb_arg_t *);
-static int smb_dcmd_vfs(uintptr_t, uint_t, int, const mdb_arg_t *);
-static int smb_vfs_walk_init(mdb_walk_state_t *);
-static int smb_vfs_walk_step(mdb_walk_state_t *);
-static void smb_node_help(void);
-static int smb_dcmd_node(uintptr_t, uint_t, int, const mdb_arg_t *);
-static int smb_node_walk_init(mdb_walk_state_t *);
-static int smb_node_walk_step(mdb_walk_state_t *);
-static int smb_lock(uintptr_t, uint_t, int, const mdb_arg_t *);
-static int smb_oplock(uintptr_t, uint_t, int, const mdb_arg_t *);
-static int smb_oplock_grant(uintptr_t, uint_t, int, const mdb_arg_t *);
-static int smb_ace(uintptr_t, uint_t, int, const mdb_arg_t *);
-static int smb_ace_walk_init(mdb_walk_state_t *);
-static int smb_ace_walk_step(mdb_walk_state_t *);
-static int smb_acl(uintptr_t, uint_t, int, const mdb_arg_t *);
-static int smb_sd(uintptr_t, uint_t, int, const mdb_arg_t *);
-static int smb_sid(uintptr_t, uint_t, int, const mdb_arg_t *);
 static int smb_sid_print(uintptr_t);
-static int smb_fssd(uintptr_t, uint_t, int, const mdb_arg_t *);
 static int smb_dcmd_getopt(uint_t *, int, const mdb_arg_t *);
 static int smb_dcmd_setopt(uint_t, int, mdb_arg_t *);
 static int smb_obj_expand(uintptr_t, uint_t, const smb_exp_t *, ulong_t);
 static int smb_obj_list(const char *, uint_t, uint_t);
 static int smb_worker_findstack(uintptr_t);
-static int smb_stats(uintptr_t, uint_t, int, const mdb_arg_t *);
-
-/*
- * MDB module linkage information:
- *
- * We declare a list of structures describing our dcmds, a list of structures
- * describing our walkers and a function named _mdb_init to return a pointer
- * to our module information.
- */
-static const mdb_dcmd_t dcmds[] = {
-	{   "smblist",
-	    "[-seutfdwv]",
-	    "print tree of SMB objects",
-	    smb_dcmd_list,
-	    smb_dcmd_list_help },
-	{   "smbsrv",
-	    "[-seutfdwv]",
-	    "print smb_server information",
-	    smb_dcmd_server },
-	{   "smbshares",
-	    "[-v]",
-	    "print smb_kshare_t information",
-	    smb_dcmd_kshare },
-	{   "smbvfs",
-	    "[-v]",
-	    "print smb_vfs information",
-	    smb_dcmd_vfs },
-	{   "smbnode",
-	    "?[-vps]",
-	    "print smb_node_t information",
-	    smb_dcmd_node,
-	    smb_node_help },
-	{   "smbsess",
-	    "[-utfdwv]",
-	    "print smb_session_t information",
-	    smb_dcmd_session,
-	    smb_dcmd_session_help},
-	{   "smbreq",
-	    ":[-v]",
-	    "print smb_request_t information",
-	    smb_dcmd_request },
-	{   "smblock", ":[-v]",
-	    "print smb_lock_t information", smb_lock },
-	{   "smbuser",
-	    ":[-vdftq]",
-	    "print smb_user_t information",
-	    smb_dcmd_user,
-	    smb_dcmd_user_help },
-	{   "smbtree",
-	    ":[-vdf]",
-	    "print smb_tree_t information",
-	    smb_dcmd_tree,
-	    smb_dcmd_tree_help },
-	{   "smbodir",
-	    ":[-v]",
-	    "print smb_odir_t information",
-	    smb_dcmd_odir },
-	{   "smbofile",
-	    "[-v]",
-	    "print smb_file_t information",
-	    smb_dcmd_ofile },
-	{   "smboplock", NULL,
-	    "print smb_oplock_t information", smb_oplock },
-	{   "smboplockgrant", NULL,
-	    "print smb_oplock_grant_t information", smb_oplock_grant },
-	{   "smbstat", NULL,
-	    "print all smb dispatched requests statistics",
-	    smb_stats },
-	{   "smbace", "[-v]",
-	    "print smb_ace_t information", smb_ace },
-	{   "smbacl", "[-v]",
-	    "print smb_acl_t information", smb_acl },
-	{   "smbsid", "[-v]",
-	    "print smb_sid_t information", smb_sid },
-	{   "smbsd", "[-v]",
-	    "print smb_sd_t information", smb_sd },
-	{   "smbfssd", "[-v]",
-	    "print smb_fssd_t information", smb_fssd },
-	{ NULL }
-};
-
-static const mdb_walker_t walkers[] = {
-	{   "smbnode_walker",
-	    "walk list of smb_node_t structures",
-	    smb_node_walk_init,
-	    smb_node_walk_step,
-	    NULL,
-	    NULL },
-	{   "smbvfs_walker",
-	    "walk list of smb_vfs_t structures",
-	    smb_vfs_walk_init,
-	    smb_vfs_walk_step,
-	    NULL,
-	    NULL },
-	{   "smbace_walker",
-	    "walk list of smb_ace_t structures",
-	    smb_ace_walk_init,
-	    smb_ace_walk_step,
-	    NULL,
-	    NULL },
-	{ NULL }
-};
-
-static const mdb_modinfo_t modinfo = {
-	MDB_API_VERSION, dcmds, walkers
-};
-
-const mdb_modinfo_t *
-_mdb_init(void)
-{
-	return (&modinfo);
-}
 
 /*
  * *****************************************************************************
@@ -542,7 +400,7 @@
  */
 
 static void
-smb_dcmd_list_help(void)
+smblist_help(void)
 {
 	mdb_printf(
 	    "Displays the list of objects using an indented tree format.\n"
@@ -570,7 +428,7 @@
  */
 /*ARGSUSED*/
 static int
-smb_dcmd_list(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
+smblist_dcmd(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
 {
 	GElf_Sym	sym;
 	uint_t		opts = 0;
@@ -637,7 +495,7 @@
  */
 /*ARGSUSED*/
 static int
-smb_dcmd_server(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
+smbsrv_dcmd(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
 {
 	uint_t		opts;
 	ulong_t		indent = 0;
@@ -726,7 +584,7 @@
 };
 
 static void
-smb_dcmd_session_help(void)
+smbsess_help(void)
 {
 	mdb_printf(
 	    "Display the contents of smb_session_t, with optional"
@@ -746,7 +604,7 @@
  * smbsess dcmd - Print out the smb_session structure.
  */
 static int
-smb_dcmd_session(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
+smbsess_dcmd(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
 {
 	uint_t		opts;
 	ulong_t		indent = 0;
@@ -866,7 +724,7 @@
 	"%-?p %-?p %-14lld %-14lld %-16s %s\n"
 
 static int
-smb_dcmd_request(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
+smbreq_dcmd(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
 {
 	uint_t		opts;
 
@@ -1033,7 +891,7 @@
 };
 
 static void
-smb_dcmd_user_help(void)
+smbuser_help(void)
 {
 	mdb_printf(
 	    "Display the contents of smb_user_t, with optional filtering.\n\n");
@@ -1045,7 +903,7 @@
 }
 
 static int
-smb_dcmd_user(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
+smbuser_dcmd(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
 {
 	uint_t		opts;
 
@@ -1141,7 +999,7 @@
 };
 
 static void
-smb_dcmd_tree_help(void)
+smbtree_help(void)
 {
 	mdb_printf(
 	    "Display the contents of smb_tree_t, with optional filtering.\n\n");
@@ -1155,7 +1013,7 @@
 }
 
 static int
-smb_dcmd_tree(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
+smbtree_dcmd(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
 {
 	uint_t		opts;
 	ulong_t		indent = 0;
@@ -1231,7 +1089,7 @@
 };
 
 static int
-smb_dcmd_odir(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
+smbodir_dcmd(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
 {
 	uint_t		opts;
 
@@ -1302,7 +1160,7 @@
 };
 
 static int
-smb_dcmd_ofile(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
+smbofile_dcmd(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
 {
 	uint_t		opts;
 
@@ -1369,78 +1227,86 @@
  * *****************************************************************************
  */
 
+struct smb_kshare_cb_args {
+	uint_t		opts;
+	char name[MAXNAMELEN];
+	char path[MAXPATHLEN];
+};
+
 static int
-smb_kshare_cb(uintptr_t addr, const void *data, void *arg)
+smb_kshare_cb(uintptr_t addr, const void *data, void *varg)
 {
-	uint_t *opts = arg;
-	uintptr_t ta, sa;
-	char name[32];
-	char path[64];
-	_NOTE(ARGUNUSED(data));
+	struct smb_kshare_cb_args *args = varg;
+	const smb_kshare_t *shr = data;
 
-	if (*opts & SMB_OPT_VERBOSE) {
+	if (args->opts & SMB_OPT_VERBOSE) {
 		mdb_arg_t	argv;
 
 		argv.a_type = MDB_TYPE_STRING;
 		argv.a_un.a_str = "smb_kshare_t";
 		/* Don't fail the walk if this fails. */
+		mdb_printf("%-?p ", addr);
 		mdb_call_dcmd("print", addr, 0, 1, &argv);
-	} else {
-		/*
-		 * Summary line for a kshare
-		 * Don't fail the walk if any of these fail.
-		 */
-		ta = addr + OFFSETOF(smb_kshare_t, shr_name);
-		if (mdb_vread(&sa, sizeof (sa), ta) < 0 ||
-		    mdb_readstr(name, sizeof (name), sa) <= 0)
-			strcpy(name, "?");
+		return (WALK_NEXT);
+	}
 
-		ta = addr + OFFSETOF(smb_kshare_t, shr_path);
-		if (mdb_vread(&sa, sizeof (sa), ta) < 0 ||
-		    mdb_readstr(path, sizeof (path), sa) <= 0)
-			strcpy(path, "?");
+	/*
+	 * Summary line for an smb_kshare_t
+	 * Don't fail the walk if any of these fail.
+	 *
+	 * Get the shr_name and shr_path strings.
+	 */
+	if (mdb_readstr(args->name, sizeof (args->name),
+	    (uintptr_t)shr->shr_name) <= 0)
+		strcpy(args->name, "?");
 
-		mdb_printf("%-?p ", addr);	/* smb_kshare_t */
-		mdb_printf("%-16s ", name);
-		mdb_printf("%-s", path);
-		mdb_printf("\n");
-	}
+	if (mdb_readstr(args->path, sizeof (args->path),
+	    (uintptr_t)shr->shr_path) <= 0)
+		strcpy(args->path, "?");
+
+	mdb_printf("%-?p ", addr);	/* smb_kshare_t */
+	mdb_printf("%-16s ", args->name);
+	mdb_printf("%-s\n", args->path);
 
 	return (WALK_NEXT);
 }
 
 /*
- * ::smbshares
+ * ::smbshare
  *
- * dcmd - Print out smb_kshare structures.
+ * smbshare dcmd - Print out smb_kshare structures.
  *	requires addr of an smb_server_t
  */
 /*ARGSUSED*/
 static int
-smb_dcmd_kshare(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
+smbshare_dcmd(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
 {
-	uint_t		opts = 0;
+	struct smb_kshare_cb_args *args;
 
+	args = mdb_zalloc(sizeof (*args), UM_SLEEP | UM_GC);
 	if (mdb_getopts(argc, argv,
-	    'v', MDB_OPT_SETBITS, SMB_OPT_VERBOSE, &opts,
+	    'v', MDB_OPT_SETBITS, SMB_OPT_VERBOSE, &args->opts,
 	    NULL) != argc)
 		return (DCMD_USAGE);
 
 	if (!(flags & DCMD_ADDRSPEC))
 		return (DCMD_USAGE);
-	addr += OFFSETOF(smb_server_t, sv_export.e_share_avl.avl_tree);
 
 	if (DCMD_HDRSPEC(flags)) {
-		mdb_printf(
-		    "%<b>%<u>"
-		    "%-?s "
-		    "%-16s "
-		    "%-s"
-		    "%</u>%</b>\n",
-		    "smb_kshare_t", "name", "path");
+		if ((args->opts & SMB_OPT_VERBOSE) != 0) {
+			mdb_printf("%<b>%<u>SMB kshares list:%</u>%</b>\n");
+		} else {
+			mdb_printf(
+			    "%<b>%<u>"
+			    "%-?s "
+			    "%-16s "
+			    "%-s"
+			    "%</u>%</b>\n",
+			    "smb_kshare_t", "name", "path");
+		}
 	}
 
-	if (mdb_pwalk("avl", smb_kshare_cb, &opts, addr) == -1) {
+	if (mdb_pwalk("smbshare_walker", smb_kshare_cb, args, addr) == -1) {
 		mdb_warn("cannot walk smb_kshare avl");
 		return (DCMD_ERR);
 	}
@@ -1449,76 +1315,128 @@
 }
 
 /*
+ * Initialize the smb_kshare_t walker to point to the smb_export
+ * in the specified smb_server_t instance.  (no global walks)
+ */
+static int
+smb_kshare_walk_init(mdb_walk_state_t *wsp)
+{
+
+	if (wsp->walk_addr == 0) {
+		mdb_printf("require address of an smb_server_t\n");
+		return (WALK_ERR);
+	}
+
+	wsp->walk_addr +=
+	    OFFSETOF(smb_server_t, sv_export.e_share_avl.avl_tree);
+
+	if (mdb_layered_walk("avl", wsp) == -1) {
+		mdb_warn("failed to walk list of smb_kshare_t");
+		return (WALK_ERR);
+	}
+
+	return (WALK_NEXT);
+}
+
+static int
+smb_kshare_walk_step(mdb_walk_state_t *wsp)
+{
+	return (wsp->walk_callback(wsp->walk_addr, wsp->walk_layer,
+	    wsp->walk_cbdata));
+}
+
+/*
  * *****************************************************************************
  * ******************************** smb_vfs_t **********************************
  * *****************************************************************************
  */
 
+struct smb_vfs_cb_args {
+	uint_t		opts;
+	vnode_t		vn;
+	char		path[MAXPATHLEN];
+};
+
+static int
+smb_vfs_cb(uintptr_t addr, const void *data, void *varg)
+{
+	struct smb_vfs_cb_args *args = varg;
+	const smb_vfs_t *sf = data;
+
+	if (args->opts & SMB_OPT_VERBOSE) {
+		mdb_arg_t	argv;
+
+		argv.a_type = MDB_TYPE_STRING;
+		argv.a_un.a_str = "smb_vfs_t";
+		/* Don't fail the walk if this fails. */
+		mdb_printf("%-?p ", addr);
+		mdb_call_dcmd("print", addr, 0, 1, &argv);
+		return (WALK_NEXT);
+	}
+
+	/*
+	 * Summary line for an smb_vfs_t
+	 * Don't fail the walk if any of these fail.
+	 *
+	 * Get the vnode v_path string if we can.
+	 */
+	strcpy(args->path, "?");
+	if (mdb_vread(&args->vn, sizeof (args->vn),
+	    (uintptr_t)sf->sv_rootvp) == sizeof (args->vn))
+		(void) mdb_readstr(args->path, sizeof (args->path),
+		    (uintptr_t)args->vn.v_path);
+
+	mdb_printf("%-?p ", addr);
+	mdb_printf("%-10d ", sf->sv_refcnt);
+	mdb_printf("%-?p ", sf->sv_vfsp);
+	mdb_printf("%-?p ", sf->sv_rootvp);
+	mdb_printf("%-s\n", args->path);
+
+	return (WALK_NEXT);
+}
+
 /*
  * ::smbvfs
  *
  * smbvfs dcmd - Prints out smb_vfs structures.
+ *	requires addr of an smb_server_t
  */
 /*ARGSUSED*/
 static int
-smb_dcmd_vfs(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
+smbvfs_dcmd(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
 {
-	int		verbose = FALSE;
-	smb_vfs_t	*sf;
-	vnode_t		*vn;
-	char		*path;
+	struct smb_vfs_cb_args *args;
 
+	args = mdb_zalloc(sizeof (*args), UM_SLEEP | UM_GC);
 	if (mdb_getopts(argc, argv,
-	    'v', MDB_OPT_SETBITS, TRUE, &verbose,
+	    'v', MDB_OPT_SETBITS, SMB_OPT_VERBOSE, &args->opts,
 	    NULL) != argc)
 		return (DCMD_USAGE);
 
-	/*
-	 * If no smb_vfs address was specified on the command line, we can
-	 * print out all smb_vfs by invoking the smb_vfs walker, using
-	 * this dcmd itself as the callback.
-	 */
-	if (!(flags & DCMD_ADDRSPEC)) {
-		if (mdb_walk_dcmd("smbvfs_walker", "smbvfs",
-		    argc, argv) == -1) {
-			mdb_warn("failed to walk 'smb_vfs'");
-			return (DCMD_ERR);
-		}
-		return (DCMD_OK);
-	}
+	if (!(flags & DCMD_ADDRSPEC))
+		return (DCMD_USAGE);
 
 	if (DCMD_HDRSPEC(flags)) {
-		mdb_printf(
-		    "%<b>%<u>"
-		    "%-?s "
-		    "%-10s "
-		    "%-16s "
-		    "%-16s"
-		    "%-s"
-		    "%</u>%</b>\n",
-		    "SMB_VFS", "REFCNT", "VFS", "VNODE", "ROOT");
+		if ((args->opts & SMB_OPT_VERBOSE) != 0) {
+			mdb_printf("%<b>%<u>SMB VFS list:%</u>%</b>\n");
+		} else {
+			mdb_printf(
+			    "%<b>%<u>"
+			    "%-?s "
+			    "%-10s "
+			    "%-16s "
+			    "%-16s"
+			    "%-s"
+			    "%</u>%</b>\n",
+			    "SMB_VFS", "REFCNT", "VFS", "VNODE", "ROOT");
+		}
 	}
 
-	sf = mdb_alloc(sizeof (*sf), UM_SLEEP | UM_GC);
-	if (mdb_vread(sf, sizeof (*sf), addr) == -1) {
-		mdb_warn("failed to read smb_vfs at %p", addr);
+	if (mdb_pwalk("smbvfs_walker", smb_vfs_cb, args, addr) == -1) {
+		mdb_warn("cannot walk smb_vfs list");
 		return (DCMD_ERR);
 	}
 
-	vn = mdb_alloc(sizeof (*vn), UM_SLEEP | UM_GC);
-	if (mdb_vread(vn, sizeof (*vn),
-	    (uintptr_t)sf->sv_rootvp) == -1) {
-		mdb_warn("failed to read vnode at %p", sf->sv_rootvp);
-		return (DCMD_ERR);
-	}
-
-	path = mdb_zalloc(MAXPATHLEN, UM_SLEEP | UM_GC);
-	(void) mdb_vread(path, MAXPATHLEN, (uintptr_t)vn->v_path);
-
-	mdb_printf(
-	    "%-?p %-10d %-?p %-?p %-s\n", addr, sf->sv_refcnt,
-	    sf->sv_vfsp, sf->sv_rootvp, path);
-
 	return (DCMD_OK);
 }
 
@@ -1539,7 +1457,7 @@
 	    OFFSETOF(smb_server_t, sv_export.e_vfs_list.ll_list);
 
 	if (mdb_layered_walk("list", wsp) == -1) {
-		mdb_warn("failed to walk list of VFS");
+		mdb_warn("failed to walk list of smb_vfs_t");
 		return (WALK_ERR);
 	}
 
@@ -1560,7 +1478,7 @@
  */
 
 static void
-smb_node_help(void)
+smbnode_help(void)
 {
 	mdb_printf(
 	    "Display the contents of smb_node_t, with optional filtering.\n\n");
@@ -1580,7 +1498,7 @@
  * smb_node dcmd - Print out smb_node structure.
  */
 static int
-smb_dcmd_node(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
+smbnode_dcmd(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
 {
 	smb_node_t	node;
 	int		rc;
@@ -1819,7 +1737,7 @@
  */
 
 static int
-smb_lock(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
+smblock_dcmd(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
 {
 	smb_lock_t	lock;
 	int		verbose = FALSE;
@@ -1916,7 +1834,8 @@
  */
 /*ARGSUSED*/
 static int
-smb_oplock_grant(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
+smboplockgrant_dcmd(uintptr_t addr, uint_t flags, int argc,
+    const mdb_arg_t *argv)
 {
 	smb_oplock_grant_t	grant;
 	char			 *level;
@@ -1961,7 +1880,7 @@
  */
 /*ARGSUSED*/
 static int
-smb_oplock(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
+smboplock_dcmd(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
 {
 	smb_oplock_t	oplock;
 	uintptr_t	list_addr;
@@ -2009,7 +1928,7 @@
  */
 /*ARGSUSED*/
 static int
-smb_stats(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
+smbstat_dcmd(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
 {
 	smb_server_t	*sv;
 
@@ -2098,7 +2017,7 @@
  * ::smbace
  */
 static int
-smb_ace(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
+smbace_dcmd(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
 {
 	smb_ace_t	ace;
 	int		verbose = FALSE;
@@ -2180,7 +2099,7 @@
  * ::smbacl
  */
 static int
-smb_acl(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
+smbacl_dcmd(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
 {
 	smb_acl_t	acl;
 
@@ -2217,7 +2136,7 @@
  * ::smbsd
  */
 static int
-smb_sd(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
+smbsd_dcmd(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
 {
 	smb_sd_t	sd;
 	int		rc;
@@ -2305,7 +2224,7 @@
  */
 /*ARGSUSED*/
 static int
-smb_sid(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
+smbsid_dcmd(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
 {
 	/*
 	 * An smb_sid address is required.
@@ -2367,7 +2286,7 @@
  * ::smbfssd
  */
 static int
-smb_fssd(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
+smbfssd_dcmd(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
 {
 	smb_fssd_t	fssd;
 	int		rc;
@@ -2546,3 +2465,128 @@
 	mdb_printf("\n");
 	return (DCMD_OK);
 }
+
+/*
+ * MDB module linkage information:
+ *
+ * We declare a list of structures describing our dcmds, a list of structures
+ * describing our walkers and a function named _mdb_init to return a pointer
+ * to our module information.
+ */
+static const mdb_dcmd_t dcmds[] = {
+	{   "smblist",
+	    "[-seutfdwv]",
+	    "print tree of SMB objects",
+	    smblist_dcmd,
+	    smblist_help },
+	{   "smbsrv",
+	    "[-seutfdwv]",
+	    "print smb_server information",
+	    smbsrv_dcmd },
+	{   "smbshare",
+	    ":[-v]",
+	    "print smb_kshare_t information",
+	    smbshare_dcmd },
+	{   "smbvfs",
+	    ":[-v]",
+	    "print smb_vfs information",
+	    smbvfs_dcmd },
+	{   "smbnode",
+	    "?[-vps]",
+	    "print smb_node_t information",
+	    smbnode_dcmd,
+	    smbnode_help },
+	{   "smbsess",
+	    "[-utfdwv]",
+	    "print smb_session_t information",
+	    smbsess_dcmd,
+	    smbsess_help},
+	{   "smbreq",
+	    ":[-v]",
+	    "print smb_request_t information",
+	    smbreq_dcmd },
+	{   "smblock", ":[-v]",
+	    "print smb_lock_t information",
+	    smblock_dcmd },
+	{   "smbuser",
+	    ":[-vdftq]",
+	    "print smb_user_t information",
+	    smbuser_dcmd,
+	    smbuser_help },
+	{   "smbtree",
+	    ":[-vdf]",
+	    "print smb_tree_t information",
+	    smbtree_dcmd,
+	    smbtree_help },
+	{   "smbodir",
+	    ":[-v]",
+	    "print smb_odir_t information",
+	    smbodir_dcmd },
+	{   "smbofile",
+	    "[-v]",
+	    "print smb_file_t information",
+	    smbofile_dcmd },
+	{   "smboplock", NULL,
+	    "print smb_oplock_t information",
+	    smboplock_dcmd },
+	{   "smboplockgrant", NULL,
+	    "print smb_oplock_grant_t information",
+	    smboplockgrant_dcmd },
+	{   "smbstat", NULL,
+	    "print all smb dispatched requests statistics",
+	    smbstat_dcmd },
+	{   "smbace", "[-v]",
+	    "print smb_ace_t information",
+	    smbace_dcmd },
+	{   "smbacl", "[-v]",
+	    "print smb_acl_t information",
+	    smbacl_dcmd },
+	{   "smbsid", "[-v]",
+	    "print smb_sid_t information",
+	    smbsid_dcmd },
+	{   "smbsd", "[-v]",
+	    "print smb_sd_t information",
+	    smbsd_dcmd },
+	{   "smbfssd", "[-v]",
+	    "print smb_fssd_t information",
+	    smbfssd_dcmd },
+	{ NULL }
+};
+
+static const mdb_walker_t walkers[] = {
+	{   "smbnode_walker",
+	    "walk list of smb_node_t structures",
+	    smb_node_walk_init,
+	    smb_node_walk_step,
+	    NULL,
+	    NULL },
+	{   "smbshare_walker",
+	    "walk list of smb_kshare_t structures",
+	    smb_kshare_walk_init,
+	    smb_kshare_walk_step,
+	    NULL,
+	    NULL },
+	{   "smbvfs_walker",
+	    "walk list of smb_vfs_t structures",
+	    smb_vfs_walk_init,
+	    smb_vfs_walk_step,
+	    NULL,
+	    NULL },
+	{   "smbace_walker",
+	    "walk list of smb_ace_t structures",
+	    smb_ace_walk_init,
+	    smb_ace_walk_step,
+	    NULL,
+	    NULL },
+	{ NULL }
+};
+
+static const mdb_modinfo_t modinfo = {
+	MDB_API_VERSION, dcmds, walkers
+};
+
+const mdb_modinfo_t *
+_mdb_init(void)
+{
+	return (&modinfo);
+}