17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 51110f384Sedp * Common Development and Distribution License (the "License"). 61110f384Sedp * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate /* 22*f4b3ec61Sdh155122 * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 237c478bd9Sstevel@tonic-gate * Use is subject to license terms. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 277c478bd9Sstevel@tonic-gate /* All Rights Reserved */ 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate 307c478bd9Sstevel@tonic-gate #ifndef _SYS_SAD_H 317c478bd9Sstevel@tonic-gate #define _SYS_SAD_H 327c478bd9Sstevel@tonic-gate 337c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.5 */ 347c478bd9Sstevel@tonic-gate 357c478bd9Sstevel@tonic-gate #include <sys/types.h> 36*f4b3ec61Sdh155122 #ifdef _KERNEL 37*f4b3ec61Sdh155122 #include <sys/strsubr.h> 38*f4b3ec61Sdh155122 #endif 391110f384Sedp #include <sys/modhash.h> 407c478bd9Sstevel@tonic-gate 417c478bd9Sstevel@tonic-gate #ifdef __cplusplus 427c478bd9Sstevel@tonic-gate extern "C" { 437c478bd9Sstevel@tonic-gate #endif 447c478bd9Sstevel@tonic-gate 457c478bd9Sstevel@tonic-gate /* 467c478bd9Sstevel@tonic-gate * Streams Administrative Driver 477c478bd9Sstevel@tonic-gate */ 487c478bd9Sstevel@tonic-gate 497c478bd9Sstevel@tonic-gate /* 507c478bd9Sstevel@tonic-gate * As time has passed, it has become necessary to add members to some 517c478bd9Sstevel@tonic-gate * of the structures passed downstream with these ioctls. Currently, 527c478bd9Sstevel@tonic-gate * only the SAD_GAP/SAD_SAP ioctls are versioned, (which use the 537c478bd9Sstevel@tonic-gate * strapush structure), but the versioning mechanism is general enough 547c478bd9Sstevel@tonic-gate * to be applied to any SAD ioctls. This is done by repartitioning 557c478bd9Sstevel@tonic-gate * the SAD ioctl namespace to include a version number in addition to 567c478bd9Sstevel@tonic-gate * the command (see below). 577c478bd9Sstevel@tonic-gate * 587c478bd9Sstevel@tonic-gate * In the case of the SAD_GAP/SAD_SAP ioctls, an application can 597c478bd9Sstevel@tonic-gate * choose which "version" of the ioctl to use by #defining AP_VERSION 607c478bd9Sstevel@tonic-gate * before including this file. Old code implicitly has AP_VERSION set 617c478bd9Sstevel@tonic-gate * to 0, and even newly compiled code defaults to an AP_VERSION of 0, 627c478bd9Sstevel@tonic-gate * since it may not be aware of the new structure members and 637c478bd9Sstevel@tonic-gate * therefore not know to set them to reasonable values. In order for 647c478bd9Sstevel@tonic-gate * programs to make use of a newer version, they must explicitly 657c478bd9Sstevel@tonic-gate * #define AP_VERSION to the appropriate value. Note that the kernel 667c478bd9Sstevel@tonic-gate * always defaults to the latest version, since it is internally 677c478bd9Sstevel@tonic-gate * self-consistent. 687c478bd9Sstevel@tonic-gate */ 697c478bd9Sstevel@tonic-gate #ifndef AP_VERSION 707c478bd9Sstevel@tonic-gate #ifdef _KERNEL 717c478bd9Sstevel@tonic-gate #define AP_VERSION 1 /* latest version */ 727c478bd9Sstevel@tonic-gate #else 737c478bd9Sstevel@tonic-gate #define AP_VERSION 0 /* SVR4 version */ 747c478bd9Sstevel@tonic-gate #endif 757c478bd9Sstevel@tonic-gate #endif 767c478bd9Sstevel@tonic-gate 777c478bd9Sstevel@tonic-gate /* 787c478bd9Sstevel@tonic-gate * ioctl defines 797c478bd9Sstevel@tonic-gate * 807c478bd9Sstevel@tonic-gate * The layout for the low 16 bits is 01000101VVVVCCCC, where the 817c478bd9Sstevel@tonic-gate * first bitpattern is `D' in binary, followed by a 4 bit version 827c478bd9Sstevel@tonic-gate * field (limiting the number of versions to 16), followed by a 837c478bd9Sstevel@tonic-gate * 4 bit command field (limiting the number of commands to 16). 847c478bd9Sstevel@tonic-gate */ 857c478bd9Sstevel@tonic-gate #define SADIOC ('D' << 8) 867c478bd9Sstevel@tonic-gate #define SAD_SAP (SADIOC|AP_VERSION << 4|01) 877c478bd9Sstevel@tonic-gate #define SAD_GAP (SADIOC|AP_VERSION << 4|02) 887c478bd9Sstevel@tonic-gate #define SAD_VML (SADIOC|03) /* validate module list */ 897c478bd9Sstevel@tonic-gate 907c478bd9Sstevel@tonic-gate /* 917c478bd9Sstevel@tonic-gate * Device naming and numbering conventions. 927c478bd9Sstevel@tonic-gate */ 937c478bd9Sstevel@tonic-gate #define USERDEV "/dev/sad/user" 947c478bd9Sstevel@tonic-gate #define ADMINDEV "/dev/sad/admin" 957c478bd9Sstevel@tonic-gate 967c478bd9Sstevel@tonic-gate #define USRMIN 0 977c478bd9Sstevel@tonic-gate #define ADMMIN 1 987c478bd9Sstevel@tonic-gate 997c478bd9Sstevel@tonic-gate /* 1007c478bd9Sstevel@tonic-gate * The maximum modules you can push on a stream using the autopush 1017c478bd9Sstevel@tonic-gate * feature. This should be less than NSTRPUSH. 1027c478bd9Sstevel@tonic-gate */ 1037c478bd9Sstevel@tonic-gate #define MAXAPUSH 8 1047c478bd9Sstevel@tonic-gate 1057c478bd9Sstevel@tonic-gate /* 1067c478bd9Sstevel@tonic-gate * autopush info common to user and kernel 1077c478bd9Sstevel@tonic-gate */ 1087c478bd9Sstevel@tonic-gate struct apcommon { 1097c478bd9Sstevel@tonic-gate uint_t apc_cmd; /* command (see below) */ 1107c478bd9Sstevel@tonic-gate major_t apc_major; /* major # of device */ 1117c478bd9Sstevel@tonic-gate minor_t apc_minor; /* minor # of device */ 1127c478bd9Sstevel@tonic-gate minor_t apc_lastminor; /* last minor for range */ 1137c478bd9Sstevel@tonic-gate uint_t apc_npush; /* number of modules to push */ 1147c478bd9Sstevel@tonic-gate }; 1157c478bd9Sstevel@tonic-gate 1167c478bd9Sstevel@tonic-gate /* 1177c478bd9Sstevel@tonic-gate * New autopush information structure. This wouldn't be necessary 1187c478bd9Sstevel@tonic-gate * except `struct apcommon' wasn't defined last in the `strapush' 1197c478bd9Sstevel@tonic-gate * structure, making it difficult to grow the structure without 1207c478bd9Sstevel@tonic-gate * breaking binary compatibility. Note that new members can be added 1217c478bd9Sstevel@tonic-gate * to this structure in the future, at which point AP_VERSION should 1227c478bd9Sstevel@tonic-gate * be incremented (of course, a new STRAPUSH_Vx_LEN macro should be 1237c478bd9Sstevel@tonic-gate * added and sad.c should be changed to handle the new member). 1247c478bd9Sstevel@tonic-gate */ 1257c478bd9Sstevel@tonic-gate struct apdata { 1267c478bd9Sstevel@tonic-gate uint_t apd_anchor; /* position of anchor in stream */ 1277c478bd9Sstevel@tonic-gate }; 1287c478bd9Sstevel@tonic-gate 1297c478bd9Sstevel@tonic-gate /* 1307c478bd9Sstevel@tonic-gate * ap_cmd: various flavors of autopush 1317c478bd9Sstevel@tonic-gate */ 1327c478bd9Sstevel@tonic-gate #define SAP_CLEAR 0 /* remove configuration list */ 1337c478bd9Sstevel@tonic-gate #define SAP_ONE 1 /* configure one minor device */ 1347c478bd9Sstevel@tonic-gate #define SAP_RANGE 2 /* configure range of minor devices */ 1357c478bd9Sstevel@tonic-gate #define SAP_ALL 3 /* configure all minor devices */ 1367c478bd9Sstevel@tonic-gate 1377c478bd9Sstevel@tonic-gate /* 1387c478bd9Sstevel@tonic-gate * format for autopush ioctls 1397c478bd9Sstevel@tonic-gate */ 1407c478bd9Sstevel@tonic-gate struct strapush { 1417c478bd9Sstevel@tonic-gate struct apcommon sap_common; /* see above */ 1427c478bd9Sstevel@tonic-gate char sap_list[MAXAPUSH][FMNAMESZ + 1]; /* module list */ 1437c478bd9Sstevel@tonic-gate #if AP_VERSION > 0 1447c478bd9Sstevel@tonic-gate struct apdata sap_data; /* see above */ 1457c478bd9Sstevel@tonic-gate #endif 1467c478bd9Sstevel@tonic-gate }; 1477c478bd9Sstevel@tonic-gate 1487c478bd9Sstevel@tonic-gate #define sap_cmd sap_common.apc_cmd 1497c478bd9Sstevel@tonic-gate #define sap_major sap_common.apc_major 1507c478bd9Sstevel@tonic-gate #define sap_minor sap_common.apc_minor 1517c478bd9Sstevel@tonic-gate #define sap_lastminor sap_common.apc_lastminor 1527c478bd9Sstevel@tonic-gate #define sap_npush sap_common.apc_npush 1537c478bd9Sstevel@tonic-gate #define sap_anchor sap_data.apd_anchor 1547c478bd9Sstevel@tonic-gate 1557c478bd9Sstevel@tonic-gate #ifdef _KERNEL 1567c478bd9Sstevel@tonic-gate 1577c478bd9Sstevel@tonic-gate /* 1587c478bd9Sstevel@tonic-gate * state values for ioctls 1597c478bd9Sstevel@tonic-gate */ 1607c478bd9Sstevel@tonic-gate #define GETSTRUCT 1 1617c478bd9Sstevel@tonic-gate #define GETRESULT 2 1627c478bd9Sstevel@tonic-gate #define GETLIST 3 1637c478bd9Sstevel@tonic-gate 1647c478bd9Sstevel@tonic-gate #define SAD_VER(ioccmd) (((ioccmd) >> 4) & 0x0f) 1657c478bd9Sstevel@tonic-gate #define SAD_CMD(ioccmd) ((ioccmd) & ~0xf0) 1667c478bd9Sstevel@tonic-gate 1677c478bd9Sstevel@tonic-gate #define STRAPUSH_V0_LEN (size_t)(&((struct strapush *)0)->sap_data) 1687c478bd9Sstevel@tonic-gate #define STRAPUSH_V1_LEN (size_t)(STRAPUSH_V0_LEN + sizeof (uint_t)) 1697c478bd9Sstevel@tonic-gate 1707c478bd9Sstevel@tonic-gate struct saddev { 1717c478bd9Sstevel@tonic-gate queue_t *sa_qp; /* pointer to read queue */ 1727c478bd9Sstevel@tonic-gate caddr_t sa_addr; /* saved address for copyout */ 1737c478bd9Sstevel@tonic-gate int sa_flags; /* see below */ 174*f4b3ec61Sdh155122 str_stack_t *sa_ss; 1757c478bd9Sstevel@tonic-gate }; 1767c478bd9Sstevel@tonic-gate 1777c478bd9Sstevel@tonic-gate /* 1787c478bd9Sstevel@tonic-gate * values for saddev flags field. 1797c478bd9Sstevel@tonic-gate */ 1807c478bd9Sstevel@tonic-gate #define SADPRIV 0x01 1817c478bd9Sstevel@tonic-gate 1827c478bd9Sstevel@tonic-gate /* 1837c478bd9Sstevel@tonic-gate * Module Autopush Cache 1847c478bd9Sstevel@tonic-gate */ 1857c478bd9Sstevel@tonic-gate struct autopush { 1867c478bd9Sstevel@tonic-gate struct apcommon ap_common; /* see above */ 1877c478bd9Sstevel@tonic-gate char ap_list[MAXAPUSH][FMNAMESZ + 1]; 1887c478bd9Sstevel@tonic-gate /* list of modules to push */ 1897c478bd9Sstevel@tonic-gate int ap_cnt; /* in use count */ 1907c478bd9Sstevel@tonic-gate struct apdata ap_data; /* see above */ 1917c478bd9Sstevel@tonic-gate }; 1927c478bd9Sstevel@tonic-gate 1937c478bd9Sstevel@tonic-gate /* 1947c478bd9Sstevel@tonic-gate * The command issued by the user ultimately becomes 1957c478bd9Sstevel@tonic-gate * the type of the autopush entry. Therefore, occurrences of 1967c478bd9Sstevel@tonic-gate * "type" in the code refer to an existing autopush entry. 1977c478bd9Sstevel@tonic-gate * Occurrences of "cmd" in the code refer to the command the 1987c478bd9Sstevel@tonic-gate * user is currently trying to complete. types and cmds take 1997c478bd9Sstevel@tonic-gate * on the same values. 2007c478bd9Sstevel@tonic-gate */ 2017c478bd9Sstevel@tonic-gate #define ap_type ap_common.apc_cmd 2027c478bd9Sstevel@tonic-gate #define ap_major ap_common.apc_major 2037c478bd9Sstevel@tonic-gate #define ap_minor ap_common.apc_minor 2047c478bd9Sstevel@tonic-gate #define ap_lastminor ap_common.apc_lastminor 2057c478bd9Sstevel@tonic-gate #define ap_npush ap_common.apc_npush 2067c478bd9Sstevel@tonic-gate #define ap_anchor ap_data.apd_anchor 2077c478bd9Sstevel@tonic-gate 2087c478bd9Sstevel@tonic-gate /* 2097c478bd9Sstevel@tonic-gate * function prototypes 2107c478bd9Sstevel@tonic-gate */ 2117c478bd9Sstevel@tonic-gate #ifdef C2_AUDIT 2127c478bd9Sstevel@tonic-gate void audit_stropen(struct vnode *, dev_t *, int, cred_t *); 2137c478bd9Sstevel@tonic-gate void audit_strclose(struct vnode *, int, cred_t *); 2147c478bd9Sstevel@tonic-gate void audit_strioctl(struct vnode *, int, intptr_t, int, int, cred_t *, int *); 2157c478bd9Sstevel@tonic-gate struct strbuf; 2167c478bd9Sstevel@tonic-gate void audit_strputmsg(struct vnode *, struct strbuf *, struct strbuf *, 2177c478bd9Sstevel@tonic-gate unsigned char, int, int); 2187c478bd9Sstevel@tonic-gate void audit_fdsend(int, struct file *, int); 2197c478bd9Sstevel@tonic-gate void audit_fdrecv(int, struct file *); 2207c478bd9Sstevel@tonic-gate #endif 2217c478bd9Sstevel@tonic-gate 222*f4b3ec61Sdh155122 extern void sad_initspace(str_stack_t *); 223*f4b3ec61Sdh155122 extern void sad_freespace(str_stack_t *); 2247c478bd9Sstevel@tonic-gate 2251110f384Sedp /* 226*f4b3ec61Sdh155122 * The following interfaces do not care about ss_sad_lock. 2271110f384Sedp */ 2281110f384Sedp extern struct autopush *sad_ap_alloc(void); 2291110f384Sedp extern int sad_apc_verify(struct apcommon *); 2301110f384Sedp extern int sad_ap_verify(struct autopush *); 2311110f384Sedp 2321110f384Sedp /* 233*f4b3ec61Sdh155122 * The following interfaces attempt to acquire ss_sad_lock. 2341110f384Sedp */ 235*f4b3ec61Sdh155122 extern void sad_ap_rele(struct autopush *, str_stack_t *); 236*f4b3ec61Sdh155122 extern struct autopush *sad_ap_find_by_dev(dev_t, str_stack_t *); 2371110f384Sedp 2381110f384Sedp /* 239*f4b3ec61Sdh155122 * The following interfaces require ss_sad_lock to be held when invoked. 2401110f384Sedp */ 241*f4b3ec61Sdh155122 extern void sad_ap_insert(struct autopush *, str_stack_t *); 242*f4b3ec61Sdh155122 extern void sad_ap_remove(struct autopush *, str_stack_t *); 243*f4b3ec61Sdh155122 extern struct autopush *sad_ap_find(struct apcommon *, str_stack_t *); 2441110f384Sedp 2457c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 2467c478bd9Sstevel@tonic-gate 2477c478bd9Sstevel@tonic-gate #ifdef __cplusplus 2487c478bd9Sstevel@tonic-gate } 2497c478bd9Sstevel@tonic-gate #endif 2507c478bd9Sstevel@tonic-gate 2517c478bd9Sstevel@tonic-gate #endif /* _SYS_SAD_H */ 252