6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 */
25
26 #pragma ident "%Z%%M% %I% %E% SMI"
27
28 #include <meta.h>
29 #include <assert.h>
30 #include <ctype.h>
31 #include <mdiox.h>
32 #include <meta.h>
33 #include <stdio.h>
34 #include <stdlib.h>
35 #include <strings.h>
36 #include <sys/lvm/md_mddb.h>
37 #include <sys/lvm/md_names.h>
38 #include <sys/lvm/md_crc.h>
39 #include <sys/lvm/md_convert.h>
40
41
42 /*
43 * Design Notes:
44 *
45 * All of the code in this file supports the addition of metastat -c output
46 * for the verbose option of metaimport. Some of this code is also used by
47 * the command metastat for concise output(cmd/lvm/util/metastat.c).
48 * The code is designed to produce the same output as metastat -c does for a
49 * given diskset--with a couple exceptions.
50 * The primary differences between the output for the metastat -c command and
51 * metastat output for metaimport -v are:
52 * - the set name is not printed next to each metadevice
53 * - top-level state information is not printed for some metadevices
54 * - the percent that a disk has completed resyncing is not listed
144 /* pointer to the unit structure for the metadevice, e.g. rb_data[0] */
145 void *record;
146 } md_im_rec_t;
147
148 /*
149 * md_im_list is used to group toplevel metadevices by type and to group
150 * the underlying devices for a particular metadevice.
151 */
152 typedef struct md_im_list {
153 struct md_im_list *next;
154 struct md_im_rec *mdrec;
155 } md_im_list_t;
156
157
158 /*
159 * MAXSIZEMDRECNAME is the value that has historically been used to allocate
160 * space for the metadevice name
161 */
162 #define MAXSIZEMDRECNAME 20
163 #define NAMEWIDTH 16
164 #define offsetof(s, m) ((size_t)(&(((s *)0)->m)))
165 #define NOT_PHYSICAL_DEV 0
166 #define PHYSICAL_DEV 1
167
168
169 /*
170 * strip_blacks()
171 *
172 * Strip blanks from string. Used for size field in concise output.
173 */
174 static char *
175 strip_blanks(char *s)
176 {
177 char *p;
178
179 for (p = s; *p; ) {
180 if (*p == ' ') {
181 char *t;
182 for (t = p; *t; t++) {
183 *t = *(t + 1);
184 }
|
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 */
25
26 #include <meta.h>
27 #include <assert.h>
28 #include <ctype.h>
29 #include <mdiox.h>
30 #include <meta.h>
31 #include <stdio.h>
32 #include <stdlib.h>
33 #include <stddef.h>
34 #include <strings.h>
35 #include <sys/lvm/md_mddb.h>
36 #include <sys/lvm/md_names.h>
37 #include <sys/lvm/md_crc.h>
38 #include <sys/lvm/md_convert.h>
39
40
41 /*
42 * Design Notes:
43 *
44 * All of the code in this file supports the addition of metastat -c output
45 * for the verbose option of metaimport. Some of this code is also used by
46 * the command metastat for concise output(cmd/lvm/util/metastat.c).
47 * The code is designed to produce the same output as metastat -c does for a
48 * given diskset--with a couple exceptions.
49 * The primary differences between the output for the metastat -c command and
50 * metastat output for metaimport -v are:
51 * - the set name is not printed next to each metadevice
52 * - top-level state information is not printed for some metadevices
53 * - the percent that a disk has completed resyncing is not listed
143 /* pointer to the unit structure for the metadevice, e.g. rb_data[0] */
144 void *record;
145 } md_im_rec_t;
146
147 /*
148 * md_im_list is used to group toplevel metadevices by type and to group
149 * the underlying devices for a particular metadevice.
150 */
151 typedef struct md_im_list {
152 struct md_im_list *next;
153 struct md_im_rec *mdrec;
154 } md_im_list_t;
155
156
157 /*
158 * MAXSIZEMDRECNAME is the value that has historically been used to allocate
159 * space for the metadevice name
160 */
161 #define MAXSIZEMDRECNAME 20
162 #define NAMEWIDTH 16
163 #define NOT_PHYSICAL_DEV 0
164 #define PHYSICAL_DEV 1
165
166
167 /*
168 * strip_blacks()
169 *
170 * Strip blanks from string. Used for size field in concise output.
171 */
172 static char *
173 strip_blanks(char *s)
174 {
175 char *p;
176
177 for (p = s; *p; ) {
178 if (*p == ' ') {
179 char *t;
180 for (t = p; *t; t++) {
181 *t = *(t + 1);
182 }
|