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