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