acpi: Narrow workaround for broken interrupt settings
[dragonfly.git] / sys / sys / ucred.h
blob1e426dd8f936defa80b5803dc3069ce6da549cf3
1 /*
2 * Copyright (c) 1989, 1993
3 * The Regents of the University of California. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. Neither the name of the University nor the names of its contributors
14 * may be used to endorse or promote products derived from this software
15 * without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
29 * @(#)ucred.h 8.4 (Berkeley) 1/9/95
30 * $FreeBSD: src/sys/sys/ucred.h,v 1.14.2.5 2002/03/09 05:20:25 dd Exp $
31 * $DragonFly: src/sys/sys/ucred.h,v 1.9 2007/01/08 21:32:57 corecode Exp $
34 #ifndef _SYS_UCRED_H_
35 #define _SYS_UCRED_H_
37 #ifndef _SYS_TYPES_H_
38 #include <sys/types.h>
39 #endif
40 #ifndef _SYS_PARAM_H_
41 #include <sys/param.h>
42 #endif
43 #ifndef _SYS_CAPS_H_
44 #include <sys/caps.h>
45 #endif
46 #ifndef _SYS_SPINLOCK_H_
47 #include <sys/spinlock.h>
48 #endif
50 struct prison;
53 * Credentials.
55 * Please do not inspect cr_uid directly to determine superuserness.
56 * Only the priv(9) functions should be used for this.
58 * NOTE: Creds are accessed a lot, and cr_ref is also adjusted a lot.
59 * This can ping-pong fields in its cache line that are otherwise
60 * read-only. To solve this problem we note that even in really
61 * busy systems, ucred isn't replicated a whole lot. So put
62 * the blasted cr_ref in its own cache line.
64 struct ucred {
65 struct {
66 long cr_ref; /* reference count */
67 } __cachealign;
68 uid_t cr_uid; /* effective user id */
69 short cr_ngroups; /* number of groups */
70 gid_t cr_groups[NGROUPS]; /* groups */
71 struct uidinfo *cr_uidinfo; /* per uid resource consumption */
72 struct uidinfo *cr_ruidinfo; /* per ruid resource consumption */
73 struct prison *cr_prison; /* prison info */
74 uid_t cr_ruid; /* Real user id. */
75 uid_t cr_svuid; /* Saved effective user id. */
76 gid_t cr_rgid; /* Real group id. */
77 gid_t cr_svgid; /* Saved effective group id. */
78 __syscaps_t cr_caps; /* System restrictions */
79 } __cachealign;
81 #define cr_gid cr_groups[0]
82 #define NOCRED ((struct ucred *)0) /* no credential available */
83 #define FSCRED ((struct ucred *)-1) /* filesystem credential */
86 * This is the external representation of struct ucred, based upon the
87 * size of a 4.2-RELEASE struct ucred. There will probably never be
88 * any need to change the size of this or layout of its used fields.
90 struct xucred {
91 u_int cr_version; /* structure layout version */
92 uid_t cr_uid; /* effective user id */
93 short cr_ngroups; /* number of groups */
94 gid_t cr_groups[NGROUPS]; /* groups */
95 void *_cr_unused1; /* compatibility with old ucred */
97 #define XUCRED_VERSION 0
99 #ifdef _KERNEL
101 struct proc;
103 struct ucred *change_euid (uid_t euid);
104 struct ucred *change_ruid (uid_t ruid);
105 struct ucred *cratom (struct ucred **pcr);
106 struct ucred *cratom_proc (struct proc *p);
107 struct ucred *crcopy (struct ucred *cr);
108 struct ucred *crdup (struct ucred *cr);
109 struct ucred *crdup_nocaps (struct ucred *cr);
110 void crfree (struct ucred *cr);
111 struct ucred *crget (void);
112 struct ucred *crhold (struct ucred *cr);
113 void cru2x (struct ucred *cr, struct xucred *xcr);
114 int groupmember (gid_t gid, struct ucred *cred);
115 #endif /* _KERNEL */
117 #endif /* !_SYS_UCRED_H_ */