]> git.saurik.com Git - apple/xnu.git/blob - bsd/sys/ipc.h
xnu-792.13.8.tar.gz
[apple/xnu.git] / bsd / sys / ipc.h
1 /*
2 * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_OSREFERENCE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the
10 * License may not be used to create, or enable the creation or
11 * redistribution of, unlawful or unlicensed copies of an Apple operating
12 * system, or to circumvent, violate, or enable the circumvention or
13 * violation of, any terms of an Apple operating system software license
14 * agreement.
15 *
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this
18 * file.
19 *
20 * The Original Code and all software distributed under the License are
21 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
22 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
23 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
25 * Please see the License for the specific language governing rights and
26 * limitations under the License.
27 *
28 * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
29 */
30 /*
31 * Copyright (c) 1988 University of Utah.
32 * Copyright (c) 1990, 1993
33 * The Regents of the University of California. All rights reserved.
34 * (c) UNIX System Laboratories, Inc.
35 * All or some portions of this file are derived from material licensed
36 * to the University of California by American Telephone and Telegraph
37 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
38 * the permission of UNIX System Laboratories, Inc.
39 *
40 * This code is derived from software contributed to Berkeley by
41 * the Systems Programming Group of the University of Utah Computer
42 * Science Department.
43 *
44 * Redistribution and use in source and binary forms, with or without
45 * modification, are permitted provided that the following conditions
46 * are met:
47 * 1. Redistributions of source code must retain the above copyright
48 * notice, this list of conditions and the following disclaimer.
49 * 2. Redistributions in binary form must reproduce the above copyright
50 * notice, this list of conditions and the following disclaimer in the
51 * documentation and/or other materials provided with the distribution.
52 * 3. All advertising materials mentioning features or use of this software
53 * must display the following acknowledgement:
54 * This product includes software developed by the University of
55 * California, Berkeley and its contributors.
56 * 4. Neither the name of the University nor the names of its contributors
57 * may be used to endorse or promote products derived from this software
58 * without specific prior written permission.
59 *
60 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
61 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
62 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
63 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
64 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
65 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
66 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
67 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
68 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
69 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
70 * SUCH DAMAGE.
71 *
72 * @(#)ipc.h 8.4 (Berkeley) 2/19/95
73 */
74
75 /*
76 * SVID compatible ipc.h file
77 */
78 #ifndef _SYS_IPC_H_
79 #define _SYS_IPC_H_
80
81 #include <sys/appleapiopts.h>
82 #include <sys/cdefs.h>
83
84 #include <sys/_types.h>
85
86 /*
87 * [XSI] The uid_t, gid_t, mode_t, and key_t types SHALL be defined as
88 * described in <sys/types.h>.
89 */
90 #ifndef _UID_T
91 typedef __darwin_uid_t uid_t; /* user id */
92 #define _UID_T
93 #endif
94
95 #ifndef _GID_T
96 typedef __darwin_gid_t gid_t;
97 #define _GID_T
98 #endif
99
100 #ifndef _MODE_T
101 typedef __darwin_mode_t mode_t;
102 #define _MODE_T
103 #endif
104
105 #ifndef _KEY_T
106 #define _KEY_T
107 typedef __int32_t key_t;
108 #endif
109
110 /*
111 * Technically, we should force all code references to the new structure
112 * definition, not in just the standards conformance case, and leave the
113 * legacy interface there for binary compatibility only. Currently, we
114 * are only forcing this for programs requesting standards conformance.
115 */
116 #if defined(__POSIX_C_SOURCE) || defined(kernel) || defined(__LP64__)
117 /*
118 * [XSI] Information used in determining permission to perform an IPC
119 * operation
120 */
121 struct __ipc_perm_new {
122 uid_t uid; /* [XSI] Owner's user ID */
123 gid_t gid; /* [XSI] Owner's group ID */
124 uid_t cuid; /* [XSI] Creator's user ID */
125 gid_t cgid; /* [XSI] Creator's group ID */
126 mode_t mode; /* [XSI] Read/write permission */
127 unsigned short _seq; /* Reserved for internal use */
128 key_t _key; /* Reserved for internal use */
129 };
130 #define ipc_perm __ipc_perm_new
131 #else /* !_POSIX_C_SOURCE */
132 #define ipc_perm __ipc_perm_old
133 #endif /* !_POSIX_C_SOURCE */
134
135 #if !defined(__POSIX_C_SOURCE) && !defined(__LP64__)
136 /*
137 * Legacy structure; this structure is maintained for binary backward
138 * compatability with previous versions of the interface. New code
139 * should not use this interface, since ID values may be truncated.
140 */
141 struct __ipc_perm_old {
142 __uint16_t cuid; /* Creator's user ID */
143 __uint16_t cgid; /* Creator's group ID */
144 __uint16_t uid; /* Owner's user ID */
145 __uint16_t gid; /* Owner's group ID */
146 mode_t mode; /* Read/Write permission */
147 __uint16_t seq; /* Reserved for internal use */
148 key_t key; /* Reserved for internal use */
149 };
150 #endif /* !_POSIX_C_SOURCE */
151
152 /*
153 * [XSI] Definitions shall be provided for the following constants:
154 */
155
156 /* Mode bits */
157 #define IPC_CREAT 001000 /* Create entry if key does not exist */
158 #define IPC_EXCL 002000 /* Fail if key exists */
159 #define IPC_NOWAIT 004000 /* Error if request must wait */
160
161 /* Keys */
162 #define IPC_PRIVATE ((key_t)0) /* Private key */
163
164 /* Control commands */
165 #define IPC_RMID 0 /* Remove identifier */
166 #define IPC_SET 1 /* Set options */
167 #define IPC_STAT 2 /* Get options */
168
169
170 #ifndef _POSIX_C_SOURCE
171
172 /* common mode bits */
173 #define IPC_R 000400 /* Read permission */
174 #define IPC_W 000200 /* Write/alter permission */
175 #define IPC_M 010000 /* Modify control info permission */
176
177 #endif /* !_POSIX_C_SOURCE */
178
179
180 #ifdef BSD_KERNEL_PRIVATE
181 /*
182 * Kernel implementation details which should not be utilized by user
183 * space programs.
184 */
185
186 /* Macros to convert between ipc ids and array indices or sequence ids */
187 #define IPCID_TO_IX(id) ((id) & 0xffff)
188 #define IPCID_TO_SEQ(id) (((id) >> 16) & 0xffff)
189 #define IXSEQ_TO_IPCID(ix,perm) (((perm.seq) << 16) | (ix & 0xffff))
190
191 struct ucred;
192
193 int ipcperm(struct ucred *, struct ipc_perm *, int);
194 #endif /* BSD_KERNEL_PRIVATE */
195
196 #ifndef KERNEL
197
198 __BEGIN_DECLS
199 /* [XSI] */
200 key_t ftok(const char *, int);
201 __END_DECLS
202
203 #endif /* !KERNEL */
204
205 #endif /* !_SYS_IPC_H_ */