/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2011 Nexenta Systems, Inc. All rights reserved.
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <sys/mdb_modapi.h>
#include <netsmb/smb_conn.h>
#include <netsmb/smb_pass.h>
/*
* We need to read in a private copy
* of every string we want to print out.
*/
void
{
} else {
}
}
/*
* Walker for smb_connobj_t structures, including
* smb_vc_t and smb_share_t which "inherit" from it.
* Tricky: Exploit the "inheritance" of smb_connobj_t
* with common functions for walk_init, walk_next.
*/
typedef struct smb_co_walk_data {
union co_u {
} u;
/*
* Common walk_init for walking structs inherited
* from smb_connobj_t (smb_vc_t, smb_share_t)
*/
int
{
return (WALK_ERR);
/*
* Save the parent pointer for later checks, and
* the level so we know which union member it is.
* Also the size of this union member.
*/
switch (level) {
case SMBL_SM:
break;
case SMBL_VC:
break;
case SMBL_SHARE:
break;
default:
break;
}
/*
* Read in the parent object. Just need the
* invariant part (smb_connobj_t) so we can
* get the list of children below it.
*/
return (WALK_ERR);
}
/*
* Finally, setup to walk the list of children.
*/
return (WALK_NEXT);
}
/*
* Walk the (global) VC list.
*/
int
{
mdb_warn("::walk smb_vc only supports global walks\n");
return (WALK_ERR);
}
/* Locate the VC list head. */
mdb_warn("failed to lookup `smb_vclist'\n");
return (WALK_ERR);
}
}
/*
* Walk the share list below some VC.
*/
int
{
/*
* Initial walk_addr is address of parent (VC)
*/
mdb_warn("::walk smb_ss does not support global walks\n");
return (WALK_ERR);
}
}
/*
* Common walk_step for walking structs inherited
* from smb_connobj_t (smb_vc_t, smb_share_t)
*/
int
{
int status;
return (WALK_DONE);
return (WALK_ERR);
}
/* XXX: Sanity check level? parent pointer? */
wsp->walk_cbdata);
return (status);
}
/*
* Dcmd (and callback function) to print a summary of
* all VCs, and optionally all shares under each VC.
*/
typedef struct smb_co_cbdata {
int printed_header;
/*
* Call-back function for walking a share list.
*/
int
{
mdb_inc_indent(2);
/* Anything wanted here? */
mdb_dec_indent(2);
}
return (WALK_NEXT);
}
static const char *
{
const char *cp;
/* Got this in smb_vc_dcmd. */
/* Get the name for the enum value. */
return ("?");
/* Skip the prefix part. */
cp += prefix_len;
return (cp);
}
/*
* Call-back function for walking the VC list.
*/
int
{
if (cbd->printed_header == 0) {
mdb_printf("// smb_vc_t uid server \tuser\t\tstate\n");
}
case AF_INET:
break;
case AF_INET6:
break;
default:
break;
}
else
mdb_inc_indent(2);
mdb_warn("failed to walk 'nsmb_ss'");
/* Don't: return (WALK_ERR); */
}
mdb_dec_indent(2);
}
return (WALK_NEXT);
}
int
{
return (DCMD_USAGE);
}
mdb_warn("Could not find enum smbiod_state");
}
if (!(flags & DCMD_ADDRSPEC)) {
mdb_warn("failed to walk 'nsmb_vc'");
return (DCMD_ERR);
}
return (DCMD_OK);
}
return (DCMD_ERR);
}
return (DCMD_OK);
}
void
smb_vc_help(void)
{
mdb_printf("Options:\n"
" -r recursive display of share lists\n"
" -v be verbose when displaying smb_vc\n");
}
/*
* Walker for the request list on a VC,
* and dcmd to show a summary.
*/
int
{
/*
* Initial walk_addr is the address of the VC.
* Add offsetof(iod_rqlist) to get the rqhead.
*/
mdb_warn("::walk smb_ss does not support global walks\n");
return (WALK_ERR);
}
return (WALK_ERR);
}
return (WALK_NEXT);
}
int
{
int status;
return (WALK_DONE);
return (WALK_ERR);
}
wsp->walk_cbdata);
return (status);
}
typedef struct rqlist_cbdata {
int printed_header;
int
{
if (cbd->printed_header == 0) {
mdb_printf("// smb_rq_t MID cmd sr_state sr_flags\n");
}
mdb_printf("\n");
return (WALK_NEXT);
}
/*ARGSUSED*/
int
{
/*
* Initial walk_addr is address of parent (VC)
*/
if (!(flags & DCMD_ADDRSPEC)) {
mdb_warn("address required\n");
return (DCMD_ERR);
}
mdb_warn("failed to walk 'nsmb_rqlist'");
return (DCMD_ERR);
}
return (DCMD_OK);
}
/*
* AVL walker for the passwords AVL tree,
* and dcmd to show a summary.
*/
static int
{
mdb_warn("pwtree walk only supports global walks\n");
return (WALK_ERR);
}
mdb_warn("failed to find symbol 'smb_ptd'");
return (WALK_ERR);
}
mdb_warn("failed to walk 'avl'\n");
return (WALK_ERR);
}
return (WALK_NEXT);
}
static int
{
return (WALK_ERR);
}
}
typedef struct pwtree_cbdata {
int printed_header;
int
{
/* Optional filtering by UID. */
return (WALK_NEXT);
}
if (cbd->printed_header == 0) {
mdb_printf("// smb_passid_t UID domain user\n");
}
mdb_printf("\n");
return (WALK_NEXT);
}
/*ARGSUSED*/
int
{
return (DCMD_USAGE);
}
if (uid_str) {
/*
* Want the the default radix to be 10 here.
* If the string has some kind of radix prefix,
* just use that as-is, otherwise prepend "0t".
* Cheating on the "not a digit" test, but
* mdb_strtoull will do a real syntax check.
*/
} else {
}
} else
if (flags & DCMD_ADDRSPEC) {
mdb_warn("address not allowed\n");
return (DCMD_ERR);
}
mdb_warn("failed to walk 'nsmb_pwtree'");
return (DCMD_ERR);
}
return (DCMD_OK);
}
void
pwtree_help(void)
{
mdb_printf("Options:\n"
" -u uid show only entries belonging to uid (decimal)\n");
}
{ "nsmb_vc", "?[-rv]",
"show smb_vc (or list)",
{ "nsmb_rqlist", ":",
"show smb_rq list on a VC",
rqlist_dcmd, NULL },
{ "nsmb_pwtree", "?[-u uid]",
"list smb_passid_t (password tree)",
{NULL}
};
{ "nsmb_vc", "walk nsmb VC list",
{ "nsmb_ss", "walk nsmb share list for some VC",
{ "nsmb_rqlist", "walk request list for some VC",
{ "nsmb_pwtree", "walk passord AVL tree",
{NULL}
};
};
const mdb_modinfo_t *
_mdb_init(void)
{
return (&modinfo);
}