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