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*4a0fa546SMarek Pospisil * Copyright (c) 1988, 2010, Oracle and/or its affiliates. All rights reserved. 237c478bd9Sstevel@tonic-gate */ 247c478bd9Sstevel@tonic-gate 257c478bd9Sstevel@tonic-gate /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 267c478bd9Sstevel@tonic-gate /* All Rights Reserved */ 277c478bd9Sstevel@tonic-gate 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate #ifndef _SYS_SAD_H 307c478bd9Sstevel@tonic-gate #define _SYS_SAD_H 317c478bd9Sstevel@tonic-gate 327c478bd9Sstevel@tonic-gate #include <sys/types.h> 33f4b3ec61Sdh155122 #ifdef _KERNEL 34f4b3ec61Sdh155122 #include <sys/strsubr.h> 35f4b3ec61Sdh155122 #endif 361110f384Sedp #include <sys/modhash.h> 377c478bd9Sstevel@tonic-gate 387c478bd9Sstevel@tonic-gate #ifdef __cplusplus 397c478bd9Sstevel@tonic-gate extern "C" { 407c478bd9Sstevel@tonic-gate #endif 417c478bd9Sstevel@tonic-gate 427c478bd9Sstevel@tonic-gate /* 437c478bd9Sstevel@tonic-gate * Streams Administrative Driver 447c478bd9Sstevel@tonic-gate */ 457c478bd9Sstevel@tonic-gate 467c478bd9Sstevel@tonic-gate /* 477c478bd9Sstevel@tonic-gate * As time has passed, it has become necessary to add members to some 487c478bd9Sstevel@tonic-gate * of the structures passed downstream with these ioctls. Currently, 497c478bd9Sstevel@tonic-gate * only the SAD_GAP/SAD_SAP ioctls are versioned, (which use the 507c478bd9Sstevel@tonic-gate * strapush structure), but the versioning mechanism is general enough 517c478bd9Sstevel@tonic-gate * to be applied to any SAD ioctls. This is done by repartitioning 527c478bd9Sstevel@tonic-gate * the SAD ioctl namespace to include a version number in addition to 537c478bd9Sstevel@tonic-gate * the command (see below). 547c478bd9Sstevel@tonic-gate * 557c478bd9Sstevel@tonic-gate * In the case of the SAD_GAP/SAD_SAP ioctls, an application can 567c478bd9Sstevel@tonic-gate * choose which "version" of the ioctl to use by #defining AP_VERSION 577c478bd9Sstevel@tonic-gate * before including this file. Old code implicitly has AP_VERSION set 587c478bd9Sstevel@tonic-gate * to 0, and even newly compiled code defaults to an AP_VERSION of 0, 597c478bd9Sstevel@tonic-gate * since it may not be aware of the new structure members and 607c478bd9Sstevel@tonic-gate * therefore not know to set them to reasonable values. In order for 617c478bd9Sstevel@tonic-gate * programs to make use of a newer version, they must explicitly 627c478bd9Sstevel@tonic-gate * #define AP_VERSION to the appropriate value. Note that the kernel 637c478bd9Sstevel@tonic-gate * always defaults to the latest version, since it is internally 647c478bd9Sstevel@tonic-gate * self-consistent. 657c478bd9Sstevel@tonic-gate */ 667c478bd9Sstevel@tonic-gate #ifndef AP_VERSION 677c478bd9Sstevel@tonic-gate #ifdef _KERNEL 687c478bd9Sstevel@tonic-gate #define AP_VERSION 1 /* latest version */ 697c478bd9Sstevel@tonic-gate #else 707c478bd9Sstevel@tonic-gate #define AP_VERSION 0 /* SVR4 version */ 717c478bd9Sstevel@tonic-gate #endif 727c478bd9Sstevel@tonic-gate #endif 737c478bd9Sstevel@tonic-gate 747c478bd9Sstevel@tonic-gate /* 757c478bd9Sstevel@tonic-gate * ioctl defines 767c478bd9Sstevel@tonic-gate * 777c478bd9Sstevel@tonic-gate * The layout for the low 16 bits is 01000101VVVVCCCC, where the 787c478bd9Sstevel@tonic-gate * first bitpattern is `D' in binary, followed by a 4 bit version 797c478bd9Sstevel@tonic-gate * field (limiting the number of versions to 16), followed by a 807c478bd9Sstevel@tonic-gate * 4 bit command field (limiting the number of commands to 16). 817c478bd9Sstevel@tonic-gate */ 827c478bd9Sstevel@tonic-gate #define SADIOC ('D' << 8) 837c478bd9Sstevel@tonic-gate #define SAD_SAP (SADIOC|AP_VERSION << 4|01) 847c478bd9Sstevel@tonic-gate #define SAD_GAP (SADIOC|AP_VERSION << 4|02) 857c478bd9Sstevel@tonic-gate #define SAD_VML (SADIOC|03) /* validate module list */ 867c478bd9Sstevel@tonic-gate 877c478bd9Sstevel@tonic-gate /* 887c478bd9Sstevel@tonic-gate * Device naming and numbering conventions. 897c478bd9Sstevel@tonic-gate */ 907c478bd9Sstevel@tonic-gate #define USERDEV "/dev/sad/user" 917c478bd9Sstevel@tonic-gate #define ADMINDEV "/dev/sad/admin" 927c478bd9Sstevel@tonic-gate 937c478bd9Sstevel@tonic-gate #define USRMIN 0 947c478bd9Sstevel@tonic-gate #define ADMMIN 1 957c478bd9Sstevel@tonic-gate 967c478bd9Sstevel@tonic-gate /* 977c478bd9Sstevel@tonic-gate * The maximum modules you can push on a stream using the autopush 987c478bd9Sstevel@tonic-gate * feature. This should be less than NSTRPUSH. 997c478bd9Sstevel@tonic-gate */ 1007c478bd9Sstevel@tonic-gate #define MAXAPUSH 8 1017c478bd9Sstevel@tonic-gate 1027c478bd9Sstevel@tonic-gate /* 1037c478bd9Sstevel@tonic-gate * autopush info common to user and kernel 1047c478bd9Sstevel@tonic-gate */ 1057c478bd9Sstevel@tonic-gate struct apcommon { 1067c478bd9Sstevel@tonic-gate uint_t apc_cmd; /* command (see below) */ 1077c478bd9Sstevel@tonic-gate major_t apc_major; /* major # of device */ 1087c478bd9Sstevel@tonic-gate minor_t apc_minor; /* minor # of device */ 1097c478bd9Sstevel@tonic-gate minor_t apc_lastminor; /* last minor for range */ 1107c478bd9Sstevel@tonic-gate uint_t apc_npush; /* number of modules to push */ 1117c478bd9Sstevel@tonic-gate }; 1127c478bd9Sstevel@tonic-gate 1137c478bd9Sstevel@tonic-gate /* 1147c478bd9Sstevel@tonic-gate * New autopush information structure. This wouldn't be necessary 1157c478bd9Sstevel@tonic-gate * except `struct apcommon' wasn't defined last in the `strapush' 1167c478bd9Sstevel@tonic-gate * structure, making it difficult to grow the structure without 1177c478bd9Sstevel@tonic-gate * breaking binary compatibility. Note that new members can be added 1187c478bd9Sstevel@tonic-gate * to this structure in the future, at which point AP_VERSION should 1197c478bd9Sstevel@tonic-gate * be incremented (of course, a new STRAPUSH_Vx_LEN macro should be 1207c478bd9Sstevel@tonic-gate * added and sad.c should be changed to handle the new member). 1217c478bd9Sstevel@tonic-gate */ 1227c478bd9Sstevel@tonic-gate struct apdata { 1237c478bd9Sstevel@tonic-gate uint_t apd_anchor; /* position of anchor in stream */ 1247c478bd9Sstevel@tonic-gate }; 1257c478bd9Sstevel@tonic-gate 1267c478bd9Sstevel@tonic-gate /* 1277c478bd9Sstevel@tonic-gate * ap_cmd: various flavors of autopush 1287c478bd9Sstevel@tonic-gate */ 1297c478bd9Sstevel@tonic-gate #define SAP_CLEAR 0 /* remove configuration list */ 1307c478bd9Sstevel@tonic-gate #define SAP_ONE 1 /* configure one minor device */ 1317c478bd9Sstevel@tonic-gate #define SAP_RANGE 2 /* configure range of minor devices */ 1327c478bd9Sstevel@tonic-gate #define SAP_ALL 3 /* configure all minor devices */ 1337c478bd9Sstevel@tonic-gate 1347c478bd9Sstevel@tonic-gate /* 1357c478bd9Sstevel@tonic-gate * format for autopush ioctls 1367c478bd9Sstevel@tonic-gate */ 1377c478bd9Sstevel@tonic-gate struct strapush { 1387c478bd9Sstevel@tonic-gate struct apcommon sap_common; /* see above */ 1397c478bd9Sstevel@tonic-gate char sap_list[MAXAPUSH][FMNAMESZ + 1]; /* module list */ 1407c478bd9Sstevel@tonic-gate #if AP_VERSION > 0 1417c478bd9Sstevel@tonic-gate struct apdata sap_data; /* see above */ 1427c478bd9Sstevel@tonic-gate #endif 1437c478bd9Sstevel@tonic-gate }; 1447c478bd9Sstevel@tonic-gate 1457c478bd9Sstevel@tonic-gate #define sap_cmd sap_common.apc_cmd 1467c478bd9Sstevel@tonic-gate #define sap_major sap_common.apc_major 1477c478bd9Sstevel@tonic-gate #define sap_minor sap_common.apc_minor 1487c478bd9Sstevel@tonic-gate #define sap_lastminor sap_common.apc_lastminor 1497c478bd9Sstevel@tonic-gate #define sap_npush sap_common.apc_npush 1507c478bd9Sstevel@tonic-gate #define sap_anchor sap_data.apd_anchor 1517c478bd9Sstevel@tonic-gate 1527c478bd9Sstevel@tonic-gate #ifdef _KERNEL 1537c478bd9Sstevel@tonic-gate 1547c478bd9Sstevel@tonic-gate /* 1557c478bd9Sstevel@tonic-gate * state values for ioctls 1567c478bd9Sstevel@tonic-gate */ 1577c478bd9Sstevel@tonic-gate #define GETSTRUCT 1 1587c478bd9Sstevel@tonic-gate #define GETRESULT 2 1597c478bd9Sstevel@tonic-gate #define GETLIST 3 1607c478bd9Sstevel@tonic-gate 1617c478bd9Sstevel@tonic-gate #define SAD_VER(ioccmd) (((ioccmd) >> 4) & 0x0f) 1627c478bd9Sstevel@tonic-gate #define SAD_CMD(ioccmd) ((ioccmd) & ~0xf0) 1637c478bd9Sstevel@tonic-gate 1647c478bd9Sstevel@tonic-gate #define STRAPUSH_V0_LEN (size_t)(&((struct strapush *)0)->sap_data) 1657c478bd9Sstevel@tonic-gate #define STRAPUSH_V1_LEN (size_t)(STRAPUSH_V0_LEN + sizeof (uint_t)) 1667c478bd9Sstevel@tonic-gate 1677c478bd9Sstevel@tonic-gate struct saddev { 1687c478bd9Sstevel@tonic-gate queue_t *sa_qp; /* pointer to read queue */ 1697c478bd9Sstevel@tonic-gate caddr_t sa_addr; /* saved address for copyout */ 1707c478bd9Sstevel@tonic-gate int sa_flags; /* see below */ 171f4b3ec61Sdh155122 str_stack_t *sa_ss; 1727c478bd9Sstevel@tonic-gate }; 1737c478bd9Sstevel@tonic-gate 1747c478bd9Sstevel@tonic-gate /* 1757c478bd9Sstevel@tonic-gate * values for saddev flags field. 1767c478bd9Sstevel@tonic-gate */ 1777c478bd9Sstevel@tonic-gate #define SADPRIV 0x01 1787c478bd9Sstevel@tonic-gate 1797c478bd9Sstevel@tonic-gate /* 1807c478bd9Sstevel@tonic-gate * Module Autopush Cache 1817c478bd9Sstevel@tonic-gate */ 1827c478bd9Sstevel@tonic-gate struct autopush { 1837c478bd9Sstevel@tonic-gate struct apcommon ap_common; /* see above */ 1847c478bd9Sstevel@tonic-gate char ap_list[MAXAPUSH][FMNAMESZ + 1]; 1857c478bd9Sstevel@tonic-gate /* list of modules to push */ 1867c478bd9Sstevel@tonic-gate int ap_cnt; /* in use count */ 1877c478bd9Sstevel@tonic-gate struct apdata ap_data; /* see above */ 1887c478bd9Sstevel@tonic-gate }; 1897c478bd9Sstevel@tonic-gate 1907c478bd9Sstevel@tonic-gate /* 1917c478bd9Sstevel@tonic-gate * The command issued by the user ultimately becomes 1927c478bd9Sstevel@tonic-gate * the type of the autopush entry. Therefore, occurrences of 1937c478bd9Sstevel@tonic-gate * "type" in the code refer to an existing autopush entry. 1947c478bd9Sstevel@tonic-gate * Occurrences of "cmd" in the code refer to the command the 1957c478bd9Sstevel@tonic-gate * user is currently trying to complete. types and cmds take 1967c478bd9Sstevel@tonic-gate * on the same values. 1977c478bd9Sstevel@tonic-gate */ 1987c478bd9Sstevel@tonic-gate #define ap_type ap_common.apc_cmd 1997c478bd9Sstevel@tonic-gate #define ap_major ap_common.apc_major 2007c478bd9Sstevel@tonic-gate #define ap_minor ap_common.apc_minor 2017c478bd9Sstevel@tonic-gate #define ap_lastminor ap_common.apc_lastminor 2027c478bd9Sstevel@tonic-gate #define ap_npush ap_common.apc_npush 2037c478bd9Sstevel@tonic-gate #define ap_anchor ap_data.apd_anchor 2047c478bd9Sstevel@tonic-gate 2057c478bd9Sstevel@tonic-gate /* 2067c478bd9Sstevel@tonic-gate * function prototypes 2077c478bd9Sstevel@tonic-gate */ 2087c478bd9Sstevel@tonic-gate struct strbuf; 2097c478bd9Sstevel@tonic-gate void audit_strputmsg(struct vnode *, struct strbuf *, struct strbuf *, 2107c478bd9Sstevel@tonic-gate unsigned char, int, int); 2117c478bd9Sstevel@tonic-gate void audit_fdsend(int, struct file *, int); 2127c478bd9Sstevel@tonic-gate void audit_fdrecv(int, struct file *); 2137c478bd9Sstevel@tonic-gate 214f4b3ec61Sdh155122 extern void sad_initspace(str_stack_t *); 215f4b3ec61Sdh155122 extern void sad_freespace(str_stack_t *); 2167c478bd9Sstevel@tonic-gate 2171110f384Sedp /* 218f4b3ec61Sdh155122 * The following interfaces do not care about ss_sad_lock. 2191110f384Sedp */ 2201110f384Sedp extern struct autopush *sad_ap_alloc(void); 2211110f384Sedp extern int sad_apc_verify(struct apcommon *); 2221110f384Sedp extern int sad_ap_verify(struct autopush *); 2231110f384Sedp 2241110f384Sedp /* 225f4b3ec61Sdh155122 * The following interfaces attempt to acquire ss_sad_lock. 2261110f384Sedp */ 227f4b3ec61Sdh155122 extern void sad_ap_rele(struct autopush *, str_stack_t *); 228f4b3ec61Sdh155122 extern struct autopush *sad_ap_find_by_dev(dev_t, str_stack_t *); 2291110f384Sedp 2301110f384Sedp /* 231f4b3ec61Sdh155122 * The following interfaces require ss_sad_lock to be held when invoked. 2321110f384Sedp */ 233f4b3ec61Sdh155122 extern void sad_ap_insert(struct autopush *, str_stack_t *); 234f4b3ec61Sdh155122 extern void sad_ap_remove(struct autopush *, str_stack_t *); 235f4b3ec61Sdh155122 extern struct autopush *sad_ap_find(struct apcommon *, str_stack_t *); 2361110f384Sedp 2377c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 2387c478bd9Sstevel@tonic-gate 2397c478bd9Sstevel@tonic-gate #ifdef __cplusplus 2407c478bd9Sstevel@tonic-gate } 2417c478bd9Sstevel@tonic-gate #endif 2427c478bd9Sstevel@tonic-gate 2437c478bd9Sstevel@tonic-gate #endif /* _SYS_SAD_H */ 244