1 /* $NetBSD: netbsd32_compat_50.c,v 1.7 2009/11/11 09:48:51 rmind Exp $ */
4 * Copyright (c) 2008 The NetBSD Foundation, Inc.
7 * This code is derived from software contributed to The NetBSD Foundation
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. All advertising materials mentioning features or use of this software
19 * must display the following acknowledgement:
20 * This product includes software developed by the NetBSD
21 * Foundation, Inc. and its contributors.
22 * 4. Neither the name of The NetBSD Foundation nor the names of its
23 * contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
26 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 * POSSIBILITY OF SUCH DAMAGE.
38 #include <sys/cdefs.h>
39 __KERNEL_RCSID(0, "$NetBSD: netbsd32_compat_50.c,v 1.7 2009/11/11 09:48:51 rmind Exp $");
41 #if defined(_KERNEL_OPT)
47 #include <sys/param.h>
48 #include <sys/systm.h>
49 #include <sys/malloc.h>
50 #include <sys/mount.h>
51 #include <sys/socket.h>
52 #include <sys/socketvar.h>
55 #include <sys/ktrace.h>
56 #include <sys/eventvar.h>
57 #include <sys/resourcevar.h>
58 #include <sys/vnode.h>
60 #include <sys/filedesc.h>
62 #include <sys/namei.h>
63 #include <sys/statvfs.h>
64 #include <sys/syscallargs.h>
66 #include <sys/dirent.h>
67 #include <sys/kauth.h>
68 #include <sys/vfs_syscalls.h>
74 #include <compat/netbsd32/netbsd32.h>
75 #include <compat/netbsd32/netbsd32_syscallargs.h>
76 #include <compat/netbsd32/netbsd32_conv.h>
77 #include <compat/sys/mount.h>
78 #include <compat/sys/time.h>
82 * Common routine to set access and modification times given a vnode.
85 get_utimes32(const netbsd32_timeval50p_t
*tptr
, struct timeval
*tv
,
89 struct netbsd32_timeval50 tv32
[2];
96 error
= copyin(tptr
, tv32
, sizeof(tv32
));
99 netbsd32_to_timeval50(&tv32
[0], &tv
[0]);
100 netbsd32_to_timeval50(&tv32
[1], &tv
[1]);
107 compat_50_netbsd32_mknod(struct lwp
*l
,
108 const struct compat_50_netbsd32_mknod_args
*uap
, register_t
*retval
)
111 syscallarg(netbsd32_charp) path;
112 syscallarg(mode_t) mode;
113 syscallarg(uint32_t) dev;
115 return do_sys_mknod(l
, SCARG_P32(uap
, path
), SCARG(uap
, mode
),
116 SCARG(uap
, dev
), retval
, UIO_USERSPACE
);
120 compat_50_netbsd32_select(struct lwp
*l
,
121 const struct compat_50_netbsd32_select_args
*uap
, register_t
*retval
)
125 syscallarg(netbsd32_fd_setp_t) in;
126 syscallarg(netbsd32_fd_setp_t) ou;
127 syscallarg(netbsd32_fd_setp_t) ex;
128 syscallarg(netbsd32_timeval50p_t) tv;
131 struct netbsd32_timeval50 tv32
;
132 struct timespec ats
, *ts
= NULL
;
134 if (SCARG_P32(uap
, tv
)) {
135 error
= copyin(SCARG_P32(uap
, tv
), &tv32
, sizeof(tv32
));
138 ats
.tv_sec
= tv32
.tv_sec
;
139 ats
.tv_nsec
= tv32
.tv_usec
* 1000;
143 return selcommon(retval
, SCARG(uap
, nd
), SCARG_P32(uap
, in
),
144 SCARG_P32(uap
, ou
), SCARG_P32(uap
, ex
), ts
, NULL
);
149 compat_50_netbsd32_gettimeofday(struct lwp
*l
,
150 const struct compat_50_netbsd32_gettimeofday_args
*uap
, register_t
*retval
)
153 syscallarg(netbsd32_timeval50p_t) tp;
154 syscallarg(netbsd32_timezonep_t) tzp;
157 struct netbsd32_timeval50 tv32
;
159 struct netbsd32_timezone tzfake
;
161 if (SCARG_P32(uap
, tp
)) {
163 netbsd32_from_timeval50(&atv
, &tv32
);
164 error
= copyout(&tv32
, SCARG_P32(uap
, tp
), sizeof(tv32
));
168 if (SCARG_P32(uap
, tzp
)) {
170 * NetBSD has no kernel notion of time zone, so we just
171 * fake up a timezone struct and return it if demanded.
173 tzfake
.tz_minuteswest
= 0;
174 tzfake
.tz_dsttime
= 0;
175 error
= copyout(&tzfake
, SCARG_P32(uap
, tzp
), sizeof(tzfake
));
181 compat_50_netbsd32_settimeofday(struct lwp
*l
,
182 const struct compat_50_netbsd32_settimeofday_args
*uap
, register_t
*retval
)
185 syscallarg(const netbsd32_timeval50p_t) tv;
186 syscallarg(const netbsd32_timezonep_t) tzp;
188 struct netbsd32_timeval50 atv32
;
192 struct proc
*p
= l
->l_proc
;
194 /* Verify all parameters before changing time. */
197 * NetBSD has no kernel notion of time zone, and only an
198 * obsolete program would try to set it, so we log a warning.
200 if (SCARG_P32(uap
, tzp
))
201 printf("pid %d attempted to set the "
202 "(obsolete) kernel time zone\n", p
->p_pid
);
204 if (SCARG_P32(uap
, tv
) == 0)
207 if ((error
= copyin(SCARG_P32(uap
, tv
), &atv32
, sizeof(atv32
))) != 0)
210 netbsd32_to_timeval50(&atv32
, &atv
);
211 TIMEVAL_TO_TIMESPEC(&atv
, &ats
);
212 return settime(p
, &ats
);
216 compat_50_netbsd32_utimes(struct lwp
*l
,
217 const struct compat_50_netbsd32_utimes_args
*uap
, register_t
*retval
)
220 syscallarg(const netbsd32_charp) path;
221 syscallarg(const netbsd32_timeval50p_t) tptr;
224 struct timeval tv
[2], *tvp
;
226 error
= get_utimes32(SCARG_P32(uap
, tptr
), tv
, &tvp
);
230 return do_sys_utimes(l
, NULL
, SCARG_P32(uap
, path
), FOLLOW
,
235 compat_50_netbsd32_adjtime(struct lwp
*l
,
236 const struct compat_50_netbsd32_adjtime_args
*uap
, register_t
*retval
)
239 syscallarg(const netbsd32_timeval50p_t) delta;
240 syscallarg(netbsd32_timeval50p_t) olddelta;
242 struct netbsd32_timeval50 atv
;
245 extern int time_adjusted
; /* in kern_ntptime.c */
246 extern int64_t time_adjtime
; /* in kern_ntptime.c */
248 if ((error
= kauth_authorize_system(l
->l_cred
,
249 KAUTH_SYSTEM_TIME
, KAUTH_REQ_SYSTEM_TIME_ADJTIME
, NULL
, NULL
,
253 if (SCARG_P32(uap
, olddelta
)) {
254 atv
.tv_sec
= time_adjtime
/ 1000000;
255 atv
.tv_usec
= time_adjtime
% 1000000;
256 if (atv
.tv_usec
< 0) {
257 atv
.tv_usec
+= 1000000;
261 SCARG_P32(uap
, olddelta
),
267 if (SCARG_P32(uap
, delta
)) {
268 error
= copyin(SCARG_P32(uap
, delta
), &atv
,
269 sizeof(struct timeval
));
273 time_adjtime
= (int64_t)atv
.tv_sec
* 1000000 + atv
.tv_usec
;
276 /* We need to save the system time during shutdown */
283 #if defined(LFS) || !defined(_KERNEL)
285 compat_50_netbsd32_lfs_segwait(struct lwp
*l
,
286 const struct compat_50_netbsd32_lfs_segwait_args
*uap
, register_t
*retval
)
293 compat_50_netbsd32_futimes(struct lwp
*l
,
294 const struct compat_50_netbsd32_futimes_args
*uap
, register_t
*retval
)
298 syscallarg(const netbsd32_timeval50p_t) tptr;
302 struct timeval tv
[2], *tvp
;
304 error
= get_utimes32(SCARG_P32(uap
, tptr
), tv
, &tvp
);
308 /* fd_getvnode() will use the descriptor for us */
309 if ((error
= fd_getvnode(SCARG(uap
, fd
), &fp
)) != 0)
312 error
= do_sys_utimes(l
, fp
->f_data
, NULL
, 0, tvp
, UIO_SYSSPACE
);
314 fd_putfile(SCARG(uap
, fd
));
319 compat_50_netbsd32_clock_gettime(struct lwp
*l
,
320 const struct compat_50_netbsd32_clock_gettime_args
*uap
, register_t
*retval
)
323 syscallarg(netbsd32_clockid_t) clock_id;
324 syscallarg(netbsd32_timespec50p_t) tp;
328 struct netbsd32_timespec50 ts32
;
330 clock_id
= SCARG(uap
, clock_id
);
331 if (clock_id
!= CLOCK_REALTIME
)
335 netbsd32_from_timespec50(&ats
, &ts32
);
337 return copyout(&ts32
, SCARG_P32(uap
, tp
), sizeof(ts32
));
341 compat_50_netbsd32_clock_settime(struct lwp
*l
,
342 const struct compat_50_netbsd32_clock_settime_args
*uap
, register_t
*retval
)
345 syscallarg(netbsd32_clockid_t) clock_id;
346 syscallarg(const netbsd32_timespec50p_t) tp;
348 struct netbsd32_timespec50 ts32
;
353 clock_id
= SCARG(uap
, clock_id
);
354 if (clock_id
!= CLOCK_REALTIME
)
357 if ((error
= copyin(SCARG_P32(uap
, tp
), &ts32
, sizeof(ts32
))) != 0)
360 netbsd32_to_timespec50(&ts32
, &ats
);
361 return settime(l
->l_proc
, &ats
);
365 compat_50_netbsd32_clock_getres(struct lwp
*l
,
366 const struct compat_50_netbsd32_clock_getres_args
*uap
, register_t
*retval
)
369 syscallarg(netbsd32_clockid_t) clock_id;
370 syscallarg(netbsd32_timespec50p_t) tp;
372 struct netbsd32_timespec50 ts32
;
377 clock_id
= SCARG(uap
, clock_id
);
378 if (clock_id
!= CLOCK_REALTIME
)
381 if (SCARG_P32(uap
, tp
)) {
383 ts
.tv_nsec
= 1000000000 / hz
;
385 netbsd32_from_timespec50(&ts
, &ts32
);
386 error
= copyout(&ts
, SCARG_P32(uap
, tp
), sizeof(ts
));
393 compat_50_netbsd32_timer_settime(struct lwp
*l
,
394 const struct compat_50_netbsd32_timer_settime_args
*uap
, register_t
*retval
)
397 syscallarg(netbsd32_timer_t) timerid;
398 syscallarg(int) flags;
399 syscallarg(const netbsd32_itimerspec50p_t) value;
400 syscallarg(netbsd32_itimerspec50p_t) ovalue;
403 struct itimerspec value
, ovalue
, *ovp
= NULL
;
404 struct netbsd32_itimerspec50 its32
;
406 if ((error
= copyin(SCARG_P32(uap
, value
), &its32
, sizeof(its32
))) != 0)
408 netbsd32_to_timespec50(&its32
.it_interval
, &value
.it_interval
);
409 netbsd32_to_timespec50(&its32
.it_value
, &value
.it_value
);
411 if (SCARG_P32(uap
, ovalue
))
414 if ((error
= dotimer_settime(SCARG(uap
, timerid
), &value
, ovp
,
415 SCARG(uap
, flags
), l
->l_proc
)) != 0)
419 netbsd32_from_timespec50(&ovp
->it_interval
, &its32
.it_interval
);
420 netbsd32_from_timespec50(&ovp
->it_value
, &its32
.it_value
);
421 return copyout(&its32
, SCARG_P32(uap
, ovalue
), sizeof(its32
));
427 compat_50_netbsd32_timer_gettime(struct lwp
*l
, const struct compat_50_netbsd32_timer_gettime_args
*uap
, register_t
*retval
)
430 syscallarg(netbsd32_timer_t) timerid;
431 syscallarg(netbsd32_itimerspec50p_t) value;
434 struct itimerspec its
;
435 struct netbsd32_itimerspec50 its32
;
437 if ((error
= dotimer_gettime(SCARG(uap
, timerid
), l
->l_proc
,
441 netbsd32_from_timespec50(&its
.it_interval
, &its32
.it_interval
);
442 netbsd32_from_timespec50(&its
.it_value
, &its32
.it_value
);
444 return copyout(&its32
, SCARG_P32(uap
, value
), sizeof(its32
));
448 compat_50_netbsd32_nanosleep(struct lwp
*l
,
449 const struct compat_50_netbsd32_nanosleep_args
*uap
, register_t
*retval
)
452 syscallarg(const netbsd32_timespec50p_t) rqtp;
453 syscallarg(netbsd32_timespecp_t) rmtp;
456 struct netbsd32_timespec50 ts32
;
457 struct timespec rqt
, ctime
, rmt
;
460 error
= copyin(SCARG_P32(uap
, rqtp
), &ts32
, sizeof(ts32
));
464 netbsd32_to_timespec50(&ts32
, &rqt
);
465 if (itimespecfix(&rqt
))
469 timespecadd(&rqt
, &ctime
, &rqt
);
472 * Avoid inadvertantly sleeping forever
477 error
= tsleep(&nanowait
, PWAIT
| PCATCH
, "nanosleep", timo
);
478 if (error
== ERESTART
)
480 if (error
== EWOULDBLOCK
)
483 if (SCARG_P32(uap
, rmtp
)) {
488 timespecsub(&rqt
, &rmt
, &rmt
);
492 netbsd32_from_timespec50(&rmt
, &ts32
);
493 error1
= copyout(&ts32
, SCARG_P32(uap
,rmtp
), sizeof(ts32
));
502 compat_50_netbsd32_sigtimedwait_put_info(const void *src
, void *dst
, size_t size
)
504 const siginfo_t
*info
= src
;
507 netbsd32_si_to_si32(&info32
, info
);
509 return copyout(&info32
, dst
, sizeof(info32
));
513 compat_50_netbsd32_sigtimedwait_fetch_timeout(const void *src
, void *dst
, size_t size
)
515 struct timespec
*ts
= dst
;
516 struct netbsd32_timespec50 ts32
;
519 error
= copyin(src
, &ts32
, sizeof(ts32
));
523 netbsd32_to_timespec50(&ts32
, ts
);
528 compat_50_netbsd32_sigtimedwait_put_timeout(const void *src
, void *dst
, size_t size
)
530 const struct timespec
*ts
= src
;
531 struct netbsd32_timespec50 ts32
;
533 netbsd32_from_timespec50(ts
, &ts32
);
535 return copyout(&ts32
, dst
, sizeof(ts32
));
539 compat_50_netbsd32___sigtimedwait(struct lwp
*l
,
540 const struct compat_50_netbsd32___sigtimedwait_args
*uap
, register_t
*retval
)
543 syscallarg(netbsd32_sigsetp_t) set;
544 syscallarg(netbsd32_siginfop_t) info;
545 syscallarg(netbsd32_timespec50p_t) timeout;
547 struct sys_____sigtimedwait50_args ua
;
549 NETBSD32TOP_UAP(set
, const sigset_t
);
550 NETBSD32TOP_UAP(info
, siginfo_t
);
551 NETBSD32TOP_UAP(timeout
, struct timespec
);
553 return __sigtimedwait1(l
, &ua
, retval
,
554 compat_50_netbsd32_sigtimedwait_put_info
,
555 compat_50_netbsd32_sigtimedwait_fetch_timeout
,
556 compat_50_netbsd32_sigtimedwait_put_timeout
);
561 compat_50_netbsd32_lutimes(struct lwp
*l
,
562 const struct compat_50_netbsd32_lutimes_args
*uap
, register_t
*retval
)
565 syscallarg(const netbsd32_charp) path;
566 syscallarg(const netbsd32_timeval50p_t) tptr;
569 struct timeval tv
[2], *tvp
;
571 error
= get_utimes32(SCARG_P32(uap
, tptr
), tv
, &tvp
);
575 return do_sys_utimes(l
, NULL
, SCARG_P32(uap
, path
), NOFOLLOW
,
580 compat_50_netbsd32__lwp_park(struct lwp
*l
,
581 const struct compat_50_netbsd32__lwp_park_args
*uap
, register_t
*retval
)
584 syscallarg(const netbsd32_timespec50p) ts;
585 syscallarg(lwpid_t) unpark;
586 syscallarg(netbsd32_voidp) hint;
587 syscallarg(netbsd32_voidp) unparkhint;
589 struct timespec ts
, *tsp
;
590 struct netbsd32_timespec50 ts32
;
593 if (SCARG_P32(uap
, ts
) == NULL
)
596 error
= copyin(SCARG_P32(uap
, ts
), &ts32
, sizeof ts32
);
599 netbsd32_to_timespec50(&ts32
, &ts
);
603 if (SCARG(uap
, unpark
) != 0) {
604 error
= lwp_unpark(SCARG(uap
, unpark
),
605 SCARG_P32(uap
, unparkhint
));
610 return lwp_park(tsp
, SCARG_P32(uap
, hint
));
615 netbsd32_kevent_fetch_timeout(const void *src
, void *dest
, size_t length
)
617 struct netbsd32_timespec50 ts32
;
620 KASSERT(length
== sizeof(struct timespec50
));
622 error
= copyin(src
, &ts32
, sizeof(ts32
));
625 netbsd32_to_timespec50(&ts32
, (struct timespec
*)dest
);
630 netbsd32_kevent_fetch_changes(void *private, const struct kevent
*changelist
,
631 struct kevent
*changes
, size_t index
, int n
)
633 const struct netbsd32_kevent
*src
=
634 (const struct netbsd32_kevent
*)changelist
;
635 struct netbsd32_kevent
*kev32
, *changes32
= private;
638 error
= copyin(src
+ index
, changes32
, n
* sizeof(*changes32
));
641 for (i
= 0, kev32
= changes32
; i
< n
; i
++, kev32
++, changes
++)
642 netbsd32_to_kevent(kev32
, changes
);
647 netbsd32_kevent_put_events(void *private, struct kevent
*events
,
648 struct kevent
*eventlist
, size_t index
, int n
)
650 struct netbsd32_kevent
*kev32
, *events32
= private;
653 for (i
= 0, kev32
= events32
; i
< n
; i
++, kev32
++, events
++)
654 netbsd32_from_kevent(events
, kev32
);
655 kev32
= (struct netbsd32_kevent
*)eventlist
;
656 return copyout(events32
, kev32
, n
* sizeof(*events32
));
660 compat_50_netbsd32_kevent(struct lwp
*l
,
661 const struct compat_50_netbsd32_kevent_args
*uap
, register_t
*retval
)
665 syscallarg(netbsd32_keventp_t) changelist;
666 syscallarg(netbsd32_size_t) nchanges;
667 syscallarg(netbsd32_keventp_t) eventlist;
668 syscallarg(netbsd32_size_t) nevents;
669 syscallarg(netbsd32_timespec50p_t) timeout;
672 size_t maxalloc
, nchanges
, nevents
;
673 struct kevent_ops netbsd32_kevent_ops
= {
674 keo_fetch_timeout
: netbsd32_kevent_fetch_timeout
,
675 keo_fetch_changes
: netbsd32_kevent_fetch_changes
,
676 keo_put_events
: netbsd32_kevent_put_events
,
679 nchanges
= SCARG(uap
, nchanges
);
680 nevents
= SCARG(uap
, nevents
);
681 maxalloc
= MIN(KQ_NEVENTS
, MAX(nchanges
, nevents
));
682 netbsd32_kevent_ops
.keo_private
=
683 malloc(maxalloc
* sizeof(struct netbsd32_kevent
), M_TEMP
,
686 error
= kevent1(retval
, SCARG(uap
, fd
),
687 NETBSD32PTR64(SCARG(uap
, changelist
)), nchanges
,
688 NETBSD32PTR64(SCARG(uap
, eventlist
)), nevents
,
689 NETBSD32PTR64(SCARG(uap
, timeout
)), &netbsd32_kevent_ops
);
691 free(netbsd32_kevent_ops
.keo_private
, M_TEMP
);
697 compat_50_netbsd32_pselect(struct lwp
*l
,
698 const struct compat_50_netbsd32_pselect_args
*uap
, register_t
*retval
)
702 syscallarg(netbsd32_fd_setp_t) in;
703 syscallarg(netbsd32_fd_setp_t) ou;
704 syscallarg(netbsd32_fd_setp_t) ex;
705 syscallarg(const netbsd32_timespec50p_t) ts;
706 syscallarg(const netbsd32_sigsetp_t) mask;
709 struct netbsd32_timespec50 ts32
;
710 struct timespec ats
, *ts
= NULL
;
711 sigset_t amask
, *mask
= NULL
;
713 if (SCARG_P32(uap
, ts
)) {
714 error
= copyin(SCARG_P32(uap
, ts
), &ts32
, sizeof(ts32
));
717 netbsd32_to_timespec50(&ts32
, &ats
);
720 if (SCARG_P32(uap
, mask
)) {
721 error
= copyin(SCARG_P32(uap
, mask
), &amask
, sizeof(amask
));
727 return selcommon(retval
, SCARG(uap
, nd
), SCARG_P32(uap
, in
),
728 SCARG_P32(uap
, ou
), SCARG_P32(uap
, ex
), ts
, mask
);
733 compat_50_netbsd32_pollts(struct lwp
*l
,
734 const struct compat_50_netbsd32_pollts_args
*uap
, register_t
*retval
)
737 syscallarg(struct netbsd32_pollfdp_t) fds;
738 syscallarg(u_int) nfds;
739 syscallarg(const netbsd32_timespec50p_t) ts;
740 syscallarg(const netbsd32_sigsetp_t) mask;
743 struct netbsd32_timespec50 ts32
;
744 struct timespec ats
, *ts
= NULL
;
745 sigset_t amask
, *mask
= NULL
;
747 if (SCARG_P32(uap
, ts
)) {
748 error
= copyin(SCARG_P32(uap
, ts
), &ts32
, sizeof(ts32
));
751 netbsd32_to_timespec50(&ts32
, &ats
);
754 if (NETBSD32PTR64( SCARG(uap
, mask
))) {
755 error
= copyin(SCARG_P32(uap
, mask
), &amask
, sizeof(amask
));
761 return pollcommon(retval
, SCARG_P32(uap
, fds
),
762 SCARG(uap
, nfds
), ts
, mask
);
766 compat_50_netbsd32___stat30(struct lwp
*l
,
767 const struct compat_50_netbsd32___stat30_args
*uap
, register_t
*retval
)
770 syscallarg(const netbsd32_charp) path;
771 syscallarg(netbsd32_stat50p_t) ub;
773 struct netbsd32_stat50 sb32
;
778 path
= SCARG_P32(uap
, path
);
780 error
= do_sys_stat(path
, FOLLOW
, &sb
);
783 netbsd32_from___stat50(&sb
, &sb32
);
784 error
= copyout(&sb32
, SCARG_P32(uap
, ub
), sizeof(sb32
));
789 compat_50_netbsd32___fstat30(struct lwp
*l
,
790 const struct compat_50_netbsd32___fstat30_args
*uap
, register_t
*retval
)
794 syscallarg(netbsd32_stat50p_t) sb;
796 struct netbsd32_stat50 sb32
;
800 error
= do_sys_fstat(SCARG(uap
, fd
), &ub
);
802 netbsd32_from___stat50(&ub
, &sb32
);
803 error
= copyout(&sb32
, SCARG_P32(uap
, sb
), sizeof(sb32
));
809 compat_50_netbsd32___lstat30(struct lwp
*l
,
810 const struct compat_50_netbsd32___lstat30_args
*uap
, register_t
*retval
)
813 syscallarg(const netbsd32_charp) path;
814 syscallarg(netbsd32_stat50p_t) ub;
816 struct netbsd32_stat50 sb32
;
821 path
= SCARG_P32(uap
, path
);
823 error
= do_sys_stat(path
, NOFOLLOW
, &sb
);
826 netbsd32_from___stat50(&sb
, &sb32
);
827 error
= copyout(&sb32
, SCARG_P32(uap
, ub
), sizeof(sb32
));
832 compat_50_netbsd32___fhstat40(struct lwp
*l
, const struct compat_50_netbsd32___fhstat40_args
*uap
, register_t
*retval
)
835 syscallarg(const netbsd32_pointer_t) fhp;
836 syscallarg(netbsd32_size_t) fh_size;
837 syscallarg(netbsd32_stat50p_t) sb;
840 struct netbsd32_stat50 sb32
;
843 error
= do_fhstat(l
, SCARG_P32(uap
, fhp
), SCARG(uap
, fh_size
), &sb
);
845 netbsd32_from___stat50(&sb
, &sb32
);
846 error
= copyout(&sb32
, SCARG_P32(uap
, sb
), sizeof(sb
));
852 compat_50_netbsd32_wait4(struct lwp
*l
, const struct compat_50_netbsd32_wait4_args
*uap
, register_t
*retval
)
856 syscallarg(netbsd32_intp) status;
857 syscallarg(int) options;
858 syscallarg(netbsd32_rusage50p_t) rusage;
860 int error
, status
, pid
= SCARG(uap
, pid
);
861 struct netbsd32_rusage50 ru32
;
864 error
= do_sys_wait(&pid
, &status
, SCARG(uap
, options
),
865 SCARG_P32(uap
, rusage
) != NULL
? &ru
: NULL
);
871 if (SCARG_P32(uap
, rusage
)) {
872 netbsd32_from_rusage50(&ru
, &ru32
);
873 error
= copyout(&ru32
, SCARG_P32(uap
, rusage
), sizeof(ru32
));
876 if (error
== 0 && SCARG_P32(uap
, status
))
877 error
= copyout(&status
, SCARG_P32(uap
, status
), sizeof(status
));
884 compat_50_netbsd32_getrusage(struct lwp
*l
, const struct compat_50_netbsd32_getrusage_args
*uap
, register_t
*retval
)
888 syscallarg(netbsd32_rusage50p_t) rusage;
890 struct proc
*p
= l
->l_proc
;
892 struct netbsd32_rusage50 ru
;
894 switch (SCARG(uap
, who
)) {
897 rup
= &p
->p_stats
->p_ru
;
898 mutex_enter(p
->p_lock
);
899 calcru(p
, &rup
->ru_utime
, &rup
->ru_stime
, NULL
, NULL
);
900 mutex_exit(p
->p_lock
);
903 case RUSAGE_CHILDREN
:
904 rup
= &p
->p_stats
->p_cru
;
910 netbsd32_from_rusage50(rup
, &ru
);
911 return copyout(&ru
, SCARG_P32(uap
, rusage
), sizeof(ru
));
915 compat_50_netbsd32_setitimer(struct lwp
*l
,
916 const struct compat_50_netbsd32_setitimer_args
*uap
, register_t
*retval
)
919 syscallarg(int) which;
920 syscallarg(const netbsd32_itimerval50p_t) itv;
921 syscallarg(netbsd32_itimerval50p_t) oitv;
923 struct proc
*p
= l
->l_proc
;
924 struct netbsd32_itimerval50 s32it
, *itv32
;
925 int which
= SCARG(uap
, which
);
926 struct compat_50_netbsd32_getitimer_args getargs
;
927 struct itimerval aitv
;
930 if ((u_int
)which
> ITIMER_PROF
)
932 itv32
= SCARG_P32(uap
, itv
);
934 if ((error
= copyin(itv32
, &s32it
, sizeof(s32it
))))
936 netbsd32_to_itimerval50(&s32it
, &aitv
);
938 if (SCARG_P32(uap
, oitv
) != 0) {
939 SCARG(&getargs
, which
) = which
;
940 SCARG(&getargs
, itv
) = SCARG(uap
, oitv
);
941 if ((error
= compat_50_netbsd32_getitimer(l
, &getargs
, retval
)) != 0)
947 return dosetitimer(p
, which
, &aitv
);
951 compat_50_netbsd32_getitimer(struct lwp
*l
, const struct compat_50_netbsd32_getitimer_args
*uap
, register_t
*retval
)
954 syscallarg(int) which;
955 syscallarg(netbsd32_itimerval50p_t) itv;
957 struct proc
*p
= l
->l_proc
;
958 struct netbsd32_itimerval50 s32it
;
959 struct itimerval aitv
;
962 error
= dogetitimer(p
, SCARG(uap
, which
), &aitv
);
966 netbsd32_from_itimerval50(&aitv
, &s32it
);
967 return copyout(&s32it
, SCARG_P32(uap
, itv
), sizeof(s32it
));
973 compat_50_netbsd32___semctl14(struct lwp
*l
, const struct compat_50_netbsd32___semctl14_args
*uap
, register_t
*retval
)
975 return do_netbsd32___semctl14(l
, uap
, retval
, NULL
);
979 do_netbsd32___semctl14(struct lwp
*l
, const struct compat_50_netbsd32___semctl14_args
*uap
, register_t
*retval
, void *vkarg
)
982 syscallarg(int) semid;
983 syscallarg(int) semnum;
985 syscallarg(netbsd32_semun50p_t) arg;
987 struct semid_ds sembuf
;
988 struct netbsd32_semid_ds50 sembuf32
;
992 union netbsd32_semun50 karg32
;
994 cmd
= SCARG(uap
, cmd
);
1014 karg32
= *(union netbsd32_semun50
*)vkarg
;
1016 error
= copyin(SCARG_P32(uap
, arg
), &karg32
,
1021 if (pass_arg
== &karg
) {
1025 karg
.array
= NETBSD32PTR64(karg32
.array
);
1028 karg
.val
= karg32
.val
;
1032 if (cmd
== IPC_SET
) {
1033 error
= copyin(NETBSD32PTR64(karg32
.buf
), &sembuf32
,
1037 netbsd32_to_semid_ds50(&sembuf32
, &sembuf
);
1041 error
= semctl1(l
, SCARG(uap
, semid
), SCARG(uap
, semnum
), cmd
,
1044 if (error
== 0 && cmd
== IPC_STAT
) {
1045 netbsd32_from_semid_ds50(&sembuf
, &sembuf32
);
1046 error
= copyout(&sembuf32
, NETBSD32PTR64(karg32
.buf
),
1054 #if defined(SYSVMSG)
1057 compat_50_netbsd32___msgctl13(struct lwp
*l
, const struct compat_50_netbsd32___msgctl13_args
*uap
, register_t
*retval
)
1060 syscallarg(int) msqid;
1061 syscallarg(int) cmd;
1062 syscallarg(netbsd32_msqid_ds50p_t) buf;
1065 struct netbsd32_msqid_ds50 ds32
;
1068 cmd
= SCARG(uap
, cmd
);
1069 if (cmd
== IPC_SET
) {
1070 error
= copyin(SCARG_P32(uap
, buf
), &ds32
, sizeof(ds32
));
1073 netbsd32_to_msqid_ds50(&ds32
, &ds
);
1076 error
= msgctl1(l
, SCARG(uap
, msqid
), cmd
,
1077 (cmd
== IPC_SET
|| cmd
== IPC_STAT
) ? &ds
: NULL
);
1079 if (error
== 0 && cmd
== IPC_STAT
) {
1080 netbsd32_from_msqid_ds50(&ds
, &ds32
);
1081 error
= copyout(&ds32
, SCARG_P32(uap
, buf
), sizeof(ds32
));
1088 #if defined(SYSVSHM)
1091 compat_50_netbsd32___shmctl13(struct lwp
*l
, const struct compat_50_netbsd32___shmctl13_args
*uap
, register_t
*retval
)
1094 syscallarg(int) shmid;
1095 syscallarg(int) cmd;
1096 syscallarg(netbsd32_shmid_ds50p_t) buf;
1099 struct netbsd32_shmid_ds50 ds32
;
1102 cmd
= SCARG(uap
, cmd
);
1103 if (cmd
== IPC_SET
) {
1104 error
= copyin(SCARG_P32(uap
, buf
), &ds32
, sizeof(ds32
));
1107 netbsd32_to_shmid_ds50(&ds32
, &ds
);
1110 error
= shmctl1(l
, SCARG(uap
, shmid
), cmd
,
1111 (cmd
== IPC_SET
|| cmd
== IPC_STAT
) ? &ds
: NULL
);
1113 if (error
== 0 && cmd
== IPC_STAT
) {
1114 netbsd32_from_shmid_ds50(&ds
, &ds32
);
1115 error
= copyout(&ds32
, SCARG_P32(uap
, buf
), sizeof(ds32
));