kern_ipc_10.c revision 1.2 1 /* $NetBSD: kern_ipc_10.c,v 1.2 1995/08/10 04:08:57 mycroft Exp $ */
2
3 /*
4 * Copyright (c) 1994 Adam Glass and Charles Hannum. All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. All advertising materials mentioning features or use of this software
15 * must display the following acknowledgement:
16 * This product includes software developed by Adam Glass and Charles
17 * Hannum.
18 * 4. The names of the authors may not be used to endorse or promote products
19 * derived from this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
22 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */
32
33 #include <sys/param.h>
34 #include <sys/systm.h>
35 #include <sys/kernel.h>
36 #include <sys/proc.h>
37 #include <sys/sem.h>
38 #include <sys/malloc.h>
39
40 #include <sys/mount.h>
41 #include <sys/syscallargs.h>
42
43 #include <vm/vm.h>
44 #include <vm/vm_map.h>
45 #include <vm/vm_map.h>
46 #include <vm/vm_kern.h>
47
48 #ifdef SYSVSEM
49 int
50 compat_10_semsys(p, uap, retval)
51 struct proc *p;
52 struct compat_10_semsys_args /* {
53 syscallarg(int) which;
54 syscallarg(int) a2;
55 syscallarg(int) a3;
56 syscallarg(int) a4;
57 syscallarg(int) a5;
58 } */ *uap;
59 register_t *retval;
60 {
61 struct __semctl_args /* {
62 syscallarg(int) semid;
63 syscallarg(int) semnum;
64 syscallarg(int) cmd;
65 syscallarg(union semun *) arg;
66 } */ __semctl_args;
67 struct semget_args /* {
68 syscallarg(key_t) key;
69 syscallarg(int) nsems;
70 syscallarg(int) semflg;
71 } */ semget_args;
72 struct semop_args /* {
73 syscallarg(int) semid;
74 syscallarg(struct sembuf *) sops;
75 syscallarg(u_int) nsops;
76 } */ semop_args;
77 struct semconfig_args /* {
78 syscallarg(int) flag;
79 } */ semconfig_args;
80
81 switch (SCARG(uap, which)) {
82 case 0: /* __semctl() */
83 SCARG(&__semctl_args, semid) = SCARG(uap, a2);
84 SCARG(&__semctl_args, semnum) = SCARG(uap, a3);
85 SCARG(&__semctl_args, cmd) = SCARG(uap, a4);
86 SCARG(&__semctl_args, arg) = (union semun *)SCARG(uap, a5);
87 return (__semctl(p, &__semctl_args, retval));
88
89 case 1: /* semget() */
90 SCARG(&semget_args, key) = SCARG(uap, a2);
91 SCARG(&semget_args, nsems) = SCARG(uap, a3);
92 SCARG(&semget_args, semflg) = SCARG(uap, a4);
93 return (semget(p, &semget_args, retval));
94
95 case 2: /* semop() */
96 SCARG(&semop_args, semid) = SCARG(uap, a2);
97 SCARG(&semop_args, sops) = (struct sembuf *)SCARG(uap, a3);
98 SCARG(&semop_args, nsops) = SCARG(uap, a4);
99 return (semop(p, &semop_args, retval));
100
101 case 3: /* semconfig() */
102 SCARG(&semconfig_args, flag) = SCARG(uap, a2);
103 return (semconfig(p, &semconfig_args, retval));
104
105 default:
106 return (EINVAL);
107 }
108 }
109 #endif
110
111 #ifdef SYSVSHM
112 int
113 compat_10_shmsys(p, uap, retval)
114 struct proc *p;
115 struct compat_10_shmsys_args /* {
116 syscallarg(int) which;
117 syscallarg(int) a2;
118 syscallarg(int) a3;
119 syscallarg(int) a4;
120 } */ *uap;
121 register_t *retval;
122 {
123 struct shmat_args /* {
124 syscallarg(int) shmid;
125 syscallarg(void *) shmaddr;
126 syscallarg(int) shmflg;
127 } */ shmat_args;
128 struct shmctl_args /* {
129 syscallarg(int) shmid;
130 syscallarg(int) cmd;
131 syscallarg(struct shmid_ds *) buf;
132 } */ shmctl_args;
133 struct shmdt_args /* {
134 syscallarg(void *) shmaddr;
135 } */ shmdt_args;
136 struct shmget_args /* {
137 syscallarg(key_t) key;
138 syscallarg(int) size;
139 syscallarg(int) shmflg;
140 } */ shmget_args;
141
142 switch (SCARG(uap, which)) {
143 case 0: /* shmat() */
144 SCARG(&shmat_args, shmid) = SCARG(uap, a2);
145 SCARG(&shmat_args, shmaddr) = (void *)SCARG(uap, a3);
146 SCARG(&shmat_args, shmflg) = SCARG(uap, a4);
147 return (shmat(p, &shmat_args, retval));
148
149 case 1: /* shmctl() */
150 SCARG(&shmctl_args, shmid) = SCARG(uap, a2);
151 SCARG(&shmctl_args, cmd) = SCARG(uap, a3);
152 SCARG(&shmctl_args, buf) = (struct shmid_ds *)SCARG(uap, a4);
153 return (shmctl(p, &shmctl_args, retval));
154
155 case 2: /* shmdt() */
156 SCARG(&shmat_args, shmaddr) = (void *)SCARG(uap, a2);
157 return (shmdt(p, &shmdt_args, retval));
158
159 case 3: /* shmget() */
160 SCARG(&shmget_args, key) = SCARG(uap, a2);
161 SCARG(&shmget_args, size) = SCARG(uap, a3);
162 SCARG(&shmget_args, shmflg) = SCARG(uap, a4);
163 return (shmget(p, &shmget_args, retval));
164
165 default:
166 return (EINVAL);
167 }
168 }
169 #endif
170
171 #ifdef SYSVMSG
172 int
173 compat_10_msgsys(p, uap, retval)
174 struct caller *p;
175 struct compat_10_msgsys_args /* {
176 syscallarg(int) which;
177 syscallarg(int) a2;
178 syscallarg(int) a3;
179 syscallarg(int) a4;
180 syscallarg(int) a5;
181 syscallarg(int) a6;
182 } */ *uap;
183 register_t *retval;
184 {
185 struct msgctl_args /* {
186 syscallarg(int) msqid;
187 syscallarg(int) cmd;
188 syscallarg(struct msqid_ds *) buf;
189 } */ msgctl_args;
190 struct msgget_args /* {
191 syscallarg(key_t) key;
192 syscallarg(int) msgflg;
193 } */ msgget_args;
194 struct msgsnd_args /* {
195 syscallarg(int) msqid;
196 syscallarg(void *) msgp;
197 syscallarg(size_t) msgsz;
198 syscallarg(int) msgflg;
199 } */ msgsnd_args;
200 struct msgrcv_args /* {
201 syscallarg(int) msqid;
202 syscallarg(void *) msgp;
203 syscallarg(size_t) msgsz;
204 syscallarg(long) msgtyp;
205 syscallarg(int) msgflg;
206 } */ msgrcv_args;
207
208 switch (SCARG(uap, which)) {
209 case 0: /* msgctl()*/
210 SCARG(&msgctl_args, msqid) = SCARG(uap, a2);
211 SCARG(&msgctl_args, cmd) = SCARG(uap, a3);
212 SCARG(&msgctl_args, buf) =
213 (struct msqid_ds *)SCARG(uap, a4);
214 return (msgctl(p, &msgctl_args, retval));
215
216 case 1: /* msgget() */
217 SCARG(&msgget_args, key) = SCARG(uap, a2);
218 SCARG(&msgget_args, msgflg) = SCARG(uap, a3);
219 return (msgget(p, &msgget_args, retval));
220
221 case 2: /* msgsnd() */
222 SCARG(&msgsnd_args, msqid) = SCARG(uap, a2);
223 SCARG(&msgsnd_args, msgp) = (void *)SCARG(uap, a3);
224 SCARG(&msgsnd_args, msgsz) = SCARG(uap, a4);
225 SCARG(&msgsnd_args, msgflg) = SCARG(uap, a5);
226 return (msgsnd(p, &msgsnd_args, retval));
227
228 case 3: /* msgrcv() */
229 SCARG(&msgrcv_args, msqid) = SCARG(uap, a2);
230 SCARG(&msgrcv_args, msgp) = (void *)SCARG(uap, a3);
231 SCARG(&msgrcv_args, msgsz) = SCARG(uap, a4);
232 SCARG(&msgrcv_args, msgtyp) = SCARG(uap, a5);
233 SCARG(&msgrcv_args, msgflg) = SCARG(uap, a6);
234 return (msgrcv(p, &msgrcv_args, retval));
235
236 default:
237 return (EINVAL);
238 }
239 }
240 #endif
241