1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
|
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 1997 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
#ifndef _DEVTAB_H
#define _DEVTAB_H
#pragma ident "%Z%%M% %I% %E% SMI"
#include <stdio.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
* devtab.h
*
* This header file is local to the liboam component
* and should not contain any data that may need to
* be reference anywhere. The definitions here are used
* to reference the device tables and the device-group
* tables.
*/
/*
* Constant definitions
* NULL Manifest constant NULL (null-address)
* TRUE Boolean TRUE value
* FALSE Boolean FALSE value
* DTAB_BUFSIZ Initial buffersize for reading device table records
* DTAB_BUFINC Amount to increase device table record buffer
* DGRP_BUFSIZ Initial buffersize for reading devgrp table records
* DGRP_BUFINC Amount to increase device-group table record buffer
* XTND_MAXCNT Maximum extend count (may have insane tables)
* DTAB_ESCS Characters that are escaped in fields in the devtab
*/
#ifndef NULL
#define NULL (0)
#endif
#ifndef TRUE
#define TRUE (1)
#endif
#ifndef FALSE
#define FALSE (0)
#endif
#define DTAB_BUFSIZ 512
#define DTAB_BUFINC 512
#define DGRP_BUFSIZ 512
#define DGRP_BUFINC 512
#define XTND_MAXCNT 16
#define DTAB_ESCS ":\\\"\n"
/*
* oam_devtab File descriptor of the open device table
*/
extern FILE *oam_devtab;
extern FILE *oam_dgroup;
/*
* Structure definitions for device table records:
* devtabent Describes an entry in the device table
* dgrpent Describes an entry in the device-group table
* attrval Describes an attribute/value pair
*/
/*
* struct devtabent
*
* Describes an entry in the device table.
*
* entryno This record's entry number in the device table
* comment Comment flag, TRUE if record is a comment
* alias The device's alias
* cdevice A pathname to the inode describing the device as
* a character-special device
* bdevice A pathname to the inode describing the device as
* a block-special device
* pathname A pathname to the device (not char or blk special)
* attrstr The character-string containing the attributes
* attrlist The address of the first attribute description
*/
struct devtabent {
int entryno; /* Entry number of this record */
int comment; /* Comment flag */
char *alias; /* Alias of the device */
char *cdevice; /* Character device pathname */
char *bdevice; /* Block device pathname */
char *pathname; /* Vanilla pathname */
char *attrstr; /* String containing attributes */
struct attrval *attrlist; /* Addr of 1st attribute description */
};
/*
* struct attrval
*
* Describes an attribute-value pair
*
* char *attr Pointer to the name of the attribute
* char *val Pointer to the name of the value of the attr
* struct attrval *next Pointer to the next item in the list
*/
struct attrval {
char *attr; /* Attribute name */
char *val; /* Value of the attribute */
struct attrval *next; /* Next attrval in list */
};
/*
* Structure definitions for device-group records:
* struct dgrptabent Describes a record in the device-group table
* struct member Describes a member of a device group
*/
/*
* struct dgrptabent
* entryno The entry number of this record
* comment Comment flag, TRUE if record is a comment
* name The name of the device group
* memberspace The buffer containing the members of the
* device group
* membership Pointer to the head of the list of
* members in the group.
*/
struct dgrptabent {
int entryno; /* Entry number of this record */
int comment; /* TRUE if a comment record */
char *name; /* Device group name */
char *dataspace; /* Buffer containing membership */
struct member *membership; /* Ptr to top of membership list */
};
/*
* struct member
* name Member name (a device alias or pathname)
* next Ptr to next item in the list
*/
struct member {
char *name; /* Member name */
struct member *next; /* Next member in the list */
};
/*
* Global function and data definitions:
* _setdevtab() Rewinds the open device table
* _enddevtab() Closes the open device table
* _getdevtabent() Gets the next device table entry
* _freedevtabent() Frees space allocated to a device-table entry
* _getdevrec() Gets a specific device table entry
* _opendevtab() Open the device table
* _devtabpath() Get the pathname of the device table file
*
* _setdgrptab() Rewind the open device-group table
* _enddgrptab() Close the open device table
* _getdgrptabent() Get the next device-group table entry
* _freedgrptabent() Frees space alloced to a dev-grp table entry
* _getdgrprec() Gets a specific device-group table entry
* _opendgrptab() Open the device group table
* _dgrptabpath() Get the pathname of the device group table file
*
* _openlkfile() Open device lock file
* rsvtabpath() Get device lock file pathname
* _closelkfile() Close device lock file
*
* _validalias() Determine if a character-string is a valid alias
* unreserv() Remove a device reservation
*/
void _setdevtab(void);
void _enddevtab(void);
struct devtabent *_getdevtabent(void);
void _freedevtabent(struct devtabent *);
struct devtabent *_getdevrec(char *);
int _opendevtab(char *);
char *_devtabpath(void);
void _setdgrptab(void);
void _enddgrptab(void);
struct dgrptabent *_getdgrptabent(void);
void _freedgrptabent(struct dgrptabent *);
struct dgrptabent *_getdgrprec(char *);
int _opendgrptab(char *);
char *_dgrptabpath(void);
int _openlkfile(void);
char *_rsvtabpath(void);
int _closelkfile(void);
int _validalias(char *);
int unreserv(int, char *);
extern int _adddevtabrec(char *, char **);
extern int _moddevtabrec(char *, char **);
extern int _putdevtabrec(FILE *stream, struct devtabent *rec);
extern int _rmdevtabattrs(char *, char **, char ***);
extern int _rmdevtabrec(char *);
extern int _adddgrptabrec(char *dgrp, char **members);
extern int _putdgrptabrec(FILE *stream, struct dgrptabent *rec);
extern int _rmdgrpmems(char *dgrp, char **mems, char ***notfounds);
extern int _rmdgrptabrec(char *dgrp);
#ifdef __cplusplus
}
#endif
#endif /* _DEVTAB_H */
|