Home | History | Annotate | Line # | Download | only in common
linux32_unistd.c revision 1.10.8.1
      1  1.10.8.1      matt /*	$NetBSD: linux32_unistd.c,v 1.10.8.1 2007/11/06 23:25:06 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.1      matt __KERNEL_RCSID(0, "$NetBSD: linux32_unistd.c,v 1.10.8.1 2007/11/06 23:25:06 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.1      manu linux32_sys_brk(l, v, retval)
     77       1.1      manu 	struct lwp *l;
     78       1.1      manu 	void *v;
     79       1.1      manu 	register_t *retval;
     80       1.1      manu {
     81       1.1      manu 	struct linux32_sys_brk_args /* {
     82       1.1      manu 		syscallarg(netbsd32_charp) nsize;
     83       1.1      manu 	} */ *uap = v;
     84       1.1      manu 	struct linux_sys_brk_args ua;
     85       1.1      manu 
     86       1.1      manu 	NETBSD32TOP_UAP(nsize, char);
     87       1.1      manu 	return linux_sys_brk(l, &ua, retval);
     88       1.1      manu }
     89       1.1      manu 
     90       1.1      manu int
     91       1.1      manu linux32_sys_llseek(l, v, retval)
     92       1.1      manu 	struct lwp *l;
     93       1.1      manu 	void *v;
     94       1.1      manu 	register_t *retval;
     95       1.1      manu {
     96       1.1      manu 	struct linux32_sys_llseek_args /* {
     97       1.1      manu 		syscallcarg(int) fd;
     98       1.1      manu                 syscallarg(u_int32_t) ohigh;
     99       1.1      manu                 syscallarg(u_int32_t) olow;
    100       1.6  christos 		syscallarg(netbsd32_void *) res;
    101       1.1      manu 		syscallcarg(int) whence;
    102       1.1      manu 	} */ *uap = v;
    103       1.1      manu 	struct linux_sys_llseek_args ua;
    104       1.1      manu 
    105       1.1      manu 	NETBSD32TO64_UAP(fd);
    106       1.1      manu 	NETBSD32TO64_UAP(ohigh);
    107       1.1      manu 	NETBSD32TO64_UAP(olow);
    108       1.1      manu 	NETBSD32TOP_UAP(res, char);
    109       1.1      manu 	NETBSD32TO64_UAP(whence);
    110       1.1      manu 
    111       1.1      manu 	return linux_sys_llseek(l, &ua, retval);
    112       1.1      manu }
    113       1.1      manu 
    114       1.1      manu int
    115       1.1      manu linux32_sys_readlink(l, v, retval)
    116       1.1      manu 	struct lwp *l;
    117       1.1      manu 	void *v;
    118       1.1      manu 	register_t *retval;
    119       1.1      manu {
    120       1.1      manu 	struct linux32_sys_readlink_args /* {
    121       1.1      manu 		syscallarg(const netbsd32_charp) name;
    122       1.1      manu 		syscallarg(netbsd32_charp) buf;
    123       1.1      manu 		syscallarg(int) count;
    124       1.1      manu 	} */ *uap = v;
    125       1.1      manu 	struct linux_sys_readlink_args ua;
    126       1.1      manu 
    127       1.1      manu 	NETBSD32TOP_UAP(name, const char);
    128       1.1      manu 	NETBSD32TOP_UAP(buf, char)
    129       1.1      manu 	NETBSD32TO64_UAP(count);
    130       1.1      manu 
    131       1.1      manu 	return linux_sys_readlink(l, &ua, retval);
    132       1.1      manu }
    133       1.1      manu 
    134       1.1      manu 
    135       1.1      manu int
    136       1.1      manu linux32_sys_select(l, v, retval)
    137       1.1      manu 	struct lwp *l;
    138       1.1      manu 	void *v;
    139       1.1      manu 	register_t *retval;
    140       1.1      manu {
    141       1.1      manu 	struct linux32_sys_select_args /* {
    142       1.1      manu 		syscallarg(int) nfds;
    143       1.1      manu 		syscallarg(netbsd32_fd_setp_t) readfds;
    144       1.1      manu 		syscallarg(netbsd32_fd_setp_t) writefds;
    145       1.1      manu 		syscallarg(netbsd32_fd_setp_t) exceptfds;
    146       1.1      manu 		syscallarg(netbsd32_timevalp_t) timeout;
    147       1.1      manu 	} */ *uap = v;
    148       1.1      manu 
    149       1.1      manu 	return linux32_select1(l, retval, SCARG(uap, nfds),
    150       1.7       dsl 	    SCARG_P32(uap, readfds),
    151       1.7       dsl 	    SCARG_P32(uap, writefds),
    152       1.7       dsl 	    SCARG_P32(uap, exceptfds),
    153       1.7       dsl 	    SCARG_P32(uap, timeout));
    154       1.1      manu }
    155       1.1      manu 
    156       1.1      manu int
    157       1.1      manu linux32_sys_oldselect(l, v, retval)
    158       1.1      manu 	struct lwp *l;
    159       1.1      manu 	void *v;
    160       1.1      manu 	register_t *retval;
    161       1.1      manu {
    162       1.1      manu 	struct linux32_sys_oldselect_args /* {
    163       1.1      manu 		syscallarg(linux32_oldselectp_t) lsp;
    164       1.1      manu 	} */ *uap = v;
    165       1.1      manu 	struct linux32_oldselect lsp32;
    166       1.1      manu 	int error;
    167       1.1      manu 
    168       1.7       dsl 	if ((error = copyin(SCARG_P32(uap, lsp), &lsp32, sizeof(lsp32))) != 0)
    169       1.1      manu 		return error;
    170       1.1      manu 
    171       1.1      manu 	return linux32_select1(l, retval, lsp32.nfds,
    172       1.1      manu 	     NETBSD32PTR64(lsp32.readfds), NETBSD32PTR64(lsp32.writefds),
    173       1.1      manu 	     NETBSD32PTR64(lsp32.exceptfds), NETBSD32PTR64(lsp32.timeout));
    174       1.1      manu }
    175       1.1      manu 
    176       1.1      manu static int
    177       1.1      manu linux32_select1(l, retval, nfds, readfds, writefds, exceptfds, timeout)
    178       1.1      manu         struct lwp *l;
    179       1.1      manu         register_t *retval;
    180       1.1      manu         int nfds;
    181       1.1      manu         fd_set *readfds, *writefds, *exceptfds;
    182       1.1      manu         struct timeval *timeout;
    183       1.1      manu {
    184      1.10       dsl 	struct timeval tv0, tv1, utv, *tv = NULL;
    185       1.1      manu 	struct netbsd32_timeval utv32;
    186       1.1      manu 	int error;
    187       1.1      manu 
    188      1.10       dsl 	timerclear(&utv); /* XXX GCC4 */
    189       1.2       skd 
    190       1.1      manu 	/*
    191       1.1      manu 	 * Store current time for computation of the amount of
    192       1.1      manu 	 * time left.
    193       1.1      manu 	 */
    194       1.1      manu 	if (timeout) {
    195       1.1      manu 		if ((error = copyin(timeout, &utv32, sizeof(utv32))))
    196       1.1      manu 			return error;
    197       1.1      manu 
    198       1.1      manu 		netbsd32_to_timeval(&utv32, &utv);
    199       1.1      manu 
    200       1.1      manu 		if (itimerfix(&utv)) {
    201       1.1      manu 			/*
    202       1.1      manu 			 * The timeval was invalid.  Convert it to something
    203       1.1      manu 			 * valid that will act as it does under Linux.
    204       1.1      manu 			 */
    205       1.1      manu 			utv.tv_sec += utv.tv_usec / 1000000;
    206       1.1      manu 			utv.tv_usec %= 1000000;
    207       1.1      manu 			if (utv.tv_usec < 0) {
    208       1.1      manu 				utv.tv_sec -= 1;
    209       1.1      manu 				utv.tv_usec += 1000000;
    210       1.1      manu 			}
    211       1.1      manu 			if (utv.tv_sec < 0)
    212       1.1      manu 				timerclear(&utv);
    213       1.1      manu 		}
    214       1.1      manu 		microtime(&tv0);
    215       1.8     njoly 		tv = &utv;
    216       1.1      manu 	}
    217       1.1      manu 
    218       1.1      manu 	error = selcommon(l, retval, nfds,
    219       1.8     njoly 	    readfds, writefds, exceptfds, tv, NULL);
    220       1.1      manu 
    221       1.1      manu 	if (error) {
    222       1.1      manu 		/*
    223       1.1      manu 		 * See fs/select.c in the Linux kernel.  Without this,
    224       1.1      manu 		 * Maelstrom doesn't work.
    225       1.1      manu 		 */
    226       1.1      manu 		if (error == ERESTART)
    227       1.1      manu 			error = EINTR;
    228       1.1      manu 		return error;
    229       1.1      manu 	}
    230       1.1      manu 
    231       1.1      manu 	if (timeout) {
    232       1.1      manu 		if (*retval) {
    233       1.1      manu 			/*
    234       1.1      manu 			 * Compute how much time was left of the timeout,
    235       1.1      manu 			 * by subtracting the current time and the time
    236       1.1      manu 			 * before we started the call, and subtracting
    237       1.1      manu 			 * that result from the user-supplied value.
    238       1.1      manu 			 */
    239       1.1      manu 			microtime(&tv1);
    240       1.1      manu 			timersub(&tv1, &tv0, &tv1);
    241      1.10       dsl 			timersub(&utv, &tv1, &utv);
    242       1.1      manu 			if (utv.tv_sec < 0)
    243       1.1      manu 				timerclear(&utv);
    244       1.1      manu 		} else {
    245       1.1      manu 			timerclear(&utv);
    246       1.1      manu 		}
    247       1.1      manu 
    248       1.1      manu 		netbsd32_from_timeval(&utv, &utv32);
    249       1.1      manu 
    250       1.1      manu 		if ((error = copyout(&utv32, timeout, sizeof(utv32))))
    251       1.1      manu 			return error;
    252       1.1      manu 	}
    253       1.1      manu 
    254       1.1      manu 	return 0;
    255       1.1      manu }
    256       1.1      manu 
    257       1.1      manu int
    258       1.1      manu linux32_sys_pipe(l, v, retval)
    259       1.1      manu 	struct lwp *l;
    260       1.1      manu 	void *v;
    261       1.1      manu 	register_t *retval;
    262       1.1      manu {
    263       1.1      manu 	struct linux32_sys_pipe_args /* {
    264       1.1      manu 		syscallarg(netbsd32_intp) fd;
    265       1.1      manu 	} */ *uap = v;
    266       1.1      manu 	int error;
    267       1.1      manu 	int pfds[2];
    268       1.1      manu 
    269       1.1      manu 	if ((error = sys_pipe(l, 0, retval)))
    270       1.1      manu 		return error;
    271       1.1      manu 
    272       1.1      manu 	pfds[0] = (int)retval[0];
    273       1.1      manu 	pfds[1] = (int)retval[1];
    274       1.1      manu 
    275       1.7       dsl 	if ((error = copyout(pfds, SCARG_P32(uap, fd), 2 * sizeof (int))) != 0)
    276       1.1      manu 		return error;
    277       1.1      manu 
    278       1.1      manu 	retval[0] = 0;
    279       1.1      manu 	retval[1] = 0;
    280       1.1      manu 
    281       1.1      manu 	return 0;
    282       1.1      manu }
    283       1.1      manu 
    284       1.1      manu 
    285       1.1      manu int
    286       1.1      manu linux32_sys_unlink(l, v, retval)
    287       1.1      manu 	struct lwp *l;
    288       1.1      manu 	void *v;
    289       1.1      manu 	register_t *retval;
    290       1.1      manu {
    291       1.1      manu 	struct linux32_sys_unlink_args /* {
    292       1.1      manu 		syscallarg(const netbsd32_charp) path;
    293       1.1      manu 	} */ *uap = v;
    294       1.1      manu 	struct linux_sys_unlink_args ua;
    295       1.1      manu 
    296       1.1      manu 	NETBSD32TOP_UAP(path, const char);
    297       1.1      manu 
    298       1.1      manu 	return linux_sys_unlink(l, &ua, retval);
    299       1.1      manu }
    300       1.1      manu 
    301       1.1      manu int
    302       1.1      manu linux32_sys_creat(l, v, retval)
    303       1.1      manu 	struct lwp *l;
    304       1.1      manu 	void *v;
    305       1.1      manu 	register_t *retval;
    306       1.1      manu {
    307       1.1      manu 	struct linux32_sys_creat_args /* {
    308       1.1      manu 		syscallarg(const netbsd32_charp) path;
    309       1.1      manu 		syscallarg(int) mode;
    310       1.1      manu 	} */ *uap = v;
    311       1.1      manu 	struct sys_open_args ua;
    312       1.1      manu 
    313       1.1      manu 	NETBSD32TOP_UAP(path, const char);
    314       1.1      manu 	SCARG(&ua, flags) = O_CREAT | O_TRUNC | O_WRONLY;
    315       1.1      manu 	NETBSD32TO64_UAP(mode);
    316       1.1      manu 
    317       1.1      manu 	return sys_open(l, &ua, retval);
    318       1.1      manu }
    319       1.1      manu 
    320       1.1      manu int
    321       1.1      manu linux32_sys_mknod(l, v, retval)
    322       1.1      manu 	struct lwp *l;
    323       1.1      manu 	void *v;
    324       1.1      manu 	register_t *retval;
    325       1.1      manu {
    326       1.1      manu 	struct linux32_sys_mknod_args /* {
    327       1.1      manu 		syscallarg(const netbsd32_charp) path;
    328       1.1      manu 		syscallarg(int) mode;
    329       1.1      manu 		syscallarg(int) dev;
    330       1.1      manu 	} */ *uap = v;
    331       1.1      manu 	struct linux_sys_mknod_args ua;
    332       1.1      manu 
    333       1.1      manu 	NETBSD32TOP_UAP(path, const char);
    334       1.1      manu 	NETBSD32TO64_UAP(mode);
    335       1.1      manu 	NETBSD32TO64_UAP(dev);
    336       1.1      manu 
    337       1.1      manu 	return linux_sys_mknod(l, &ua, retval);
    338       1.1      manu }
    339       1.1      manu 
    340       1.1      manu int
    341  1.10.8.1      matt linux32_sys_chown16(l, v, retval)
    342       1.1      manu 	struct lwp *l;
    343       1.1      manu 	void *v;
    344       1.1      manu 	register_t *retval;
    345       1.1      manu {
    346  1.10.8.1      matt 	struct linux32_sys_chown16_args /* {
    347       1.1      manu 		syscallarg(const netbsd32_charp) path;
    348  1.10.8.1      matt 		syscallarg(int) uid;
    349  1.10.8.1      matt 		syscallarg(int) gid;
    350       1.1      manu 	} */ *uap = v;
    351  1.10.8.1      matt         struct sys___posix_chown_args ua;
    352       1.1      manu 
    353       1.1      manu 	NETBSD32TOP_UAP(path, const char);
    354       1.1      manu 
    355  1.10.8.1      matt         if ((linux32_uid_t)SCARG(uap, uid) == (linux32_uid_t)-1)
    356  1.10.8.1      matt         	SCARG(&ua, uid) = (uid_t)-1;
    357  1.10.8.1      matt 	else
    358  1.10.8.1      matt         	SCARG(&ua, uid) = SCARG(uap, uid);
    359  1.10.8.1      matt 
    360  1.10.8.1      matt         if ((linux32_gid_t)SCARG(uap, gid) == (linux32_gid_t)-1)
    361  1.10.8.1      matt         	SCARG(&ua, gid) = (gid_t)-1;
    362  1.10.8.1      matt 	else
    363  1.10.8.1      matt         	SCARG(&ua, gid) = SCARG(uap, gid);
    364  1.10.8.1      matt 
    365  1.10.8.1      matt         return sys___posix_chown(l, &ua, retval);
    366       1.1      manu }
    367       1.1      manu 
    368       1.1      manu int
    369       1.1      manu linux32_sys_lchown16(l, v, retval)
    370       1.1      manu 	struct lwp *l;
    371       1.1      manu 	void *v;
    372       1.1      manu 	register_t *retval;
    373       1.1      manu {
    374       1.1      manu 	struct linux32_sys_lchown16_args /* {
    375       1.1      manu 		syscallarg(const netbsd32_charp) path;
    376       1.1      manu 		syscallarg(int) uid;
    377       1.1      manu 		syscallarg(int) gid;
    378       1.1      manu 	} */ *uap = v;
    379       1.1      manu         struct sys___posix_lchown_args ua;
    380       1.1      manu 
    381       1.1      manu 	NETBSD32TOP_UAP(path, const char);
    382       1.1      manu 
    383       1.1      manu         if ((linux32_uid_t)SCARG(uap, uid) == (linux32_uid_t)-1)
    384       1.1      manu         	SCARG(&ua, uid) = (uid_t)-1;
    385       1.1      manu 	else
    386       1.1      manu         	SCARG(&ua, uid) = SCARG(uap, uid);
    387       1.1      manu 
    388       1.1      manu         if ((linux32_gid_t)SCARG(uap, gid) == (linux32_gid_t)-1)
    389       1.1      manu         	SCARG(&ua, gid) = (gid_t)-1;
    390       1.1      manu 	else
    391       1.1      manu         	SCARG(&ua, gid) = SCARG(uap, gid);
    392       1.1      manu 
    393       1.1      manu         return sys___posix_lchown(l, &ua, retval);
    394       1.1      manu }
    395       1.1      manu 
    396       1.1      manu int
    397       1.1      manu linux32_sys_break(l, v, retval)
    398       1.1      manu 	struct lwp *l;
    399       1.1      manu 	void *v;
    400       1.1      manu 	register_t *retval;
    401       1.1      manu {
    402       1.1      manu #if 0
    403       1.1      manu 	struct linux32_sys_break_args /* {
    404       1.1      manu 		syscallarg(const netbsd32_charp) nsize;
    405       1.1      manu 	} */ *uap = v;
    406       1.1      manu #endif
    407       1.1      manu 
    408       1.1      manu 	return ENOSYS;
    409       1.1      manu }
    410       1.1      manu 
    411       1.1      manu int
    412       1.1      manu linux32_sys_rename(l, v, retval)
    413       1.1      manu 	struct lwp *l;
    414       1.1      manu 	void *v;
    415       1.1      manu 	register_t *retval;
    416       1.1      manu {
    417       1.1      manu 	struct linux32_sys_rename_args /* {
    418       1.1      manu 		syscallarg(const netbsd32_charp) from;
    419       1.1      manu 		syscallarg(const netbsd32_charp) to;
    420       1.1      manu 	} */ *uap = v;
    421       1.1      manu 	struct sys_rename_args ua;
    422       1.1      manu 
    423       1.1      manu 	NETBSD32TOP_UAP(from, const char);
    424       1.1      manu 	NETBSD32TOP_UAP(to, const char);
    425       1.1      manu 
    426       1.1      manu 	return sys___posix_rename(l, &ua, retval);
    427       1.1      manu }
    428       1.1      manu 
    429       1.1      manu int
    430       1.1      manu linux32_sys_getgroups16(l, v, retval)
    431       1.1      manu 	struct lwp *l;
    432       1.1      manu 	void *v;
    433       1.1      manu 	register_t *retval;
    434       1.1      manu {
    435       1.1      manu 	struct linux32_sys_getgroups16_args /* {
    436       1.1      manu 		syscallarg(int) gidsetsize;
    437       1.1      manu 		syscallarg(linux32_gidp_t) gidset;
    438       1.1      manu 	} */ *uap = v;
    439       1.1      manu 	struct linux_sys_getgroups16_args ua;
    440       1.1      manu 
    441       1.1      manu 	NETBSD32TO64_UAP(gidsetsize);
    442       1.4      manu 	NETBSD32TOP_UAP(gidset, linux_gid_t);
    443       1.1      manu 
    444       1.1      manu 	return linux_sys_getgroups16(l, &ua, retval);
    445       1.1      manu }
    446       1.1      manu 
    447       1.1      manu int
    448       1.1      manu linux32_sys_setgroups16(l, v, retval)
    449       1.1      manu 	struct lwp *l;
    450       1.1      manu 	void *v;
    451       1.1      manu 	register_t *retval;
    452       1.1      manu {
    453       1.1      manu 	struct linux32_sys_setgroups16_args /* {
    454       1.1      manu 		syscallarg(int) gidsetsize;
    455       1.1      manu 		syscallarg(linux32_gidp_t) gidset;
    456       1.1      manu 	} */ *uap = v;
    457       1.1      manu 	struct linux_sys_setgroups16_args ua;
    458       1.1      manu 
    459       1.1      manu 	NETBSD32TO64_UAP(gidsetsize);
    460       1.4      manu 	NETBSD32TOP_UAP(gidset, linux_gid_t);
    461       1.1      manu 
    462       1.1      manu 	return linux_sys_setgroups16(l, &ua, retval);
    463       1.1      manu }
    464       1.1      manu 
    465       1.1      manu int
    466       1.1      manu linux32_sys_swapon(l, v, retval)
    467       1.1      manu 	struct lwp *l;
    468       1.1      manu 	void *v;
    469       1.1      manu 	register_t *retval;
    470       1.1      manu {
    471       1.1      manu 	struct linux32_sys_swapon_args /* {
    472       1.1      manu 		syscallarg(const netbsd32_charp) name;
    473       1.1      manu 	} */ *uap = v;
    474       1.1      manu 	struct sys_swapctl_args ua;
    475       1.1      manu 
    476       1.1      manu         SCARG(&ua, cmd) = SWAP_ON;
    477       1.7       dsl         SCARG(&ua, arg) = SCARG_P32(uap, name);
    478       1.1      manu         SCARG(&ua, misc) = 0;   /* priority */
    479       1.1      manu         return (sys_swapctl(l, &ua, retval));
    480       1.1      manu }
    481       1.1      manu 
    482       1.1      manu int
    483       1.1      manu linux32_sys_swapoff(l, v, retval)
    484       1.1      manu 	struct lwp *l;
    485       1.1      manu 	void *v;
    486       1.1      manu 	register_t *retval;
    487       1.1      manu {
    488       1.1      manu 	struct linux32_sys_swapoff_args /* {
    489       1.1      manu 		syscallarg(const netbsd32_charp) path;
    490       1.1      manu 	} */ *uap = v;
    491       1.1      manu 	struct sys_swapctl_args ua;
    492       1.1      manu 
    493       1.1      manu         SCARG(&ua, cmd) = SWAP_OFF;
    494       1.7       dsl         SCARG(&ua, arg) = SCARG_P32(uap, path);
    495       1.1      manu         SCARG(&ua, misc) = 0;   /* priority */
    496       1.1      manu         return (sys_swapctl(l, &ua, retval));
    497       1.1      manu }
    498       1.1      manu 
    499       1.1      manu 
    500       1.1      manu int
    501       1.1      manu linux32_sys_reboot(l, v, retval)
    502       1.1      manu 	struct lwp *l;
    503       1.1      manu 	void *v;
    504       1.1      manu 	register_t *retval;
    505       1.1      manu {
    506       1.1      manu 	struct linux32_sys_reboot_args /* {
    507       1.1      manu 		syscallarg(int) magic1;
    508       1.1      manu 		syscallarg(int) magic2;
    509       1.1      manu 		syscallarg(int) cmd;
    510       1.1      manu 		syscallarg(netbsd32_voidp) arg;
    511       1.1      manu 	} */ *uap = v;
    512       1.1      manu 	struct linux_sys_reboot_args ua;
    513       1.1      manu 
    514       1.1      manu 	NETBSD32TO64_UAP(magic1);
    515       1.1      manu 	NETBSD32TO64_UAP(magic2);
    516       1.1      manu 	NETBSD32TO64_UAP(cmd);
    517       1.1      manu 	NETBSD32TOP_UAP(arg, void);
    518       1.1      manu 
    519       1.1      manu 	return linux_sys_reboot(l, &ua, retval);
    520       1.1      manu }
    521       1.1      manu 
    522       1.1      manu int
    523       1.1      manu linux32_sys_truncate(l, v, retval)
    524       1.1      manu 	struct lwp *l;
    525       1.1      manu 	void *v;
    526       1.1      manu 	register_t *retval;
    527       1.1      manu {
    528       1.1      manu 	struct linux32_sys_truncate_args /* {
    529       1.1      manu 		syscallarg(const netbsd32_charp) path;
    530       1.1      manu 		syscallarg(netbsd32_charp) buf;
    531       1.1      manu 		syscallarg(int) count;
    532       1.1      manu 	} */ *uap = v;
    533       1.1      manu 	struct compat_43_sys_truncate_args ua;
    534       1.1      manu 
    535       1.1      manu 	NETBSD32TOP_UAP(path, const char);
    536       1.1      manu 	NETBSD32TO64_UAP(length);
    537       1.1      manu 
    538       1.1      manu 	return compat_43_sys_truncate(l, &ua, retval);
    539       1.1      manu }
    540       1.1      manu 
    541       1.1      manu int
    542       1.1      manu linux32_sys_fchown16(l, v, retval)
    543       1.1      manu 	struct lwp *l;
    544       1.1      manu 	void *v;
    545       1.1      manu 	register_t *retval;
    546       1.1      manu {
    547       1.1      manu 	struct linux32_sys_fchown16_args /* {
    548       1.1      manu 		syscallarg(int) fd;
    549       1.1      manu 		syscallarg(int) uid;
    550       1.1      manu 		syscallarg(int) gid;
    551       1.1      manu 	} */ *uap = v;
    552       1.1      manu         struct sys___posix_fchown_args ua;
    553       1.1      manu 
    554       1.1      manu 	SCARG(&ua, fd) = SCARG(uap, fd);
    555       1.1      manu 
    556       1.1      manu         if ((linux32_uid_t)SCARG(uap, uid) == (linux32_uid_t)-1)
    557       1.1      manu         	SCARG(&ua, uid) = (uid_t)-1;
    558       1.1      manu 	else
    559       1.1      manu         	SCARG(&ua, uid) = SCARG(uap, uid);
    560       1.1      manu 
    561       1.1      manu         if ((linux32_gid_t)SCARG(uap, gid) == (linux32_gid_t)-1)
    562       1.1      manu         	SCARG(&ua, gid) = (gid_t)-1;
    563       1.1      manu 	else
    564       1.1      manu         	SCARG(&ua, gid) = SCARG(uap, gid);
    565       1.1      manu 
    566       1.1      manu         return sys___posix_fchown(l, &ua, retval);
    567       1.1      manu }
    568       1.3      manu 
    569       1.3      manu int
    570       1.3      manu linux32_sys_setresuid(l, v, retval)
    571       1.3      manu 	struct lwp *l;
    572       1.3      manu 	void *v;
    573       1.3      manu 	register_t *retval;
    574       1.3      manu {
    575       1.3      manu 	struct linux32_sys_setresuid_args /* {
    576       1.3      manu 		syscallarg(uid_t) ruid;
    577       1.3      manu 		syscallarg(uid_t) euid;
    578       1.3      manu 		syscallarg(uid_t) suid;
    579       1.3      manu 	} */ *uap = v;
    580       1.3      manu 	struct linux_sys_setresuid_args ua;
    581       1.3      manu 
    582       1.3      manu 	SCARG(&ua, ruid) = (SCARG(uap, ruid) == -1) ? -1 : SCARG(uap, ruid);
    583       1.3      manu 	SCARG(&ua, euid) = (SCARG(uap, euid) == -1) ? -1 : SCARG(uap, euid);
    584       1.3      manu 	SCARG(&ua, suid) = (SCARG(uap, suid) == -1) ? -1 : SCARG(uap, suid);
    585       1.3      manu 
    586       1.3      manu 	return linux_sys_setresuid(l, &ua, retval);
    587       1.3      manu }
    588       1.3      manu 
    589       1.3      manu int
    590       1.3      manu linux32_sys_setresgid(l, v, retval)
    591       1.3      manu 	struct lwp *l;
    592       1.3      manu 	void *v;
    593       1.3      manu 	register_t *retval;
    594       1.3      manu {
    595       1.3      manu 	struct linux32_sys_setresgid_args /* {
    596       1.3      manu 		syscallarg(gid_t) rgid;
    597       1.3      manu 		syscallarg(gid_t) egid;
    598       1.3      manu 		syscallarg(gid_t) sgid;
    599       1.3      manu 	} */ *uap = v;
    600       1.3      manu 	struct linux_sys_setresgid_args ua;
    601       1.3      manu 
    602       1.3      manu 	SCARG(&ua, rgid) = (SCARG(uap, rgid) == -1) ? -1 : SCARG(uap, rgid);
    603       1.3      manu 	SCARG(&ua, egid) = (SCARG(uap, egid) == -1) ? -1 : SCARG(uap, egid);
    604       1.3      manu 	SCARG(&ua, sgid) = (SCARG(uap, sgid) == -1) ? -1 : SCARG(uap, sgid);
    605       1.3      manu 
    606       1.3      manu 	return linux_sys_setresgid(l, &ua, retval);
    607       1.3      manu }
    608