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