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
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.
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]
23 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #pragma ident "%Z%%M% %I% %E% SMI"
29 #include "mdinclude.h"
31 /* array of the sets */
32 md_set_t mdset
[MD_MAXSETS
];
33 mddb_set_t set_dbs
[MD_MAXSETS
];
34 /* for the addresses of each set above */
35 uintptr_t mdset_addrs
[MD_MAXSETS
];
43 * routines to snarf the metaset information
45 * usage: ::dumpsetaddr [-s setname]
49 dumpsetaddr(uintptr_t addr
, uint_t flags
, int argc
, const mdb_arg_t
*argv
)
53 char *s_opt
= (char *)NULL
;
55 if (mdb_getopts(argc
, argv
, 's', MDB_OPT_STR
, &s_opt
,
57 /* left over arguments ?? */
62 mdb_warn("No sets read in yet - try ::metaset\n");
65 if (argc
== 0) { /* dump all sets */
66 for (i
= 0; i
< md_nsets
; i
++) {
67 if (mdset_addrs
[i
] != (uintptr_t)0)
68 mdb_printf("%d %p\n", i
, mdset_addrs
[i
]);
71 setno
= findset(s_opt
);
73 mdb_warn("no such set: %s\n", s_opt
);
76 if (mdset_addrs
[setno
] != (uintptr_t)0)
77 mdb_printf("%d %p\n", setno
,
85 * Function: snarf_ui_anchor
86 * Purpose: to read in the s_ui part of a metaset.
87 * Returns: <n> - number of configured metadevices
91 snarf_ui_anchor(int i
)
95 void **ptr
= mdset
[i
].s_ui
;
98 for (j
= 0; j
< md_nunits
; j
++) {
99 if (mdb_vread(&addr
, sizeof (void *), (uintptr_t)ptr
) == -1) {
112 * Function: snarf_sets
113 * Purpose: Entry point into the module that reads the kernel's version
114 * of the SVM configuration.
115 * First of all populates the mdset array and then for each
116 * component that makes up an "md_set_t" reads it in, via calls
117 * to other functions.
131 /* find the SVM hook - md_set */
132 if (mdb_lookup_by_name("md_set", &setsym
) == -1) {
133 mdb_warn("SVM is not configured on this machine\n");
136 /* find out how many metadevices are configured per set */
137 if (mdb_lookup_by_name("md_nunits", &nmdsym
) == -1) {
138 mdb_warn("unable to find md_nunits\n");
141 if (mdb_vread(&md_nunits
, sizeof (unit_t
), nmdsym
.st_value
) == -1) {
142 mdb_warn("failed to read md_nunits at %p\n", nmdsym
.st_value
);
146 if (mdb_lookup_by_name("md_nsets", &mdsetsym
) == -1) {
147 mdb_warn("unable to find md_nsets\n");
150 if (mdb_vread(&md_nsets
, sizeof (set_t
), mdsetsym
.st_value
) == -1) {
151 mdb_warn("failed to read md_nsets at %p\n", mdsetsym
.st_value
);
156 mdb_printf("mdset array addr: 0x%lx size is: 0x%lx\n",
157 (uintptr_t)setsym
.st_value
, sizeof (md_set_t
));
160 offset
= setsym
.st_value
;
162 for (i
= 0; i
< md_nsets
; i
++) {
163 if (mdb_vread(&mdset
[i
], sizeof (md_set_t
), offset
) == -1) {
164 mdb_warn("failed to read md_set_t at 0x%lx\n",
165 (uintptr_t)(setsym
.st_value
+ offset
));
167 /* Should check the status flags */
168 if (mdset
[i
].s_status
& MD_SET_NM_LOADED
) {
170 mdb_printf("Set %d (0x%lx) has a name space\n",
171 i
, (uintptr_t)(setsym
.st_value
+ offset
));
173 offset
+= sizeof (md_set_t
);
177 if (mdb_vread(&set_dbs
[i
], sizeof (mddb_set_t
),
178 (uintptr_t)mdset
[i
].s_db
) == -1) {
179 if (mdset
[i
].s_db
!= 0) {
180 mdb_warn("failed to read mddb_set_t at 0x%p\n",
184 mdb_warn("%d - no set configured\n", i
);
190 mdset_addrs
[i
] = (uintptr_t)(offset
);
192 (void) snarf_ui_anchor(i
);
194 /* have the set now read in the various bits and pieces */
195 offset
+= sizeof (md_set_t
);
200 mdb_printf("Number of active sets: %d\n", active_sets
);
201 mdb_printf("Max number of metadevices: %u\n", md_nunits
);
202 mdb_printf("Max number of sets: %u\n", md_nsets
);