4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
22 * Copyright (c) 1988, 2010, Oracle and/or its affiliates. All rights reserved.
25 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
26 /* All Rights Reserved */
32 #include <sys/types.h>
34 #include <sys/strsubr.h>
36 #include <sys/modhash.h>
43 * Streams Administrative Driver
47 * As time has passed, it has become necessary to add members to some
48 * of the structures passed downstream with these ioctls. Currently,
49 * only the SAD_GAP/SAD_SAP ioctls are versioned, (which use the
50 * strapush structure), but the versioning mechanism is general enough
51 * to be applied to any SAD ioctls. This is done by repartitioning
52 * the SAD ioctl namespace to include a version number in addition to
53 * the command (see below).
55 * In the case of the SAD_GAP/SAD_SAP ioctls, an application can
56 * choose which "version" of the ioctl to use by #defining AP_VERSION
57 * before including this file. Old code implicitly has AP_VERSION set
58 * to 0, and even newly compiled code defaults to an AP_VERSION of 0,
59 * since it may not be aware of the new structure members and
60 * therefore not know to set them to reasonable values. In order for
61 * programs to make use of a newer version, they must explicitly
62 * #define AP_VERSION to the appropriate value. Note that the kernel
63 * always defaults to the latest version, since it is internally
68 #define AP_VERSION 1 /* latest version */
70 #define AP_VERSION 0 /* SVR4 version */
77 * The layout for the low 16 bits is 01000101VVVVCCCC, where the
78 * first bitpattern is `D' in binary, followed by a 4 bit version
79 * field (limiting the number of versions to 16), followed by a
80 * 4 bit command field (limiting the number of commands to 16).
82 #define SADIOC ('D' << 8)
83 #define SAD_SAP (SADIOC|AP_VERSION << 4|01)
84 #define SAD_GAP (SADIOC|AP_VERSION << 4|02)
85 #define SAD_VML (SADIOC|03) /* validate module list */
88 * Device naming and numbering conventions.
90 #define USERDEV "/dev/sad/user"
91 #define ADMINDEV "/dev/sad/admin"
97 * The maximum modules you can push on a stream using the autopush
98 * feature. This should be less than NSTRPUSH.
103 * autopush info common to user and kernel
106 uint_t apc_cmd
; /* command (see below) */
107 major_t apc_major
; /* major # of device */
108 minor_t apc_minor
; /* minor # of device */
109 minor_t apc_lastminor
; /* last minor for range */
110 uint_t apc_npush
; /* number of modules to push */
114 * New autopush information structure. This wouldn't be necessary
115 * except `struct apcommon' wasn't defined last in the `strapush'
116 * structure, making it difficult to grow the structure without
117 * breaking binary compatibility. Note that new members can be added
118 * to this structure in the future, at which point AP_VERSION should
119 * be incremented (of course, a new STRAPUSH_Vx_LEN macro should be
120 * added and sad.c should be changed to handle the new member).
123 uint_t apd_anchor
; /* position of anchor in stream */
127 * ap_cmd: various flavors of autopush
129 #define SAP_CLEAR 0 /* remove configuration list */
130 #define SAP_ONE 1 /* configure one minor device */
131 #define SAP_RANGE 2 /* configure range of minor devices */
132 #define SAP_ALL 3 /* configure all minor devices */
135 * format for autopush ioctls
138 struct apcommon sap_common
; /* see above */
139 char sap_list
[MAXAPUSH
][FMNAMESZ
+ 1]; /* module list */
141 struct apdata sap_data
; /* see above */
145 #define sap_cmd sap_common.apc_cmd
146 #define sap_major sap_common.apc_major
147 #define sap_minor sap_common.apc_minor
148 #define sap_lastminor sap_common.apc_lastminor
149 #define sap_npush sap_common.apc_npush
150 #define sap_anchor sap_data.apd_anchor
155 * state values for ioctls
161 #define SAD_VER(ioccmd) (((ioccmd) >> 4) & 0x0f)
162 #define SAD_CMD(ioccmd) ((ioccmd) & ~0xf0)
164 #define STRAPUSH_V0_LEN (size_t)(&((struct strapush *)0)->sap_data)
165 #define STRAPUSH_V1_LEN (size_t)(STRAPUSH_V0_LEN + sizeof (uint_t))
168 queue_t
*sa_qp
; /* pointer to read queue */
169 caddr_t sa_addr
; /* saved address for copyout */
170 int sa_flags
; /* see below */
175 * values for saddev flags field.
180 * Module Autopush Cache
183 struct apcommon ap_common
; /* see above */
184 char ap_list
[MAXAPUSH
][FMNAMESZ
+ 1];
185 /* list of modules to push */
186 int ap_cnt
; /* in use count */
187 struct apdata ap_data
; /* see above */
191 * The command issued by the user ultimately becomes
192 * the type of the autopush entry. Therefore, occurrences of
193 * "type" in the code refer to an existing autopush entry.
194 * Occurrences of "cmd" in the code refer to the command the
195 * user is currently trying to complete. types and cmds take
196 * on the same values.
198 #define ap_type ap_common.apc_cmd
199 #define ap_major ap_common.apc_major
200 #define ap_minor ap_common.apc_minor
201 #define ap_lastminor ap_common.apc_lastminor
202 #define ap_npush ap_common.apc_npush
203 #define ap_anchor ap_data.apd_anchor
206 * function prototypes
209 void audit_strputmsg(struct vnode
*, struct strbuf
*, struct strbuf
*,
210 unsigned char, int, int);
211 void audit_fdsend(int, struct file
*, int);
212 void audit_fdrecv(int, struct file
*);
214 extern void sad_initspace(str_stack_t
*);
215 extern void sad_freespace(str_stack_t
*);
218 * The following interfaces do not care about ss_sad_lock.
220 extern struct autopush
*sad_ap_alloc(void);
221 extern int sad_apc_verify(struct apcommon
*);
222 extern int sad_ap_verify(struct autopush
*);
225 * The following interfaces attempt to acquire ss_sad_lock.
227 extern void sad_ap_rele(struct autopush
*, str_stack_t
*);
228 extern struct autopush
*sad_ap_find_by_dev(dev_t
, str_stack_t
*);
231 * The following interfaces require ss_sad_lock to be held when invoked.
233 extern void sad_ap_insert(struct autopush
*, str_stack_t
*);
234 extern void sad_ap_remove(struct autopush
*, str_stack_t
*);
235 extern struct autopush
*sad_ap_find(struct apcommon
*, str_stack_t
*);
243 #endif /* _SYS_SAD_H */