1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START 3*7c478bd9Sstevel@tonic-gate * 4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*7c478bd9Sstevel@tonic-gate * with the License. 8*7c478bd9Sstevel@tonic-gate * 9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 12*7c478bd9Sstevel@tonic-gate * and limitations under the License. 13*7c478bd9Sstevel@tonic-gate * 14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*7c478bd9Sstevel@tonic-gate * 20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END 21*7c478bd9Sstevel@tonic-gate */ 22*7c478bd9Sstevel@tonic-gate /* 23*7c478bd9Sstevel@tonic-gate * Copyright 1997-1999, 2002 Sun Microsystems, Inc. All rights reserved. 24*7c478bd9Sstevel@tonic-gate * Use is subject to license terms. 25*7c478bd9Sstevel@tonic-gate */ 26*7c478bd9Sstevel@tonic-gate 27*7c478bd9Sstevel@tonic-gate /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 28*7c478bd9Sstevel@tonic-gate /* All Rights Reserved */ 29*7c478bd9Sstevel@tonic-gate 30*7c478bd9Sstevel@tonic-gate 31*7c478bd9Sstevel@tonic-gate #ifndef _SYS_SAD_H 32*7c478bd9Sstevel@tonic-gate #define _SYS_SAD_H 33*7c478bd9Sstevel@tonic-gate 34*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.5 */ 35*7c478bd9Sstevel@tonic-gate 36*7c478bd9Sstevel@tonic-gate #include <sys/types.h> 37*7c478bd9Sstevel@tonic-gate 38*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 39*7c478bd9Sstevel@tonic-gate extern "C" { 40*7c478bd9Sstevel@tonic-gate #endif 41*7c478bd9Sstevel@tonic-gate 42*7c478bd9Sstevel@tonic-gate /* 43*7c478bd9Sstevel@tonic-gate * Streams Administrative Driver 44*7c478bd9Sstevel@tonic-gate */ 45*7c478bd9Sstevel@tonic-gate 46*7c478bd9Sstevel@tonic-gate /* 47*7c478bd9Sstevel@tonic-gate * As time has passed, it has become necessary to add members to some 48*7c478bd9Sstevel@tonic-gate * of the structures passed downstream with these ioctls. Currently, 49*7c478bd9Sstevel@tonic-gate * only the SAD_GAP/SAD_SAP ioctls are versioned, (which use the 50*7c478bd9Sstevel@tonic-gate * strapush structure), but the versioning mechanism is general enough 51*7c478bd9Sstevel@tonic-gate * to be applied to any SAD ioctls. This is done by repartitioning 52*7c478bd9Sstevel@tonic-gate * the SAD ioctl namespace to include a version number in addition to 53*7c478bd9Sstevel@tonic-gate * the command (see below). 54*7c478bd9Sstevel@tonic-gate * 55*7c478bd9Sstevel@tonic-gate * In the case of the SAD_GAP/SAD_SAP ioctls, an application can 56*7c478bd9Sstevel@tonic-gate * choose which "version" of the ioctl to use by #defining AP_VERSION 57*7c478bd9Sstevel@tonic-gate * before including this file. Old code implicitly has AP_VERSION set 58*7c478bd9Sstevel@tonic-gate * to 0, and even newly compiled code defaults to an AP_VERSION of 0, 59*7c478bd9Sstevel@tonic-gate * since it may not be aware of the new structure members and 60*7c478bd9Sstevel@tonic-gate * therefore not know to set them to reasonable values. In order for 61*7c478bd9Sstevel@tonic-gate * programs to make use of a newer version, they must explicitly 62*7c478bd9Sstevel@tonic-gate * #define AP_VERSION to the appropriate value. Note that the kernel 63*7c478bd9Sstevel@tonic-gate * always defaults to the latest version, since it is internally 64*7c478bd9Sstevel@tonic-gate * self-consistent. 65*7c478bd9Sstevel@tonic-gate */ 66*7c478bd9Sstevel@tonic-gate #ifndef AP_VERSION 67*7c478bd9Sstevel@tonic-gate #ifdef _KERNEL 68*7c478bd9Sstevel@tonic-gate #define AP_VERSION 1 /* latest version */ 69*7c478bd9Sstevel@tonic-gate #else 70*7c478bd9Sstevel@tonic-gate #define AP_VERSION 0 /* SVR4 version */ 71*7c478bd9Sstevel@tonic-gate #endif 72*7c478bd9Sstevel@tonic-gate #endif 73*7c478bd9Sstevel@tonic-gate 74*7c478bd9Sstevel@tonic-gate /* 75*7c478bd9Sstevel@tonic-gate * ioctl defines 76*7c478bd9Sstevel@tonic-gate * 77*7c478bd9Sstevel@tonic-gate * The layout for the low 16 bits is 01000101VVVVCCCC, where the 78*7c478bd9Sstevel@tonic-gate * first bitpattern is `D' in binary, followed by a 4 bit version 79*7c478bd9Sstevel@tonic-gate * field (limiting the number of versions to 16), followed by a 80*7c478bd9Sstevel@tonic-gate * 4 bit command field (limiting the number of commands to 16). 81*7c478bd9Sstevel@tonic-gate */ 82*7c478bd9Sstevel@tonic-gate #define SADIOC ('D' << 8) 83*7c478bd9Sstevel@tonic-gate #define SAD_SAP (SADIOC|AP_VERSION << 4|01) 84*7c478bd9Sstevel@tonic-gate #define SAD_GAP (SADIOC|AP_VERSION << 4|02) 85*7c478bd9Sstevel@tonic-gate #define SAD_VML (SADIOC|03) /* validate module list */ 86*7c478bd9Sstevel@tonic-gate 87*7c478bd9Sstevel@tonic-gate /* 88*7c478bd9Sstevel@tonic-gate * Device naming and numbering conventions. 89*7c478bd9Sstevel@tonic-gate */ 90*7c478bd9Sstevel@tonic-gate #define USERDEV "/dev/sad/user" 91*7c478bd9Sstevel@tonic-gate #define ADMINDEV "/dev/sad/admin" 92*7c478bd9Sstevel@tonic-gate 93*7c478bd9Sstevel@tonic-gate #define USRMIN 0 94*7c478bd9Sstevel@tonic-gate #define ADMMIN 1 95*7c478bd9Sstevel@tonic-gate 96*7c478bd9Sstevel@tonic-gate /* 97*7c478bd9Sstevel@tonic-gate * The maximum modules you can push on a stream using the autopush 98*7c478bd9Sstevel@tonic-gate * feature. This should be less than NSTRPUSH. 99*7c478bd9Sstevel@tonic-gate */ 100*7c478bd9Sstevel@tonic-gate #define MAXAPUSH 8 101*7c478bd9Sstevel@tonic-gate 102*7c478bd9Sstevel@tonic-gate /* 103*7c478bd9Sstevel@tonic-gate * autopush info common to user and kernel 104*7c478bd9Sstevel@tonic-gate */ 105*7c478bd9Sstevel@tonic-gate struct apcommon { 106*7c478bd9Sstevel@tonic-gate uint_t apc_cmd; /* command (see below) */ 107*7c478bd9Sstevel@tonic-gate major_t apc_major; /* major # of device */ 108*7c478bd9Sstevel@tonic-gate minor_t apc_minor; /* minor # of device */ 109*7c478bd9Sstevel@tonic-gate minor_t apc_lastminor; /* last minor for range */ 110*7c478bd9Sstevel@tonic-gate uint_t apc_npush; /* number of modules to push */ 111*7c478bd9Sstevel@tonic-gate }; 112*7c478bd9Sstevel@tonic-gate 113*7c478bd9Sstevel@tonic-gate /* 114*7c478bd9Sstevel@tonic-gate * New autopush information structure. This wouldn't be necessary 115*7c478bd9Sstevel@tonic-gate * except `struct apcommon' wasn't defined last in the `strapush' 116*7c478bd9Sstevel@tonic-gate * structure, making it difficult to grow the structure without 117*7c478bd9Sstevel@tonic-gate * breaking binary compatibility. Note that new members can be added 118*7c478bd9Sstevel@tonic-gate * to this structure in the future, at which point AP_VERSION should 119*7c478bd9Sstevel@tonic-gate * be incremented (of course, a new STRAPUSH_Vx_LEN macro should be 120*7c478bd9Sstevel@tonic-gate * added and sad.c should be changed to handle the new member). 121*7c478bd9Sstevel@tonic-gate */ 122*7c478bd9Sstevel@tonic-gate struct apdata { 123*7c478bd9Sstevel@tonic-gate uint_t apd_anchor; /* position of anchor in stream */ 124*7c478bd9Sstevel@tonic-gate }; 125*7c478bd9Sstevel@tonic-gate 126*7c478bd9Sstevel@tonic-gate /* 127*7c478bd9Sstevel@tonic-gate * ap_cmd: various flavors of autopush 128*7c478bd9Sstevel@tonic-gate */ 129*7c478bd9Sstevel@tonic-gate #define SAP_CLEAR 0 /* remove configuration list */ 130*7c478bd9Sstevel@tonic-gate #define SAP_ONE 1 /* configure one minor device */ 131*7c478bd9Sstevel@tonic-gate #define SAP_RANGE 2 /* configure range of minor devices */ 132*7c478bd9Sstevel@tonic-gate #define SAP_ALL 3 /* configure all minor devices */ 133*7c478bd9Sstevel@tonic-gate 134*7c478bd9Sstevel@tonic-gate /* 135*7c478bd9Sstevel@tonic-gate * format for autopush ioctls 136*7c478bd9Sstevel@tonic-gate */ 137*7c478bd9Sstevel@tonic-gate struct strapush { 138*7c478bd9Sstevel@tonic-gate struct apcommon sap_common; /* see above */ 139*7c478bd9Sstevel@tonic-gate char sap_list[MAXAPUSH][FMNAMESZ + 1]; /* module list */ 140*7c478bd9Sstevel@tonic-gate #if AP_VERSION > 0 141*7c478bd9Sstevel@tonic-gate struct apdata sap_data; /* see above */ 142*7c478bd9Sstevel@tonic-gate #endif 143*7c478bd9Sstevel@tonic-gate }; 144*7c478bd9Sstevel@tonic-gate 145*7c478bd9Sstevel@tonic-gate #define sap_cmd sap_common.apc_cmd 146*7c478bd9Sstevel@tonic-gate #define sap_major sap_common.apc_major 147*7c478bd9Sstevel@tonic-gate #define sap_minor sap_common.apc_minor 148*7c478bd9Sstevel@tonic-gate #define sap_lastminor sap_common.apc_lastminor 149*7c478bd9Sstevel@tonic-gate #define sap_npush sap_common.apc_npush 150*7c478bd9Sstevel@tonic-gate #define sap_anchor sap_data.apd_anchor 151*7c478bd9Sstevel@tonic-gate 152*7c478bd9Sstevel@tonic-gate #ifdef _KERNEL 153*7c478bd9Sstevel@tonic-gate 154*7c478bd9Sstevel@tonic-gate /* 155*7c478bd9Sstevel@tonic-gate * state values for ioctls 156*7c478bd9Sstevel@tonic-gate */ 157*7c478bd9Sstevel@tonic-gate #define GETSTRUCT 1 158*7c478bd9Sstevel@tonic-gate #define GETRESULT 2 159*7c478bd9Sstevel@tonic-gate #define GETLIST 3 160*7c478bd9Sstevel@tonic-gate 161*7c478bd9Sstevel@tonic-gate #define SAD_VER(ioccmd) (((ioccmd) >> 4) & 0x0f) 162*7c478bd9Sstevel@tonic-gate #define SAD_CMD(ioccmd) ((ioccmd) & ~0xf0) 163*7c478bd9Sstevel@tonic-gate 164*7c478bd9Sstevel@tonic-gate #define STRAPUSH_V0_LEN (size_t)(&((struct strapush *)0)->sap_data) 165*7c478bd9Sstevel@tonic-gate #define STRAPUSH_V1_LEN (size_t)(STRAPUSH_V0_LEN + sizeof (uint_t)) 166*7c478bd9Sstevel@tonic-gate 167*7c478bd9Sstevel@tonic-gate struct saddev { 168*7c478bd9Sstevel@tonic-gate queue_t *sa_qp; /* pointer to read queue */ 169*7c478bd9Sstevel@tonic-gate caddr_t sa_addr; /* saved address for copyout */ 170*7c478bd9Sstevel@tonic-gate int sa_flags; /* see below */ 171*7c478bd9Sstevel@tonic-gate }; 172*7c478bd9Sstevel@tonic-gate 173*7c478bd9Sstevel@tonic-gate /* 174*7c478bd9Sstevel@tonic-gate * values for saddev flags field. 175*7c478bd9Sstevel@tonic-gate */ 176*7c478bd9Sstevel@tonic-gate #define SADPRIV 0x01 177*7c478bd9Sstevel@tonic-gate 178*7c478bd9Sstevel@tonic-gate /* 179*7c478bd9Sstevel@tonic-gate * Module Autopush Cache 180*7c478bd9Sstevel@tonic-gate */ 181*7c478bd9Sstevel@tonic-gate struct autopush { 182*7c478bd9Sstevel@tonic-gate struct autopush *ap_nextp; /* next on list */ 183*7c478bd9Sstevel@tonic-gate int ap_flags; /* see below */ 184*7c478bd9Sstevel@tonic-gate struct apcommon ap_common; /* see above */ 185*7c478bd9Sstevel@tonic-gate char ap_list[MAXAPUSH][FMNAMESZ + 1]; 186*7c478bd9Sstevel@tonic-gate /* list of modules to push */ 187*7c478bd9Sstevel@tonic-gate int ap_cnt; /* in use count */ 188*7c478bd9Sstevel@tonic-gate struct apdata ap_data; /* see above */ 189*7c478bd9Sstevel@tonic-gate }; 190*7c478bd9Sstevel@tonic-gate 191*7c478bd9Sstevel@tonic-gate /* 192*7c478bd9Sstevel@tonic-gate * The command issued by the user ultimately becomes 193*7c478bd9Sstevel@tonic-gate * the type of the autopush entry. Therefore, occurrences of 194*7c478bd9Sstevel@tonic-gate * "type" in the code refer to an existing autopush entry. 195*7c478bd9Sstevel@tonic-gate * Occurrences of "cmd" in the code refer to the command the 196*7c478bd9Sstevel@tonic-gate * user is currently trying to complete. types and cmds take 197*7c478bd9Sstevel@tonic-gate * on the same values. 198*7c478bd9Sstevel@tonic-gate */ 199*7c478bd9Sstevel@tonic-gate #define ap_type ap_common.apc_cmd 200*7c478bd9Sstevel@tonic-gate #define ap_major ap_common.apc_major 201*7c478bd9Sstevel@tonic-gate #define ap_minor ap_common.apc_minor 202*7c478bd9Sstevel@tonic-gate #define ap_lastminor ap_common.apc_lastminor 203*7c478bd9Sstevel@tonic-gate #define ap_npush ap_common.apc_npush 204*7c478bd9Sstevel@tonic-gate #define ap_anchor ap_data.apd_anchor 205*7c478bd9Sstevel@tonic-gate 206*7c478bd9Sstevel@tonic-gate /* 207*7c478bd9Sstevel@tonic-gate * autopush flag values 208*7c478bd9Sstevel@tonic-gate */ 209*7c478bd9Sstevel@tonic-gate #define APFREE 0x00 /* free */ 210*7c478bd9Sstevel@tonic-gate #define APUSED 0x01 /* used */ 211*7c478bd9Sstevel@tonic-gate #define APHASH 0x02 /* on hash list */ 212*7c478bd9Sstevel@tonic-gate 213*7c478bd9Sstevel@tonic-gate /* 214*7c478bd9Sstevel@tonic-gate * hash function for cache 215*7c478bd9Sstevel@tonic-gate */ 216*7c478bd9Sstevel@tonic-gate #define strphash(maj) strpcache[(((int)maj)&strpmask)] 217*7c478bd9Sstevel@tonic-gate 218*7c478bd9Sstevel@tonic-gate extern struct saddev *saddev; /* sad device array */ 219*7c478bd9Sstevel@tonic-gate extern int sadcnt; /* number of elements in saddev */ 220*7c478bd9Sstevel@tonic-gate extern struct autopush *autopush; /* autopush data array */ 221*7c478bd9Sstevel@tonic-gate extern int nautopush; /* number of elements in autopush */ 222*7c478bd9Sstevel@tonic-gate extern struct autopush **strpcache; /* autopush hash list */ 223*7c478bd9Sstevel@tonic-gate extern int strpmask; /* used in hash function */ 224*7c478bd9Sstevel@tonic-gate 225*7c478bd9Sstevel@tonic-gate /* 226*7c478bd9Sstevel@tonic-gate * function prototypes 227*7c478bd9Sstevel@tonic-gate */ 228*7c478bd9Sstevel@tonic-gate #ifdef C2_AUDIT 229*7c478bd9Sstevel@tonic-gate void audit_stropen(struct vnode *, dev_t *, int, cred_t *); 230*7c478bd9Sstevel@tonic-gate void audit_strclose(struct vnode *, int, cred_t *); 231*7c478bd9Sstevel@tonic-gate void audit_strioctl(struct vnode *, int, intptr_t, int, int, cred_t *, int *); 232*7c478bd9Sstevel@tonic-gate struct strbuf; 233*7c478bd9Sstevel@tonic-gate void audit_strputmsg(struct vnode *, struct strbuf *, struct strbuf *, 234*7c478bd9Sstevel@tonic-gate unsigned char, int, int); 235*7c478bd9Sstevel@tonic-gate void audit_fdsend(int, struct file *, int); 236*7c478bd9Sstevel@tonic-gate void audit_fdrecv(int, struct file *); 237*7c478bd9Sstevel@tonic-gate #endif 238*7c478bd9Sstevel@tonic-gate 239*7c478bd9Sstevel@tonic-gate extern void ap_free(struct autopush *); 240*7c478bd9Sstevel@tonic-gate extern void sad_initspace(void); 241*7c478bd9Sstevel@tonic-gate 242*7c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 243*7c478bd9Sstevel@tonic-gate 244*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 245*7c478bd9Sstevel@tonic-gate } 246*7c478bd9Sstevel@tonic-gate #endif 247*7c478bd9Sstevel@tonic-gate 248*7c478bd9Sstevel@tonic-gate #endif /* _SYS_SAD_H */ 249