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