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 2004 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 #ifndef _SYS_DEVPOLICY_H 28*7c478bd9Sstevel@tonic-gate #define _SYS_DEVPOLICY_H 29*7c478bd9Sstevel@tonic-gate 30*7c478bd9Sstevel@tonic-gate #include <sys/types.h> 31*7c478bd9Sstevel@tonic-gate #include <sys/priv.h> 32*7c478bd9Sstevel@tonic-gate #include <sys/param.h> 33*7c478bd9Sstevel@tonic-gate #include <sys/vnode.h> 34*7c478bd9Sstevel@tonic-gate 35*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 36*7c478bd9Sstevel@tonic-gate extern "C" { 37*7c478bd9Sstevel@tonic-gate #endif 38*7c478bd9Sstevel@tonic-gate 39*7c478bd9Sstevel@tonic-gate /* 40*7c478bd9Sstevel@tonic-gate * Device policy system call interface data structure. 41*7c478bd9Sstevel@tonic-gate * 42*7c478bd9Sstevel@tonic-gate * Inside the kernel we only make the structure definition available when the 43*7c478bd9Sstevel@tonic-gate * privilege set definition is complete, i.e., something included 44*7c478bd9Sstevel@tonic-gate * <sys/priv_const.h> before including this file. 45*7c478bd9Sstevel@tonic-gate */ 46*7c478bd9Sstevel@tonic-gate 47*7c478bd9Sstevel@tonic-gate typedef struct devplcysys devplcysys_t; 48*7c478bd9Sstevel@tonic-gate 49*7c478bd9Sstevel@tonic-gate #if defined(__PRIV_CONST_IMPL) || !defined(_KERNEL) 50*7c478bd9Sstevel@tonic-gate 51*7c478bd9Sstevel@tonic-gate struct devplcysys { 52*7c478bd9Sstevel@tonic-gate major_t dps_maj; /* major number */ 53*7c478bd9Sstevel@tonic-gate minor_t dps_lomin; /* low minor number, if known */ 54*7c478bd9Sstevel@tonic-gate minor_t dps_himin; /* high minor number, if known */ 55*7c478bd9Sstevel@tonic-gate char dps_minornm[MAXNAMELEN]; /* minor name/pattern */ 56*7c478bd9Sstevel@tonic-gate boolean_t dps_isblock; /* expanded device is a block dev */ 57*7c478bd9Sstevel@tonic-gate #ifdef _KERNEL 58*7c478bd9Sstevel@tonic-gate priv_set_t dps_rdp; /* privileges required for reading */ 59*7c478bd9Sstevel@tonic-gate priv_set_t dps_wrp; /* privileges required for writing */ 60*7c478bd9Sstevel@tonic-gate #else 61*7c478bd9Sstevel@tonic-gate priv_chunk_t dps_sets[1]; /* read/write privilege sets */ 62*7c478bd9Sstevel@tonic-gate #endif 63*7c478bd9Sstevel@tonic-gate }; 64*7c478bd9Sstevel@tonic-gate 65*7c478bd9Sstevel@tonic-gate #ifdef _KERNEL 66*7c478bd9Sstevel@tonic-gate /* 67*7c478bd9Sstevel@tonic-gate * The actual device policy structure. This is returned on table 68*7c478bd9Sstevel@tonic-gate * lookups. 69*7c478bd9Sstevel@tonic-gate */ 70*7c478bd9Sstevel@tonic-gate struct devplcy { 71*7c478bd9Sstevel@tonic-gate uint32_t dp_ref; /* Reference count */ 72*7c478bd9Sstevel@tonic-gate uint32_t dp_gen; /* Generation count */ 73*7c478bd9Sstevel@tonic-gate priv_set_t dp_rdp; /* Privileges required for reading */ 74*7c478bd9Sstevel@tonic-gate priv_set_t dp_wrp; /* Privileges required for writing */ 75*7c478bd9Sstevel@tonic-gate }; 76*7c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 77*7c478bd9Sstevel@tonic-gate 78*7c478bd9Sstevel@tonic-gate #endif /* __PRIV_CONST_IMPL || !_KERNEL */ 79*7c478bd9Sstevel@tonic-gate 80*7c478bd9Sstevel@tonic-gate #ifdef _KERNEL 81*7c478bd9Sstevel@tonic-gate 82*7c478bd9Sstevel@tonic-gate typedef struct devplcy devplcy_t; 83*7c478bd9Sstevel@tonic-gate 84*7c478bd9Sstevel@tonic-gate extern devplcy_t *nullpolicy; /* The null policy */ 85*7c478bd9Sstevel@tonic-gate 86*7c478bd9Sstevel@tonic-gate extern volatile uint32_t devplcy_gen; /* The current generation count */ 87*7c478bd9Sstevel@tonic-gate 88*7c478bd9Sstevel@tonic-gate extern devplcy_t *dpget(void); 89*7c478bd9Sstevel@tonic-gate extern void dphold(devplcy_t *); 90*7c478bd9Sstevel@tonic-gate extern void dpfree(devplcy_t *); 91*7c478bd9Sstevel@tonic-gate extern devplcy_t *devpolicy_find(vnode_t *); 92*7c478bd9Sstevel@tonic-gate 93*7c478bd9Sstevel@tonic-gate extern void devpolicy_init(void); 94*7c478bd9Sstevel@tonic-gate extern int devpolicy_load(int, size_t, devplcysys_t *); 95*7c478bd9Sstevel@tonic-gate extern int devpolicy_get(int *, size_t, devplcysys_t *); 96*7c478bd9Sstevel@tonic-gate extern int devpolicy_getbyname(size_t, devplcysys_t *, char *); 97*7c478bd9Sstevel@tonic-gate 98*7c478bd9Sstevel@tonic-gate extern devplcy_t *devpolicy_priv_by_name(const char *, const char *); 99*7c478bd9Sstevel@tonic-gate 100*7c478bd9Sstevel@tonic-gate #else /* _KERNEL */ 101*7c478bd9Sstevel@tonic-gate #define DEVPLCYSYS_SZ(ip) (sizeof (devplcysys_t) + \ 102*7c478bd9Sstevel@tonic-gate ((ip)->priv_setsize * 2 - 1) * \ 103*7c478bd9Sstevel@tonic-gate sizeof (priv_chunk_t)) 104*7c478bd9Sstevel@tonic-gate #define DEVPLCYSYS_RDP(dp, ip) ((priv_set_t *)(&(dp)->dps_sets[0])) 105*7c478bd9Sstevel@tonic-gate #define DEVPLCYSYS_WRP(dp, ip) \ 106*7c478bd9Sstevel@tonic-gate ((priv_set_t *)(&(dp)->dps_sets[(ip)->priv_setsize])) 107*7c478bd9Sstevel@tonic-gate 108*7c478bd9Sstevel@tonic-gate #define DEVPLCY_TKN_RDP "read_priv_set" 109*7c478bd9Sstevel@tonic-gate #define DEVPLCY_TKN_WRP "write_priv_set" 110*7c478bd9Sstevel@tonic-gate 111*7c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 112*7c478bd9Sstevel@tonic-gate 113*7c478bd9Sstevel@tonic-gate #define MAXDEVPOLICY 1000 114*7c478bd9Sstevel@tonic-gate #define DEVPOLICY_DFLT_MAJ ((major_t)~0) 115*7c478bd9Sstevel@tonic-gate 116*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 117*7c478bd9Sstevel@tonic-gate } 118*7c478bd9Sstevel@tonic-gate #endif 119*7c478bd9Sstevel@tonic-gate 120*7c478bd9Sstevel@tonic-gate #endif /* _SYS_DEVPOLICY_H */ 121