xref: /titanic_44/usr/src/cmd/stat/common/dsr.h (revision 6dfee4834394825da35b977ca71cdc965bc7b6a4)
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 2004 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_STAT_DSR_H
28 #define	_STAT_DSR_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
36 /*
37  * Description of each device identified
38  */
39 typedef struct list_of_disks {
40 	char	*dtype;		/* device type: sd, ssd, md, st, etc. */
41 	int	dnum;		/* device number */
42 	char	*dsk;		/* in form of cNtNdN */
43 	char	*dname;		/* in form of /dev/dsk/cNtNdN */
44 	char	*devidstr;	/* in form of "id1,sd@XXXX" */
45 	uint_t	flags;		/* see SLICES_OK and PARTITIONS_OK above */
46 	int	devtype;	/* disk, metadevice, tape */
47 	uint_t	seen;		/* Used for diffing disk lists */
48 	struct list_of_disks *next;	/* link to next one */
49 } disk_list_t;
50 
51 /*
52  * Description of each mount point currently existing on the system.
53  */
54 typedef struct mnt_info {
55 	char *device_name;
56 	char *mount_point;
57 	char *devinfo;
58 	uint_t minor;
59 	struct mnt_info *next;
60 } mnt_t;
61 
62 /*
63  * A basic description of each device found
64  * on the system by walking the device tree.
65  * These entries are used to select the
66  * relevent entries from the actual /dev
67  * entries.
68  */
69 typedef struct ldinfo {
70 	char *name;
71 	char *dtype;
72 	char *devidstr;
73 	int dnum;
74 	struct ldinfo *next;
75 } ldinfo_t;
76 
77 /*
78  * Optimization for lookup of kstats.
79  * For each kstat prefix (e.g., 'sd')
80  * found in a directory one of these
81  * structures will be created.
82  *
83  * name: prefix of kstat name (e.g., 'ssd')
84  * min:  smallest number seen from kstat
85  *       name (e.g., 101 from 'sd101')
86  * max:  largest number seen from kstat
87  * list_start: beginning of disk_list structures
88  * 	for this kstat type in the main list for
89  *	this directory
90  * list_end: end of entries for this kstat type
91  * 	in this directory.
92  */
93 typedef struct dev_name {
94 	char *name;
95 	uint_t min;
96 	uint_t max;
97 	disk_list_t *list_start;
98 	disk_list_t *list_end;
99 	struct dev_name *next;
100 } dev_name_t;
101 
102 /*
103  * Definition of a "type" of disk device.
104  * Tied to the directory containing entries
105  * for that device. Divides the list of
106  * devices into localized chunks and allows
107  * quick determination as to whether an entry
108  * exists or whether we need to look at the
109  * devices upon a state change.
110  */
111 typedef struct dir_info {
112 	char *name;		/* directory name */
113 	time_t mtime;		/* mod time */
114 	disk_list_t *list;	/* master list of devices */
115 	dev_name_t *nf;		/* lists per name */
116 	uint_t skip_lookup;	/* skip lookup if device */
117 				/* does not have partitions */
118 	char *dtype;		/* Type of device */
119 	char *trimstr;		/* What do we prune */
120 	char  trimchr;		/* Char denoting end */
121 				/* of interesting data */
122 } dir_info_t;
123 
124 /*
125  * The following are used to control treatment of kstat names
126  * which fall beyond the number of disk partitions allowed on
127  * the particular ISA. PARTITIONS_OK is set only on an Intel
128  * system.
129  */
130 #define	SLICES_OK	1
131 #define	PARTITIONS_OK	2
132 
133 void do_mnttab(void);
134 mnt_t *lookup_mntent_byname(char *);
135 disk_list_t *lookup_ks_name(char *);
136 char *lookup_nfs_name(char *, kstat_ctl_t *);
137 
138 #ifdef __cplusplus
139 }
140 #endif
141 
142 #endif	/* _STAT_DSR_H */
143