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