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