FreeBSD/Linux Kernel Cross Reference
sys/sys/ipc.h
1 /*
2 * Copyright (c) 1988 University of Utah.
3 * Copyright (c) 1990, 1993
4 * The Regents of the University of California. All rights reserved.
5 * (c) UNIX System Laboratories, Inc.
6 * All or some portions of this file are derived from material licensed
7 * to the University of California by American Telephone and Telegraph
8 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
9 * the permission of UNIX System Laboratories, Inc.
10 *
11 * This code is derived from software contributed to Berkeley by
12 * the Systems Programming Group of the University of Utah Computer
13 * Science Department.
14 *
15 * Redistribution and use in source and binary forms, with or without
16 * modification, are permitted provided that the following conditions
17 * are met:
18 * 1. Redistributions of source code must retain the above copyright
19 * notice, this list of conditions and the following disclaimer.
20 * 2. Redistributions in binary form must reproduce the above copyright
21 * notice, this list of conditions and the following disclaimer in the
22 * documentation and/or other materials provided with the distribution.
23 * 3. All advertising materials mentioning features or use of this software
24 * must display the following acknowledgement:
25 * This product includes software developed by the University of
26 * California, Berkeley and its contributors.
27 * 4. Neither the name of the University nor the names of its contributors
28 * may be used to endorse or promote products derived from this software
29 * without specific prior written permission.
30 *
31 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
32 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
33 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
34 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
35 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
39 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
40 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
41 * SUCH DAMAGE.
42 *
43 * @(#)ipc.h 8.4 (Berkeley) 2/19/95
44 * $FreeBSD: releng/5.1/sys/sys/ipc.h 109205 2003-01-13 23:04:32Z dillon $
45 */
46
47 /*
48 * SVID compatible ipc.h file
49 */
50 #ifndef _SYS_IPC_H_
51 #define _SYS_IPC_H_
52
53 #include <sys/cdefs.h>
54 #include <sys/_types.h>
55
56 #ifndef _GID_T_DECLARED
57 typedef __gid_t gid_t;
58 #define _GID_T_DECLARED
59 #endif
60
61 #ifndef _KEY_T_DECLARED
62 typedef __key_t key_t;
63 #define _KEY_T_DECLARED
64 #endif
65
66 #ifndef _MODE_T_DECLARED
67 typedef __mode_t mode_t;
68 #define _MODE_T_DECLARED
69 #endif
70
71 #ifndef _UID_T_DECLARED
72 typedef __uid_t uid_t;
73 #define _UID_T_DECLARED
74 #endif
75
76 /*
77 * XXX almost all members have wrong types.
78 */
79 struct ipc_perm {
80 unsigned short cuid; /* creator user id */
81 unsigned short cgid; /* creator group id */
82 unsigned short uid; /* user id */
83 unsigned short gid; /* group id */
84 unsigned short mode; /* r/w permission */
85 unsigned short seq; /* sequence # (to generate unique ipcid) */
86 key_t key; /* user specified msg/sem/shm key */
87 };
88
89 #if __BSD_VISIBLE
90 /* common mode bits */
91 #define IPC_R 000400 /* read permission */
92 #define IPC_W 000200 /* write/alter permission */
93 #define IPC_M 010000 /* permission to change control info */
94 #endif
95
96 /* SVID required constants (same values as system 5) */
97 #define IPC_CREAT 001000 /* create entry if key does not exist */
98 #define IPC_EXCL 002000 /* fail if key exists */
99 #define IPC_NOWAIT 004000 /* error if request must wait */
100
101 #define IPC_PRIVATE (key_t)0 /* private key */
102
103 #define IPC_RMID 0 /* remove identifier */
104 #define IPC_SET 1 /* set options */
105 #define IPC_STAT 2 /* get options */
106 #if __BSD_VISIBLE
107 #define IPC_INFO 3 /* get info */
108 #endif
109
110 #ifdef _KERNEL
111 /* Macros to convert between ipc ids and array indices or sequence ids */
112 #define IPCID_TO_IX(id) ((id) & 0xffff)
113 #define IPCID_TO_SEQ(id) (((id) >> 16) & 0xffff)
114 #define IXSEQ_TO_IPCID(ix,perm) (((perm.seq) << 16) | (ix & 0xffff))
115
116 struct thread;
117 struct proc;
118 struct vmspace;
119
120 int ipcperm(struct thread *, struct ipc_perm *, int);
121 extern void (*shmfork_hook)(struct proc *, struct proc *);
122 extern void (*shmexit_hook)(struct vmspace *);
123
124 #else /* ! _KERNEL */
125
126 __BEGIN_DECLS
127 key_t ftok(const char *, int);
128 __END_DECLS
129
130 #endif /* _KERNEL */
131
132 #endif /* !_SYS_IPC_H_ */
Cache object: 22929c0047329883dd5f0f2e40184aa2
|