1*0Sstevel@tonic-gate /* 2*0Sstevel@tonic-gate * CDDL HEADER START 3*0Sstevel@tonic-gate * 4*0Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*0Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*0Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*0Sstevel@tonic-gate * with the License. 8*0Sstevel@tonic-gate * 9*0Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*0Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*0Sstevel@tonic-gate * See the License for the specific language governing permissions 12*0Sstevel@tonic-gate * and limitations under the License. 13*0Sstevel@tonic-gate * 14*0Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*0Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*0Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*0Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*0Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*0Sstevel@tonic-gate * 20*0Sstevel@tonic-gate * CDDL HEADER END 21*0Sstevel@tonic-gate */ 22*0Sstevel@tonic-gate /* 23*0Sstevel@tonic-gate * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 24*0Sstevel@tonic-gate * Use is subject to license terms. 25*0Sstevel@tonic-gate */ 26*0Sstevel@tonic-gate 27*0Sstevel@tonic-gate #ifndef _SYS_DEVPOLICY_H 28*0Sstevel@tonic-gate #define _SYS_DEVPOLICY_H 29*0Sstevel@tonic-gate 30*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 31*0Sstevel@tonic-gate 32*0Sstevel@tonic-gate #include <sys/types.h> 33*0Sstevel@tonic-gate #include <sys/priv.h> 34*0Sstevel@tonic-gate #include <sys/param.h> 35*0Sstevel@tonic-gate #include <sys/vnode.h> 36*0Sstevel@tonic-gate 37*0Sstevel@tonic-gate #ifdef __cplusplus 38*0Sstevel@tonic-gate extern "C" { 39*0Sstevel@tonic-gate #endif 40*0Sstevel@tonic-gate 41*0Sstevel@tonic-gate /* 42*0Sstevel@tonic-gate * Device policy system call interface data structure. 43*0Sstevel@tonic-gate * 44*0Sstevel@tonic-gate * Inside the kernel we only make the structure definition available when the 45*0Sstevel@tonic-gate * privilege set definition is complete, i.e., something included 46*0Sstevel@tonic-gate * <sys/priv_const.h> before including this file. 47*0Sstevel@tonic-gate */ 48*0Sstevel@tonic-gate 49*0Sstevel@tonic-gate typedef struct devplcysys devplcysys_t; 50*0Sstevel@tonic-gate 51*0Sstevel@tonic-gate #if defined(__PRIV_CONST_IMPL) || !defined(_KERNEL) 52*0Sstevel@tonic-gate 53*0Sstevel@tonic-gate struct devplcysys { 54*0Sstevel@tonic-gate major_t dps_maj; /* major number */ 55*0Sstevel@tonic-gate minor_t dps_lomin; /* low minor number, if known */ 56*0Sstevel@tonic-gate minor_t dps_himin; /* high minor number, if known */ 57*0Sstevel@tonic-gate char dps_minornm[MAXNAMELEN]; /* minor name/pattern */ 58*0Sstevel@tonic-gate boolean_t dps_isblock; /* expanded device is a block dev */ 59*0Sstevel@tonic-gate #ifdef _KERNEL 60*0Sstevel@tonic-gate priv_set_t dps_rdp; /* privileges required for reading */ 61*0Sstevel@tonic-gate priv_set_t dps_wrp; /* privileges required for writing */ 62*0Sstevel@tonic-gate #else 63*0Sstevel@tonic-gate priv_chunk_t dps_sets[1]; /* read/write privilege sets */ 64*0Sstevel@tonic-gate #endif 65*0Sstevel@tonic-gate }; 66*0Sstevel@tonic-gate 67*0Sstevel@tonic-gate #ifdef _KERNEL 68*0Sstevel@tonic-gate /* 69*0Sstevel@tonic-gate * The actual device policy structure. This is returned on table 70*0Sstevel@tonic-gate * lookups. 71*0Sstevel@tonic-gate */ 72*0Sstevel@tonic-gate struct devplcy { 73*0Sstevel@tonic-gate uint32_t dp_ref; /* Reference count */ 74*0Sstevel@tonic-gate uint32_t dp_gen; /* Generation count */ 75*0Sstevel@tonic-gate priv_set_t dp_rdp; /* Privileges required for reading */ 76*0Sstevel@tonic-gate priv_set_t dp_wrp; /* Privileges required for writing */ 77*0Sstevel@tonic-gate }; 78*0Sstevel@tonic-gate #endif /* _KERNEL */ 79*0Sstevel@tonic-gate 80*0Sstevel@tonic-gate #endif /* __PRIV_CONST_IMPL || !_KERNEL */ 81*0Sstevel@tonic-gate 82*0Sstevel@tonic-gate #ifdef _KERNEL 83*0Sstevel@tonic-gate 84*0Sstevel@tonic-gate typedef struct devplcy devplcy_t; 85*0Sstevel@tonic-gate 86*0Sstevel@tonic-gate extern devplcy_t *nullpolicy; /* The null policy */ 87*0Sstevel@tonic-gate 88*0Sstevel@tonic-gate extern volatile uint32_t devplcy_gen; /* The current generation count */ 89*0Sstevel@tonic-gate 90*0Sstevel@tonic-gate extern devplcy_t *dpget(void); 91*0Sstevel@tonic-gate extern void dphold(devplcy_t *); 92*0Sstevel@tonic-gate extern void dpfree(devplcy_t *); 93*0Sstevel@tonic-gate extern devplcy_t *devpolicy_find(vnode_t *); 94*0Sstevel@tonic-gate 95*0Sstevel@tonic-gate extern void devpolicy_init(void); 96*0Sstevel@tonic-gate extern int devpolicy_load(int, size_t, devplcysys_t *); 97*0Sstevel@tonic-gate extern int devpolicy_get(int *, size_t, devplcysys_t *); 98*0Sstevel@tonic-gate extern int devpolicy_getbyname(size_t, devplcysys_t *, char *); 99*0Sstevel@tonic-gate 100*0Sstevel@tonic-gate extern devplcy_t *devpolicy_priv_by_name(const char *, const char *); 101*0Sstevel@tonic-gate 102*0Sstevel@tonic-gate #else /* _KERNEL */ 103*0Sstevel@tonic-gate #define DEVPLCYSYS_SZ(ip) (sizeof (devplcysys_t) + \ 104*0Sstevel@tonic-gate ((ip)->priv_setsize * 2 - 1) * \ 105*0Sstevel@tonic-gate sizeof (priv_chunk_t)) 106*0Sstevel@tonic-gate #define DEVPLCYSYS_RDP(dp, ip) ((priv_set_t *)(&(dp)->dps_sets[0])) 107*0Sstevel@tonic-gate #define DEVPLCYSYS_WRP(dp, ip) \ 108*0Sstevel@tonic-gate ((priv_set_t *)(&(dp)->dps_sets[(ip)->priv_setsize])) 109*0Sstevel@tonic-gate 110*0Sstevel@tonic-gate #define DEVPLCY_TKN_RDP "read_priv_set" 111*0Sstevel@tonic-gate #define DEVPLCY_TKN_WRP "write_priv_set" 112*0Sstevel@tonic-gate 113*0Sstevel@tonic-gate #endif /* _KERNEL */ 114*0Sstevel@tonic-gate 115*0Sstevel@tonic-gate #define MAXDEVPOLICY 1000 116*0Sstevel@tonic-gate #define DEVPOLICY_DFLT_MAJ ((major_t)~0) 117*0Sstevel@tonic-gate 118*0Sstevel@tonic-gate #ifdef __cplusplus 119*0Sstevel@tonic-gate } 120*0Sstevel@tonic-gate #endif 121*0Sstevel@tonic-gate 122*0Sstevel@tonic-gate #endif /* _SYS_DEVPOLICY_H */ 123