xref: /netbsd-src/sys/compat/netbsd32/netbsd32_compat_43.c (revision 5aefcfdc06931dd97e76246d2fe0302f7b3fe094)
1 /*	$NetBSD: netbsd32_compat_43.c,v 1.13 2000/12/03 14:47:27 fvdl Exp $	*/
2 
3 /*
4  * Copyright (c) 1998 Matthew R. Green
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  * 3. The name of the author may not be used to endorse or promote products
16  *    derived from this software without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
23  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
25  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28  * SUCH DAMAGE.
29  */
30 
31 #if defined(_KERNEL) && !defined(_LKM)
32 #include "opt_compat_43.h"
33 #endif
34 
35 #include <sys/param.h>
36 #include <sys/systm.h>
37 #include <sys/fcntl.h>
38 #include <sys/malloc.h>
39 #include <sys/mount.h>
40 #include <sys/proc.h>
41 #include <sys/stat.h>
42 #include <sys/syscallargs.h>
43 #include <sys/time.h>
44 #include <sys/ucred.h>
45 #include <uvm/uvm_extern.h>
46 #include <sys/sysctl.h>
47 #include <sys/swap.h>
48 
49 #include <compat/netbsd32/netbsd32.h>
50 #include <compat/netbsd32/netbsd32_syscallargs.h>
51 
52 static void netbsd32_from_stat43 __P((struct stat43 *, struct netbsd32_stat43 *));
53 int compat_43_netbsd32_sethostid __P((struct proc *, void *, register_t *));
54 int compat_43_netbsd32_killpg __P((struct proc *, void *, register_t *retval));
55 int compat_43_netbsd32_sigblock __P((struct proc *, void *, register_t *retval));
56 int compat_43_netbsd32_sigblock __P((struct proc *, void *, register_t *retval));
57 
58 static void
59 netbsd32_from_stat43(sp43, sp32)
60 	struct stat43 *sp43;
61 	struct netbsd32_stat43 *sp32;
62 {
63 
64 	sp32->st_dev = sp43->st_dev;
65 	sp32->st_ino = sp43->st_ino;
66 	sp32->st_mode = sp43->st_mode;
67 	sp32->st_nlink = sp43->st_nlink;
68 	sp32->st_uid = sp43->st_uid;
69 	sp32->st_gid = sp43->st_gid;
70 	sp32->st_rdev = sp43->st_rdev;
71 	sp32->st_size = sp43->st_size;
72 	sp32->st_atimespec.tv_sec = sp43->st_atimespec.tv_sec;
73 	sp32->st_atimespec.tv_nsec = sp43->st_atimespec.tv_nsec;
74 	sp32->st_mtimespec.tv_sec = sp43->st_mtimespec.tv_sec;
75 	sp32->st_mtimespec.tv_nsec = sp43->st_mtimespec.tv_nsec;
76 	sp32->st_ctimespec.tv_sec = sp43->st_ctimespec.tv_sec;
77 	sp32->st_ctimespec.tv_nsec = sp43->st_ctimespec.tv_nsec;
78 	sp32->st_blksize = sp43->st_blksize;
79 	sp32->st_blocks = sp43->st_blocks;
80 	sp32->st_flags = sp43->st_flags;
81 	sp32->st_gen = sp43->st_gen;
82 }
83 
84 /* file system syscalls */
85 int
86 compat_43_netbsd32_ocreat(p, v, retval)
87 	struct proc *p;
88 	void *v;
89 	register_t *retval;
90 {
91 	struct compat_43_netbsd32_ocreat_args /* {
92 		syscallarg(const netbsd32_charp) path;
93 		syscallarg(mode_t) mode;
94 	} */ *uap = v;
95 	struct sys_open_args  ua;
96 	caddr_t sg;
97 
98 	NETBSD32TOP_UAP(path, const char);
99 	NETBSD32TO64_UAP(mode);
100 	SCARG(&ua, flags) = O_WRONLY | O_CREAT | O_TRUNC;
101 	sg = stackgap_init(p->p_emul);
102 	CHECK_ALT_EXIST(p, &sg, SCARG(&ua, path));
103 
104 	return (sys_open(p, &ua, retval));
105 }
106 
107 int
108 compat_43_netbsd32_olseek(p, v, retval)
109 	struct proc *p;
110 	void *v;
111 	register_t *retval;
112 {
113 	struct compat_43_netbsd32_olseek_args /* {
114 		syscallarg(int) fd;
115 		syscallarg(netbsd32_long) offset;
116 		syscallarg(int) whence;
117 	} */ *uap = v;
118 	struct sys_lseek_args ua;
119 	int rv;
120 	off_t rt;
121 
122 	SCARG(&ua, fd) = SCARG(uap, fd);
123 	NETBSD32TOX_UAP(offset, long);
124 	NETBSD32TO64_UAP(whence);
125 	rv = sys_lseek(p, &ua, (register_t *)&rt);
126 	*(netbsd32_long *)retval = rt;
127 
128 	return (rv);
129 }
130 
131 int
132 compat_43_netbsd32_stat43(p, v, retval)
133 	struct proc *p;
134 	void *v;
135 	register_t *retval;
136 {
137 	struct compat_43_netbsd32_stat43_args /* {
138 		syscallarg(const netbsd32_charp) path;
139 		syscallarg(netbsd32_stat43p_t) ub;
140 	} */ *uap = v;
141 	struct netbsd32_stat43 *sp32;
142 	struct stat43 sb43;
143 	struct stat43 *sp43 = &sb43;
144 	struct compat_43_sys_stat_args ua;
145 	caddr_t sg;
146 	int rv;
147 
148 	NETBSD32TOP_UAP(path, const char);
149 	SCARG(&ua, ub) = &sb43;
150 	sg = stackgap_init(p->p_emul);
151 	CHECK_ALT_EXIST(p, &sg, SCARG(&ua, path));
152 
153 	rv = compat_43_sys_stat(p, &ua, retval);
154 
155 	sp32 = (struct netbsd32_stat43 *)(u_long)SCARG(uap, ub);
156 	netbsd32_from_stat43(sp43, sp32);
157 
158 	return (rv);
159 }
160 
161 int
162 compat_43_netbsd32_lstat43(p, v, retval)
163 	struct proc *p;
164 	void *v;
165 	register_t *retval;
166 {
167 	struct compat_43_netbsd32_lstat43_args /* {
168 		syscallarg(const netbsd32_charp) path;
169 		syscallarg(netbsd32_stat43p_t) ub;
170 	} */ *uap = v;
171 	struct netbsd32_stat43 *sp32;
172 	struct stat43 sb43;
173 	struct stat43 *sp43 = &sb43;
174 	struct compat_43_sys_lstat_args ua;
175 	caddr_t sg;
176 	int rv;
177 
178 	NETBSD32TOP_UAP(path, const char);
179 	SCARG(&ua, ub) = &sb43;
180 	sg = stackgap_init(p->p_emul);
181 	CHECK_ALT_EXIST(p, &sg, SCARG(&ua, path));
182 
183 	rv = compat_43_sys_stat(p, &ua, retval);
184 
185 	sp32 = (struct netbsd32_stat43 *)(u_long)SCARG(uap, ub);
186 	netbsd32_from_stat43(sp43, sp32);
187 
188 	return (rv);
189 }
190 
191 int
192 compat_43_netbsd32_fstat43(p, v, retval)
193 	struct proc *p;
194 	void *v;
195 	register_t *retval;
196 {
197 	struct compat_43_netbsd32_fstat43_args /* {
198 		syscallarg(int) fd;
199 		syscallarg(netbsd32_stat43p_t) sb;
200 	} */ *uap = v;
201 	struct netbsd32_stat43 *sp32;
202 	struct stat43 sb43;
203 	struct stat43 *sp43 = &sb43;
204 	struct compat_43_sys_fstat_args ua;
205 	int rv;
206 
207 	NETBSD32TO64_UAP(fd);
208 	SCARG(&ua, sb) = &sb43;
209 	rv = compat_43_sys_fstat(p, &ua, retval);
210 
211 	sp32 = (struct netbsd32_stat43 *)(u_long)SCARG(uap, sb);
212 	netbsd32_from_stat43(sp43, sp32);
213 
214 	return (rv);
215 }
216 
217 int
218 compat_43_netbsd32_otruncate(p, v, retval)
219 	struct proc *p;
220 	void *v;
221 	register_t *retval;
222 {
223 	struct compat_43_netbsd32_otruncate_args /* {
224 		syscallarg(const netbsd32_charp) path;
225 		syscallarg(netbsd32_long) length;
226 	} */ *uap = v;
227 	struct sys_truncate_args ua;
228 
229 	NETBSD32TOP_UAP(path, const char);
230 	NETBSD32TO64_UAP(length);
231 	return (sys_ftruncate(p, &ua, retval));
232 }
233 
234 int
235 compat_43_netbsd32_oftruncate(p, v, retval)
236 	struct proc *p;
237 	void *v;
238 	register_t *retval;
239 {
240 	struct compat_43_netbsd32_oftruncate_args /* {
241 		syscallarg(int) fd;
242 		syscallarg(netbsd32_long) length;
243 	} */ *uap = v;
244 	struct sys_ftruncate_args ua;
245 
246 	NETBSD32TO64_UAP(fd);
247 	NETBSD32TO64_UAP(length);
248 	return (sys_ftruncate(p, &ua, retval));
249 }
250 
251 int
252 compat_43_netbsd32_ogetdirentries(p, v, retval)
253 	struct proc *p;
254 	void *v;
255 	register_t *retval;
256 {
257 	struct compat_43_netbsd32_ogetdirentries_args /* {
258 		syscallarg(int) fd;
259 		syscallarg(netbsd32_charp) buf;
260 		syscallarg(u_int) count;
261 		syscallarg(netbsd32_longp) basep;
262 	} */ *uap = v;
263 	struct compat_43_sys_getdirentries_args ua;
264 
265 	NETBSD32TO64_UAP(fd);
266 	NETBSD32TOP_UAP(buf, char);
267 	NETBSD32TO64_UAP(count);
268 	NETBSD32TOP_UAP(basep, long);
269 	return (compat_43_sys_getdirentries(p, &ua, retval));
270 }
271 
272 /* kernel syscalls */
273 int
274 compat_43_netbsd32_ogetkerninfo(p, v, retval)
275 	struct proc *p;
276 	void *v;
277 	register_t *retval;
278 {
279 	struct compat_43_netbsd32_ogetkerninfo_args /* {
280 		syscallarg(int) op;
281 		syscallarg(netbsd32_charp) where;
282 		syscallarg(netbsd32_intp) size;
283 		syscallarg(int) arg;
284 	} */ *uap = v;
285 	struct compat_43_sys_getkerninfo_args ua;
286 
287 	NETBSD32TO64_UAP(op);
288 	NETBSD32TOP_UAP(where, char);
289 	NETBSD32TOP_UAP(size, int);
290 	NETBSD32TO64_UAP(arg);
291 	return (compat_43_sys_getkerninfo(p, &ua, retval));
292 }
293 
294 int
295 compat_43_netbsd32_ogethostname(p, v, retval)
296 	struct proc *p;
297 	void *v;
298 	register_t *retval;
299 {
300 	struct compat_43_netbsd32_ogethostname_args /* {
301 		syscallarg(netbsd32_charp) hostname;
302 		syscallarg(u_int) len;
303 	} */ *uap = v;
304 	int name;
305 	size_t sz;
306 
307 	name = KERN_HOSTNAME;
308 	sz = SCARG(uap, len);
309 	return (kern_sysctl(&name, 1, (char *)(u_long)SCARG(uap, hostname),
310 	    &sz, 0, 0, p));
311 }
312 
313 int
314 compat_43_netbsd32_osethostname(p, v, retval)
315 	struct proc *p;
316 	void *v;
317 	register_t *retval;
318 {
319 	struct compat_43_netbsd32_osethostname_args /* {
320 		syscallarg(netbsd32_charp) hostname;
321 		syscallarg(u_int) len;
322 	} */ *uap = v;
323 	int name;
324 	int error;
325 
326 	if ((error = suser(p->p_ucred, &p->p_acflag)) != 0)
327 		return (error);
328 	name = KERN_HOSTNAME;
329 	return (kern_sysctl(&name, 1, 0, 0, (char *)(u_long)SCARG(uap,
330 	    hostname), SCARG(uap, len), p));
331 }
332 
333 int
334 compat_43_netbsd32_sethostid(p, v, retval)
335 	struct proc *p;
336 	void *v;
337 	register_t *retval;
338 {
339 	struct compat_43_netbsd32_sethostid_args /* {
340 		syscallarg(int32_t) hostid;
341 	} */ *uap = v;
342 	struct compat_43_sys_sethostid_args ua;
343 
344 	NETBSD32TO64_UAP(hostid);
345 	return (compat_43_sys_sethostid(p, &ua, retval));
346 }
347 
348 int
349 compat_43_netbsd32_ogetrlimit(p, v, retval)
350 	struct proc *p;
351 	void *v;
352 	register_t *retval;
353 {
354 	struct compat_43_netbsd32_ogetrlimit_args /* {
355 		syscallarg(int) which;
356 		syscallarg(netbsd32_orlimitp_t) rlp;
357 	} */ *uap = v;
358 	struct compat_43_sys_getrlimit_args ua;
359 
360 	NETBSD32TO64_UAP(which);
361 	NETBSD32TOP_UAP(rlp, struct orlimit);
362 	return (compat_43_sys_getrlimit(p, &ua, retval));
363 }
364 
365 int
366 compat_43_netbsd32_osetrlimit(p, v, retval)
367 	struct proc *p;
368 	void *v;
369 	register_t *retval;
370 {
371 	struct compat_43_netbsd32_osetrlimit_args /* {
372 		syscallarg(int) which;
373 		syscallarg(netbsd32_orlimitp_t) rlp;
374 	} */ *uap = v;
375 	struct compat_43_sys_setrlimit_args ua;
376 
377 	NETBSD32TO64_UAP(which);
378 	NETBSD32TOP_UAP(rlp, struct orlimit);
379 	return (compat_43_sys_setrlimit(p, &ua, retval));
380 }
381 
382 int
383 compat_43_netbsd32_killpg(p, v, retval)
384 	struct proc *p;
385 	void *v;
386 	register_t *retval;
387 {
388 	struct compat_43_netbsd32_killpg_args /* {
389 		syscallarg(int) pgid;
390 		syscallarg(int) signum;
391 	} */ *uap = v;
392 	struct compat_43_sys_killpg_args ua;
393 
394 	NETBSD32TO64_UAP(pgid);
395 	NETBSD32TO64_UAP(signum);
396 	return (compat_43_sys_killpg(p, &ua, retval));
397 }
398 
399 /* virtual memory syscalls */
400 int
401 compat_43_netbsd32_ommap(p, v, retval)
402 	struct proc *p;
403 	void *v;
404 	register_t *retval;
405 {
406 	struct compat_43_netbsd32_ommap_args /* {
407 		syscallarg(netbsd32_caddr_t) addr;
408 		syscallarg(netbsd32_size_t) len;
409 		syscallarg(int) prot;
410 		syscallarg(int) flags;
411 		syscallarg(int) fd;
412 		syscallarg(netbsd32_long) pos;
413 	} */ *uap = v;
414 	struct compat_43_sys_mmap_args ua;
415 
416 	NETBSD32TOX64_UAP(addr, caddr_t);
417 	NETBSD32TOX_UAP(len, size_t);
418 	NETBSD32TO64_UAP(prot);
419 	NETBSD32TO64_UAP(flags);
420 	NETBSD32TO64_UAP(fd);
421 	NETBSD32TOX_UAP(pos, long);
422 	return (compat_43_sys_mmap(p, &ua, retval));
423 }
424 
425 /* network syscalls */
426 int
427 compat_43_netbsd32_oaccept(p, v, retval)
428 	struct proc *p;
429 	void *v;
430 	register_t *retval;
431 {
432 	struct compat_43_netbsd32_oaccept_args /* {
433 		syscallarg(int) s;
434 		syscallarg(netbsd32_caddr_t) name;
435 		syscallarg(netbsd32_intp) anamelen;
436 	} */ *uap = v;
437 	struct compat_43_sys_accept_args ua;
438 
439 	NETBSD32TOX_UAP(s, int);
440 	NETBSD32TOX64_UAP(name, caddr_t);
441 	NETBSD32TOP_UAP(anamelen, int);
442 	return (compat_43_sys_accept(p, &ua, retval));
443 }
444 
445 int
446 compat_43_netbsd32_osend(p, v, retval)
447 	struct proc *p;
448 	void *v;
449 	register_t *retval;
450 {
451 	struct compat_43_netbsd32_osend_args /* {
452 		syscallarg(int) s;
453 		syscallarg(netbsd32_caddr_t) buf;
454 		syscallarg(int) len;
455 		syscallarg(int) flags;
456 	} */ *uap = v;
457 	struct compat_43_sys_send_args ua;
458 
459 	NETBSD32TO64_UAP(s);
460 	NETBSD32TOX64_UAP(buf, caddr_t);
461 	NETBSD32TO64_UAP(len);
462 	NETBSD32TO64_UAP(flags);
463 	return (compat_43_sys_send(p, &ua, retval));
464 }
465 
466 int
467 compat_43_netbsd32_orecv(p, v, retval)
468 	struct proc *p;
469 	void *v;
470 	register_t *retval;
471 {
472 	struct compat_43_netbsd32_orecv_args /* {
473 		syscallarg(int) s;
474 		syscallarg(netbsd32_caddr_t) buf;
475 		syscallarg(int) len;
476 		syscallarg(int) flags;
477 	} */ *uap = v;
478 	struct compat_43_sys_recv_args ua;
479 
480 	NETBSD32TO64_UAP(s);
481 	NETBSD32TOX64_UAP(buf, caddr_t);
482 	NETBSD32TO64_UAP(len);
483 	NETBSD32TO64_UAP(flags);
484 	return (compat_43_sys_recv(p, &ua, retval));
485 }
486 
487 /*
488  * XXX convert these to use a common iovec code to the native
489  * netbsd call.
490  */
491 int
492 compat_43_netbsd32_orecvmsg(p, v, retval)
493 	struct proc *p;
494 	void *v;
495 	register_t *retval;
496 {
497 	struct compat_43_netbsd32_orecvmsg_args /* {
498 		syscallarg(int) s;
499 		syscallarg(netbsd32_omsghdrp_t) msg;
500 		syscallarg(int) flags;
501 	} */ *uap = v;
502 	struct compat_43_sys_recvmsg_args ua;
503 	struct omsghdr omh;
504 	struct omsghdr *omhp = &omh;
505 	struct netbsd32_omsghdr *omhp32;
506 	struct iovec *iovec43p;
507 	struct netbsd32_iovec *iovec32p;
508 	int i;
509 
510 	NETBSD32TO64_UAP(s);
511 	NETBSD32TO64_UAP(flags);
512 
513 	SCARG(&ua, msg) = omhp;
514 	omhp32 = (struct netbsd32_omsghdr *)(u_long)SCARG(uap, msg);
515 	omhp->msg_name = (caddr_t)(u_long)omhp32->msg_name;
516 	omhp->msg_namelen = omhp32->msg_namelen;
517 	omhp->msg_iovlen = (size_t)omhp32->msg_iovlen;
518 	MALLOC(omhp->msg_iov, struct iovec *, sizeof(struct iovec) * omhp->msg_iovlen, M_TEMP, M_WAITOK);
519 	iovec43p = omhp->msg_iov;
520 	iovec32p = (struct netbsd32_iovec *)(u_long)omhp32->msg_iov;
521 	for (i = 0; i < omhp->msg_iovlen; i++, iovec43p++, iovec32p++) {
522 		iovec43p->iov_base = (struct iovec *)(u_long)iovec32p->iov_base;
523 		iovec43p->iov_len = (size_t)iovec32p->iov_len;
524 	}
525 
526 	omhp->msg_accrights = (caddr_t)(u_long)omhp32->msg_accrights;
527 	omhp->msg_accrightslen = omhp32->msg_accrightslen;
528 
529 	return (compat_43_sys_recvmsg(p, &ua, retval));
530 }
531 
532 int
533 compat_43_netbsd32_osendmsg(p, v, retval)
534 	struct proc *p;
535 	void *v;
536 	register_t *retval;
537 {
538 	struct compat_43_netbsd32_osendmsg_args /* {
539 		syscallarg(int) s;
540 		syscallarg(netbsd32_caddr_t) msg;
541 		syscallarg(int) flags;
542 	} */ *uap = v;
543 	struct compat_43_sys_sendmsg_args ua;
544 	struct omsghdr omh;
545 	struct omsghdr *omhp = &omh;
546 	struct netbsd32_omsghdr *omhp32;
547 	struct iovec *iovec43p;
548 	struct netbsd32_iovec *iovec32p;
549 	int i;
550 
551 	NETBSD32TO64_UAP(s);
552 	NETBSD32TO64_UAP(flags);
553 
554 	SCARG(&ua, msg) = (caddr_t)(u_long)omhp;
555 	omhp32 = (struct netbsd32_omsghdr *)(u_long)SCARG(uap, msg);
556 	omhp->msg_name = (caddr_t)(u_long)omhp32->msg_name;
557 	omhp->msg_namelen = omhp32->msg_namelen;
558 	omhp->msg_iovlen = (size_t)omhp32->msg_iovlen;
559 	MALLOC(omhp->msg_iov, struct iovec *, sizeof(struct iovec) * omhp->msg_iovlen, M_TEMP, M_WAITOK);
560 	iovec43p = omhp->msg_iov;
561 	iovec32p = (struct netbsd32_iovec *)(u_long)omhp32->msg_iov;
562 	for (i = 0; i < omhp->msg_iovlen; i++, iovec43p++, iovec32p++) {
563 		iovec43p->iov_base = (void *)(u_long)iovec32p->iov_base;
564 		iovec43p->iov_len = (size_t)iovec32p->iov_len;
565 	}
566 
567 	omhp->msg_accrights = (caddr_t)(u_long)omhp32->msg_accrights;
568 	omhp->msg_accrightslen = omhp32->msg_accrightslen;
569 
570 	return (compat_43_sys_sendmsg(p, &ua, retval));
571 }
572 
573 int
574 compat_43_netbsd32_orecvfrom(p, v, retval)
575 	struct proc *p;
576 	void *v;
577 	register_t *retval;
578 {
579 	struct compat_43_netbsd32_orecvfrom_args /* {
580 		syscallarg(int) s;
581 		syscallarg(netbsd32_caddr_t) buf;
582 		syscallarg(netbsd32_size_t) len;
583 		syscallarg(int) flags;
584 		syscallarg(netbsd32_caddr_t) from;
585 		syscallarg(netbsd32_intp) fromlenaddr;
586 	} */ *uap = v;
587 	struct compat_43_sys_recvfrom_args ua;
588 
589 	NETBSD32TO64_UAP(s);
590 	NETBSD32TOX64_UAP(buf, caddr_t);
591 	NETBSD32TOX_UAP(len, size_t);
592 	NETBSD32TO64_UAP(flags);
593 	NETBSD32TOX64_UAP(from, caddr_t);
594 	NETBSD32TOP_UAP(fromlenaddr, int);
595 	return (compat_43_sys_recvfrom(p, &ua, retval));
596 }
597 
598 int
599 compat_43_netbsd32_ogetsockname(p, v, retval)
600 	struct proc *p;
601 	void *v;
602 	register_t *retval;
603 {
604 	struct compat_43_netbsd32_ogetsockname_args /* {
605 		syscallarg(int) fdec;
606 		syscallarg(netbsd32_caddr_t) asa;
607 		syscallarg(netbsd32_intp) alen;
608 	} */ *uap = v;
609 	struct compat_43_sys_getsockname_args ua;
610 
611 	NETBSD32TO64_UAP(fdec);
612 	NETBSD32TOX64_UAP(asa, caddr_t);
613 	NETBSD32TOP_UAP(alen, int);
614 	return (compat_43_sys_getsockname(p, &ua, retval));
615 }
616 
617 int
618 compat_43_netbsd32_ogetpeername(p, v, retval)
619 	struct proc *p;
620 	void *v;
621 	register_t *retval;
622 {
623 	struct compat_43_netbsd32_ogetpeername_args /* {
624 		syscallarg(int) fdes;
625 		syscallarg(netbsd32_caddr_t) asa;
626 		syscallarg(netbsd32_intp) alen;
627 	} */ *uap = v;
628 	struct compat_43_sys_getpeername_args ua;
629 
630 	NETBSD32TO64_UAP(fdes);
631 	NETBSD32TOX64_UAP(asa, caddr_t);
632 	NETBSD32TOP_UAP(alen, int);
633 	return (compat_43_sys_getpeername(p, &ua, retval));
634 }
635 
636 /* signal syscalls */
637 int
638 compat_43_netbsd32_osigvec(p, v, retval)
639 	struct proc *p;
640 	void *v;
641 	register_t *retval;
642 {
643 	struct compat_43_netbsd32_osigvec_args /* {
644 		syscallarg(int) signum;
645 		syscallarg(netbsd32_sigvecp_t) nsv;
646 		syscallarg(netbsd32_sigvecp_t) osv;
647 	} */ *uap = v;
648 	struct compat_43_sys_sigvec_args ua;
649 	struct netbsd32_sigvec *sv32p;
650 	struct sigvec nsv, osv;
651 	int rv;
652 
653 	NETBSD32TO64_UAP(signum);
654 	if (SCARG(uap, osv))
655 		SCARG(&ua, osv) = &osv;
656 	else
657 		SCARG(&ua, osv) = NULL;
658 	if (SCARG(uap, nsv)) {
659 		SCARG(&ua, nsv) = &nsv;
660 		sv32p = (struct netbsd32_sigvec *)(u_long)SCARG(uap, nsv);
661 		nsv.sv_handler = (void *)(u_long)sv32p->sv_handler;
662 		nsv.sv_mask = sv32p->sv_mask;
663 		nsv.sv_flags = sv32p->sv_flags;
664 	} else
665 		SCARG(&ua, nsv) = NULL;
666 	rv = compat_43_sys_sigvec(p, &ua, retval);
667 	if (rv)
668 		return (rv);
669 
670 	if (SCARG(uap, osv)) {
671 		sv32p = (struct netbsd32_sigvec *)(u_long)SCARG(uap, osv);
672 		sv32p->sv_handler = (netbsd32_sigvecp_t)(u_long)osv.sv_handler;
673 		sv32p->sv_mask = osv.sv_mask;
674 		sv32p->sv_flags = osv.sv_flags;
675 	}
676 
677 	return (0);
678 }
679 
680 int
681 compat_43_netbsd32_sigblock(p, v, retval)
682 	struct proc *p;
683 	void *v;
684 	register_t *retval;
685 {
686 	struct compat_43_netbsd32_sigblock_args /* {
687 		syscallarg(int) mask;
688 	} */ *uap = v;
689 	struct compat_43_sys_sigblock_args ua;
690 
691 	NETBSD32TO64_UAP(mask);
692 	return (compat_43_sys_sigblock(p, &ua, retval));
693 }
694 
695 int
696 compat_43_netbsd32_sigsetmask(p, v, retval)
697 	struct proc *p;
698 	void *v;
699 	register_t *retval;
700 {
701 	struct compat_43_netbsd32_sigsetmask_args /* {
702 		syscallarg(int) mask;
703 	} */ *uap = v;
704 	struct compat_43_sys_sigsetmask_args ua;
705 
706 	NETBSD32TO64_UAP(mask);
707 	return (compat_43_sys_sigsetmask(p, &ua, retval));
708 }
709 
710 int
711 compat_43_netbsd32_osigstack(p, v, retval)
712 	struct proc *p;
713 	void *v;
714 	register_t *retval;
715 {
716 	struct compat_43_netbsd32_osigstack_args /* {
717 		syscallarg(netbsd32_sigstackp_t) nss;
718 		syscallarg(netbsd32_sigstackp_t) oss;
719 	} */ *uap = v;
720 	struct compat_43_sys_sigstack_args ua;
721 	struct netbsd32_sigstack *ss32p;
722 	struct sigstack nss, oss;
723 	int rv;
724 
725 	if (SCARG(uap, oss))
726 		SCARG(&ua, oss) = &oss;
727 	else
728 		SCARG(&ua, oss) = NULL;
729 	if (SCARG(uap, nss)) {
730 		SCARG(&ua, nss) = &nss;
731 		ss32p = (struct netbsd32_sigstack *)(u_long)SCARG(uap, nss);
732 		nss.ss_sp = (void *)(u_long)ss32p->ss_sp;
733 		nss.ss_onstack = ss32p->ss_onstack;
734 	} else
735 		SCARG(&ua, nss) = NULL;
736 
737 	rv = compat_43_sys_sigstack(p, &ua, retval);
738 	if (rv)
739 		return (rv);
740 
741 	if (SCARG(uap, oss)) {
742 		ss32p = (struct netbsd32_sigstack *)(u_long)SCARG(uap, oss);
743 		ss32p->ss_sp = (netbsd32_sigstackp_t)(u_long)oss.ss_sp;
744 		ss32p->ss_onstack = oss.ss_onstack;
745 	}
746 
747 	return (0);
748 }
749