Home | History | Annotate | Line # | Download | only in common
linux32_unistd.c revision 1.22.10.2
      1  1.22.10.2   haad /*	$NetBSD: linux32_unistd.c,v 1.22.10.2 2008/12/13 01:13:57 haad 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.22.10.2   haad __KERNEL_RCSID(0, "$NetBSD: linux32_unistd.c,v 1.22.10.2 2008/12/13 01:13:57 haad 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.22.10.2   haad #include <sys/kauth.h>
     50        1.1   manu 
     51        1.1   manu #include <machine/types.h>
     52        1.1   manu 
     53        1.1   manu #include <sys/syscallargs.h>
     54        1.1   manu 
     55        1.1   manu #include <compat/netbsd32/netbsd32.h>
     56        1.1   manu #include <compat/netbsd32/netbsd32_conv.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.22.10.2   haad #include <compat/linux/common/linux_ipc.h>
     64  1.22.10.2   haad #include <compat/linux/common/linux_sem.h>
     65        1.1   manu #include <compat/linux/linux_syscallargs.h>
     66        1.1   manu 
     67        1.1   manu #include <compat/linux32/common/linux32_types.h>
     68        1.1   manu #include <compat/linux32/common/linux32_signal.h>
     69        1.1   manu #include <compat/linux32/common/linux32_machdep.h>
     70        1.1   manu #include <compat/linux32/common/linux32_sysctl.h>
     71        1.1   manu #include <compat/linux32/common/linux32_socketcall.h>
     72        1.1   manu #include <compat/linux32/linux32_syscallargs.h>
     73        1.1   manu 
     74        1.1   manu static int linux32_select1(struct lwp *, register_t *,
     75        1.1   manu     int, fd_set *, fd_set *, fd_set *, struct timeval *);
     76        1.1   manu 
     77        1.1   manu int
     78       1.17    dsl linux32_sys_brk(struct lwp *l, const struct linux32_sys_brk_args *uap, register_t *retval)
     79        1.1   manu {
     80       1.17    dsl 	/* {
     81        1.1   manu 		syscallarg(netbsd32_charp) nsize;
     82       1.17    dsl 	} */
     83        1.1   manu 	struct linux_sys_brk_args ua;
     84        1.1   manu 
     85        1.1   manu 	NETBSD32TOP_UAP(nsize, char);
     86        1.1   manu 	return linux_sys_brk(l, &ua, retval);
     87        1.1   manu }
     88        1.1   manu 
     89        1.1   manu int
     90       1.17    dsl linux32_sys_llseek(struct lwp *l, const struct linux32_sys_llseek_args *uap, register_t *retval)
     91        1.1   manu {
     92       1.17    dsl 	/* {
     93        1.1   manu 		syscallcarg(int) fd;
     94        1.1   manu                 syscallarg(u_int32_t) ohigh;
     95        1.1   manu                 syscallarg(u_int32_t) olow;
     96  1.22.10.2   haad 		syscallarg(netbsd32_voidp) res;
     97        1.1   manu 		syscallcarg(int) whence;
     98       1.17    dsl 	} */
     99        1.1   manu 	struct linux_sys_llseek_args ua;
    100        1.1   manu 
    101        1.1   manu 	NETBSD32TO64_UAP(fd);
    102        1.1   manu 	NETBSD32TO64_UAP(ohigh);
    103        1.1   manu 	NETBSD32TO64_UAP(olow);
    104  1.22.10.2   haad 	NETBSD32TOP_UAP(res, void);
    105        1.1   manu 	NETBSD32TO64_UAP(whence);
    106        1.1   manu 
    107        1.1   manu 	return linux_sys_llseek(l, &ua, retval);
    108        1.1   manu }
    109        1.1   manu 
    110        1.1   manu int
    111       1.17    dsl linux32_sys_select(struct lwp *l, const struct linux32_sys_select_args *uap, register_t *retval)
    112        1.1   manu {
    113       1.17    dsl 	/* {
    114        1.1   manu 		syscallarg(int) nfds;
    115        1.1   manu 		syscallarg(netbsd32_fd_setp_t) readfds;
    116        1.1   manu 		syscallarg(netbsd32_fd_setp_t) writefds;
    117        1.1   manu 		syscallarg(netbsd32_fd_setp_t) exceptfds;
    118        1.1   manu 		syscallarg(netbsd32_timevalp_t) timeout;
    119       1.17    dsl 	} */
    120        1.1   manu 
    121        1.1   manu 	return linux32_select1(l, retval, SCARG(uap, nfds),
    122        1.7    dsl 	    SCARG_P32(uap, readfds),
    123        1.7    dsl 	    SCARG_P32(uap, writefds),
    124        1.7    dsl 	    SCARG_P32(uap, exceptfds),
    125        1.7    dsl 	    SCARG_P32(uap, timeout));
    126        1.1   manu }
    127        1.1   manu 
    128        1.1   manu int
    129       1.17    dsl linux32_sys_oldselect(struct lwp *l, const struct linux32_sys_oldselect_args *uap, register_t *retval)
    130        1.1   manu {
    131       1.17    dsl 	/* {
    132        1.1   manu 		syscallarg(linux32_oldselectp_t) lsp;
    133       1.17    dsl 	} */
    134        1.1   manu 	struct linux32_oldselect lsp32;
    135        1.1   manu 	int error;
    136        1.1   manu 
    137        1.7    dsl 	if ((error = copyin(SCARG_P32(uap, lsp), &lsp32, sizeof(lsp32))) != 0)
    138        1.1   manu 		return error;
    139        1.1   manu 
    140        1.1   manu 	return linux32_select1(l, retval, lsp32.nfds,
    141        1.1   manu 	     NETBSD32PTR64(lsp32.readfds), NETBSD32PTR64(lsp32.writefds),
    142        1.1   manu 	     NETBSD32PTR64(lsp32.exceptfds), NETBSD32PTR64(lsp32.timeout));
    143        1.1   manu }
    144        1.1   manu 
    145        1.1   manu static int
    146        1.1   manu linux32_select1(l, retval, nfds, readfds, writefds, exceptfds, timeout)
    147        1.1   manu         struct lwp *l;
    148        1.1   manu         register_t *retval;
    149        1.1   manu         int nfds;
    150        1.1   manu         fd_set *readfds, *writefds, *exceptfds;
    151        1.1   manu         struct timeval *timeout;
    152        1.1   manu {
    153       1.10    dsl 	struct timeval tv0, tv1, utv, *tv = NULL;
    154        1.1   manu 	struct netbsd32_timeval utv32;
    155        1.1   manu 	int error;
    156        1.1   manu 
    157       1.10    dsl 	timerclear(&utv); /* XXX GCC4 */
    158        1.2    skd 
    159        1.1   manu 	/*
    160        1.1   manu 	 * Store current time for computation of the amount of
    161        1.1   manu 	 * time left.
    162        1.1   manu 	 */
    163        1.1   manu 	if (timeout) {
    164        1.1   manu 		if ((error = copyin(timeout, &utv32, sizeof(utv32))))
    165        1.1   manu 			return error;
    166        1.1   manu 
    167        1.1   manu 		netbsd32_to_timeval(&utv32, &utv);
    168        1.1   manu 
    169        1.1   manu 		if (itimerfix(&utv)) {
    170        1.1   manu 			/*
    171        1.1   manu 			 * The timeval was invalid.  Convert it to something
    172        1.1   manu 			 * valid that will act as it does under Linux.
    173        1.1   manu 			 */
    174        1.1   manu 			utv.tv_sec += utv.tv_usec / 1000000;
    175        1.1   manu 			utv.tv_usec %= 1000000;
    176        1.1   manu 			if (utv.tv_usec < 0) {
    177        1.1   manu 				utv.tv_sec -= 1;
    178        1.1   manu 				utv.tv_usec += 1000000;
    179        1.1   manu 			}
    180        1.1   manu 			if (utv.tv_sec < 0)
    181        1.1   manu 				timerclear(&utv);
    182        1.1   manu 		}
    183        1.1   manu 		microtime(&tv0);
    184        1.8  njoly 		tv = &utv;
    185        1.1   manu 	}
    186        1.1   manu 
    187        1.1   manu 	error = selcommon(l, retval, nfds,
    188        1.8  njoly 	    readfds, writefds, exceptfds, tv, NULL);
    189        1.1   manu 
    190        1.1   manu 	if (error) {
    191        1.1   manu 		/*
    192        1.1   manu 		 * See fs/select.c in the Linux kernel.  Without this,
    193        1.1   manu 		 * Maelstrom doesn't work.
    194        1.1   manu 		 */
    195        1.1   manu 		if (error == ERESTART)
    196        1.1   manu 			error = EINTR;
    197        1.1   manu 		return error;
    198        1.1   manu 	}
    199        1.1   manu 
    200        1.1   manu 	if (timeout) {
    201        1.1   manu 		if (*retval) {
    202        1.1   manu 			/*
    203        1.1   manu 			 * Compute how much time was left of the timeout,
    204        1.1   manu 			 * by subtracting the current time and the time
    205        1.1   manu 			 * before we started the call, and subtracting
    206        1.1   manu 			 * that result from the user-supplied value.
    207        1.1   manu 			 */
    208        1.1   manu 			microtime(&tv1);
    209        1.1   manu 			timersub(&tv1, &tv0, &tv1);
    210       1.10    dsl 			timersub(&utv, &tv1, &utv);
    211        1.1   manu 			if (utv.tv_sec < 0)
    212        1.1   manu 				timerclear(&utv);
    213        1.1   manu 		} else {
    214        1.1   manu 			timerclear(&utv);
    215        1.1   manu 		}
    216        1.1   manu 
    217        1.1   manu 		netbsd32_from_timeval(&utv, &utv32);
    218        1.1   manu 
    219        1.1   manu 		if ((error = copyout(&utv32, timeout, sizeof(utv32))))
    220        1.1   manu 			return error;
    221        1.1   manu 	}
    222        1.1   manu 
    223        1.1   manu 	return 0;
    224        1.1   manu }
    225        1.1   manu 
    226        1.1   manu int
    227       1.17    dsl linux32_sys_pipe(struct lwp *l, const struct linux32_sys_pipe_args *uap, register_t *retval)
    228        1.1   manu {
    229       1.17    dsl 	/* {
    230        1.1   manu 		syscallarg(netbsd32_intp) fd;
    231       1.17    dsl 	} */
    232        1.1   manu 	int error;
    233        1.1   manu 	int pfds[2];
    234        1.1   manu 
    235        1.1   manu 	if ((error = sys_pipe(l, 0, retval)))
    236        1.1   manu 		return error;
    237        1.1   manu 
    238        1.1   manu 	pfds[0] = (int)retval[0];
    239        1.1   manu 	pfds[1] = (int)retval[1];
    240        1.1   manu 
    241        1.7    dsl 	if ((error = copyout(pfds, SCARG_P32(uap, fd), 2 * sizeof (int))) != 0)
    242        1.1   manu 		return error;
    243        1.1   manu 
    244        1.1   manu 	retval[0] = 0;
    245        1.1   manu 	retval[1] = 0;
    246        1.1   manu 
    247        1.1   manu 	return 0;
    248        1.1   manu }
    249        1.1   manu 
    250        1.1   manu 
    251        1.1   manu int
    252       1.17    dsl linux32_sys_unlink(struct lwp *l, const struct linux32_sys_unlink_args *uap, register_t *retval)
    253        1.1   manu {
    254       1.17    dsl 	/* {
    255        1.1   manu 		syscallarg(const netbsd32_charp) path;
    256       1.17    dsl 	} */
    257        1.1   manu 	struct linux_sys_unlink_args ua;
    258        1.1   manu 
    259        1.1   manu 	NETBSD32TOP_UAP(path, const char);
    260        1.1   manu 
    261        1.1   manu 	return linux_sys_unlink(l, &ua, retval);
    262        1.1   manu }
    263        1.1   manu 
    264        1.1   manu int
    265       1.17    dsl linux32_sys_creat(struct lwp *l, const struct linux32_sys_creat_args *uap, register_t *retval)
    266        1.1   manu {
    267       1.17    dsl 	/* {
    268        1.1   manu 		syscallarg(const netbsd32_charp) path;
    269        1.1   manu 		syscallarg(int) mode;
    270       1.17    dsl 	} */
    271        1.1   manu 	struct sys_open_args ua;
    272        1.1   manu 
    273        1.1   manu 	NETBSD32TOP_UAP(path, const char);
    274        1.1   manu 	SCARG(&ua, flags) = O_CREAT | O_TRUNC | O_WRONLY;
    275        1.1   manu 	NETBSD32TO64_UAP(mode);
    276        1.1   manu 
    277        1.1   manu 	return sys_open(l, &ua, retval);
    278        1.1   manu }
    279        1.1   manu 
    280        1.1   manu int
    281       1.17    dsl linux32_sys_mknod(struct lwp *l, const struct linux32_sys_mknod_args *uap, register_t *retval)
    282        1.1   manu {
    283       1.17    dsl 	/* {
    284        1.1   manu 		syscallarg(const netbsd32_charp) path;
    285        1.1   manu 		syscallarg(int) mode;
    286        1.1   manu 		syscallarg(int) dev;
    287       1.17    dsl 	} */
    288        1.1   manu 	struct linux_sys_mknod_args ua;
    289        1.1   manu 
    290        1.1   manu 	NETBSD32TOP_UAP(path, const char);
    291        1.1   manu 	NETBSD32TO64_UAP(mode);
    292        1.1   manu 	NETBSD32TO64_UAP(dev);
    293        1.1   manu 
    294        1.1   manu 	return linux_sys_mknod(l, &ua, retval);
    295        1.1   manu }
    296        1.1   manu 
    297        1.1   manu int
    298       1.17    dsl linux32_sys_break(struct lwp *l, const struct linux32_sys_break_args *uap, register_t *retval)
    299        1.1   manu {
    300        1.1   manu #if 0
    301       1.17    dsl 	/* {
    302        1.1   manu 		syscallarg(const netbsd32_charp) nsize;
    303       1.17    dsl 	} */
    304        1.1   manu #endif
    305        1.1   manu 
    306        1.1   manu 	return ENOSYS;
    307        1.1   manu }
    308        1.1   manu 
    309        1.1   manu int
    310       1.17    dsl linux32_sys_swapon(struct lwp *l, const struct linux32_sys_swapon_args *uap, register_t *retval)
    311        1.1   manu {
    312       1.17    dsl 	/* {
    313        1.1   manu 		syscallarg(const netbsd32_charp) name;
    314       1.17    dsl 	} */
    315        1.1   manu 	struct sys_swapctl_args ua;
    316        1.1   manu 
    317        1.1   manu         SCARG(&ua, cmd) = SWAP_ON;
    318        1.7    dsl         SCARG(&ua, arg) = SCARG_P32(uap, name);
    319        1.1   manu         SCARG(&ua, misc) = 0;   /* priority */
    320        1.1   manu         return (sys_swapctl(l, &ua, retval));
    321        1.1   manu }
    322        1.1   manu 
    323        1.1   manu int
    324       1.17    dsl linux32_sys_swapoff(struct lwp *l, const struct linux32_sys_swapoff_args *uap, register_t *retval)
    325        1.1   manu {
    326       1.17    dsl 	/* {
    327        1.1   manu 		syscallarg(const netbsd32_charp) path;
    328       1.17    dsl 	} */
    329        1.1   manu 	struct sys_swapctl_args ua;
    330        1.1   manu 
    331        1.1   manu         SCARG(&ua, cmd) = SWAP_OFF;
    332        1.7    dsl         SCARG(&ua, arg) = SCARG_P32(uap, path);
    333        1.1   manu         SCARG(&ua, misc) = 0;   /* priority */
    334        1.1   manu         return (sys_swapctl(l, &ua, retval));
    335        1.1   manu }
    336        1.1   manu 
    337        1.1   manu 
    338        1.1   manu int
    339       1.17    dsl linux32_sys_reboot(struct lwp *l, const struct linux32_sys_reboot_args *uap, register_t *retval)
    340        1.1   manu {
    341       1.17    dsl 	/* {
    342        1.1   manu 		syscallarg(int) magic1;
    343        1.1   manu 		syscallarg(int) magic2;
    344        1.1   manu 		syscallarg(int) cmd;
    345        1.1   manu 		syscallarg(netbsd32_voidp) arg;
    346       1.17    dsl 	} */
    347        1.1   manu 	struct linux_sys_reboot_args ua;
    348        1.1   manu 
    349        1.1   manu 	NETBSD32TO64_UAP(magic1);
    350        1.1   manu 	NETBSD32TO64_UAP(magic2);
    351        1.1   manu 	NETBSD32TO64_UAP(cmd);
    352        1.1   manu 	NETBSD32TOP_UAP(arg, void);
    353        1.1   manu 
    354        1.1   manu 	return linux_sys_reboot(l, &ua, retval);
    355        1.1   manu }
    356        1.1   manu 
    357        1.1   manu int
    358       1.17    dsl linux32_sys_setresuid(struct lwp *l, const struct linux32_sys_setresuid_args *uap, register_t *retval)
    359        1.3   manu {
    360       1.17    dsl 	/* {
    361        1.3   manu 		syscallarg(uid_t) ruid;
    362        1.3   manu 		syscallarg(uid_t) euid;
    363        1.3   manu 		syscallarg(uid_t) suid;
    364       1.17    dsl 	} */
    365        1.3   manu 	struct linux_sys_setresuid_args ua;
    366        1.3   manu 
    367  1.22.10.2   haad 	NETBSD32TO64_UAP(ruid);
    368  1.22.10.2   haad 	NETBSD32TO64_UAP(euid);
    369  1.22.10.2   haad 	NETBSD32TO64_UAP(suid);
    370        1.3   manu 
    371        1.3   manu 	return linux_sys_setresuid(l, &ua, retval);
    372        1.3   manu }
    373        1.3   manu 
    374        1.3   manu int
    375  1.22.10.2   haad linux32_sys_getresuid(struct lwp *l, const struct linux32_sys_getresuid_args *uap, register_t *retval)
    376  1.22.10.2   haad {
    377  1.22.10.2   haad 	/* {
    378  1.22.10.2   haad 		syscallarg(linux32_uidp_t) ruid;
    379  1.22.10.2   haad 		syscallarg(linux32_uidp_t) euid;
    380  1.22.10.2   haad 		syscallarg(linux32_uidp_t) suid;
    381  1.22.10.2   haad 	} */
    382  1.22.10.2   haad 	kauth_cred_t pc = l->l_cred;
    383  1.22.10.2   haad 	int error;
    384  1.22.10.2   haad 	uid_t uid;
    385  1.22.10.2   haad 
    386  1.22.10.2   haad 	uid = kauth_cred_getuid(pc);
    387  1.22.10.2   haad 	if ((error = copyout(&uid, SCARG_P32(uap, ruid), sizeof(uid_t))) != 0)
    388  1.22.10.2   haad 		return error;
    389  1.22.10.2   haad 
    390  1.22.10.2   haad 	uid = kauth_cred_geteuid(pc);
    391  1.22.10.2   haad 	if ((error = copyout(&uid, SCARG_P32(uap, euid), sizeof(uid_t))) != 0)
    392  1.22.10.2   haad 		return error;
    393  1.22.10.2   haad 
    394  1.22.10.2   haad 	uid = kauth_cred_getsvuid(pc);
    395  1.22.10.2   haad 	return copyout(&uid, SCARG_P32(uap, suid), sizeof(uid_t));
    396  1.22.10.2   haad }
    397  1.22.10.2   haad 
    398  1.22.10.2   haad int
    399       1.17    dsl linux32_sys_setresgid(struct lwp *l, const struct linux32_sys_setresgid_args *uap, register_t *retval)
    400        1.3   manu {
    401       1.17    dsl 	/* {
    402        1.3   manu 		syscallarg(gid_t) rgid;
    403        1.3   manu 		syscallarg(gid_t) egid;
    404        1.3   manu 		syscallarg(gid_t) sgid;
    405       1.17    dsl 	} */
    406        1.3   manu 	struct linux_sys_setresgid_args ua;
    407        1.3   manu 
    408  1.22.10.2   haad 	NETBSD32TO64_UAP(rgid);
    409  1.22.10.2   haad 	NETBSD32TO64_UAP(egid);
    410  1.22.10.2   haad 	NETBSD32TO64_UAP(sgid);
    411        1.3   manu 
    412        1.3   manu 	return linux_sys_setresgid(l, &ua, retval);
    413        1.3   manu }
    414       1.13  njoly 
    415       1.13  njoly int
    416  1.22.10.2   haad linux32_sys_getresgid(struct lwp *l, const struct linux32_sys_getresgid_args *uap, register_t *retval)
    417  1.22.10.2   haad {
    418  1.22.10.2   haad 	/* {
    419  1.22.10.2   haad 		syscallarg(linux32_gidp_t) rgid;
    420  1.22.10.2   haad 		syscallarg(linux32_gidp_t) egid;
    421  1.22.10.2   haad 		syscallarg(linux32_gidp_t) sgid;
    422  1.22.10.2   haad 	} */
    423  1.22.10.2   haad 	kauth_cred_t pc = l->l_cred;
    424  1.22.10.2   haad 	int error;
    425  1.22.10.2   haad 	gid_t gid;
    426  1.22.10.2   haad 
    427  1.22.10.2   haad 	gid = kauth_cred_getgid(pc);
    428  1.22.10.2   haad 	if ((error = copyout(&gid, SCARG_P32(uap, rgid), sizeof(gid_t))) != 0)
    429  1.22.10.2   haad 		return error;
    430  1.22.10.2   haad 
    431  1.22.10.2   haad 	gid = kauth_cred_getegid(pc);
    432  1.22.10.2   haad 	if ((error = copyout(&gid, SCARG_P32(uap, egid), sizeof(gid_t))) != 0)
    433  1.22.10.2   haad 		return error;
    434  1.22.10.2   haad 
    435  1.22.10.2   haad 	gid = kauth_cred_getsvgid(pc);
    436  1.22.10.2   haad 	return copyout(&gid, SCARG_P32(uap, sgid), sizeof(gid_t));
    437  1.22.10.2   haad }
    438  1.22.10.2   haad 
    439  1.22.10.2   haad int
    440       1.17    dsl linux32_sys_nice(struct lwp *l, const struct linux32_sys_nice_args *uap, register_t *retval)
    441       1.13  njoly {
    442       1.17    dsl 	/* {
    443       1.13  njoly 		syscallarg(int) incr;
    444       1.17    dsl 	} */
    445  1.22.10.1   haad 	struct proc *p = l->l_proc;
    446       1.22  njoly 	struct sys_setpriority_args bsa;
    447       1.13  njoly 
    448       1.13  njoly 	SCARG(&bsa, which) = PRIO_PROCESS;
    449       1.13  njoly 	SCARG(&bsa, who) = 0;
    450  1.22.10.1   haad 	SCARG(&bsa, prio) = p->p_nice - NZERO + SCARG(uap, incr);
    451       1.13  njoly 
    452       1.22  njoly 	return sys_setpriority(l, &bsa, retval);
    453       1.13  njoly }
    454       1.13  njoly 
    455       1.13  njoly int
    456       1.17    dsl linux32_sys_alarm(struct lwp *l, const struct linux32_sys_alarm_args *uap, register_t *retval)
    457       1.13  njoly {
    458       1.17    dsl 	/* {
    459       1.13  njoly 		syscallarg(unsigned int) secs;
    460       1.17    dsl 	} */
    461       1.13  njoly 	struct linux_sys_alarm_args ua;
    462       1.13  njoly 
    463       1.13  njoly 	NETBSD32TO64_UAP(secs);
    464       1.13  njoly 
    465       1.13  njoly 	return linux_sys_alarm(l, &ua, retval);
    466       1.13  njoly }
    467       1.13  njoly 
    468       1.13  njoly int
    469       1.17    dsl linux32_sys_fdatasync(struct lwp *l, const struct linux32_sys_fdatasync_args *uap, register_t *retval)
    470       1.13  njoly {
    471       1.17    dsl 	/* {
    472       1.13  njoly 		syscallarg(int) fd;
    473       1.17    dsl 	} */
    474       1.13  njoly 	struct linux_sys_fdatasync_args ua;
    475       1.13  njoly 
    476       1.13  njoly 	NETBSD32TO64_UAP(fd);
    477       1.13  njoly 
    478       1.13  njoly 	return linux_sys_fdatasync(l, &ua, retval);
    479       1.13  njoly }
    480       1.13  njoly 
    481       1.13  njoly int
    482       1.17    dsl linux32_sys_setfsuid(struct lwp *l, const struct linux32_sys_setfsuid_args *uap, register_t *retval)
    483       1.13  njoly {
    484       1.17    dsl 	/* {
    485       1.13  njoly 		syscallarg(uid_t) uid;
    486       1.17    dsl 	} */
    487       1.13  njoly 	struct linux_sys_setfsuid_args ua;
    488       1.13  njoly 
    489       1.13  njoly 	NETBSD32TO64_UAP(uid);
    490       1.13  njoly 
    491       1.13  njoly 	return linux_sys_setfsuid(l, &ua, retval);
    492       1.13  njoly }
    493       1.13  njoly 
    494       1.13  njoly int
    495       1.18  njoly linux32_sys_setfsgid(struct lwp *l, const struct linux32_sys_setfsgid_args *uap, register_t *retval)
    496       1.18  njoly {
    497       1.18  njoly 	/* {
    498       1.18  njoly 		syscallarg(gid_t) gid;
    499       1.18  njoly 	} */
    500       1.18  njoly 	struct linux_sys_setfsgid_args ua;
    501       1.18  njoly 
    502       1.18  njoly 	NETBSD32TO64_UAP(gid);
    503       1.18  njoly 
    504       1.18  njoly 	return linux_sys_setfsgid(l, &ua, retval);
    505       1.18  njoly }
    506       1.20    dsl 
    507       1.20    dsl /*
    508       1.20    dsl  * pread(2).
    509       1.20    dsl  */
    510       1.20    dsl int
    511       1.20    dsl linux32_sys_pread(struct lwp *l,
    512       1.20    dsl     const struct linux32_sys_pread_args *uap, register_t *retval)
    513       1.20    dsl {
    514       1.20    dsl 	/* {
    515       1.20    dsl 		syscallarg(int) fd;
    516       1.21  njoly 		syscallarg(netbsd32_voidp) buf;
    517       1.20    dsl 		syscallarg(netbsd32_size_t) nbyte;
    518       1.21  njoly 		syscallarg(linux32_off_t) offset;
    519       1.20    dsl 	} */
    520       1.20    dsl 	struct sys_pread_args pra;
    521       1.20    dsl 
    522       1.20    dsl 	SCARG(&pra, fd) = SCARG(uap, fd);
    523       1.21  njoly 	SCARG(&pra, buf) = SCARG_P32(uap, buf);
    524       1.20    dsl 	SCARG(&pra, nbyte) = SCARG(uap, nbyte);
    525       1.20    dsl 	SCARG(&pra, offset) = SCARG(uap, offset);
    526       1.20    dsl 
    527       1.20    dsl 	return sys_pread(l, &pra, retval);
    528       1.20    dsl }
    529       1.20    dsl 
    530       1.20    dsl /*
    531       1.20    dsl  * pwrite(2).
    532       1.20    dsl  */
    533       1.20    dsl int
    534       1.20    dsl linux32_sys_pwrite(struct lwp *l,
    535       1.20    dsl     const struct linux32_sys_pwrite_args *uap, register_t *retval)
    536       1.20    dsl {
    537       1.20    dsl 	/* {
    538       1.20    dsl 		syscallarg(int) fd;
    539       1.21  njoly 		syscallarg(const netbsd32_voidp) buf;
    540       1.20    dsl 		syscallarg(netbsd32_size_t) nbyte;
    541       1.21  njoly 		syscallarg(linux32_off_t) offset;
    542       1.20    dsl 	} */
    543       1.20    dsl 	struct sys_pwrite_args pra;
    544       1.20    dsl 
    545       1.20    dsl 	SCARG(&pra, fd) = SCARG(uap, fd);
    546       1.21  njoly 	SCARG(&pra, buf) = SCARG_P32(uap, buf);
    547       1.20    dsl 	SCARG(&pra, nbyte) = SCARG(uap, nbyte);
    548       1.20    dsl 	SCARG(&pra, offset) = SCARG(uap, offset);
    549       1.20    dsl 
    550       1.20    dsl 	return sys_pwrite(l, &pra, retval);
    551       1.20    dsl }
    552       1.20    dsl 
    553