xref: /titanic_41/usr/src/head/devmgmt.h (revision c10c16dec587a0662068f6e2991c29ed3a9db943)
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 /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
23 /*	  All Rights Reserved  	*/
24 
25 
26 #ifndef	_DEVMGMT_H
27 #define	_DEVMGMT_H
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"	/* SVr4.0 1.12	*/
30 
31 #ifdef	__cplusplus
32 extern "C" {
33 #endif
34 
35 /*
36  * devmgmt.h
37  *
38  * Contents:
39  *    -	Device Management definitions,
40  *    -	getvol() definitions
41  */
42 
43 /*
44  * Device management definitions
45  *	- Default pathnames (relative to installation point)
46  *	- Environment variable namess
47  *	- Standard field names in the device table
48  *	- Flags
49  *	- Miscellaneous definitions
50  */
51 
52 
53 /*
54  * Default pathnames (relative to the package installation
55  * point) to the files used by Device Management:
56  *
57  *	DTAB_PATH	Device table
58  *	DGRP_PATH	Device group table
59  *	DVLK_PATH	Device reservation table
60  */
61 
62 #define	DTAB_PATH			"/etc/device.tab"
63 #define	DGRP_PATH			"/etc/dgroup.tab"
64 #define	DVLK_PATH			"/etc/devlkfile"
65 
66 
67 /*
68  * Names of environment variables
69  *
70  *	OAM_DEVTAB	Name of variable that defines the pathname to
71  *			the device-table file
72  *	OAM_DGROUP	Name of variable that defines the pathname to
73  *			the device-group table file
74  *	OAM_DEVLKTAB	Name of variable that defines the pathname to
75  *			the device-reservation table file
76  */
77 
78 #define	OAM_DEVTAB			"OAM_DEVTAB"
79 #define	OAM_DGROUP			"OAM_DGROUP"
80 #define	OAM_DEVLKTAB			"OAM_DEVLKTAB"
81 
82 
83 /*
84  * Standard field names in the device table
85  */
86 
87 #define	DTAB_ALIAS			"alias"
88 #define	DTAB_CDEVICE			"cdevice"
89 #define	DTAB_BDEVICE			"bdevice"
90 #define	DTAB_PATHNAME			"pathname"
91 
92 
93 /*
94  * Flags:
95  *	For getdev() and getdgrp():
96  *		DTAB_ANDCRITERIA	Devices must meet all criteria
97  *					instead of any of the criteria
98  *		DTAB_EXCLUDEFLAG	The list of devices or device groups
99  *					is the list that is to be excluded,
100  *					not those to select from.
101  *		DTAB_LISTALL		List all device groups, even those that
102  *					have no valid members (getdgrp() only).
103  */
104 
105 #define	DTAB_ANDCRITERIA		0x01
106 #define	DTAB_EXCLUDEFLAG		0x02
107 #define	DTAB_LISTALL			0x04
108 
109 
110 /*
111  * Miscellaneous Definitions
112  *
113  *	DTAB_MXALIASLN	Maximum alias length
114  */
115 
116 #define	DTAB_MXALIASLN			14
117 
118 /*
119  * Device Management Structure definitions
120  *	reservdev	Reserved device description
121  */
122 
123 /*
124  * struct reservdev
125  *
126  *	Structure describes a reserved device.
127  *
128  *  Elements:
129  *	char   *devname		Alias of the reserved device
130  *	pid_t	key		Key used to reserve the device
131  */
132 
133 struct reservdev {
134 	char   *devname;
135 	pid_t	key;
136 };
137 
138 /*
139  * Device Management Functions:
140  *
141  *	devattr()	Returns a device's attribute
142  *	devreserv()	Reserves a device
143  *	devfree()	Frees a reserved device
144  *	reservdev()	Return list of reserved devices
145  *	getdev()	Get devices that match criteria
146  *	getdgrp()	Get device-groups containing devices
147  *			that match criteria
148  *	listdev()	List attributes defined for a device
149  *	listdgrp()	List members of a device-group
150  */
151 
152 	char			*devattr(char *, char *);
153 	int			devfree(int, char *);
154 	char			**devreserv(int, char ***);
155 	char			**getdev(char **, char **, int);
156 	char			**getdgrp(char **, char **, int);
157 	char			**listdev(char *);
158 	char			**listdgrp(char *);
159 	struct reservdev	**reservdev(void);
160 
161 /*
162  * getvol() definitions
163  */
164 
165 #define	DM_BATCH	0x0001
166 #define	DM_ELABEL	0x0002
167 #define	DM_FORMAT	0x0004
168 #define	DM_FORMFS	0x0008
169 #define	DM_WLABEL	0x0010
170 #define	DM_OLABEL	0x0020
171 
172 	int			getvol(char *, char *, int, char *);
173 
174 #ifdef	__cplusplus
175 }
176 #endif
177 
178 #endif	/* _DEVMGMT_H */
179