1*4b276f45Sguenther /* $OpenBSD: ipc.h,v 1.13 2014/11/15 21:42:50 guenther Exp $ */ 2bb63a7f5Sniklas /* $NetBSD: ipc.h,v 1.15 1996/02/09 18:25:12 christos Exp $ */ 3df930be7Sderaadt 4df930be7Sderaadt /* 5df930be7Sderaadt * Copyright (c) 1988 University of Utah. 6df930be7Sderaadt * Copyright (c) 1990, 1993 7df930be7Sderaadt * The Regents of the University of California. All rights reserved. 8df930be7Sderaadt * (c) UNIX System Laboratories, Inc. 9df930be7Sderaadt * All or some portions of this file are derived from material licensed 10df930be7Sderaadt * to the University of California by American Telephone and Telegraph 11df930be7Sderaadt * Co. or Unix System Laboratories, Inc. and are reproduced herein with 12df930be7Sderaadt * the permission of UNIX System Laboratories, Inc. 13df930be7Sderaadt * 14df930be7Sderaadt * This code is derived from software contributed to Berkeley by 15df930be7Sderaadt * the Systems Programming Group of the University of Utah Computer 16df930be7Sderaadt * Science Department. 17df930be7Sderaadt * 18df930be7Sderaadt * Redistribution and use in source and binary forms, with or without 19df930be7Sderaadt * modification, are permitted provided that the following conditions 20df930be7Sderaadt * are met: 21df930be7Sderaadt * 1. Redistributions of source code must retain the above copyright 22df930be7Sderaadt * notice, this list of conditions and the following disclaimer. 23df930be7Sderaadt * 2. Redistributions in binary form must reproduce the above copyright 24df930be7Sderaadt * notice, this list of conditions and the following disclaimer in the 25df930be7Sderaadt * documentation and/or other materials provided with the distribution. 2629295d1cSmillert * 3. Neither the name of the University nor the names of its contributors 27df930be7Sderaadt * may be used to endorse or promote products derived from this software 28df930be7Sderaadt * without specific prior written permission. 29df930be7Sderaadt * 30df930be7Sderaadt * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 31df930be7Sderaadt * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 32df930be7Sderaadt * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 33df930be7Sderaadt * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 34df930be7Sderaadt * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 35df930be7Sderaadt * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 36df930be7Sderaadt * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 37df930be7Sderaadt * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 38df930be7Sderaadt * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 39df930be7Sderaadt * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 40df930be7Sderaadt * SUCH DAMAGE. 41df930be7Sderaadt * 42df930be7Sderaadt * @(#)ipc.h 8.3 (Berkeley) 1/21/94 43df930be7Sderaadt */ 44df930be7Sderaadt 45df930be7Sderaadt /* 46df930be7Sderaadt * SVID compatible ipc.h file 47df930be7Sderaadt */ 48df930be7Sderaadt #ifndef _SYS_IPC_H_ 49df930be7Sderaadt #define _SYS_IPC_H_ 50df930be7Sderaadt 51*4b276f45Sguenther #include <sys/types.h> 52*4b276f45Sguenther 53df930be7Sderaadt struct ipc_perm { 54ba7a5ec6Sderaadt uid_t cuid; /* creator user id */ 55ba7a5ec6Sderaadt gid_t cgid; /* creator group id */ 56ba7a5ec6Sderaadt uid_t uid; /* user id */ 57ba7a5ec6Sderaadt gid_t gid; /* group id */ 58ba7a5ec6Sderaadt mode_t mode; /* r/w permission */ 590c9515ceSderaadt unsigned short seq; /* sequence # (to generate unique msg/sem/shm id) */ 60ba7a5ec6Sderaadt key_t key; /* user specified msg/sem/shm key */ 61ba7a5ec6Sderaadt }; 62ba7a5ec6Sderaadt 63df930be7Sderaadt /* common mode bits */ 64df930be7Sderaadt #define IPC_R 000400 /* read permission */ 65df930be7Sderaadt #define IPC_W 000200 /* write/alter permission */ 66df930be7Sderaadt #define IPC_M 010000 /* permission to change control info */ 67df930be7Sderaadt 68df930be7Sderaadt /* SVID required constants (same values as system 5) */ 69df930be7Sderaadt #define IPC_CREAT 001000 /* create entry if key does not exist */ 70df930be7Sderaadt #define IPC_EXCL 002000 /* fail if key exists */ 71df930be7Sderaadt #define IPC_NOWAIT 004000 /* error if request must wait */ 72df930be7Sderaadt 73df930be7Sderaadt #define IPC_PRIVATE (key_t)0 /* private key */ 74df930be7Sderaadt 75df930be7Sderaadt #define IPC_RMID 0 /* remove identifier */ 76df930be7Sderaadt #define IPC_SET 1 /* set options */ 77df930be7Sderaadt #define IPC_STAT 2 /* get options */ 78df930be7Sderaadt 79df930be7Sderaadt #ifdef _KERNEL 80df930be7Sderaadt /* Macros to convert between ipc ids and array indices or sequence ids */ 81df930be7Sderaadt #define IPCID_TO_IX(id) ((id) & 0xffff) 82df930be7Sderaadt #define IPCID_TO_SEQ(id) (((id) >> 16) & 0xffff) 83df930be7Sderaadt #define IXSEQ_TO_IPCID(ix,perm) (((perm.seq) << 16) | (ix & 0xffff)) 84bb63a7f5Sniklas 855a5d5b30Sderaadt struct ucred; 865a5d5b30Sderaadt 87c4071fd1Smillert int ipcperm(struct ucred *, struct ipc_perm *, int); 88df930be7Sderaadt 8951c1ddd9Smillert #else /* !_KERNEL */ 9051c1ddd9Smillert 91df930be7Sderaadt __BEGIN_DECLS 92c4071fd1Smillert key_t ftok(const char *, int); 93df930be7Sderaadt __END_DECLS 94df930be7Sderaadt #endif 95df930be7Sderaadt #endif /* !_SYS_IPC_H_ */ 96