2 * Copyright (c) 2004 Tim J. Robbins
3 * Copyright (c) 2002 Doug Rabson
4 * Copyright (c) 2000 Marcel Moolenaar
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer
12 * in this position and unchanged.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. The name of the author may not be used to endorse or promote products
17 * derived from this software without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
20 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
23 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 #include <sys/cdefs.h>
32 __FBSDID("$FreeBSD$");
34 #include <sys/param.h>
35 #include <sys/kernel.h>
36 #include <sys/systm.h>
38 #include <sys/fcntl.h>
39 #include <sys/imgact.h>
41 #include <sys/malloc.h>
43 #include <sys/mutex.h>
45 #include <sys/resource.h>
46 #include <sys/resourcevar.h>
47 #include <sys/syscallsubr.h>
48 #include <sys/sysproto.h>
49 #include <sys/unistd.h>
51 #include <machine/frame.h>
52 #include <machine/psl.h>
56 #include <vm/vm_extern.h>
57 #include <vm/vm_kern.h>
58 #include <vm/vm_map.h>
60 #include <amd64/linux32/linux.h>
61 #include <amd64/linux32/linux32_proto.h>
62 #include <compat/linux/linux_ipc.h>
63 #include <compat/linux/linux_signal.h>
64 #include <compat/linux/linux_util.h>
66 struct l_old_select_argv {
70 l_uintptr_t exceptfds;
75 linux_to_bsd_sigaltstack(int lsa)
79 if (lsa & LINUX_SS_DISABLE)
81 if (lsa & LINUX_SS_ONSTACK)
87 bsd_to_linux_sigaltstack(int bsa)
92 lsa |= LINUX_SS_DISABLE;
94 lsa |= LINUX_SS_ONSTACK;
99 * Custom version of exec_copyin_args() so that we can translate
103 linux_exec_copyin_args(struct image_args *args, char *fname,
104 enum uio_seg segflg, char **argv, char **envv)
111 bzero(args, sizeof(*args));
116 * Allocate temporary demand zeroed space for argument and
117 * environment strings
119 args->buf = (char *)kmem_alloc_wait(exec_map,
120 PATH_MAX + ARG_MAX + MAXSHELLCMDLEN);
121 if (args->buf == NULL)
123 args->begin_argv = args->buf;
124 args->endp = args->begin_argv;
125 args->stringspace = ARG_MAX;
127 args->fname = args->buf + ARG_MAX;
130 * Copy the file name.
132 error = (segflg == UIO_SYSSPACE) ?
133 copystr(fname, args->fname, PATH_MAX, &length) :
134 copyinstr(fname, args->fname, PATH_MAX, &length);
139 * extract arguments first
141 p32 = (u_int32_t *)argv;
143 error = copyin(p32++, &arg, sizeof(arg));
149 error = copyinstr(argp, args->endp, args->stringspace, &length);
151 if (error == ENAMETOOLONG)
156 args->stringspace -= length;
157 args->endp += length;
161 args->begin_envv = args->endp;
164 * extract environment strings
167 p32 = (u_int32_t *)envv;
169 error = copyin(p32++, &arg, sizeof(arg));
175 error = copyinstr(envp, args->endp, args->stringspace,
178 if (error == ENAMETOOLONG)
182 args->stringspace -= length;
183 args->endp += length;
191 kmem_free_wakeup(exec_map, (vm_offset_t)args->buf,
192 PATH_MAX + ARG_MAX + MAXSHELLCMDLEN);
198 linux_execve(struct thread *td, struct linux_execve_args *args)
200 struct image_args eargs;
204 LCONVPATHEXIST(td, args->path, &path);
208 printf(ARGS(execve, "%s"), path);
211 error = linux_exec_copyin_args(&eargs, path, UIO_SYSSPACE, args->argp,
215 error = kern_execve(td, &eargs, NULL);
216 exec_free_args(&eargs);
225 CTASSERT(sizeof(struct iovec32) == 8);
228 linux32_copyinuio(struct iovec32 *iovp, u_int iovcnt, struct uio **uiop)
230 struct iovec32 iov32;
237 if (iovcnt > UIO_MAXIOV)
239 iovlen = iovcnt * sizeof(struct iovec);
240 uio = malloc(iovlen + sizeof(*uio), M_IOV, M_WAITOK);
241 iov = (struct iovec *)(uio + 1);
242 for (i = 0; i < iovcnt; i++) {
243 error = copyin(&iovp[i], &iov32, sizeof(struct iovec32));
248 iov[i].iov_base = PTRIN(iov32.iov_base);
249 iov[i].iov_len = iov32.iov_len;
252 uio->uio_iovcnt = iovcnt;
253 uio->uio_segflg = UIO_USERSPACE;
254 uio->uio_offset = -1;
256 for (i = 0; i < iovcnt; i++) {
257 if (iov->iov_len > INT_MAX - uio->uio_resid) {
261 uio->uio_resid += iov->iov_len;
269 linux_readv(struct thread *td, struct linux_readv_args *uap)
274 error = linux32_copyinuio(uap->iovp, uap->iovcnt, &auio);
277 error = kern_readv(td, uap->fd, auio);
283 linux_writev(struct thread *td, struct linux_writev_args *uap)
288 error = linux32_copyinuio(uap->iovp, uap->iovcnt, &auio);
291 error = kern_writev(td, uap->fd, auio);
296 struct l_ipc_kludge {
302 linux_ipc(struct thread *td, struct linux_ipc_args *args)
305 switch (args->what & 0xFFFF) {
307 struct linux_semop_args a;
309 a.semid = args->arg1;
311 a.nsops = args->arg2;
312 return (linux_semop(td, &a));
315 struct linux_semget_args a;
318 a.nsems = args->arg2;
319 a.semflg = args->arg3;
320 return (linux_semget(td, &a));
323 struct linux_semctl_args a;
326 a.semid = args->arg1;
327 a.semnum = args->arg2;
329 error = copyin(args->ptr, &a.arg, sizeof(a.arg));
332 return (linux_semctl(td, &a));
335 struct linux_msgsnd_args a;
337 a.msqid = args->arg1;
339 a.msgsz = args->arg2;
340 a.msgflg = args->arg3;
341 return (linux_msgsnd(td, &a));
344 struct linux_msgrcv_args a;
346 a.msqid = args->arg1;
347 a.msgsz = args->arg2;
348 a.msgflg = args->arg3;
349 if ((args->what >> 16) == 0) {
350 struct l_ipc_kludge tmp;
355 error = copyin(args->ptr, &tmp, sizeof(tmp));
358 a.msgp = PTRIN(tmp.msgp);
359 a.msgtyp = tmp.msgtyp;
362 a.msgtyp = args->arg5;
364 return (linux_msgrcv(td, &a));
367 struct linux_msgget_args a;
370 a.msgflg = args->arg2;
371 return (linux_msgget(td, &a));
374 struct linux_msgctl_args a;
376 a.msqid = args->arg1;
379 return (linux_msgctl(td, &a));
382 struct linux_shmat_args a;
384 a.shmid = args->arg1;
385 a.shmaddr = args->ptr;
386 a.shmflg = args->arg2;
387 a.raddr = PTRIN((l_uint)args->arg3);
388 return (linux_shmat(td, &a));
391 struct linux_shmdt_args a;
393 a.shmaddr = args->ptr;
394 return (linux_shmdt(td, &a));
397 struct linux_shmget_args a;
401 a.shmflg = args->arg3;
402 return (linux_shmget(td, &a));
405 struct linux_shmctl_args a;
407 a.shmid = args->arg1;
410 return (linux_shmctl(td, &a));
420 linux_old_select(struct thread *td, struct linux_old_select_args *args)
422 struct l_old_select_argv linux_args;
423 struct linux_select_args newsel;
427 if (ldebug(old_select))
428 printf(ARGS(old_select, "%p"), args->ptr);
431 error = copyin(args->ptr, &linux_args, sizeof(linux_args));
435 newsel.nfds = linux_args.nfds;
436 newsel.readfds = PTRIN(linux_args.readfds);
437 newsel.writefds = PTRIN(linux_args.writefds);
438 newsel.exceptfds = PTRIN(linux_args.exceptfds);
439 newsel.timeout = PTRIN(linux_args.timeout);
440 return (linux_select(td, &newsel));
444 linux_fork(struct thread *td, struct linux_fork_args *args)
450 printf(ARGS(fork, ""));
453 if ((error = fork(td, (struct fork_args *)args)) != 0)
456 if (td->td_retval[1] == 1)
457 td->td_retval[0] = 0;
462 linux_vfork(struct thread *td, struct linux_vfork_args *args)
468 printf(ARGS(vfork, ""));
471 if ((error = vfork(td, (struct vfork_args *)args)) != 0)
473 /* Are we the child? */
474 if (td->td_retval[1] == 1)
475 td->td_retval[0] = 0;
479 #define CLONE_VM 0x100
480 #define CLONE_FS 0x200
481 #define CLONE_FILES 0x400
482 #define CLONE_SIGHAND 0x800
483 #define CLONE_PID 0x1000
486 linux_clone(struct thread *td, struct linux_clone_args *args)
488 int error, ff = RFPROC | RFSTOPPED;
495 printf(ARGS(clone, "flags %x, stack %x"),
496 (unsigned int)(uintptr_t)args->flags,
497 (unsigned int)(uintptr_t)args->stack);
498 if (args->flags & CLONE_PID)
499 printf(LMSG("CLONE_PID not yet supported"));
506 exit_signal = args->flags & 0x000000ff;
507 if (exit_signal >= LINUX_NSIG)
510 if (exit_signal <= LINUX_SIGTBLSZ)
511 exit_signal = linux_to_bsd_signal[_SIG_IDX(exit_signal)];
513 if (args->flags & CLONE_VM)
515 if (args->flags & CLONE_SIGHAND)
517 if (!(args->flags & CLONE_FILES))
520 error = fork1(td, ff, 0, &p2);
526 p2->p_sigparent = exit_signal;
528 td2 = FIRST_THREAD_IN_PROC(p2);
529 td2->td_frame->tf_rsp = PTROUT(args->stack);
533 printf(LMSG("clone: successful rfork to %ld, stack %p sig = %d"),
534 (long)p2->p_pid, args->stack, exit_signal);
538 * Make this runnable after we are finished with it.
540 mtx_lock_spin(&sched_lock);
542 setrunqueue(td2, SRQ_BORING);
543 mtx_unlock_spin(&sched_lock);
545 td->td_retval[0] = p2->p_pid;
546 td->td_retval[1] = 0;
550 #define STACK_SIZE (2 * 1024 * 1024)
551 #define GUARD_SIZE (4 * PAGE_SIZE)
553 static int linux_mmap_common(struct thread *, struct l_mmap_argv *);
556 linux_mmap2(struct thread *td, struct linux_mmap2_args *args)
558 struct l_mmap_argv linux_args;
562 printf(ARGS(mmap2, "0x%08x, %d, %d, 0x%08x, %d, %d"),
563 args->addr, args->len, args->prot,
564 args->flags, args->fd, args->pgoff);
567 linux_args.addr = PTROUT(args->addr);
568 linux_args.len = args->len;
569 linux_args.prot = args->prot;
570 linux_args.flags = args->flags;
571 linux_args.fd = args->fd;
572 linux_args.pgoff = args->pgoff;
574 return (linux_mmap_common(td, &linux_args));
578 linux_mmap(struct thread *td, struct linux_mmap_args *args)
581 struct l_mmap_argv linux_args;
583 error = copyin(args->ptr, &linux_args, sizeof(linux_args));
589 printf(ARGS(mmap, "0x%08x, %d, %d, 0x%08x, %d, %d"),
590 linux_args.addr, linux_args.len, linux_args.prot,
591 linux_args.flags, linux_args.fd, linux_args.pgoff);
593 if ((linux_args.pgoff % PAGE_SIZE) != 0)
595 linux_args.pgoff /= PAGE_SIZE;
597 return (linux_mmap_common(td, &linux_args));
601 linux_mmap_common(struct thread *td, struct l_mmap_argv *linux_args)
603 struct proc *p = td->td_proc;
604 struct mmap_args /* {
622 * You must specify exactly one of MAP_SHARED and MAP_PRIVATE
624 if (! ((linux_args->flags & LINUX_MAP_SHARED) ^
625 (linux_args->flags & LINUX_MAP_PRIVATE)))
628 if (linux_args->flags & LINUX_MAP_SHARED)
629 bsd_args.flags |= MAP_SHARED;
630 if (linux_args->flags & LINUX_MAP_PRIVATE)
631 bsd_args.flags |= MAP_PRIVATE;
632 if (linux_args->flags & LINUX_MAP_FIXED)
633 bsd_args.flags |= MAP_FIXED;
634 if (linux_args->flags & LINUX_MAP_ANON)
635 bsd_args.flags |= MAP_ANON;
637 bsd_args.flags |= MAP_NOSYNC;
638 if (linux_args->flags & LINUX_MAP_GROWSDOWN)
639 bsd_args.flags |= MAP_STACK;
642 * PROT_READ, PROT_WRITE, or PROT_EXEC implies PROT_READ and PROT_EXEC
643 * on Linux/i386. We do this to ensure maximum compatibility.
644 * Linux/ia64 does the same in i386 emulation mode.
646 bsd_args.prot = linux_args->prot;
647 if (bsd_args.prot & (PROT_READ | PROT_WRITE | PROT_EXEC))
648 bsd_args.prot |= PROT_READ | PROT_EXEC;
650 /* Linux does not check file descriptor when MAP_ANONYMOUS is set. */
651 bsd_args.fd = (bsd_args.flags & MAP_ANON) ? -1 : linux_args->fd;
652 if (bsd_args.fd != -1) {
654 * Linux follows Solaris mmap(2) description:
655 * The file descriptor fildes is opened with
656 * read permission, regardless of the
657 * protection options specified.
660 if ((error = fget(td, bsd_args.fd, &fp)) != 0)
662 if (fp->f_type != DTYPE_VNODE) {
667 /* Linux mmap() just fails for O_WRONLY files */
668 if (!(fp->f_flag & FREAD)) {
676 if (linux_args->flags & LINUX_MAP_GROWSDOWN) {
678 * The Linux MAP_GROWSDOWN option does not limit auto
679 * growth of the region. Linux mmap with this option
680 * takes as addr the inital BOS, and as len, the initial
681 * region size. It can then grow down from addr without
682 * limit. However, Linux threads has an implicit internal
683 * limit to stack size of STACK_SIZE. Its just not
684 * enforced explicitly in Linux. But, here we impose
685 * a limit of (STACK_SIZE - GUARD_SIZE) on the stack
686 * region, since we can do this with our mmap.
688 * Our mmap with MAP_STACK takes addr as the maximum
689 * downsize limit on BOS, and as len the max size of
690 * the region. It then maps the top SGROWSIZ bytes,
691 * and auto grows the region down, up to the limit
694 * If we don't use the MAP_STACK option, the effect
695 * of this code is to allocate a stack region of a
696 * fixed size of (STACK_SIZE - GUARD_SIZE).
699 if ((caddr_t)PTRIN(linux_args->addr) + linux_args->len >
700 p->p_vmspace->vm_maxsaddr) {
702 * Some Linux apps will attempt to mmap
703 * thread stacks near the top of their
704 * address space. If their TOS is greater
705 * than vm_maxsaddr, vm_map_growstack()
706 * will confuse the thread stack with the
707 * process stack and deliver a SEGV if they
708 * attempt to grow the thread stack past their
709 * current stacksize rlimit. To avoid this,
710 * adjust vm_maxsaddr upwards to reflect
711 * the current stacksize rlimit rather
712 * than the maximum possible stacksize.
713 * It would be better to adjust the
714 * mmap'ed region, but some apps do not check
715 * mmap's return value.
718 p->p_vmspace->vm_maxsaddr = (char *)LINUX32_USRSTACK -
719 lim_cur(p, RLIMIT_STACK);
724 * This gives us our maximum stack size and a new BOS.
725 * If we're using VM_STACK, then mmap will just map
726 * the top SGROWSIZ bytes, and let the stack grow down
727 * to the limit at BOS. If we're not using VM_STACK
728 * we map the full stack, since we don't have a way
731 if (linux_args->len > STACK_SIZE - GUARD_SIZE) {
732 bsd_args.addr = (caddr_t)PTRIN(linux_args->addr);
733 bsd_args.len = linux_args->len;
735 bsd_args.addr = (caddr_t)PTRIN(linux_args->addr) -
736 (STACK_SIZE - GUARD_SIZE - linux_args->len);
737 bsd_args.len = STACK_SIZE - GUARD_SIZE;
740 bsd_args.addr = (caddr_t)PTRIN(linux_args->addr);
741 bsd_args.len = linux_args->len;
743 bsd_args.pos = (off_t)linux_args->pgoff * PAGE_SIZE;
748 printf("-> %s(%p, %d, %d, 0x%08x, %d, 0x%x)\n",
750 (void *)bsd_args.addr, (int)bsd_args.len, bsd_args.prot,
751 bsd_args.flags, bsd_args.fd, (int)bsd_args.pos);
753 error = mmap(td, &bsd_args);
756 printf("-> %s() return: 0x%x (0x%08x)\n",
757 __func__, error, (u_int)td->td_retval[0]);
763 linux_mprotect(struct thread *td, struct linux_mprotect_args *uap)
765 struct mprotect_args bsd_args;
767 bsd_args.addr = uap->addr;
768 bsd_args.len = uap->len;
769 bsd_args.prot = uap->prot;
770 if (bsd_args.prot & (PROT_READ | PROT_WRITE | PROT_EXEC))
771 bsd_args.prot |= PROT_READ | PROT_EXEC;
772 return (mprotect(td, &bsd_args));
776 linux_iopl(struct thread *td, struct linux_iopl_args *args)
780 if (args->level < 0 || args->level > 3)
782 if ((error = suser(td)) != 0)
784 if ((error = securelevel_gt(td->td_ucred, 0)) != 0)
786 td->td_frame->tf_rflags = (td->td_frame->tf_rflags & ~PSL_IOPL) |
787 (args->level * (PSL_IOPL / 3));
793 linux_pipe(struct thread *td, struct linux_pipe_args *args)
801 printf(ARGS(pipe, "*"));
804 reg_rdx = td->td_retval[1];
807 td->td_retval[1] = reg_rdx;
811 pip[0] = td->td_retval[0];
812 pip[1] = td->td_retval[1];
813 error = copyout(pip, args->pipefds, 2 * sizeof(int));
815 td->td_retval[1] = reg_rdx;
819 td->td_retval[1] = reg_rdx;
820 td->td_retval[0] = 0;
825 linux_sigaction(struct thread *td, struct linux_sigaction_args *args)
828 l_sigaction_t act, oact;
832 if (ldebug(sigaction))
833 printf(ARGS(sigaction, "%d, %p, %p"),
834 args->sig, (void *)args->nsa, (void *)args->osa);
837 if (args->nsa != NULL) {
838 error = copyin(args->nsa, &osa, sizeof(l_osigaction_t));
841 act.lsa_handler = osa.lsa_handler;
842 act.lsa_flags = osa.lsa_flags;
843 act.lsa_restorer = osa.lsa_restorer;
844 LINUX_SIGEMPTYSET(act.lsa_mask);
845 act.lsa_mask.__bits[0] = osa.lsa_mask;
848 error = linux_do_sigaction(td, args->sig, args->nsa ? &act : NULL,
849 args->osa ? &oact : NULL);
851 if (args->osa != NULL && !error) {
852 osa.lsa_handler = oact.lsa_handler;
853 osa.lsa_flags = oact.lsa_flags;
854 osa.lsa_restorer = oact.lsa_restorer;
855 osa.lsa_mask = oact.lsa_mask.__bits[0];
856 error = copyout(&osa, args->osa, sizeof(l_osigaction_t));
863 * Linux has two extra args, restart and oldmask. We don't use these,
864 * but it seems that "restart" is actually a context pointer that
865 * enables the signal to happen with a different register set.
868 linux_sigsuspend(struct thread *td, struct linux_sigsuspend_args *args)
874 if (ldebug(sigsuspend))
875 printf(ARGS(sigsuspend, "%08lx"), (unsigned long)args->mask);
878 LINUX_SIGEMPTYSET(mask);
879 mask.__bits[0] = args->mask;
880 linux_to_bsd_sigset(&mask, &sigmask);
881 return (kern_sigsuspend(td, sigmask));
885 linux_rt_sigsuspend(struct thread *td, struct linux_rt_sigsuspend_args *uap)
892 if (ldebug(rt_sigsuspend))
893 printf(ARGS(rt_sigsuspend, "%p, %d"),
894 (void *)uap->newset, uap->sigsetsize);
897 if (uap->sigsetsize != sizeof(l_sigset_t))
900 error = copyin(uap->newset, &lmask, sizeof(l_sigset_t));
904 linux_to_bsd_sigset(&lmask, &sigmask);
905 return (kern_sigsuspend(td, sigmask));
909 linux_pause(struct thread *td, struct linux_pause_args *args)
911 struct proc *p = td->td_proc;
916 printf(ARGS(pause, ""));
920 sigmask = td->td_sigmask;
922 return (kern_sigsuspend(td, sigmask));
926 linux_sigaltstack(struct thread *td, struct linux_sigaltstack_args *uap)
933 if (ldebug(sigaltstack))
934 printf(ARGS(sigaltstack, "%p, %p"), uap->uss, uap->uoss);
937 if (uap->uss != NULL) {
938 error = copyin(uap->uss, &lss, sizeof(l_stack_t));
942 ss.ss_sp = PTRIN(lss.ss_sp);
943 ss.ss_size = lss.ss_size;
944 ss.ss_flags = linux_to_bsd_sigaltstack(lss.ss_flags);
946 error = kern_sigaltstack(td, (uap->uss != NULL) ? &ss : NULL,
947 (uap->uoss != NULL) ? &oss : NULL);
948 if (!error && uap->uoss != NULL) {
949 lss.ss_sp = PTROUT(oss.ss_sp);
950 lss.ss_size = oss.ss_size;
951 lss.ss_flags = bsd_to_linux_sigaltstack(oss.ss_flags);
952 error = copyout(&lss, uap->uoss, sizeof(l_stack_t));
959 linux_ftruncate64(struct thread *td, struct linux_ftruncate64_args *args)
961 struct ftruncate_args sa;
964 if (ldebug(ftruncate64))
965 printf(ARGS(ftruncate64, "%u, %jd"), args->fd,
966 (intmax_t)args->length);
971 sa.length = args->length;
972 return ftruncate(td, &sa);
976 linux_gettimeofday(struct thread *td, struct linux_gettimeofday_args *uap)
985 atv32.tv_sec = atv.tv_sec;
986 atv32.tv_usec = atv.tv_usec;
987 error = copyout(&atv32, uap->tp, sizeof(atv32));
989 if (error == 0 && uap->tzp != NULL) {
990 rtz.tz_minuteswest = tz_minuteswest;
991 rtz.tz_dsttime = tz_dsttime;
992 error = copyout(&rtz, uap->tzp, sizeof(rtz));
998 linux_settimeofday(struct thread *td, struct linux_settimeofday_args *uap)
1001 struct timeval atv, *tvp;
1002 struct timezone atz, *tzp;
1006 error = copyin(uap->tp, &atv32, sizeof(atv32));
1009 atv.tv_sec = atv32.tv_sec;
1010 atv.tv_usec = atv32.tv_usec;
1015 error = copyin(uap->tzp, &atz, sizeof(atz));
1021 return (kern_settimeofday(td, tvp, tzp));
1025 linux_getrusage(struct thread *td, struct linux_getrusage_args *uap)
1027 struct l_rusage s32;
1031 error = kern_getrusage(td, uap->who, &s);
1034 if (uap->rusage != NULL) {
1035 s32.ru_utime.tv_sec = s.ru_utime.tv_sec;
1036 s32.ru_utime.tv_usec = s.ru_utime.tv_usec;
1037 s32.ru_stime.tv_sec = s.ru_stime.tv_sec;
1038 s32.ru_stime.tv_usec = s.ru_stime.tv_usec;
1039 s32.ru_maxrss = s.ru_maxrss;
1040 s32.ru_ixrss = s.ru_ixrss;
1041 s32.ru_idrss = s.ru_idrss;
1042 s32.ru_isrss = s.ru_isrss;
1043 s32.ru_minflt = s.ru_minflt;
1044 s32.ru_majflt = s.ru_majflt;
1045 s32.ru_nswap = s.ru_nswap;
1046 s32.ru_inblock = s.ru_inblock;
1047 s32.ru_oublock = s.ru_oublock;
1048 s32.ru_msgsnd = s.ru_msgsnd;
1049 s32.ru_msgrcv = s.ru_msgrcv;
1050 s32.ru_nsignals = s.ru_nsignals;
1051 s32.ru_nvcsw = s.ru_nvcsw;
1052 s32.ru_nivcsw = s.ru_nivcsw;
1053 error = copyout(&s32, uap->rusage, sizeof(s32));
1059 linux_sched_rr_get_interval(struct thread *td,
1060 struct linux_sched_rr_get_interval_args *uap)
1063 struct l_timespec ts32;
1066 error = kern_sched_rr_get_interval(td, uap->pid, &ts);
1069 ts32.tv_sec = ts.tv_sec;
1070 ts32.tv_nsec = ts.tv_nsec;
1071 return (copyout(&ts32, uap->interval, sizeof(ts32)));