1139825Simp/*-
21541Srgrimes * Copyright (c) 1988 University of Utah.
31541Srgrimes * Copyright (c) 1990, 1993
41541Srgrimes *	The Regents of the University of California.  All rights reserved.
51541Srgrimes * (c) UNIX System Laboratories, Inc.
61541Srgrimes * All or some portions of this file are derived from material licensed
71541Srgrimes * to the University of California by American Telephone and Telegraph
81541Srgrimes * Co. or Unix System Laboratories, Inc. and are reproduced herein with
91541Srgrimes * the permission of UNIX System Laboratories, Inc.
101541Srgrimes *
111541Srgrimes * This code is derived from software contributed to Berkeley by
121541Srgrimes * the Systems Programming Group of the University of Utah Computer
131541Srgrimes * Science Department.
141541Srgrimes *
151541Srgrimes * Redistribution and use in source and binary forms, with or without
161541Srgrimes * modification, are permitted provided that the following conditions
171541Srgrimes * are met:
181541Srgrimes * 1. Redistributions of source code must retain the above copyright
191541Srgrimes *    notice, this list of conditions and the following disclaimer.
201541Srgrimes * 2. Redistributions in binary form must reproduce the above copyright
211541Srgrimes *    notice, this list of conditions and the following disclaimer in the
221541Srgrimes *    documentation and/or other materials provided with the distribution.
231541Srgrimes * 4. Neither the name of the University nor the names of its contributors
241541Srgrimes *    may be used to endorse or promote products derived from this software
251541Srgrimes *    without specific prior written permission.
261541Srgrimes *
271541Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
281541Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
291541Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
301541Srgrimes * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
311541Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
321541Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
331541Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
341541Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
351541Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
361541Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
371541Srgrimes * SUCH DAMAGE.
381541Srgrimes *
3914480Shsu *	@(#)ipc.h	8.4 (Berkeley) 2/19/95
4050477Speter * $FreeBSD: releng/10.3/sys/sys/ipc.h 241837 2012-10-22 02:59:55Z eadler $
411541Srgrimes */
421541Srgrimes
431541Srgrimes/*
441541Srgrimes * SVID compatible ipc.h file
451541Srgrimes */
461541Srgrimes#ifndef _SYS_IPC_H_
471541Srgrimes#define _SYS_IPC_H_
481541Srgrimes
49105130Smike#include <sys/cdefs.h>
50105130Smike#include <sys/_types.h>
51105130Smike
52105130Smike#ifndef _GID_T_DECLARED
53105130Smiketypedef	__gid_t		gid_t;
54105130Smike#define	_GID_T_DECLARED
55105130Smike#endif
56105130Smike
57105130Smike#ifndef _KEY_T_DECLARED
58105130Smiketypedef	__key_t		key_t;
59105130Smike#define	_KEY_T_DECLARED
60105130Smike#endif
61105130Smike
62105130Smike#ifndef _MODE_T_DECLARED
63105130Smiketypedef	__mode_t	mode_t;
64105130Smike#define	_MODE_T_DECLARED
65105130Smike#endif
66105130Smike
67105130Smike#ifndef _UID_T_DECLARED
68105130Smiketypedef	__uid_t		uid_t;
69105130Smike#define	_UID_T_DECLARED
70105130Smike#endif
71105130Smike
72194910Sjhb#if defined(COMPAT_FREEBSD4) || defined(COMPAT_FREEBSD5) || \
73241837Seadler    defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD7) || \
74241837Seadler    defined(COMPAT_43)
75194910Sjhbstruct ipc_perm_old {
76108071Swollman	unsigned short	cuid;	/* creator user id */
77108071Swollman	unsigned short	cgid;	/* creator group id */
78108071Swollman	unsigned short	uid;	/* user id */
79108071Swollman	unsigned short	gid;	/* group id */
80108071Swollman	unsigned short	mode;	/* r/w permission */
81108071Swollman	unsigned short	seq;	/* sequence # (to generate unique ipcid) */
82108071Swollman	key_t		key;	/* user specified msg/sem/shm key */
831541Srgrimes};
84194910Sjhb#endif
851541Srgrimes
86194910Sjhbstruct ipc_perm {
87194910Sjhb	uid_t		cuid;	/* creator user id */
88194910Sjhb	gid_t		cgid;	/* creator group id */
89194910Sjhb	uid_t		uid;	/* user id */
90194910Sjhb	gid_t		gid;	/* group id */
91194910Sjhb	mode_t		mode;	/* r/w permission */
92194910Sjhb	unsigned short	seq;	/* sequence # (to generate unique ipcid) */
93194910Sjhb	key_t		key;	/* user specified msg/sem/shm key */
94194910Sjhb};
95194910Sjhb
96105130Smike#if __BSD_VISIBLE
971541Srgrimes/* common mode bits */
985279Sdg#define	IPC_R		000400	/* read permission */
995279Sdg#define	IPC_W		000200	/* write/alter permission */
1005279Sdg#define	IPC_M		010000	/* permission to change control info */
101105130Smike#endif
1021541Srgrimes
1031541Srgrimes/* SVID required constants (same values as system 5) */
1045279Sdg#define	IPC_CREAT	001000	/* create entry if key does not exist */
1055279Sdg#define	IPC_EXCL	002000	/* fail if key exists */
1065279Sdg#define	IPC_NOWAIT	004000	/* error if request must wait */
1071541Srgrimes
1081541Srgrimes#define	IPC_PRIVATE	(key_t)0 /* private key */
1091541Srgrimes
1101541Srgrimes#define	IPC_RMID	0	/* remove identifier */
1111541Srgrimes#define	IPC_SET		1	/* set options */
1121541Srgrimes#define	IPC_STAT	2	/* get options */
113105130Smike#if __BSD_VISIBLE
114176221Scsjp/*
115176221Scsjp * For Linux compatability.
116176221Scsjp */
11785623Smr#define	IPC_INFO	3	/* get info */
118105130Smike#endif
1191541Srgrimes
12055205Speter#ifdef _KERNEL
1212729Sdfr/* Macros to convert between ipc ids and array indices or sequence ids */
1222729Sdfr#define	IPCID_TO_IX(id)		((id) & 0xffff)
1232729Sdfr#define	IPCID_TO_SEQ(id)	(((id) >> 16) & 0xffff)
1242729Sdfr#define	IXSEQ_TO_IPCID(ix,perm)	(((perm.seq) << 16) | (ix & 0xffff))
1253304Sphk
12683366Sjulianstruct thread;
12746116Sphkstruct proc;
128109205Sdillonstruct vmspace;
12932995Sbde
130194910Sjhb#if defined(COMPAT_FREEBSD4) || defined(COMPAT_FREEBSD5) || \
131194910Sjhb    defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD7)
132194910Sjhbvoid	ipcperm_old2new(struct ipc_perm_old *, struct ipc_perm *);
133194910Sjhbvoid	ipcperm_new2old(struct ipc_perm *, struct ipc_perm_old *);
134194910Sjhb#endif
135194910Sjhb
13692719Salfredint	ipcperm(struct thread *, struct ipc_perm *, int);
13769449Salfredextern void (*shmfork_hook)(struct proc *, struct proc *);
138109205Sdillonextern void (*shmexit_hook)(struct vmspace *);
13969449Salfred
14055205Speter#else /* ! _KERNEL */
14116092Sjoerg
14216092Sjoerg__BEGIN_DECLS
14392719Salfredkey_t	ftok(const char *, int);
14416092Sjoerg__END_DECLS
14516092Sjoerg
14655205Speter#endif /* _KERNEL */
1472729Sdfr
1481541Srgrimes#endif /* !_SYS_IPC_H_ */
149