7712 mandoc -Tlint does always exit with error code 0
[unleashed.git] / usr / src / cmd / mdb / common / modules / md / walk_hsp.c
blob10dfa129a511191cad60e394d54f2d89551024e1
1 /*
2 * CDDL HEADER START
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.
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]
20 * CDDL HEADER END
23 * Copyright 2003 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"
32 * walk the hotspare pools
34 /* ARGSUSED */
35 int
36 hotsparepool_walk_init(mdb_walk_state_t *wsp)
38 uintptr_t addr;
40 snarf_sets();
41 addr = (uintptr_t)mdset[0].s_hsp;
42 wsp->walk_data = mdb_alloc(sizeof (int), UM_SLEEP);
43 /* walk_data hold the number of the set we're walking */
44 *((int *)wsp->walk_data) = 0;
45 mdb_printf("Hotspare Pools for set number 0\n");
46 wsp->walk_addr = addr;
47 return (WALK_NEXT);
50 int
51 hotsparepool_walk_step(mdb_walk_state_t *wsp)
53 int status;
54 hot_spare_pool_t hsp;
56 if (wsp->walk_addr == NULL) {
57 *((int *)wsp->walk_data) += 1;
58 if (*((int *)wsp->walk_data) < md_nsets) {
59 wsp->walk_addr =
60 (uintptr_t)mdset[*((int *)wsp->walk_data)].s_hsp;
61 if (wsp->walk_addr == NULL)
62 return (WALK_NEXT);
63 mdb_printf("Hotspare Pools for set number %d\n",
64 *((int *)wsp->walk_data));
65 } else {
66 return (WALK_DONE);
70 if (mdb_vread(&hsp, sizeof (hot_spare_pool_t), wsp->walk_addr) !=
71 sizeof (hot_spare_pool_t)) {
72 mdb_warn("failed to read hot_spare_pool_t at %p",
73 wsp->walk_addr);
74 return (WALK_DONE);
79 status = wsp->walk_callback(wsp->walk_addr, (&hsp)->hsp_next,
80 wsp->walk_cbdata);
82 wsp->walk_addr = (uintptr_t)(&hsp)->hsp_next;
84 return (status);
87 void
88 hotsparepool_walk_fini(mdb_walk_state_t *wsp)
90 mdb_free(wsp->walk_data, sizeof (int));