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