xref: /titanic_41/usr/src/cmd/mdb/common/modules/md/md.c (revision 45916cd2fec6e79bca5dee0421bd39e3c2910d1e)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2003 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #pragma ident	"%Z%%M%	%I%	%E% SMI"
28 
29 #include <sys/mdb_modapi.h>
30 
31 
32 int	md_verbose = 0;		/* be verbose about the addresses */
33 
34 extern int metaset(uintptr_t, uint_t, int, const mdb_arg_t *);
35 extern int metastat(uintptr_t, uint_t, int, const mdb_arg_t *);
36 extern int set_io(uintptr_t, uint_t, int, const mdb_arg_t *);
37 extern int dumpnamespace(uintptr_t, uint_t, int, const mdb_arg_t *);
38 extern int dumpsetaddr(uintptr_t, uint_t, int, const mdb_arg_t *);
39 extern int dumphotspare(uintptr_t, uint_t, int, const mdb_arg_t *);
40 extern void set_io_help();
41 
42 /* from mdbgen */
43 extern int mddb_db_walk_init(mdb_walk_state_t *);
44 extern int mddb_db_walk_step(mdb_walk_state_t *);
45 extern int mddb_de_ic_walk_init(mdb_walk_state_t *);
46 extern int mddb_de_ic_walk_step(mdb_walk_state_t *);
47 extern int hotsparepool_walk_init(mdb_walk_state_t *);
48 extern int hotsparepool_walk_step(mdb_walk_state_t *);
49 extern void hotsparepool_walk_fini(mdb_walk_state_t *);
50 extern int didnamespace_walk_init(mdb_walk_state_t *);
51 extern int didnamespace_walk_step(mdb_walk_state_t *);
52 extern void didnamespace_walk_fini(mdb_walk_state_t *);
53 extern int namespace_walk_init(mdb_walk_state_t *);
54 extern int namespace_walk_step(mdb_walk_state_t *);
55 extern void namespace_walk_fini(mdb_walk_state_t *);
56 extern int sets_walk_init(mdb_walk_state_t *);
57 extern int sets_walk_step(mdb_walk_state_t *);
58 extern void sets_walk_fini(mdb_walk_state_t *);
59 extern int units_walk_init(mdb_walk_state_t *);
60 extern int units_walk_step(mdb_walk_state_t *);
61 extern void units_walk_fini(mdb_walk_state_t *);
62 extern int simple_de_ic(uintptr_t, uint_t, int, const mdb_arg_t *);
63 int md_set_verbose(uintptr_t, uint_t, int, const mdb_arg_t *);
64 
65 
66 const mdb_dcmd_t dcmds[] = {
67 	{ "md_verbose", NULL, "toggle verbose mode for SVM dcmds",
68 	    md_set_verbose },
69 	{ "metaset", NULL, "list SVM metasets", metaset },
70 	{ "metastat", "[-v]", "list SVM metadevices",
71 	    metastat },
72 	{ "set_io", NULL, "show the pending IO counts", set_io,
73 	    set_io_help },
74 	{ "dumpnamespace", "[-s setname]", "dump the SVM name space",
75 	    dumpnamespace },
76 	{ "dumphotspare", NULL, "dump the hot spare pools",
77 	    dumphotspare },
78 	{ "dumpsetaddr", "[-s setname]", "dump the SVM set addresses",
79 	    dumpsetaddr },
80 	{ "simple_de_ic", NULL, "simple mddb_de_ic_t",
81 	    simple_de_ic },
82 	{ NULL }
83 };
84 
85 static const mdb_walker_t walkers[] = {
86 	{ "mddb_db", "walk list of mddb_db_t structures",
87 	    mddb_db_walk_init, mddb_db_walk_step, NULL, NULL },
88 	{ "mddb_de_ic", "walk list of mddb_de_t structures",
89 	    mddb_de_ic_walk_init, mddb_de_ic_walk_step, NULL, NULL },
90 	{ "hotsparepool", "walk list of hotspare pools",
91 	    hotsparepool_walk_init, hotsparepool_walk_step,
92 	    hotsparepool_walk_fini, NULL },
93 	{ "didnamespace", "walk the did namespace",
94 	    didnamespace_walk_init, didnamespace_walk_step,
95 	    didnamespace_walk_fini, NULL },
96 	{ "namespace", "walk the namespace",
97 	    namespace_walk_init, namespace_walk_step, namespace_walk_fini,
98 	    NULL },
99 	{ "md_sets", "walk list of sets",
100 	    sets_walk_init, sets_walk_step, sets_walk_fini, NULL },
101 	{ "md_units", "walk list of unit structures",
102 	    units_walk_init, units_walk_step, units_walk_fini, NULL },
103 	{ NULL }
104 };
105 
106 static const mdb_modinfo_t modinfo = {
107 	MDB_API_VERSION, dcmds, walkers
108 };
109 
110 const mdb_modinfo_t *
111 _mdb_init(void)
112 {
113 	return (&modinfo);
114 }
115 
116 
117 /* ARGSUSED */
118 int
119 md_set_verbose(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
120 {
121 	md_verbose = !md_verbose;
122 
123 	if ((flags & DCMD_ADDRSPEC) != 0 || argc != 0)
124 		return (DCMD_USAGE);
125 
126 	mdb_printf("Verbose mode is now %d\n", md_verbose);
127 	return (DCMD_OK);
128 }
129