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