smbfs.c revision 4bff34e37def8a90f9194d81bc345c52ba20086a
/*
* 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 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <sys/mdb_modapi.h>
#include <sys/refstr_impl.h>
#include "smbfs.h"
#include "smbfs_node.h"
/*
* This macro lets us easily use both sizeof (typename)
* and the string-ified typename for the error message.
*/
!= sizeof (obj_type)) { \
return (err); \
}
/*
* We need to read in a private copy
* of every string we want to print out.
*/
void
{
char buf[64];
} else {
}
}
/*
* Dcmd (and callback function) to print a summary of
* all "smbfs" entries in the VFS list.
*/
typedef struct smbfs_vfs_cbdata {
int flags;
int printed_header;
int
{
/* Filter by matching smbfs ops vector. */
return (WALK_NEXT);
}
if (cbd->printed_header == 0) {
mdb_printf("// vfs_t smbmntinfo_t mnt_path\n");
}
/*
* Note: vfs_mntpt is a refstr_t.
* Advance to string member.
*/
mdb_printf("\n");
mdb_inc_indent(2);
/* Don't fail the walk if this fails. */
mdb_warn("error reading smbmntinfo_t at %p",
} else {
/* Interesting parts of smbmntinfo_t */
mdb_printf("smi_share: %p, smi_root: %p\n",
}
mdb_dec_indent(2);
}
return (WALK_NEXT);
}
int
{
/*
* Get the ops address here, so things work
* even if the smbfs module is loaded later
* than this mdb module.
*/
mdb_warn("failed to find 'smbfs_vfsops'\n");
return (DCMD_ERR);
}
return (DCMD_USAGE);
}
if (!(flags & DCMD_ADDRSPEC)) {
== -1) {
mdb_warn("can't walk smbfs vfs");
return (DCMD_ERR);
}
return (DCMD_OK);
}
return (DCMD_OK);
}
void
smbfs_vfs_help(void)
{
"Display addresses of the mounted smbfs structures\n"
"and the pathname of the mountpoint\n"
"\nOptions:\n"
" -v display details of the smbmntinfo\n");
}
/*
* Walker for the smbnode hash table.
*/
typedef struct smbnode_walk_data {
int tabsize; /* size of table */
int nextidx; /* next bucket index */
int
{
int tabsize;
mdb_warn("smbnode only supports global walks\n");
return (WALK_ERR);
}
mdb_warn("failed to read `smbtablesize'\n");
return (WALK_ERR);
}
if (tabsize == 0) {
return (WALK_DONE);
}
mdb_warn("failed to read `smbtable'\n");
return (WALK_ERR);
}
return (WALK_ERR);
}
return (WALK_NEXT);
}
int
{
int status;
/* Skip an empty bucket */
}
return (WALK_DONE);
mdb_warn("failed to read smbnode at %p in bucket %p\n",
/* Proceed with next bucket. */
goto next_bucket;
}
/* Move to next node in this bucket */
return (status);
}
/*ARGSUSED*/
void
{
/* UM_GC takes care of it all. */
}
/*
* Dcmd (and callback function) to print a summary of
* all smbnodes in the node hash table.
*/
typedef struct smbnode_cbdata {
int flags;
int printed_header;
/* TODO: only nodes with a given [-h]ash */
int
{
/* Optional filtering by mount point. */
return (WALK_NEXT);
}
if (cbd->printed_header == 0) {
mdb_printf("// smbnode vnode rpath\n");
}
mdb_printf("\n");
mdb_inc_indent(2);
/* Don't fail the walk if this fails. */
mdb_warn("error reading vnode_t at %p",
} else {
/* Interesting parts of vnode_t */
mdb_printf("v_type: %d v_path:",
mdb_printf("\n");
}
mdb_dec_indent(2);
}
return (WALK_NEXT);
}
int
{
return (DCMD_USAGE);
}
if (!(flags & DCMD_ADDRSPEC)) {
== -1) {
mdb_warn("cannot walk smbnodes");
return (DCMD_ERR);
}
return (DCMD_OK);
}
return (DCMD_OK);
}
void
smbnode_help(void)
{
mdb_printf("Options:\n"
" -m mntinfo only show smbnodes belonging to mntinfo\n"
" -v be verbose when displaying smbnodes\n");
}
static const mdb_dcmd_t dcmds[] = {
{ "smbfs_vfs", "?[-v]",
"show smbfs-mounted vfs structs",
{ "smbnode", "?[-v] [-m mntinfo]",
{NULL}
};
static const mdb_walker_t walkers[] = {
{ "smbnode", "walk smbnode hash table",
{NULL}
};
static const mdb_modinfo_t modinfo = {
};
const mdb_modinfo_t *
_mdb_init(void)
{
return (&modinfo);
}