xref: /onnv-gate/usr/src/head/devmgmt.h (revision 0:68f95e015346)
1*0Sstevel@tonic-gate /*
2*0Sstevel@tonic-gate  * CDDL HEADER START
3*0Sstevel@tonic-gate  *
4*0Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*0Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*0Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*0Sstevel@tonic-gate  * with the License.
8*0Sstevel@tonic-gate  *
9*0Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*0Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*0Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*0Sstevel@tonic-gate  * and limitations under the License.
13*0Sstevel@tonic-gate  *
14*0Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*0Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*0Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*0Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*0Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*0Sstevel@tonic-gate  *
20*0Sstevel@tonic-gate  * CDDL HEADER END
21*0Sstevel@tonic-gate  */
22*0Sstevel@tonic-gate /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
23*0Sstevel@tonic-gate /*	  All Rights Reserved  	*/
24*0Sstevel@tonic-gate 
25*0Sstevel@tonic-gate 
26*0Sstevel@tonic-gate #ifndef	_DEVMGMT_H
27*0Sstevel@tonic-gate #define	_DEVMGMT_H
28*0Sstevel@tonic-gate 
29*0Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"	/* SVr4.0 1.12	*/
30*0Sstevel@tonic-gate 
31*0Sstevel@tonic-gate #ifdef	__cplusplus
32*0Sstevel@tonic-gate extern "C" {
33*0Sstevel@tonic-gate #endif
34*0Sstevel@tonic-gate 
35*0Sstevel@tonic-gate /*
36*0Sstevel@tonic-gate  * devmgmt.h
37*0Sstevel@tonic-gate  *
38*0Sstevel@tonic-gate  * Contents:
39*0Sstevel@tonic-gate  *    -	Device Management definitions,
40*0Sstevel@tonic-gate  *    -	getvol() definitions
41*0Sstevel@tonic-gate  */
42*0Sstevel@tonic-gate 
43*0Sstevel@tonic-gate /*
44*0Sstevel@tonic-gate  * Device management definitions
45*0Sstevel@tonic-gate  *	- Default pathnames (relative to installation point)
46*0Sstevel@tonic-gate  *	- Environment variable namess
47*0Sstevel@tonic-gate  *	- Standard field names in the device table
48*0Sstevel@tonic-gate  *	- Flags
49*0Sstevel@tonic-gate  *	- Miscellaneous definitions
50*0Sstevel@tonic-gate  */
51*0Sstevel@tonic-gate 
52*0Sstevel@tonic-gate 
53*0Sstevel@tonic-gate /*
54*0Sstevel@tonic-gate  * Default pathnames (relative to the package installation
55*0Sstevel@tonic-gate  * point) to the files used by Device Management:
56*0Sstevel@tonic-gate  *
57*0Sstevel@tonic-gate  *	DTAB_PATH	Device table
58*0Sstevel@tonic-gate  *	DGRP_PATH	Device group table
59*0Sstevel@tonic-gate  *	DVLK_PATH	Device reservation table
60*0Sstevel@tonic-gate  */
61*0Sstevel@tonic-gate 
62*0Sstevel@tonic-gate #define	DTAB_PATH			"/etc/device.tab"
63*0Sstevel@tonic-gate #define	DGRP_PATH			"/etc/dgroup.tab"
64*0Sstevel@tonic-gate #define	DVLK_PATH			"/etc/devlkfile"
65*0Sstevel@tonic-gate 
66*0Sstevel@tonic-gate 
67*0Sstevel@tonic-gate /*
68*0Sstevel@tonic-gate  * Names of environment variables
69*0Sstevel@tonic-gate  *
70*0Sstevel@tonic-gate  *	OAM_DEVTAB	Name of variable that defines the pathname to
71*0Sstevel@tonic-gate  *			the device-table file
72*0Sstevel@tonic-gate  *	OAM_DGROUP	Name of variable that defines the pathname to
73*0Sstevel@tonic-gate  *			the device-group table file
74*0Sstevel@tonic-gate  *	OAM_DEVLKTAB	Name of variable that defines the pathname to
75*0Sstevel@tonic-gate  *			the device-reservation table file
76*0Sstevel@tonic-gate  */
77*0Sstevel@tonic-gate 
78*0Sstevel@tonic-gate #define	OAM_DEVTAB			"OAM_DEVTAB"
79*0Sstevel@tonic-gate #define	OAM_DGROUP			"OAM_DGROUP"
80*0Sstevel@tonic-gate #define	OAM_DEVLKTAB			"OAM_DEVLKTAB"
81*0Sstevel@tonic-gate 
82*0Sstevel@tonic-gate 
83*0Sstevel@tonic-gate /*
84*0Sstevel@tonic-gate  * Standard field names in the device table
85*0Sstevel@tonic-gate  */
86*0Sstevel@tonic-gate 
87*0Sstevel@tonic-gate #define	DTAB_ALIAS			"alias"
88*0Sstevel@tonic-gate #define	DTAB_CDEVICE			"cdevice"
89*0Sstevel@tonic-gate #define	DTAB_BDEVICE			"bdevice"
90*0Sstevel@tonic-gate #define	DTAB_PATHNAME			"pathname"
91*0Sstevel@tonic-gate 
92*0Sstevel@tonic-gate 
93*0Sstevel@tonic-gate /*
94*0Sstevel@tonic-gate  * Flags:
95*0Sstevel@tonic-gate  *	For getdev() and getdgrp():
96*0Sstevel@tonic-gate  *		DTAB_ANDCRITERIA	Devices must meet all criteria
97*0Sstevel@tonic-gate  *					instead of any of the criteria
98*0Sstevel@tonic-gate  *		DTAB_EXCLUDEFLAG	The list of devices or device groups
99*0Sstevel@tonic-gate  *					is the list that is to be excluded,
100*0Sstevel@tonic-gate  *					not those to select from.
101*0Sstevel@tonic-gate  *		DTAB_LISTALL		List all device groups, even those that
102*0Sstevel@tonic-gate  *					have no valid members (getdgrp() only).
103*0Sstevel@tonic-gate  */
104*0Sstevel@tonic-gate 
105*0Sstevel@tonic-gate #define	DTAB_ANDCRITERIA		0x01
106*0Sstevel@tonic-gate #define	DTAB_EXCLUDEFLAG		0x02
107*0Sstevel@tonic-gate #define	DTAB_LISTALL			0x04
108*0Sstevel@tonic-gate 
109*0Sstevel@tonic-gate 
110*0Sstevel@tonic-gate /*
111*0Sstevel@tonic-gate  * Miscellaneous Definitions
112*0Sstevel@tonic-gate  *
113*0Sstevel@tonic-gate  *	DTAB_MXALIASLN	Maximum alias length
114*0Sstevel@tonic-gate  */
115*0Sstevel@tonic-gate 
116*0Sstevel@tonic-gate #define	DTAB_MXALIASLN			14
117*0Sstevel@tonic-gate 
118*0Sstevel@tonic-gate /*
119*0Sstevel@tonic-gate  * Device Management Structure definitions
120*0Sstevel@tonic-gate  *	reservdev	Reserved device description
121*0Sstevel@tonic-gate  */
122*0Sstevel@tonic-gate 
123*0Sstevel@tonic-gate /*
124*0Sstevel@tonic-gate  * struct reservdev
125*0Sstevel@tonic-gate  *
126*0Sstevel@tonic-gate  *	Structure describes a reserved device.
127*0Sstevel@tonic-gate  *
128*0Sstevel@tonic-gate  *  Elements:
129*0Sstevel@tonic-gate  *	char   *devname		Alias of the reserved device
130*0Sstevel@tonic-gate  *	pid_t	key		Key used to reserve the device
131*0Sstevel@tonic-gate  */
132*0Sstevel@tonic-gate 
133*0Sstevel@tonic-gate struct reservdev {
134*0Sstevel@tonic-gate 	char   *devname;
135*0Sstevel@tonic-gate 	pid_t	key;
136*0Sstevel@tonic-gate };
137*0Sstevel@tonic-gate 
138*0Sstevel@tonic-gate /*
139*0Sstevel@tonic-gate  * Device Management Functions:
140*0Sstevel@tonic-gate  *
141*0Sstevel@tonic-gate  *	devattr()	Returns a device's attribute
142*0Sstevel@tonic-gate  *	devreserv()	Reserves a device
143*0Sstevel@tonic-gate  *	devfree()	Frees a reserved device
144*0Sstevel@tonic-gate  *	reservdev()	Return list of reserved devices
145*0Sstevel@tonic-gate  *	getdev()	Get devices that match criteria
146*0Sstevel@tonic-gate  *	getdgrp()	Get device-groups containing devices
147*0Sstevel@tonic-gate  *			that match criteria
148*0Sstevel@tonic-gate  *	listdev()	List attributes defined for a device
149*0Sstevel@tonic-gate  *	listdgrp()	List members of a device-group
150*0Sstevel@tonic-gate  */
151*0Sstevel@tonic-gate 
152*0Sstevel@tonic-gate 	char			*devattr(char *, char *);
153*0Sstevel@tonic-gate 	int			devfree(int, char *);
154*0Sstevel@tonic-gate 	char			**devreserv(int, char ***);
155*0Sstevel@tonic-gate 	char			**getdev(char **, char **, int);
156*0Sstevel@tonic-gate 	char			**getdgrp(char **, char **, int);
157*0Sstevel@tonic-gate 	char			**listdev(char *);
158*0Sstevel@tonic-gate 	char			**listdgrp(char *);
159*0Sstevel@tonic-gate 	struct reservdev	**reservdev(void);
160*0Sstevel@tonic-gate 
161*0Sstevel@tonic-gate /*
162*0Sstevel@tonic-gate  * getvol() definitions
163*0Sstevel@tonic-gate  */
164*0Sstevel@tonic-gate 
165*0Sstevel@tonic-gate #define	DM_BATCH	0x0001
166*0Sstevel@tonic-gate #define	DM_ELABEL	0x0002
167*0Sstevel@tonic-gate #define	DM_FORMAT	0x0004
168*0Sstevel@tonic-gate #define	DM_FORMFS	0x0008
169*0Sstevel@tonic-gate #define	DM_WLABEL	0x0010
170*0Sstevel@tonic-gate #define	DM_OLABEL	0x0020
171*0Sstevel@tonic-gate 
172*0Sstevel@tonic-gate 	int			getvol(char *, char *, int, char *);
173*0Sstevel@tonic-gate 
174*0Sstevel@tonic-gate #ifdef	__cplusplus
175*0Sstevel@tonic-gate }
176*0Sstevel@tonic-gate #endif
177*0Sstevel@tonic-gate 
178*0Sstevel@tonic-gate #endif	/* _DEVMGMT_H */
179