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