Home | History | Annotate | Line # | Download | only in common
linux32_unistd.c revision 1.10.8.3
      1  1.10.8.3   matt /*	$NetBSD: linux32_unistd.c,v 1.10.8.3 2008/01/09 01:51:24 matt Exp $ */
      2       1.1   manu 
      3       1.1   manu /*-
      4       1.1   manu  * Copyright (c) 2006 Emmanuel Dreyfus, all rights reserved.
      5       1.1   manu  *
      6       1.1   manu  * Redistribution and use in source and binary forms, with or without
      7       1.1   manu  * modification, are permitted provided that the following conditions
      8       1.1   manu  * are met:
      9       1.1   manu  * 1. Redistributions of source code must retain the above copyright
     10       1.1   manu  *    notice, this list of conditions and the following disclaimer.
     11       1.1   manu  * 2. Redistributions in binary form must reproduce the above copyright
     12       1.1   manu  *    notice, this list of conditions and the following disclaimer in the
     13       1.1   manu  *    documentation and/or other materials provided with the distribution.
     14       1.1   manu  * 3. All advertising materials mentioning features or use of this software
     15       1.1   manu  *    must display the following acknowledgement:
     16       1.1   manu  *	This product includes software developed by Emmanuel Dreyfus
     17       1.1   manu  * 4. The name of the author may not be used to endorse or promote
     18       1.1   manu  *    products derived from this software without specific prior written
     19       1.1   manu  *    permission.
     20       1.1   manu  *
     21       1.1   manu  * THIS SOFTWARE IS PROVIDED BY THE THE AUTHOR AND CONTRIBUTORS ``AS IS''
     22       1.1   manu  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
     23       1.1   manu  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     24       1.1   manu  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS
     25       1.1   manu  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     26       1.1   manu  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     27       1.1   manu  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     28       1.1   manu  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     29       1.1   manu  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     30       1.1   manu  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     31       1.1   manu  * POSSIBILITY OF SUCH DAMAGE.
     32       1.1   manu  */
     33       1.1   manu 
     34       1.1   manu #include <sys/cdefs.h>
     35       1.1   manu 
     36  1.10.8.3   matt __KERNEL_RCSID(0, "$NetBSD: linux32_unistd.c,v 1.10.8.3 2008/01/09 01:51:24 matt Exp $");
     37       1.1   manu 
     38       1.1   manu #include <sys/types.h>
     39       1.1   manu #include <sys/param.h>
     40       1.1   manu #include <sys/fstypes.h>
     41       1.1   manu #include <sys/signal.h>
     42       1.1   manu #include <sys/dirent.h>
     43       1.1   manu #include <sys/kernel.h>
     44       1.1   manu #include <sys/fcntl.h>
     45       1.1   manu #include <sys/select.h>
     46       1.1   manu #include <sys/proc.h>
     47       1.1   manu #include <sys/ucred.h>
     48       1.1   manu #include <sys/swap.h>
     49       1.1   manu 
     50       1.1   manu #include <machine/types.h>
     51       1.1   manu 
     52       1.1   manu #include <sys/syscallargs.h>
     53       1.1   manu 
     54       1.1   manu #include <compat/netbsd32/netbsd32.h>
     55       1.1   manu #include <compat/netbsd32/netbsd32_conv.h>
     56       1.1   manu #include <compat/netbsd32/netbsd32_syscallargs.h>
     57       1.1   manu 
     58       1.1   manu #include <compat/linux/common/linux_types.h>
     59       1.1   manu #include <compat/linux/common/linux_signal.h>
     60       1.1   manu #include <compat/linux/common/linux_machdep.h>
     61       1.1   manu #include <compat/linux/common/linux_misc.h>
     62       1.1   manu #include <compat/linux/common/linux_oldolduname.h>
     63       1.1   manu #include <compat/linux/linux_syscallargs.h>
     64       1.1   manu 
     65       1.1   manu #include <compat/linux32/common/linux32_types.h>
     66       1.1   manu #include <compat/linux32/common/linux32_signal.h>
     67       1.1   manu #include <compat/linux32/common/linux32_machdep.h>
     68       1.1   manu #include <compat/linux32/common/linux32_sysctl.h>
     69       1.1   manu #include <compat/linux32/common/linux32_socketcall.h>
     70       1.1   manu #include <compat/linux32/linux32_syscallargs.h>
     71       1.1   manu 
     72       1.1   manu static int linux32_select1(struct lwp *, register_t *,
     73       1.1   manu     int, fd_set *, fd_set *, fd_set *, struct timeval *);
     74       1.1   manu 
     75       1.1   manu int
     76  1.10.8.3   matt linux32_sys_brk(struct lwp *l, const struct linux32_sys_brk_args *uap, register_t *retval)
     77       1.1   manu {
     78  1.10.8.3   matt 	/* {
     79       1.1   manu 		syscallarg(netbsd32_charp) nsize;
     80  1.10.8.3   matt 	} */
     81       1.1   manu 	struct linux_sys_brk_args ua;
     82       1.1   manu 
     83       1.1   manu 	NETBSD32TOP_UAP(nsize, char);
     84       1.1   manu 	return linux_sys_brk(l, &ua, retval);
     85       1.1   manu }
     86       1.1   manu 
     87       1.1   manu int
     88  1.10.8.3   matt linux32_sys_llseek(struct lwp *l, const struct linux32_sys_llseek_args *uap, register_t *retval)
     89       1.1   manu {
     90  1.10.8.3   matt 	/* {
     91       1.1   manu 		syscallcarg(int) fd;
     92       1.1   manu                 syscallarg(u_int32_t) ohigh;
     93       1.1   manu                 syscallarg(u_int32_t) olow;
     94  1.10.8.3   matt 		syscallarg(netbsd32_caddr_t) res;
     95       1.1   manu 		syscallcarg(int) whence;
     96  1.10.8.3   matt 	} */
     97       1.1   manu 	struct linux_sys_llseek_args ua;
     98       1.1   manu 
     99       1.1   manu 	NETBSD32TO64_UAP(fd);
    100       1.1   manu 	NETBSD32TO64_UAP(ohigh);
    101       1.1   manu 	NETBSD32TO64_UAP(olow);
    102       1.1   manu 	NETBSD32TOP_UAP(res, char);
    103       1.1   manu 	NETBSD32TO64_UAP(whence);
    104       1.1   manu 
    105       1.1   manu 	return linux_sys_llseek(l, &ua, retval);
    106       1.1   manu }
    107       1.1   manu 
    108       1.1   manu int
    109  1.10.8.3   matt linux32_sys_select(struct lwp *l, const struct linux32_sys_select_args *uap, register_t *retval)
    110       1.1   manu {
    111  1.10.8.3   matt 	/* {
    112       1.1   manu 		syscallarg(int) nfds;
    113       1.1   manu 		syscallarg(netbsd32_fd_setp_t) readfds;
    114       1.1   manu 		syscallarg(netbsd32_fd_setp_t) writefds;
    115       1.1   manu 		syscallarg(netbsd32_fd_setp_t) exceptfds;
    116       1.1   manu 		syscallarg(netbsd32_timevalp_t) timeout;
    117  1.10.8.3   matt 	} */
    118       1.1   manu 
    119       1.1   manu 	return linux32_select1(l, retval, SCARG(uap, nfds),
    120       1.7    dsl 	    SCARG_P32(uap, readfds),
    121       1.7    dsl 	    SCARG_P32(uap, writefds),
    122       1.7    dsl 	    SCARG_P32(uap, exceptfds),
    123       1.7    dsl 	    SCARG_P32(uap, timeout));
    124       1.1   manu }
    125       1.1   manu 
    126       1.1   manu int
    127  1.10.8.3   matt linux32_sys_oldselect(struct lwp *l, const struct linux32_sys_oldselect_args *uap, register_t *retval)
    128       1.1   manu {
    129  1.10.8.3   matt 	/* {
    130       1.1   manu 		syscallarg(linux32_oldselectp_t) lsp;
    131  1.10.8.3   matt 	} */
    132       1.1   manu 	struct linux32_oldselect lsp32;
    133       1.1   manu 	int error;
    134       1.1   manu 
    135       1.7    dsl 	if ((error = copyin(SCARG_P32(uap, lsp), &lsp32, sizeof(lsp32))) != 0)
    136       1.1   manu 		return error;
    137       1.1   manu 
    138       1.1   manu 	return linux32_select1(l, retval, lsp32.nfds,
    139       1.1   manu 	     NETBSD32PTR64(lsp32.readfds), NETBSD32PTR64(lsp32.writefds),
    140       1.1   manu 	     NETBSD32PTR64(lsp32.exceptfds), NETBSD32PTR64(lsp32.timeout));
    141       1.1   manu }
    142       1.1   manu 
    143       1.1   manu static int
    144       1.1   manu linux32_select1(l, retval, nfds, readfds, writefds, exceptfds, timeout)
    145       1.1   manu         struct lwp *l;
    146       1.1   manu         register_t *retval;
    147       1.1   manu         int nfds;
    148       1.1   manu         fd_set *readfds, *writefds, *exceptfds;
    149       1.1   manu         struct timeval *timeout;
    150       1.1   manu {
    151      1.10    dsl 	struct timeval tv0, tv1, utv, *tv = NULL;
    152       1.1   manu 	struct netbsd32_timeval utv32;
    153       1.1   manu 	int error;
    154       1.1   manu 
    155      1.10    dsl 	timerclear(&utv); /* XXX GCC4 */
    156       1.2    skd 
    157       1.1   manu 	/*
    158       1.1   manu 	 * Store current time for computation of the amount of
    159       1.1   manu 	 * time left.
    160       1.1   manu 	 */
    161       1.1   manu 	if (timeout) {
    162       1.1   manu 		if ((error = copyin(timeout, &utv32, sizeof(utv32))))
    163       1.1   manu 			return error;
    164       1.1   manu 
    165       1.1   manu 		netbsd32_to_timeval(&utv32, &utv);
    166       1.1   manu 
    167       1.1   manu 		if (itimerfix(&utv)) {
    168       1.1   manu 			/*
    169       1.1   manu 			 * The timeval was invalid.  Convert it to something
    170       1.1   manu 			 * valid that will act as it does under Linux.
    171       1.1   manu 			 */
    172       1.1   manu 			utv.tv_sec += utv.tv_usec / 1000000;
    173       1.1   manu 			utv.tv_usec %= 1000000;
    174       1.1   manu 			if (utv.tv_usec < 0) {
    175       1.1   manu 				utv.tv_sec -= 1;
    176       1.1   manu 				utv.tv_usec += 1000000;
    177       1.1   manu 			}
    178       1.1   manu 			if (utv.tv_sec < 0)
    179       1.1   manu 				timerclear(&utv);
    180       1.1   manu 		}
    181       1.1   manu 		microtime(&tv0);
    182       1.8  njoly 		tv = &utv;
    183       1.1   manu 	}
    184       1.1   manu 
    185       1.1   manu 	error = selcommon(l, retval, nfds,
    186       1.8  njoly 	    readfds, writefds, exceptfds, tv, NULL);
    187       1.1   manu 
    188       1.1   manu 	if (error) {
    189       1.1   manu 		/*
    190       1.1   manu 		 * See fs/select.c in the Linux kernel.  Without this,
    191       1.1   manu 		 * Maelstrom doesn't work.
    192       1.1   manu 		 */
    193       1.1   manu 		if (error == ERESTART)
    194       1.1   manu 			error = EINTR;
    195       1.1   manu 		return error;
    196       1.1   manu 	}
    197       1.1   manu 
    198       1.1   manu 	if (timeout) {
    199       1.1   manu 		if (*retval) {
    200       1.1   manu 			/*
    201       1.1   manu 			 * Compute how much time was left of the timeout,
    202       1.1   manu 			 * by subtracting the current time and the time
    203       1.1   manu 			 * before we started the call, and subtracting
    204       1.1   manu 			 * that result from the user-supplied value.
    205       1.1   manu 			 */
    206       1.1   manu 			microtime(&tv1);
    207       1.1   manu 			timersub(&tv1, &tv0, &tv1);
    208      1.10    dsl 			timersub(&utv, &tv1, &utv);
    209       1.1   manu 			if (utv.tv_sec < 0)
    210       1.1   manu 				timerclear(&utv);
    211       1.1   manu 		} else {
    212       1.1   manu 			timerclear(&utv);
    213       1.1   manu 		}
    214       1.1   manu 
    215       1.1   manu 		netbsd32_from_timeval(&utv, &utv32);
    216       1.1   manu 
    217       1.1   manu 		if ((error = copyout(&utv32, timeout, sizeof(utv32))))
    218       1.1   manu 			return error;
    219       1.1   manu 	}
    220       1.1   manu 
    221       1.1   manu 	return 0;
    222       1.1   manu }
    223       1.1   manu 
    224       1.1   manu int
    225  1.10.8.3   matt linux32_sys_pipe(struct lwp *l, const struct linux32_sys_pipe_args *uap, register_t *retval)
    226       1.1   manu {
    227  1.10.8.3   matt 	/* {
    228       1.1   manu 		syscallarg(netbsd32_intp) fd;
    229  1.10.8.3   matt 	} */
    230       1.1   manu 	int error;
    231       1.1   manu 	int pfds[2];
    232       1.1   manu 
    233       1.1   manu 	if ((error = sys_pipe(l, 0, retval)))
    234       1.1   manu 		return error;
    235       1.1   manu 
    236       1.1   manu 	pfds[0] = (int)retval[0];
    237       1.1   manu 	pfds[1] = (int)retval[1];
    238       1.1   manu 
    239       1.7    dsl 	if ((error = copyout(pfds, SCARG_P32(uap, fd), 2 * sizeof (int))) != 0)
    240       1.1   manu 		return error;
    241       1.1   manu 
    242       1.1   manu 	retval[0] = 0;
    243       1.1   manu 	retval[1] = 0;
    244       1.1   manu 
    245       1.1   manu 	return 0;
    246       1.1   manu }
    247       1.1   manu 
    248       1.1   manu 
    249       1.1   manu int
    250  1.10.8.3   matt linux32_sys_unlink(struct lwp *l, const struct linux32_sys_unlink_args *uap, register_t *retval)
    251       1.1   manu {
    252  1.10.8.3   matt 	/* {
    253       1.1   manu 		syscallarg(const netbsd32_charp) path;
    254  1.10.8.3   matt 	} */
    255       1.1   manu 	struct linux_sys_unlink_args ua;
    256       1.1   manu 
    257       1.1   manu 	NETBSD32TOP_UAP(path, const char);
    258       1.1   manu 
    259       1.1   manu 	return linux_sys_unlink(l, &ua, retval);
    260       1.1   manu }
    261       1.1   manu 
    262       1.1   manu int
    263  1.10.8.3   matt linux32_sys_creat(struct lwp *l, const struct linux32_sys_creat_args *uap, register_t *retval)
    264       1.1   manu {
    265  1.10.8.3   matt 	/* {
    266       1.1   manu 		syscallarg(const netbsd32_charp) path;
    267       1.1   manu 		syscallarg(int) mode;
    268  1.10.8.3   matt 	} */
    269       1.1   manu 	struct sys_open_args ua;
    270       1.1   manu 
    271       1.1   manu 	NETBSD32TOP_UAP(path, const char);
    272       1.1   manu 	SCARG(&ua, flags) = O_CREAT | O_TRUNC | O_WRONLY;
    273       1.1   manu 	NETBSD32TO64_UAP(mode);
    274       1.1   manu 
    275       1.1   manu 	return sys_open(l, &ua, retval);
    276       1.1   manu }
    277       1.1   manu 
    278       1.1   manu int
    279  1.10.8.3   matt linux32_sys_mknod(struct lwp *l, const struct linux32_sys_mknod_args *uap, register_t *retval)
    280       1.1   manu {
    281  1.10.8.3   matt 	/* {
    282       1.1   manu 		syscallarg(const netbsd32_charp) path;
    283       1.1   manu 		syscallarg(int) mode;
    284       1.1   manu 		syscallarg(int) dev;
    285  1.10.8.3   matt 	} */
    286       1.1   manu 	struct linux_sys_mknod_args ua;
    287       1.1   manu 
    288       1.1   manu 	NETBSD32TOP_UAP(path, const char);
    289       1.1   manu 	NETBSD32TO64_UAP(mode);
    290       1.1   manu 	NETBSD32TO64_UAP(dev);
    291       1.1   manu 
    292       1.1   manu 	return linux_sys_mknod(l, &ua, retval);
    293       1.1   manu }
    294       1.1   manu 
    295       1.1   manu int
    296  1.10.8.3   matt linux32_sys_chown16(struct lwp *l, const struct linux32_sys_chown16_args *uap, register_t *retval)
    297       1.1   manu {
    298  1.10.8.3   matt 	/* {
    299       1.1   manu 		syscallarg(const netbsd32_charp) path;
    300  1.10.8.1   matt 		syscallarg(int) uid;
    301  1.10.8.1   matt 		syscallarg(int) gid;
    302  1.10.8.3   matt 	} */
    303  1.10.8.1   matt         struct sys___posix_chown_args ua;
    304       1.1   manu 
    305       1.1   manu 	NETBSD32TOP_UAP(path, const char);
    306       1.1   manu 
    307  1.10.8.1   matt         if ((linux32_uid_t)SCARG(uap, uid) == (linux32_uid_t)-1)
    308  1.10.8.1   matt         	SCARG(&ua, uid) = (uid_t)-1;
    309  1.10.8.1   matt 	else
    310  1.10.8.1   matt         	SCARG(&ua, uid) = SCARG(uap, uid);
    311  1.10.8.1   matt 
    312  1.10.8.1   matt         if ((linux32_gid_t)SCARG(uap, gid) == (linux32_gid_t)-1)
    313  1.10.8.1   matt         	SCARG(&ua, gid) = (gid_t)-1;
    314  1.10.8.1   matt 	else
    315  1.10.8.1   matt         	SCARG(&ua, gid) = SCARG(uap, gid);
    316  1.10.8.1   matt 
    317  1.10.8.1   matt         return sys___posix_chown(l, &ua, retval);
    318       1.1   manu }
    319       1.1   manu 
    320       1.1   manu int
    321  1.10.8.3   matt linux32_sys_lchown16(struct lwp *l, const struct linux32_sys_lchown16_args *uap, register_t *retval)
    322       1.1   manu {
    323  1.10.8.3   matt 	/* {
    324       1.1   manu 		syscallarg(const netbsd32_charp) path;
    325       1.1   manu 		syscallarg(int) uid;
    326       1.1   manu 		syscallarg(int) gid;
    327  1.10.8.3   matt 	} */
    328       1.1   manu         struct sys___posix_lchown_args ua;
    329       1.1   manu 
    330       1.1   manu 	NETBSD32TOP_UAP(path, const char);
    331       1.1   manu 
    332       1.1   manu         if ((linux32_uid_t)SCARG(uap, uid) == (linux32_uid_t)-1)
    333       1.1   manu         	SCARG(&ua, uid) = (uid_t)-1;
    334       1.1   manu 	else
    335       1.1   manu         	SCARG(&ua, uid) = SCARG(uap, uid);
    336       1.1   manu 
    337       1.1   manu         if ((linux32_gid_t)SCARG(uap, gid) == (linux32_gid_t)-1)
    338       1.1   manu         	SCARG(&ua, gid) = (gid_t)-1;
    339       1.1   manu 	else
    340       1.1   manu         	SCARG(&ua, gid) = SCARG(uap, gid);
    341       1.1   manu 
    342       1.1   manu         return sys___posix_lchown(l, &ua, retval);
    343       1.1   manu }
    344       1.1   manu 
    345       1.1   manu int
    346  1.10.8.3   matt linux32_sys_break(struct lwp *l, const struct linux32_sys_break_args *uap, register_t *retval)
    347       1.1   manu {
    348       1.1   manu #if 0
    349  1.10.8.3   matt 	/* {
    350       1.1   manu 		syscallarg(const netbsd32_charp) nsize;
    351  1.10.8.3   matt 	} */
    352       1.1   manu #endif
    353       1.1   manu 
    354       1.1   manu 	return ENOSYS;
    355       1.1   manu }
    356       1.1   manu 
    357       1.1   manu int
    358  1.10.8.3   matt linux32_sys_rename(struct lwp *l, const struct linux32_sys_rename_args *uap, register_t *retval)
    359       1.1   manu {
    360  1.10.8.3   matt 	/* {
    361       1.1   manu 		syscallarg(const netbsd32_charp) from;
    362       1.1   manu 		syscallarg(const netbsd32_charp) to;
    363  1.10.8.3   matt 	} */
    364  1.10.8.3   matt 	struct sys___posix_rename_args ua;
    365       1.1   manu 
    366       1.1   manu 	NETBSD32TOP_UAP(from, const char);
    367       1.1   manu 	NETBSD32TOP_UAP(to, const char);
    368       1.1   manu 
    369       1.1   manu 	return sys___posix_rename(l, &ua, retval);
    370       1.1   manu }
    371       1.1   manu 
    372       1.1   manu int
    373  1.10.8.3   matt linux32_sys_getgroups16(struct lwp *l, const struct linux32_sys_getgroups16_args *uap, register_t *retval)
    374       1.1   manu {
    375  1.10.8.3   matt 	/* {
    376       1.1   manu 		syscallarg(int) gidsetsize;
    377       1.1   manu 		syscallarg(linux32_gidp_t) gidset;
    378  1.10.8.3   matt 	} */
    379       1.1   manu 	struct linux_sys_getgroups16_args ua;
    380       1.1   manu 
    381       1.1   manu 	NETBSD32TO64_UAP(gidsetsize);
    382       1.4   manu 	NETBSD32TOP_UAP(gidset, linux_gid_t);
    383       1.1   manu 
    384       1.1   manu 	return linux_sys_getgroups16(l, &ua, retval);
    385       1.1   manu }
    386       1.1   manu 
    387       1.1   manu int
    388  1.10.8.3   matt linux32_sys_setgroups16(struct lwp *l, const struct linux32_sys_setgroups16_args *uap, register_t *retval)
    389       1.1   manu {
    390  1.10.8.3   matt 	/* {
    391       1.1   manu 		syscallarg(int) gidsetsize;
    392       1.1   manu 		syscallarg(linux32_gidp_t) gidset;
    393  1.10.8.3   matt 	} */
    394       1.1   manu 	struct linux_sys_setgroups16_args ua;
    395       1.1   manu 
    396       1.1   manu 	NETBSD32TO64_UAP(gidsetsize);
    397       1.4   manu 	NETBSD32TOP_UAP(gidset, linux_gid_t);
    398       1.1   manu 
    399       1.1   manu 	return linux_sys_setgroups16(l, &ua, retval);
    400       1.1   manu }
    401       1.1   manu 
    402       1.1   manu int
    403  1.10.8.3   matt linux32_sys_swapon(struct lwp *l, const struct linux32_sys_swapon_args *uap, register_t *retval)
    404       1.1   manu {
    405  1.10.8.3   matt 	/* {
    406       1.1   manu 		syscallarg(const netbsd32_charp) name;
    407  1.10.8.3   matt 	} */
    408       1.1   manu 	struct sys_swapctl_args ua;
    409       1.1   manu 
    410       1.1   manu         SCARG(&ua, cmd) = SWAP_ON;
    411       1.7    dsl         SCARG(&ua, arg) = SCARG_P32(uap, name);
    412       1.1   manu         SCARG(&ua, misc) = 0;   /* priority */
    413       1.1   manu         return (sys_swapctl(l, &ua, retval));
    414       1.1   manu }
    415       1.1   manu 
    416       1.1   manu int
    417  1.10.8.3   matt linux32_sys_swapoff(struct lwp *l, const struct linux32_sys_swapoff_args *uap, register_t *retval)
    418       1.1   manu {
    419  1.10.8.3   matt 	/* {
    420       1.1   manu 		syscallarg(const netbsd32_charp) path;
    421  1.10.8.3   matt 	} */
    422       1.1   manu 	struct sys_swapctl_args ua;
    423       1.1   manu 
    424       1.1   manu         SCARG(&ua, cmd) = SWAP_OFF;
    425       1.7    dsl         SCARG(&ua, arg) = SCARG_P32(uap, path);
    426       1.1   manu         SCARG(&ua, misc) = 0;   /* priority */
    427       1.1   manu         return (sys_swapctl(l, &ua, retval));
    428       1.1   manu }
    429       1.1   manu 
    430       1.1   manu 
    431       1.1   manu int
    432  1.10.8.3   matt linux32_sys_reboot(struct lwp *l, const struct linux32_sys_reboot_args *uap, register_t *retval)
    433       1.1   manu {
    434  1.10.8.3   matt 	/* {
    435       1.1   manu 		syscallarg(int) magic1;
    436       1.1   manu 		syscallarg(int) magic2;
    437       1.1   manu 		syscallarg(int) cmd;
    438       1.1   manu 		syscallarg(netbsd32_voidp) arg;
    439  1.10.8.3   matt 	} */
    440       1.1   manu 	struct linux_sys_reboot_args ua;
    441       1.1   manu 
    442       1.1   manu 	NETBSD32TO64_UAP(magic1);
    443       1.1   manu 	NETBSD32TO64_UAP(magic2);
    444       1.1   manu 	NETBSD32TO64_UAP(cmd);
    445       1.1   manu 	NETBSD32TOP_UAP(arg, void);
    446       1.1   manu 
    447       1.1   manu 	return linux_sys_reboot(l, &ua, retval);
    448       1.1   manu }
    449       1.1   manu 
    450       1.1   manu int
    451  1.10.8.3   matt linux32_sys_truncate(struct lwp *l, const struct linux32_sys_truncate_args *uap, register_t *retval)
    452       1.1   manu {
    453  1.10.8.3   matt 	/* {
    454       1.1   manu 		syscallarg(const netbsd32_charp) path;
    455       1.1   manu 		syscallarg(netbsd32_charp) buf;
    456       1.1   manu 		syscallarg(int) count;
    457  1.10.8.3   matt 	} */
    458       1.1   manu 	struct compat_43_sys_truncate_args ua;
    459       1.1   manu 
    460       1.1   manu 	NETBSD32TOP_UAP(path, const char);
    461       1.1   manu 	NETBSD32TO64_UAP(length);
    462       1.1   manu 
    463       1.1   manu 	return compat_43_sys_truncate(l, &ua, retval);
    464       1.1   manu }
    465       1.1   manu 
    466       1.1   manu int
    467  1.10.8.3   matt linux32_sys_fchown16(struct lwp *l, const struct linux32_sys_fchown16_args *uap, register_t *retval)
    468       1.1   manu {
    469  1.10.8.3   matt 	/* {
    470       1.1   manu 		syscallarg(int) fd;
    471       1.1   manu 		syscallarg(int) uid;
    472       1.1   manu 		syscallarg(int) gid;
    473  1.10.8.3   matt 	} */
    474       1.1   manu         struct sys___posix_fchown_args ua;
    475       1.1   manu 
    476       1.1   manu 	SCARG(&ua, fd) = SCARG(uap, fd);
    477       1.1   manu 
    478       1.1   manu         if ((linux32_uid_t)SCARG(uap, uid) == (linux32_uid_t)-1)
    479       1.1   manu         	SCARG(&ua, uid) = (uid_t)-1;
    480       1.1   manu 	else
    481       1.1   manu         	SCARG(&ua, uid) = SCARG(uap, uid);
    482       1.1   manu 
    483       1.1   manu         if ((linux32_gid_t)SCARG(uap, gid) == (linux32_gid_t)-1)
    484       1.1   manu         	SCARG(&ua, gid) = (gid_t)-1;
    485       1.1   manu 	else
    486       1.1   manu         	SCARG(&ua, gid) = SCARG(uap, gid);
    487       1.1   manu 
    488       1.1   manu         return sys___posix_fchown(l, &ua, retval);
    489       1.1   manu }
    490       1.3   manu 
    491       1.3   manu int
    492  1.10.8.3   matt linux32_sys_setresuid(struct lwp *l, const struct linux32_sys_setresuid_args *uap, register_t *retval)
    493       1.3   manu {
    494  1.10.8.3   matt 	/* {
    495       1.3   manu 		syscallarg(uid_t) ruid;
    496       1.3   manu 		syscallarg(uid_t) euid;
    497       1.3   manu 		syscallarg(uid_t) suid;
    498  1.10.8.3   matt 	} */
    499       1.3   manu 	struct linux_sys_setresuid_args ua;
    500       1.3   manu 
    501       1.3   manu 	SCARG(&ua, ruid) = (SCARG(uap, ruid) == -1) ? -1 : SCARG(uap, ruid);
    502       1.3   manu 	SCARG(&ua, euid) = (SCARG(uap, euid) == -1) ? -1 : SCARG(uap, euid);
    503       1.3   manu 	SCARG(&ua, suid) = (SCARG(uap, suid) == -1) ? -1 : SCARG(uap, suid);
    504       1.3   manu 
    505       1.3   manu 	return linux_sys_setresuid(l, &ua, retval);
    506       1.3   manu }
    507       1.3   manu 
    508       1.3   manu int
    509  1.10.8.3   matt linux32_sys_setresgid(struct lwp *l, const struct linux32_sys_setresgid_args *uap, register_t *retval)
    510       1.3   manu {
    511  1.10.8.3   matt 	/* {
    512       1.3   manu 		syscallarg(gid_t) rgid;
    513       1.3   manu 		syscallarg(gid_t) egid;
    514       1.3   manu 		syscallarg(gid_t) sgid;
    515  1.10.8.3   matt 	} */
    516       1.3   manu 	struct linux_sys_setresgid_args ua;
    517       1.3   manu 
    518       1.3   manu 	SCARG(&ua, rgid) = (SCARG(uap, rgid) == -1) ? -1 : SCARG(uap, rgid);
    519       1.3   manu 	SCARG(&ua, egid) = (SCARG(uap, egid) == -1) ? -1 : SCARG(uap, egid);
    520       1.3   manu 	SCARG(&ua, sgid) = (SCARG(uap, sgid) == -1) ? -1 : SCARG(uap, sgid);
    521       1.3   manu 
    522       1.3   manu 	return linux_sys_setresgid(l, &ua, retval);
    523       1.3   manu }
    524  1.10.8.2   matt 
    525  1.10.8.2   matt int
    526  1.10.8.3   matt linux32_sys_nice(struct lwp *l, const struct linux32_sys_nice_args *uap, register_t *retval)
    527  1.10.8.2   matt {
    528  1.10.8.3   matt 	/* {
    529  1.10.8.2   matt 		syscallarg(int) incr;
    530  1.10.8.3   matt 	} */
    531  1.10.8.2   matt 	struct netbsd32_setpriority_args bsa;
    532  1.10.8.2   matt 
    533  1.10.8.2   matt 	SCARG(&bsa, which) = PRIO_PROCESS;
    534  1.10.8.2   matt 	SCARG(&bsa, who) = 0;
    535  1.10.8.2   matt 	SCARG(&bsa, prio) = SCARG(uap, incr);
    536  1.10.8.2   matt 
    537  1.10.8.2   matt 	return netbsd32_setpriority(l, &bsa, retval);
    538  1.10.8.2   matt }
    539  1.10.8.2   matt 
    540  1.10.8.2   matt int
    541  1.10.8.3   matt linux32_sys_alarm(struct lwp *l, const struct linux32_sys_alarm_args *uap, register_t *retval)
    542  1.10.8.2   matt {
    543  1.10.8.3   matt 	/* {
    544  1.10.8.2   matt 		syscallarg(unsigned int) secs;
    545  1.10.8.3   matt 	} */
    546  1.10.8.2   matt 	struct linux_sys_alarm_args ua;
    547  1.10.8.2   matt 
    548  1.10.8.2   matt 	NETBSD32TO64_UAP(secs);
    549  1.10.8.2   matt 
    550  1.10.8.2   matt 	return linux_sys_alarm(l, &ua, retval);
    551  1.10.8.2   matt }
    552  1.10.8.2   matt 
    553  1.10.8.2   matt int
    554  1.10.8.3   matt linux32_sys_fdatasync(struct lwp *l, const struct linux32_sys_fdatasync_args *uap, register_t *retval)
    555  1.10.8.2   matt {
    556  1.10.8.3   matt 	/* {
    557  1.10.8.2   matt 		syscallarg(int) fd;
    558  1.10.8.3   matt 	} */
    559  1.10.8.2   matt 	struct linux_sys_fdatasync_args ua;
    560  1.10.8.2   matt 
    561  1.10.8.2   matt 	NETBSD32TO64_UAP(fd);
    562  1.10.8.2   matt 
    563  1.10.8.2   matt 	return linux_sys_fdatasync(l, &ua, retval);
    564  1.10.8.2   matt }
    565  1.10.8.2   matt 
    566  1.10.8.2   matt int
    567  1.10.8.3   matt linux32_sys_setfsuid(struct lwp *l, const struct linux32_sys_setfsuid_args *uap, register_t *retval)
    568  1.10.8.2   matt {
    569  1.10.8.3   matt 	/* {
    570  1.10.8.2   matt 		syscallarg(uid_t) uid;
    571  1.10.8.3   matt 	} */
    572  1.10.8.2   matt 	struct linux_sys_setfsuid_args ua;
    573  1.10.8.2   matt 
    574  1.10.8.2   matt 	NETBSD32TO64_UAP(uid);
    575  1.10.8.2   matt 
    576  1.10.8.2   matt 	return linux_sys_setfsuid(l, &ua, retval);
    577  1.10.8.2   matt }
    578  1.10.8.2   matt 
    579  1.10.8.2   matt int
    580  1.10.8.3   matt linux32_sys_setfsgid(struct lwp *l, const struct linux32_sys_setfsgid_args *uap, register_t *retval)
    581  1.10.8.3   matt {
    582  1.10.8.3   matt 	/* {
    583  1.10.8.3   matt 		syscallarg(gid_t) gid;
    584  1.10.8.3   matt 	} */
    585  1.10.8.3   matt 	struct linux_sys_setfsgid_args ua;
    586  1.10.8.3   matt 
    587  1.10.8.3   matt 	NETBSD32TO64_UAP(gid);
    588  1.10.8.3   matt 
    589  1.10.8.3   matt 	return linux_sys_setfsgid(l, &ua, retval);
    590  1.10.8.3   matt }
    591  1.10.8.3   matt 
    592  1.10.8.3   matt int
    593  1.10.8.3   matt linux32_sys_setreuid16(struct lwp *l, const struct linux32_sys_setreuid16_args *uap, register_t *retval)
    594  1.10.8.2   matt {
    595  1.10.8.3   matt 	/* {
    596  1.10.8.2   matt 		syscallarg(int) ruid;
    597  1.10.8.2   matt 		syscallarg(int) euid;
    598  1.10.8.3   matt 	} */
    599  1.10.8.2   matt 	struct sys_setreuid_args bsa;
    600  1.10.8.2   matt 
    601  1.10.8.2   matt 	if ((linux32_uid_t)SCARG(uap, ruid) == (linux32_uid_t)-1)
    602  1.10.8.2   matt 		SCARG(&bsa, ruid) = (uid_t)-1;
    603  1.10.8.2   matt 	else
    604  1.10.8.2   matt 		SCARG(&bsa, ruid) = SCARG(uap, ruid);
    605  1.10.8.2   matt 	if ((linux32_uid_t)SCARG(uap, euid) == (linux32_uid_t)-1)
    606  1.10.8.2   matt 		SCARG(&bsa, euid) = (uid_t)-1;
    607  1.10.8.2   matt 	else
    608  1.10.8.2   matt 		SCARG(&bsa, euid) = SCARG(uap, euid);
    609  1.10.8.2   matt 
    610  1.10.8.2   matt 	return sys_setreuid(l, &bsa, retval);
    611  1.10.8.2   matt }
    612  1.10.8.2   matt 
    613  1.10.8.2   matt int
    614  1.10.8.3   matt linux32_sys_setregid16(struct lwp *l, const struct linux32_sys_setregid16_args *uap, register_t *retval)
    615  1.10.8.2   matt {
    616  1.10.8.3   matt 	/* {
    617  1.10.8.2   matt 		syscallarg(int) rgid;
    618  1.10.8.2   matt 		syscallarg(int) egid;
    619  1.10.8.3   matt 	} */
    620  1.10.8.2   matt 	struct sys_setregid_args bsa;
    621  1.10.8.2   matt 
    622  1.10.8.2   matt 	if ((linux32_gid_t)SCARG(uap, rgid) == (linux32_gid_t)-1)
    623  1.10.8.2   matt 		SCARG(&bsa, rgid) = (gid_t)-1;
    624  1.10.8.2   matt 	else
    625  1.10.8.2   matt 		SCARG(&bsa, rgid) = SCARG(uap, rgid);
    626  1.10.8.2   matt 	if ((linux32_gid_t)SCARG(uap, egid) == (linux32_gid_t)-1)
    627  1.10.8.2   matt 		SCARG(&bsa, egid) = (gid_t)-1;
    628  1.10.8.2   matt 	else
    629  1.10.8.2   matt 		SCARG(&bsa, egid) = SCARG(uap, egid);
    630  1.10.8.2   matt 
    631  1.10.8.2   matt 	return sys_setregid(l, &bsa, retval);
    632  1.10.8.2   matt }
    633  1.10.8.2   matt 
    634  1.10.8.2   matt int
    635  1.10.8.3   matt linux32_sys_setresuid16(struct lwp *l, const struct linux32_sys_setresuid16_args *uap, register_t *retval)
    636  1.10.8.2   matt {
    637  1.10.8.3   matt 	/* {
    638  1.10.8.2   matt 		syscallarg(uid_t) ruid;
    639  1.10.8.2   matt 		syscallarg(uid_t) euid;
    640  1.10.8.2   matt 		syscallarg(uid_t) suid;
    641  1.10.8.3   matt 	} */
    642  1.10.8.2   matt 	struct linux32_sys_setresuid_args lsa;
    643  1.10.8.2   matt 
    644  1.10.8.2   matt 	if ((linux32_uid_t)SCARG(uap, ruid) == (linux32_uid_t)-1)
    645  1.10.8.2   matt 		SCARG(&lsa, ruid) = (uid_t)-1;
    646  1.10.8.2   matt 	else
    647  1.10.8.2   matt 		SCARG(&lsa, ruid) = SCARG(uap, ruid);
    648  1.10.8.2   matt 	if ((linux32_uid_t)SCARG(uap, euid) == (linux32_uid_t)-1)
    649  1.10.8.2   matt 		SCARG(&lsa, euid) = (uid_t)-1;
    650  1.10.8.2   matt 	else
    651  1.10.8.2   matt 		SCARG(&lsa, euid) = SCARG(uap, euid);
    652  1.10.8.2   matt 	if ((linux32_uid_t)SCARG(uap, suid) == (linux32_uid_t)-1)
    653  1.10.8.2   matt 		SCARG(&lsa, suid) = (uid_t)-1;
    654  1.10.8.2   matt 	else
    655  1.10.8.2   matt 		SCARG(&lsa, suid) = SCARG(uap, euid);
    656  1.10.8.2   matt 
    657  1.10.8.2   matt 	return linux32_sys_setresuid(l, &lsa, retval);
    658  1.10.8.2   matt }
    659  1.10.8.2   matt 
    660  1.10.8.2   matt int
    661  1.10.8.3   matt linux32_sys_setresgid16(struct lwp *l, const struct linux32_sys_setresgid16_args *uap, register_t *retval)
    662  1.10.8.2   matt {
    663  1.10.8.3   matt 	/* {
    664  1.10.8.2   matt 		syscallarg(gid_t) rgid;
    665  1.10.8.2   matt 		syscallarg(gid_t) egid;
    666  1.10.8.2   matt 		syscallarg(gid_t) sgid;
    667  1.10.8.3   matt 	} */
    668  1.10.8.2   matt 	struct linux32_sys_setresgid_args lsa;
    669  1.10.8.2   matt 
    670  1.10.8.2   matt 	if ((linux32_gid_t)SCARG(uap, rgid) == (linux32_gid_t)-1)
    671  1.10.8.2   matt 		SCARG(&lsa, rgid) = (gid_t)-1;
    672  1.10.8.2   matt 	else
    673  1.10.8.2   matt 		SCARG(&lsa, rgid) = SCARG(uap, rgid);
    674  1.10.8.2   matt 	if ((linux32_gid_t)SCARG(uap, egid) == (linux32_gid_t)-1)
    675  1.10.8.2   matt 		SCARG(&lsa, egid) = (gid_t)-1;
    676  1.10.8.2   matt 	else
    677  1.10.8.2   matt 		SCARG(&lsa, egid) = SCARG(uap, egid);
    678  1.10.8.2   matt 	if ((linux32_gid_t)SCARG(uap, sgid) == (linux32_gid_t)-1)
    679  1.10.8.2   matt 		SCARG(&lsa, sgid) = (gid_t)-1;
    680  1.10.8.2   matt 	else
    681  1.10.8.2   matt 		SCARG(&lsa, sgid) = SCARG(uap, sgid);
    682  1.10.8.2   matt 
    683  1.10.8.2   matt 	return linux32_sys_setresgid(l, &lsa, retval);
    684  1.10.8.2   matt }
    685