xref: /netbsd-src/sys/compat/common/kern_ipc_10.c (revision 2a399c6883d870daece976daec6ffa7bb7f934ce)
1 /*	$NetBSD: kern_ipc_10.c,v 1.4 1995/10/07 06:26:25 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_sys_semsys(p, v, retval)
51 	struct proc *p;
52 	void *v;
53 	register_t *retval;
54 {
55 	struct compat_10_sys_semsys_args /* {
56 		syscallarg(int) which;
57 		syscallarg(int) a2;
58 		syscallarg(int) a3;
59 		syscallarg(int) a4;
60 		syscallarg(int) a5;
61 	} */ *uap = v;
62 	struct sys___semctl_args /* {
63 		syscallarg(int) semid;
64 		syscallarg(int) semnum;
65 		syscallarg(int) cmd;
66 		syscallarg(union semun *) arg;
67 	} */ __semctl_args;
68 	struct sys_semget_args /* {
69 		syscallarg(key_t) key;
70 		syscallarg(int) nsems;
71 		syscallarg(int) semflg;
72 	} */ semget_args;
73 	struct sys_semop_args /* {
74 		syscallarg(int) semid;
75 		syscallarg(struct sembuf *) sops;
76 		syscallarg(u_int) nsops;
77 	} */ semop_args;
78 	struct sys_semconfig_args /* {
79 		syscallarg(int) flag;
80 	} */ semconfig_args;
81 
82 	switch (SCARG(uap, which)) {
83 	case 0:						/* __semctl() */
84 		SCARG(&__semctl_args, semid) = SCARG(uap, a2);
85 		SCARG(&__semctl_args, semnum) = SCARG(uap, a3);
86 		SCARG(&__semctl_args, cmd) = SCARG(uap, a4);
87 		SCARG(&__semctl_args, arg) = (union semun *)SCARG(uap, a5);
88 		return (sys___semctl(p, &__semctl_args, retval));
89 
90 	case 1:						/* semget() */
91 		SCARG(&semget_args, key) = SCARG(uap, a2);
92 		SCARG(&semget_args, nsems) = SCARG(uap, a3);
93 		SCARG(&semget_args, semflg) = SCARG(uap, a4);
94 		return (sys_semget(p, &semget_args, retval));
95 
96 	case 2:						/* semop() */
97 		SCARG(&semop_args, semid) = SCARG(uap, a2);
98 		SCARG(&semop_args, sops) = (struct sembuf *)SCARG(uap, a3);
99 		SCARG(&semop_args, nsops) = SCARG(uap, a4);
100 		return (sys_semop(p, &semop_args, retval));
101 
102 	case 3:						/* semconfig() */
103 		SCARG(&semconfig_args, flag) = SCARG(uap, a2);
104 		return (sys_semconfig(p, &semconfig_args, retval));
105 
106 	default:
107 		return (EINVAL);
108 	}
109 }
110 #endif
111 
112 #ifdef SYSVSHM
113 int
114 compat_10_sys_shmsys(p, v, retval)
115 	struct proc *p;
116 	void *v;
117 	register_t *retval;
118 {
119 	struct compat_10_sys_shmsys_args /* {
120 		syscallarg(int) which;
121 		syscallarg(int) a2;
122 		syscallarg(int) a3;
123 		syscallarg(int) a4;
124 	} */ *uap = v;
125 	struct sys_shmat_args /* {
126 		syscallarg(int) shmid;
127 		syscallarg(void *) shmaddr;
128 		syscallarg(int) shmflg;
129 	} */ shmat_args;
130 	struct sys_shmctl_args /* {
131 		syscallarg(int) shmid;
132 		syscallarg(int) cmd;
133 		syscallarg(struct shmid_ds *) buf;
134 	} */ shmctl_args;
135 	struct sys_shmdt_args /* {
136 		syscallarg(void *) shmaddr;
137 	} */ shmdt_args;
138 	struct sys_shmget_args /* {
139 		syscallarg(key_t) key;
140 		syscallarg(int) size;
141 		syscallarg(int) shmflg;
142 	} */ shmget_args;
143 
144 	switch (SCARG(uap, which)) {
145 	case 0:						/* shmat() */
146 		SCARG(&shmat_args, shmid) = SCARG(uap, a2);
147 		SCARG(&shmat_args, shmaddr) = (void *)SCARG(uap, a3);
148 		SCARG(&shmat_args, shmflg) = SCARG(uap, a4);
149 		return (sys_shmat(p, &shmat_args, retval));
150 
151 	case 1:						/* shmctl() */
152 		SCARG(&shmctl_args, shmid) = SCARG(uap, a2);
153 		SCARG(&shmctl_args, cmd) = SCARG(uap, a3);
154 		SCARG(&shmctl_args, buf) = (struct shmid_ds *)SCARG(uap, a4);
155 		return (sys_shmctl(p, &shmctl_args, retval));
156 
157 	case 2:						/* shmdt() */
158 		SCARG(&shmat_args, shmaddr) = (void *)SCARG(uap, a2);
159 		return (sys_shmdt(p, &shmdt_args, retval));
160 
161 	case 3:						/* shmget() */
162 		SCARG(&shmget_args, key) = SCARG(uap, a2);
163 		SCARG(&shmget_args, size) = SCARG(uap, a3);
164 		SCARG(&shmget_args, shmflg) = SCARG(uap, a4);
165 		return (sys_shmget(p, &shmget_args, retval));
166 
167 	default:
168 		return (EINVAL);
169 	}
170 }
171 #endif
172 
173 #ifdef SYSVMSG
174 int
175 compat_10_sys_msgsys(p, v, retval)
176 	struct proc *p;
177 	void *v;
178 	register_t *retval;
179 {
180 	struct compat_10_sys_msgsys_args /* {
181 		syscallarg(int) which;
182 		syscallarg(int) a2;
183 		syscallarg(int) a3;
184 		syscallarg(int) a4;
185 		syscallarg(int) a5;
186 		syscallarg(int) a6;
187 	} */ *uap = v;
188 	struct sys_msgctl_args /* {
189 		syscallarg(int) msqid;
190 		syscallarg(int) cmd;
191 		syscallarg(struct msqid_ds *) buf;
192 	} */ msgctl_args;
193 	struct sys_msgget_args /* {
194 		syscallarg(key_t) key;
195 		syscallarg(int) msgflg;
196 	} */ msgget_args;
197 	struct sys_msgsnd_args /* {
198 		syscallarg(int) msqid;
199 		syscallarg(void *) msgp;
200 		syscallarg(size_t) msgsz;
201 		syscallarg(int) msgflg;
202 	} */ msgsnd_args;
203 	struct sys_msgrcv_args /* {
204 		syscallarg(int) msqid;
205 		syscallarg(void *) msgp;
206 		syscallarg(size_t) msgsz;
207 		syscallarg(long) msgtyp;
208 		syscallarg(int) msgflg;
209 	} */ msgrcv_args;
210 
211 	switch (SCARG(uap, which)) {
212 	case 0:					/* msgctl()*/
213 		SCARG(&msgctl_args, msqid) = SCARG(uap, a2);
214 		SCARG(&msgctl_args, cmd) = SCARG(uap, a3);
215 		SCARG(&msgctl_args, buf) =
216 		    (struct msqid_ds *)SCARG(uap, a4);
217 		return (sys_msgctl(p, &msgctl_args, retval));
218 
219 	case 1:					/* msgget() */
220 		SCARG(&msgget_args, key) = SCARG(uap, a2);
221 		SCARG(&msgget_args, msgflg) = SCARG(uap, a3);
222 		return (sys_msgget(p, &msgget_args, retval));
223 
224 	case 2:					/* msgsnd() */
225 		SCARG(&msgsnd_args, msqid) = SCARG(uap, a2);
226 		SCARG(&msgsnd_args, msgp) = (void *)SCARG(uap, a3);
227 		SCARG(&msgsnd_args, msgsz) = SCARG(uap, a4);
228 		SCARG(&msgsnd_args, msgflg) = SCARG(uap, a5);
229 		return (sys_msgsnd(p, &msgsnd_args, retval));
230 
231 	case 3:					/* msgrcv() */
232 		SCARG(&msgrcv_args, msqid) = SCARG(uap, a2);
233 		SCARG(&msgrcv_args, msgp) = (void *)SCARG(uap, a3);
234 		SCARG(&msgrcv_args, msgsz) = SCARG(uap, a4);
235 		SCARG(&msgrcv_args, msgtyp) = SCARG(uap, a5);
236 		SCARG(&msgrcv_args, msgflg) = SCARG(uap, a6);
237 		return (sys_msgrcv(p, &msgrcv_args, retval));
238 
239 	default:
240 		return (EINVAL);
241 	}
242 }
243 #endif
244