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