Home | History | Annotate | Line # | Download | only in netbsd32
netbsd32_compat_43.c revision 1.37.2.4
      1  1.37.2.4        ad /*	$NetBSD: netbsd32_compat_43.c,v 1.37.2.4 2007/07/15 13:27:13 ad Exp $	*/
      2       1.1       mrg 
      3       1.1       mrg /*
      4      1.19       mrg  * Copyright (c) 1998, 2001 Matthew R. Green
      5       1.1       mrg  * All rights reserved.
      6       1.1       mrg  *
      7       1.1       mrg  * Redistribution and use in source and binary forms, with or without
      8       1.1       mrg  * modification, are permitted provided that the following conditions
      9       1.1       mrg  * are met:
     10       1.1       mrg  * 1. Redistributions of source code must retain the above copyright
     11       1.1       mrg  *    notice, this list of conditions and the following disclaimer.
     12       1.1       mrg  * 2. Redistributions in binary form must reproduce the above copyright
     13       1.1       mrg  *    notice, this list of conditions and the following disclaimer in the
     14       1.1       mrg  *    documentation and/or other materials provided with the distribution.
     15       1.1       mrg  * 3. The name of the author may not be used to endorse or promote products
     16       1.1       mrg  *    derived from this software without specific prior written permission.
     17       1.1       mrg  *
     18       1.1       mrg  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     19       1.1       mrg  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     20       1.1       mrg  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     21       1.1       mrg  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     22       1.7       mrg  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
     23       1.1       mrg  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
     24       1.1       mrg  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
     25       1.1       mrg  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
     26       1.7       mrg  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     27       1.1       mrg  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     28       1.1       mrg  * SUCH DAMAGE.
     29       1.1       mrg  */
     30      1.20     lukem 
     31      1.20     lukem #include <sys/cdefs.h>
     32  1.37.2.4        ad __KERNEL_RCSID(0, "$NetBSD: netbsd32_compat_43.c,v 1.37.2.4 2007/07/15 13:27:13 ad Exp $");
     33      1.13      fvdl 
     34      1.17       mrg #if defined(_KERNEL_OPT)
     35      1.13      fvdl #include "opt_compat_43.h"
     36      1.13      fvdl #endif
     37       1.1       mrg 
     38       1.1       mrg #include <sys/param.h>
     39       1.1       mrg #include <sys/systm.h>
     40       1.1       mrg #include <sys/fcntl.h>
     41  1.37.2.2        ad #include <sys/filedesc.h>
     42       1.1       mrg #include <sys/malloc.h>
     43  1.37.2.4        ad #include <sys/mbuf.h>
     44       1.1       mrg #include <sys/mount.h>
     45  1.37.2.2        ad #include <sys/namei.h>
     46      1.32       chs #include <sys/socket.h>
     47       1.1       mrg #include <sys/proc.h>
     48  1.37.2.4        ad #include <sys/socket.h>
     49  1.37.2.4        ad #include <sys/socketvar.h>
     50       1.1       mrg #include <sys/stat.h>
     51       1.1       mrg #include <sys/syscallargs.h>
     52       1.1       mrg #include <sys/time.h>
     53       1.1       mrg #include <sys/ucred.h>
     54  1.37.2.2        ad #include <sys/vfs_syscalls.h>
     55      1.10       mrg #include <uvm/uvm_extern.h>
     56       1.1       mrg #include <sys/sysctl.h>
     57       1.3       mrg #include <sys/swap.h>
     58       1.1       mrg 
     59       1.5       mrg #include <compat/netbsd32/netbsd32.h>
     60       1.5       mrg #include <compat/netbsd32/netbsd32_syscallargs.h>
     61       1.1       mrg 
     62      1.31  christos #include <compat/sys/stat.h>
     63      1.31  christos #include <compat/sys/signal.h>
     64      1.31  christos #include <compat/sys/signalvar.h>
     65      1.33  christos #include <compat/sys/socket.h>
     66      1.31  christos 
     67      1.24   thorpej int compat_43_netbsd32_sethostid __P((struct lwp *, void *, register_t *));
     68      1.24   thorpej int compat_43_netbsd32_killpg __P((struct lwp *, void *, register_t *retval));
     69      1.24   thorpej int compat_43_netbsd32_sigblock __P((struct lwp *, void *, register_t *retval));
     70      1.24   thorpej int compat_43_netbsd32_sigblock __P((struct lwp *, void *, register_t *retval));
     71      1.24   thorpej int compat_43_netbsd32_sigsetmask __P((struct lwp *, void *, register_t *retval));
     72       1.9       eeh 
     73  1.37.2.2        ad static void
     74  1.37.2.2        ad netbsd32_from_stat(const struct stat *sb, struct netbsd32_stat43 *sp32)
     75  1.37.2.2        ad {
     76  1.37.2.2        ad 
     77  1.37.2.2        ad 	sp32->st_dev = sb->st_dev;
     78  1.37.2.2        ad 	sp32->st_ino = sb->st_ino;
     79  1.37.2.2        ad 	sp32->st_mode = sb->st_mode;
     80  1.37.2.2        ad 	sp32->st_nlink = sb->st_nlink;
     81  1.37.2.2        ad 	sp32->st_uid = sb->st_uid;
     82  1.37.2.2        ad 	sp32->st_gid = sb->st_gid;
     83  1.37.2.2        ad 	sp32->st_rdev = sb->st_rdev;
     84  1.37.2.2        ad 	sp32->st_size = sb->st_size < (quad_t)1 << 32 ? sb->st_size : -2;
     85  1.37.2.2        ad 	sp32->st_atimespec.tv_sec = sb->st_atimespec.tv_sec;
     86  1.37.2.2        ad 	sp32->st_atimespec.tv_nsec = sb->st_atimespec.tv_nsec;
     87  1.37.2.2        ad 	sp32->st_mtimespec.tv_sec = sb->st_mtimespec.tv_sec;
     88  1.37.2.2        ad 	sp32->st_mtimespec.tv_nsec = sb->st_mtimespec.tv_nsec;
     89  1.37.2.2        ad 	sp32->st_ctimespec.tv_sec = sb->st_ctimespec.tv_sec;
     90  1.37.2.2        ad 	sp32->st_ctimespec.tv_nsec = sb->st_ctimespec.tv_nsec;
     91  1.37.2.2        ad 	sp32->st_blksize = sb->st_blksize;
     92  1.37.2.2        ad 	sp32->st_blocks = sb->st_blocks;
     93  1.37.2.2        ad 	sp32->st_flags = sb->st_flags;
     94  1.37.2.2        ad 	sp32->st_gen = sb->st_gen;
     95       1.1       mrg }
     96       1.1       mrg 
     97       1.1       mrg /* file system syscalls */
     98       1.1       mrg int
     99      1.24   thorpej compat_43_netbsd32_ocreat(l, v, retval)
    100      1.24   thorpej 	struct lwp *l;
    101       1.1       mrg 	void *v;
    102       1.1       mrg 	register_t *retval;
    103       1.1       mrg {
    104       1.8       eeh 	struct compat_43_netbsd32_ocreat_args /* {
    105       1.5       mrg 		syscallarg(const netbsd32_charp) path;
    106       1.1       mrg 		syscallarg(mode_t) mode;
    107       1.1       mrg 	} */ *uap = v;
    108       1.1       mrg 	struct sys_open_args  ua;
    109       1.1       mrg 
    110       1.6       mrg 	NETBSD32TOP_UAP(path, const char);
    111       1.6       mrg 	NETBSD32TO64_UAP(mode);
    112       1.1       mrg 	SCARG(&ua, flags) = O_WRONLY | O_CREAT | O_TRUNC;
    113       1.1       mrg 
    114      1.24   thorpej 	return (sys_open(l, &ua, retval));
    115       1.1       mrg }
    116       1.1       mrg 
    117       1.1       mrg int
    118      1.24   thorpej compat_43_netbsd32_olseek(l, v, retval)
    119      1.24   thorpej 	struct lwp *l;
    120       1.1       mrg 	void *v;
    121       1.1       mrg 	register_t *retval;
    122       1.1       mrg {
    123       1.8       eeh 	struct compat_43_netbsd32_olseek_args /* {
    124       1.1       mrg 		syscallarg(int) fd;
    125       1.5       mrg 		syscallarg(netbsd32_long) offset;
    126       1.1       mrg 		syscallarg(int) whence;
    127       1.1       mrg 	} */ *uap = v;
    128       1.1       mrg 	struct sys_lseek_args ua;
    129       1.1       mrg 	int rv;
    130       1.1       mrg 	off_t rt;
    131       1.1       mrg 
    132       1.1       mrg 	SCARG(&ua, fd) = SCARG(uap, fd);
    133       1.6       mrg 	NETBSD32TOX_UAP(offset, long);
    134       1.6       mrg 	NETBSD32TO64_UAP(whence);
    135      1.24   thorpej 	rv = sys_lseek(l, &ua, (register_t *)&rt);
    136      1.18       eeh 	*retval = rt;
    137       1.1       mrg 
    138       1.1       mrg 	return (rv);
    139       1.1       mrg }
    140       1.1       mrg 
    141       1.1       mrg int
    142      1.24   thorpej compat_43_netbsd32_stat43(l, v, retval)
    143      1.24   thorpej 	struct lwp *l;
    144       1.1       mrg 	void *v;
    145       1.1       mrg 	register_t *retval;
    146       1.1       mrg {
    147       1.8       eeh 	struct compat_43_netbsd32_stat43_args /* {
    148       1.5       mrg 		syscallarg(const netbsd32_charp) path;
    149       1.5       mrg 		syscallarg(netbsd32_stat43p_t) ub;
    150       1.1       mrg 	} */ *uap = v;
    151  1.37.2.2        ad 	struct stat sb;
    152      1.15       mrg 	struct netbsd32_stat43 sb32;
    153  1.37.2.2        ad 	int error;
    154       1.1       mrg 
    155  1.37.2.2        ad 	error = do_sys_stat(l, SCARG_P32(uap, path), FOLLOW, &sb);
    156  1.37.2.2        ad 	if (error == 0) {
    157  1.37.2.2        ad 		netbsd32_from_stat(&sb, &sb32);
    158  1.37.2.2        ad 		error = copyout(&sb32, SCARG_P32(uap, ub), sizeof(sb32));
    159  1.37.2.2        ad 	}
    160  1.37.2.2        ad 	return error;
    161       1.1       mrg }
    162       1.1       mrg 
    163       1.1       mrg int
    164      1.24   thorpej compat_43_netbsd32_lstat43(l, v, retval)
    165      1.24   thorpej 	struct lwp *l;
    166       1.1       mrg 	void *v;
    167       1.1       mrg 	register_t *retval;
    168       1.1       mrg {
    169       1.8       eeh 	struct compat_43_netbsd32_lstat43_args /* {
    170       1.5       mrg 		syscallarg(const netbsd32_charp) path;
    171       1.5       mrg 		syscallarg(netbsd32_stat43p_t) ub;
    172       1.1       mrg 	} */ *uap = v;
    173  1.37.2.2        ad 	struct stat sb;
    174      1.15       mrg 	struct netbsd32_stat43 sb32;
    175  1.37.2.2        ad 	int error;
    176       1.1       mrg 
    177  1.37.2.2        ad 	error = do_sys_stat(l, SCARG_P32(uap, path), NOFOLLOW, &sb);
    178  1.37.2.2        ad 	if (error == 0) {
    179  1.37.2.2        ad 		netbsd32_from_stat(&sb, &sb32);
    180  1.37.2.2        ad 		error = copyout(&sb32, SCARG_P32(uap, ub), sizeof(sb32));
    181  1.37.2.2        ad 	}
    182  1.37.2.2        ad 	return error;
    183       1.1       mrg }
    184       1.1       mrg 
    185       1.1       mrg int
    186      1.24   thorpej compat_43_netbsd32_fstat43(l, v, retval)
    187      1.24   thorpej 	struct lwp *l;
    188       1.1       mrg 	void *v;
    189       1.1       mrg 	register_t *retval;
    190       1.1       mrg {
    191       1.8       eeh 	struct compat_43_netbsd32_fstat43_args /* {
    192       1.1       mrg 		syscallarg(int) fd;
    193       1.5       mrg 		syscallarg(netbsd32_stat43p_t) sb;
    194       1.1       mrg 	} */ *uap = v;
    195  1.37.2.2        ad 	struct stat sb;
    196      1.15       mrg 	struct netbsd32_stat43 sb32;
    197  1.37.2.2        ad 	int error;
    198       1.1       mrg 
    199  1.37.2.2        ad 	error = do_sys_fstat(l, SCARG(uap, fd), &sb);
    200  1.37.2.2        ad 	if (error == 0) {
    201  1.37.2.2        ad 		netbsd32_from_stat(&sb, &sb32);
    202  1.37.2.2        ad 		error = copyout(&sb32, SCARG_P32(uap, sb), sizeof(sb32));
    203  1.37.2.2        ad 	}
    204  1.37.2.2        ad 	return error;
    205       1.1       mrg }
    206       1.1       mrg 
    207       1.1       mrg int
    208      1.24   thorpej compat_43_netbsd32_otruncate(l, v, retval)
    209      1.24   thorpej 	struct lwp *l;
    210       1.1       mrg 	void *v;
    211       1.1       mrg 	register_t *retval;
    212       1.1       mrg {
    213       1.8       eeh 	struct compat_43_netbsd32_otruncate_args /* {
    214       1.5       mrg 		syscallarg(const netbsd32_charp) path;
    215       1.5       mrg 		syscallarg(netbsd32_long) length;
    216       1.1       mrg 	} */ *uap = v;
    217       1.1       mrg 	struct sys_truncate_args ua;
    218       1.1       mrg 
    219       1.6       mrg 	NETBSD32TOP_UAP(path, const char);
    220       1.6       mrg 	NETBSD32TO64_UAP(length);
    221      1.24   thorpej 	return (sys_ftruncate(l, &ua, retval));
    222       1.1       mrg }
    223       1.1       mrg 
    224       1.1       mrg int
    225      1.24   thorpej compat_43_netbsd32_oftruncate(l, v, retval)
    226      1.24   thorpej 	struct lwp *l;
    227       1.1       mrg 	void *v;
    228       1.1       mrg 	register_t *retval;
    229       1.1       mrg {
    230       1.8       eeh 	struct compat_43_netbsd32_oftruncate_args /* {
    231       1.1       mrg 		syscallarg(int) fd;
    232       1.5       mrg 		syscallarg(netbsd32_long) length;
    233       1.1       mrg 	} */ *uap = v;
    234       1.1       mrg 	struct sys_ftruncate_args ua;
    235       1.1       mrg 
    236       1.6       mrg 	NETBSD32TO64_UAP(fd);
    237       1.6       mrg 	NETBSD32TO64_UAP(length);
    238      1.24   thorpej 	return (sys_ftruncate(l, &ua, retval));
    239       1.1       mrg }
    240       1.1       mrg 
    241       1.1       mrg int
    242      1.24   thorpej compat_43_netbsd32_ogetdirentries(l, v, retval)
    243      1.24   thorpej 	struct lwp *l;
    244       1.1       mrg 	void *v;
    245       1.1       mrg 	register_t *retval;
    246       1.1       mrg {
    247       1.8       eeh 	struct compat_43_netbsd32_ogetdirentries_args /* {
    248       1.1       mrg 		syscallarg(int) fd;
    249       1.5       mrg 		syscallarg(netbsd32_charp) buf;
    250       1.1       mrg 		syscallarg(u_int) count;
    251       1.5       mrg 		syscallarg(netbsd32_longp) basep;
    252       1.1       mrg 	} */ *uap = v;
    253       1.1       mrg 	struct compat_43_sys_getdirentries_args ua;
    254       1.1       mrg 
    255       1.6       mrg 	NETBSD32TO64_UAP(fd);
    256       1.6       mrg 	NETBSD32TOP_UAP(buf, char);
    257       1.6       mrg 	NETBSD32TO64_UAP(count);
    258       1.6       mrg 	NETBSD32TOP_UAP(basep, long);
    259      1.24   thorpej 	return (compat_43_sys_getdirentries(l, &ua, retval));
    260       1.1       mrg }
    261       1.1       mrg 
    262       1.1       mrg /* kernel syscalls */
    263       1.1       mrg int
    264      1.24   thorpej compat_43_netbsd32_ogetkerninfo(l, v, retval)
    265      1.24   thorpej 	struct lwp *l;
    266       1.1       mrg 	void *v;
    267       1.1       mrg 	register_t *retval;
    268       1.1       mrg {
    269       1.8       eeh 	struct compat_43_netbsd32_ogetkerninfo_args /* {
    270       1.1       mrg 		syscallarg(int) op;
    271       1.5       mrg 		syscallarg(netbsd32_charp) where;
    272       1.5       mrg 		syscallarg(netbsd32_intp) size;
    273       1.1       mrg 		syscallarg(int) arg;
    274       1.1       mrg 	} */ *uap = v;
    275       1.1       mrg 	struct compat_43_sys_getkerninfo_args ua;
    276       1.1       mrg 
    277       1.6       mrg 	NETBSD32TO64_UAP(op);
    278       1.6       mrg 	NETBSD32TOP_UAP(where, char);
    279       1.6       mrg 	NETBSD32TOP_UAP(size, int);
    280       1.6       mrg 	NETBSD32TO64_UAP(arg);
    281      1.24   thorpej 	return (compat_43_sys_getkerninfo(l, &ua, retval));
    282       1.1       mrg }
    283       1.1       mrg 
    284       1.1       mrg int
    285      1.24   thorpej compat_43_netbsd32_ogethostname(l, v, retval)
    286      1.24   thorpej 	struct lwp* l;
    287       1.1       mrg 	void *v;
    288       1.1       mrg 	register_t *retval;
    289       1.1       mrg {
    290       1.8       eeh 	struct compat_43_netbsd32_ogethostname_args /* {
    291       1.5       mrg 		syscallarg(netbsd32_charp) hostname;
    292       1.1       mrg 		syscallarg(u_int) len;
    293       1.1       mrg 	} */ *uap = v;
    294      1.29    atatat 	int name[2];
    295       1.1       mrg 	size_t sz;
    296       1.1       mrg 
    297      1.29    atatat 	name[0] = CTL_KERN;
    298      1.29    atatat 	name[1] = KERN_HOSTNAME;
    299       1.1       mrg 	sz = SCARG(uap, len);
    300      1.29    atatat 	return (old_sysctl(&name[0], 2,
    301  1.37.2.1        ad 	    SCARG_P32(uap, hostname), &sz, 0, 0, l));
    302       1.1       mrg }
    303       1.1       mrg 
    304       1.1       mrg int
    305      1.24   thorpej compat_43_netbsd32_osethostname(l, v, retval)
    306      1.24   thorpej 	struct lwp* l;
    307       1.1       mrg 	void *v;
    308       1.1       mrg 	register_t *retval;
    309       1.1       mrg {
    310       1.8       eeh 	struct compat_43_netbsd32_osethostname_args /* {
    311       1.5       mrg 		syscallarg(netbsd32_charp) hostname;
    312       1.1       mrg 		syscallarg(u_int) len;
    313       1.1       mrg 	} */ *uap = v;
    314      1.29    atatat 	int name[2];
    315       1.1       mrg 
    316      1.29    atatat 	name[0] = CTL_KERN;
    317      1.29    atatat 	name[1] = KERN_HOSTNAME;
    318  1.37.2.1        ad 	return old_sysctl(&name[0], 2, 0, 0, (char *)SCARG_P32(uap,
    319  1.37.2.1        ad 	    hostname), SCARG(uap, len), l);
    320       1.1       mrg }
    321       1.1       mrg 
    322       1.1       mrg int
    323      1.24   thorpej compat_43_netbsd32_sethostid(l, v, retval)
    324      1.24   thorpej 	struct lwp* l;
    325       1.4       eeh 	void *v;
    326       1.4       eeh 	register_t *retval;
    327       1.4       eeh {
    328       1.8       eeh 	struct compat_43_netbsd32_sethostid_args /* {
    329       1.4       eeh 		syscallarg(int32_t) hostid;
    330       1.4       eeh 	} */ *uap = v;
    331       1.4       eeh 	struct compat_43_sys_sethostid_args ua;
    332       1.4       eeh 
    333       1.6       mrg 	NETBSD32TO64_UAP(hostid);
    334      1.24   thorpej 	return (compat_43_sys_sethostid(l, &ua, retval));
    335       1.4       eeh }
    336       1.4       eeh 
    337       1.4       eeh int
    338      1.24   thorpej compat_43_netbsd32_ogetrlimit(l, v, retval)
    339      1.24   thorpej 	struct lwp* l;
    340       1.1       mrg 	void *v;
    341       1.1       mrg 	register_t *retval;
    342       1.1       mrg {
    343       1.8       eeh 	struct compat_43_netbsd32_ogetrlimit_args /* {
    344       1.1       mrg 		syscallarg(int) which;
    345       1.5       mrg 		syscallarg(netbsd32_orlimitp_t) rlp;
    346       1.1       mrg 	} */ *uap = v;
    347       1.1       mrg 	struct compat_43_sys_getrlimit_args ua;
    348       1.1       mrg 
    349       1.6       mrg 	NETBSD32TO64_UAP(which);
    350       1.6       mrg 	NETBSD32TOP_UAP(rlp, struct orlimit);
    351      1.24   thorpej 	return (compat_43_sys_getrlimit(l, &ua, retval));
    352       1.1       mrg }
    353       1.1       mrg 
    354       1.1       mrg int
    355      1.24   thorpej compat_43_netbsd32_osetrlimit(l, v, retval)
    356      1.24   thorpej 	struct lwp* l;
    357       1.1       mrg 	void *v;
    358       1.1       mrg 	register_t *retval;
    359       1.1       mrg {
    360       1.8       eeh 	struct compat_43_netbsd32_osetrlimit_args /* {
    361       1.1       mrg 		syscallarg(int) which;
    362       1.5       mrg 		syscallarg(netbsd32_orlimitp_t) rlp;
    363       1.1       mrg 	} */ *uap = v;
    364       1.1       mrg 	struct compat_43_sys_setrlimit_args ua;
    365       1.1       mrg 
    366       1.6       mrg 	NETBSD32TO64_UAP(which);
    367       1.6       mrg 	NETBSD32TOP_UAP(rlp, struct orlimit);
    368      1.24   thorpej 	return (compat_43_sys_setrlimit(l, &ua, retval));
    369       1.1       mrg }
    370       1.1       mrg 
    371       1.4       eeh int
    372      1.24   thorpej compat_43_netbsd32_killpg(l, v, retval)
    373      1.24   thorpej 	struct lwp* l;
    374       1.4       eeh 	void *v;
    375       1.4       eeh 	register_t *retval;
    376       1.4       eeh {
    377       1.8       eeh 	struct compat_43_netbsd32_killpg_args /* {
    378       1.4       eeh 		syscallarg(int) pgid;
    379       1.4       eeh 		syscallarg(int) signum;
    380       1.4       eeh 	} */ *uap = v;
    381       1.4       eeh 	struct compat_43_sys_killpg_args ua;
    382       1.4       eeh 
    383       1.6       mrg 	NETBSD32TO64_UAP(pgid);
    384       1.6       mrg 	NETBSD32TO64_UAP(signum);
    385      1.24   thorpej 	return (compat_43_sys_killpg(l, &ua, retval));
    386       1.4       eeh }
    387       1.4       eeh 
    388       1.1       mrg /* virtual memory syscalls */
    389       1.1       mrg int
    390      1.24   thorpej compat_43_netbsd32_ommap(l, v, retval)
    391      1.24   thorpej 	struct lwp* l;
    392       1.1       mrg 	void *v;
    393       1.1       mrg 	register_t *retval;
    394       1.1       mrg {
    395       1.8       eeh 	struct compat_43_netbsd32_ommap_args /* {
    396      1.37  christos 		syscallarg(netbsd32_caddr_t) addr;
    397       1.5       mrg 		syscallarg(netbsd32_size_t) len;
    398       1.1       mrg 		syscallarg(int) prot;
    399       1.1       mrg 		syscallarg(int) flags;
    400       1.1       mrg 		syscallarg(int) fd;
    401       1.5       mrg 		syscallarg(netbsd32_long) pos;
    402       1.1       mrg 	} */ *uap = v;
    403       1.1       mrg 	struct compat_43_sys_mmap_args ua;
    404       1.1       mrg 
    405  1.37.2.1        ad 	NETBSD32TOP_UAP(addr, void *);
    406       1.6       mrg 	NETBSD32TOX_UAP(len, size_t);
    407       1.6       mrg 	NETBSD32TO64_UAP(prot);
    408       1.6       mrg 	NETBSD32TO64_UAP(flags);
    409       1.6       mrg 	NETBSD32TO64_UAP(fd);
    410       1.6       mrg 	NETBSD32TOX_UAP(pos, long);
    411      1.24   thorpej 	return (compat_43_sys_mmap(l, &ua, retval));
    412       1.4       eeh }
    413       1.4       eeh 
    414       1.1       mrg /* network syscalls */
    415       1.1       mrg int
    416      1.24   thorpej compat_43_netbsd32_oaccept(l, v, retval)
    417      1.24   thorpej 	struct lwp* l;
    418       1.1       mrg 	void *v;
    419       1.1       mrg 	register_t *retval;
    420       1.1       mrg {
    421       1.8       eeh 	struct compat_43_netbsd32_oaccept_args /* {
    422       1.1       mrg 		syscallarg(int) s;
    423      1.37  christos 		syscallarg(netbsd32_caddr_t) name;
    424       1.5       mrg 		syscallarg(netbsd32_intp) anamelen;
    425       1.1       mrg 	} */ *uap = v;
    426       1.1       mrg 	struct compat_43_sys_accept_args ua;
    427       1.1       mrg 
    428       1.6       mrg 	NETBSD32TOX_UAP(s, int);
    429  1.37.2.1        ad 	NETBSD32TOP_UAP(name, void *);
    430       1.6       mrg 	NETBSD32TOP_UAP(anamelen, int);
    431      1.24   thorpej 	return (compat_43_sys_accept(l, &ua, retval));
    432       1.1       mrg }
    433       1.1       mrg 
    434       1.1       mrg int
    435      1.24   thorpej compat_43_netbsd32_osend(l, v, retval)
    436      1.24   thorpej 	struct lwp* l;
    437       1.1       mrg 	void *v;
    438       1.1       mrg 	register_t *retval;
    439       1.1       mrg {
    440       1.8       eeh 	struct compat_43_netbsd32_osend_args /* {
    441       1.1       mrg 		syscallarg(int) s;
    442      1.37  christos 		syscallarg(netbsd32_caddr_t) buf;
    443       1.1       mrg 		syscallarg(int) len;
    444       1.1       mrg 		syscallarg(int) flags;
    445       1.1       mrg 	} */ *uap = v;
    446       1.1       mrg 	struct compat_43_sys_send_args ua;
    447       1.1       mrg 
    448       1.6       mrg 	NETBSD32TO64_UAP(s);
    449  1.37.2.1        ad 	NETBSD32TOP_UAP(buf, void *);
    450       1.6       mrg 	NETBSD32TO64_UAP(len);
    451       1.6       mrg 	NETBSD32TO64_UAP(flags);
    452      1.24   thorpej 	return (compat_43_sys_send(l, &ua, retval));
    453       1.1       mrg }
    454       1.1       mrg 
    455       1.1       mrg int
    456      1.24   thorpej compat_43_netbsd32_orecv(l, v, retval)
    457      1.24   thorpej 	struct lwp* l;
    458       1.1       mrg 	void *v;
    459       1.1       mrg 	register_t *retval;
    460       1.1       mrg {
    461       1.8       eeh 	struct compat_43_netbsd32_orecv_args /* {
    462       1.1       mrg 		syscallarg(int) s;
    463      1.37  christos 		syscallarg(netbsd32_caddr_t) buf;
    464       1.1       mrg 		syscallarg(int) len;
    465       1.1       mrg 		syscallarg(int) flags;
    466       1.1       mrg 	} */ *uap = v;
    467       1.1       mrg 	struct compat_43_sys_recv_args ua;
    468       1.1       mrg 
    469       1.6       mrg 	NETBSD32TO64_UAP(s);
    470  1.37.2.1        ad 	NETBSD32TOP_UAP(buf, void *);
    471       1.6       mrg 	NETBSD32TO64_UAP(len);
    472       1.6       mrg 	NETBSD32TO64_UAP(flags);
    473      1.24   thorpej 	return (compat_43_sys_recv(l, &ua, retval));
    474       1.1       mrg }
    475       1.1       mrg 
    476       1.1       mrg /*
    477  1.37.2.4        ad  * This is a brutal clone of compat_43_sys_recvmsg().
    478       1.1       mrg  */
    479       1.1       mrg int
    480      1.24   thorpej compat_43_netbsd32_orecvmsg(l, v, retval)
    481      1.24   thorpej 	struct lwp* l;
    482       1.1       mrg 	void *v;
    483       1.1       mrg 	register_t *retval;
    484       1.1       mrg {
    485       1.8       eeh 	struct compat_43_netbsd32_orecvmsg_args /* {
    486       1.1       mrg 		syscallarg(int) s;
    487       1.5       mrg 		syscallarg(netbsd32_omsghdrp_t) msg;
    488       1.1       mrg 		syscallarg(int) flags;
    489       1.1       mrg 	} */ *uap = v;
    490  1.37.2.4        ad 	struct netbsd32_omsghdr omsg;
    491  1.37.2.4        ad 	struct msghdr msg;
    492  1.37.2.4        ad 	struct mbuf *from, *control;
    493  1.37.2.4        ad 	struct iovec *iov, aiov[UIO_SMALLIOV];
    494  1.37.2.4        ad 	int error;
    495       1.1       mrg 
    496  1.37.2.4        ad 	error = copyin(SCARG_P32(uap, msg), &omsg, sizeof (struct omsghdr));
    497      1.16       mrg 	if (error)
    498      1.16       mrg 		return (error);
    499      1.16       mrg 
    500  1.37.2.4        ad 	if (NETBSD32PTR64(omsg.msg_accrights) == NULL)
    501  1.37.2.4        ad 		omsg.msg_accrightslen = 0;
    502  1.37.2.4        ad 	/* it was this way in 4.4BSD */
    503  1.37.2.4        ad 	if (omsg.msg_accrightslen > MLEN)
    504  1.37.2.4        ad 		return EINVAL;
    505  1.37.2.4        ad 
    506  1.37.2.4        ad 	iov = netbsd32_get_iov(NETBSD32PTR64(omsg.msg_iov), omsg.msg_iovlen,
    507  1.37.2.4        ad 	    aiov, __arraycount(aiov));
    508  1.37.2.4        ad 	if (iov == NULL)
    509  1.37.2.4        ad 		return EFAULT;
    510  1.37.2.4        ad 
    511  1.37.2.4        ad 	msg.msg_name	= NETBSD32PTR64(omsg.msg_name);
    512  1.37.2.4        ad 	msg.msg_namelen = omsg.msg_namelen;
    513  1.37.2.4        ad 	msg.msg_iovlen	= omsg.msg_iovlen;
    514  1.37.2.4        ad 	msg.msg_iov	= iov;
    515  1.37.2.4        ad 	msg.msg_flags	= SCARG(uap, flags) & MSG_USERFLAGS;
    516  1.37.2.4        ad 
    517  1.37.2.4        ad 	error = do_sys_recvmsg(l, SCARG(uap, s), &msg, &from,
    518  1.37.2.4        ad 	    NETBSD32PTR64(omsg.msg_accrights) != NULL ? &control : NULL,
    519  1.37.2.4        ad 	    retval);
    520  1.37.2.4        ad 	if (error != 0)
    521  1.37.2.4        ad 		return error;
    522       1.1       mrg 
    523  1.37.2.4        ad 	/*
    524  1.37.2.4        ad 	 * If there is any control information and it's SCM_RIGHTS,
    525  1.37.2.4        ad 	 * pass it back to the program.
    526  1.37.2.4        ad 	 * XXX: maybe there can be more than one chunk of control data?
    527  1.37.2.4        ad 	 */
    528  1.37.2.4        ad 	if (NETBSD32PTR64(omsg.msg_accrights) != NULL && control != NULL) {
    529  1.37.2.4        ad 		struct cmsghdr *cmsg = mtod(control, void *);
    530       1.1       mrg 
    531  1.37.2.4        ad 		if (cmsg->cmsg_level == SOL_SOCKET
    532  1.37.2.4        ad 		    && cmsg->cmsg_type == SCM_RIGHTS
    533  1.37.2.4        ad 		    && cmsg->cmsg_len < omsg.msg_accrightslen
    534  1.37.2.4        ad 		    && copyout(CMSG_DATA(cmsg),
    535  1.37.2.4        ad 			    NETBSD32PTR64(omsg.msg_accrights),
    536  1.37.2.4        ad 			    cmsg->cmsg_len) == 0) {
    537  1.37.2.4        ad 			omsg.msg_accrightslen = cmsg->cmsg_len;
    538  1.37.2.4        ad 			free_control_mbuf(l, control, control->m_next);
    539  1.37.2.4        ad 		} else {
    540  1.37.2.4        ad 			omsg.msg_accrightslen = 0;
    541  1.37.2.4        ad 			free_control_mbuf(l, control, control);
    542  1.37.2.4        ad 		}
    543  1.37.2.4        ad 	} else
    544  1.37.2.4        ad 		omsg.msg_accrightslen = 0;
    545      1.16       mrg 
    546  1.37.2.4        ad 	if (from != NULL)
    547  1.37.2.4        ad 		/* convert from sockaddr sa_family to osockaddr one here */
    548  1.37.2.4        ad 		mtod(from, struct osockaddr *)->sa_family =
    549  1.37.2.4        ad 				    mtod(from, struct sockaddr *)->sa_family;
    550  1.37.2.4        ad 
    551  1.37.2.4        ad 	error = copyout_sockname(NETBSD32PTR64(omsg.msg_name),
    552  1.37.2.4        ad 	    &omsg.msg_namelen, 0, from);
    553  1.37.2.4        ad 	if (from != NULL)
    554  1.37.2.4        ad 		m_free(from);
    555      1.16       mrg 
    556  1.37.2.4        ad 	if (error != 0)
    557  1.37.2.4        ad 		 error = copyout(&omsg, SCARG_P32(uap, msg), sizeof(omsg));
    558  1.37.2.4        ad 
    559  1.37.2.4        ad 	return error;
    560       1.1       mrg }
    561       1.1       mrg 
    562       1.1       mrg int
    563      1.24   thorpej compat_43_netbsd32_osendmsg(l, v, retval)
    564      1.24   thorpej 	struct lwp* l;
    565       1.1       mrg 	void *v;
    566       1.1       mrg 	register_t *retval;
    567       1.1       mrg {
    568       1.8       eeh 	struct compat_43_netbsd32_osendmsg_args /* {
    569       1.1       mrg 		syscallarg(int) s;
    570      1.37  christos 		syscallarg(netbsd32_caddr_t) msg;
    571       1.1       mrg 		syscallarg(int) flags;
    572       1.1       mrg 	} */ *uap = v;
    573  1.37.2.4        ad 	struct iovec *iov, aiov[UIO_SMALLIOV];
    574  1.37.2.4        ad 	struct netbsd32_omsghdr omsg;
    575  1.37.2.4        ad 	struct msghdr msg;
    576  1.37.2.4        ad 	int error;
    577  1.37.2.4        ad 	struct mbuf *nam;
    578  1.37.2.4        ad 	struct osockaddr *osa;
    579  1.37.2.4        ad 	struct sockaddr *sa;
    580       1.1       mrg 
    581  1.37.2.4        ad 	error = copyin(SCARG_P32(uap, msg), &omsg, sizeof (struct omsghdr));
    582  1.37.2.4        ad 	if (error != 0)
    583      1.16       mrg 		return (error);
    584      1.16       mrg 
    585  1.37.2.4        ad 	iov = netbsd32_get_iov(NETBSD32PTR64(omsg.msg_iov), omsg.msg_iovlen,
    586  1.37.2.4        ad 	    aiov, __arraycount(aiov));
    587  1.37.2.4        ad 	if (iov == NULL)
    588  1.37.2.4        ad 		return EFAULT;
    589  1.37.2.4        ad 
    590  1.37.2.4        ad 	msg.msg_iovlen = omsg.msg_iovlen;
    591  1.37.2.4        ad 	msg.msg_iov = iov;
    592  1.37.2.4        ad 	msg.msg_flags = MSG_NAMEMBUF;
    593  1.37.2.4        ad 
    594  1.37.2.4        ad 	error = sockargs(&nam, NETBSD32PTR64(omsg.msg_name), omsg.msg_namelen,
    595  1.37.2.4        ad 	    MT_SONAME);
    596  1.37.2.4        ad 	if (error != 0)
    597  1.37.2.4        ad 		goto out;
    598  1.37.2.4        ad 
    599  1.37.2.4        ad 	sa = mtod(nam, void *);
    600  1.37.2.4        ad 	osa = mtod(nam, void *);
    601  1.37.2.4        ad 	sa->sa_family = osa->sa_family;
    602  1.37.2.4        ad 	sa->sa_len = omsg.msg_namelen;
    603  1.37.2.4        ad 
    604  1.37.2.4        ad 	msg.msg_name = nam;
    605  1.37.2.4        ad 	msg.msg_namelen = omsg.msg_namelen;
    606  1.37.2.4        ad 	error = compat43_set_accrights(&msg, NETBSD32PTR64(omsg.msg_accrights),
    607  1.37.2.4        ad 	    omsg.msg_accrightslen);
    608  1.37.2.4        ad 	if (error != 0) {
    609  1.37.2.4        ad 		m_free(nam);
    610  1.37.2.4        ad 		goto out;
    611       1.1       mrg 	}
    612       1.1       mrg 
    613  1.37.2.4        ad 	error = do_sys_sendmsg(l, SCARG(uap, s), &msg, SCARG(uap, flags), retval);
    614  1.37.2.4        ad 
    615  1.37.2.4        ad     out:
    616  1.37.2.4        ad 	if (iov != aiov)
    617  1.37.2.4        ad 		free(iov, M_TEMP);
    618  1.37.2.4        ad 	return (error);
    619       1.1       mrg }
    620       1.1       mrg 
    621       1.1       mrg int
    622      1.24   thorpej compat_43_netbsd32_orecvfrom(l, v, retval)
    623      1.24   thorpej 	struct lwp* l;
    624       1.1       mrg 	void *v;
    625       1.1       mrg 	register_t *retval;
    626       1.1       mrg {
    627       1.8       eeh 	struct compat_43_netbsd32_orecvfrom_args /* {
    628       1.1       mrg 		syscallarg(int) s;
    629      1.37  christos 		syscallarg(netbsd32_caddr_t) buf;
    630       1.5       mrg 		syscallarg(netbsd32_size_t) len;
    631       1.1       mrg 		syscallarg(int) flags;
    632      1.37  christos 		syscallarg(netbsd32_caddr_t) from;
    633       1.5       mrg 		syscallarg(netbsd32_intp) fromlenaddr;
    634       1.1       mrg 	} */ *uap = v;
    635       1.1       mrg 	struct compat_43_sys_recvfrom_args ua;
    636       1.1       mrg 
    637       1.6       mrg 	NETBSD32TO64_UAP(s);
    638  1.37.2.1        ad 	NETBSD32TOP_UAP(buf, void *);
    639       1.6       mrg 	NETBSD32TOX_UAP(len, size_t);
    640       1.6       mrg 	NETBSD32TO64_UAP(flags);
    641  1.37.2.1        ad 	NETBSD32TOP_UAP(from, void *);
    642       1.6       mrg 	NETBSD32TOP_UAP(fromlenaddr, int);
    643      1.24   thorpej 	return (compat_43_sys_recvfrom(l, &ua, retval));
    644       1.1       mrg }
    645       1.1       mrg 
    646       1.1       mrg int
    647      1.24   thorpej compat_43_netbsd32_ogetsockname(l, v, retval)
    648      1.24   thorpej 	struct lwp* l;
    649       1.1       mrg 	void *v;
    650       1.1       mrg 	register_t *retval;
    651       1.1       mrg {
    652       1.8       eeh 	struct compat_43_netbsd32_ogetsockname_args /* {
    653       1.1       mrg 		syscallarg(int) fdec;
    654      1.37  christos 		syscallarg(netbsd32_caddr_t) asa;
    655       1.5       mrg 		syscallarg(netbsd32_intp) alen;
    656       1.1       mrg 	} */ *uap = v;
    657       1.1       mrg 	struct compat_43_sys_getsockname_args ua;
    658       1.1       mrg 
    659       1.6       mrg 	NETBSD32TO64_UAP(fdec);
    660  1.37.2.1        ad 	NETBSD32TOP_UAP(asa, void *);
    661  1.37.2.1        ad 	NETBSD32TOP_UAP(alen, int *);
    662      1.24   thorpej 	return (compat_43_sys_getsockname(l, &ua, retval));
    663       1.1       mrg }
    664       1.1       mrg 
    665       1.1       mrg int
    666      1.24   thorpej compat_43_netbsd32_ogetpeername(l, v, retval)
    667      1.24   thorpej 	struct lwp* l;
    668       1.1       mrg 	void *v;
    669       1.1       mrg 	register_t *retval;
    670       1.1       mrg {
    671       1.8       eeh 	struct compat_43_netbsd32_ogetpeername_args /* {
    672       1.1       mrg 		syscallarg(int) fdes;
    673      1.37  christos 		syscallarg(netbsd32_caddr_t) asa;
    674       1.5       mrg 		syscallarg(netbsd32_intp) alen;
    675       1.1       mrg 	} */ *uap = v;
    676       1.1       mrg 	struct compat_43_sys_getpeername_args ua;
    677       1.1       mrg 
    678       1.6       mrg 	NETBSD32TO64_UAP(fdes);
    679  1.37.2.1        ad 	NETBSD32TOP_UAP(asa, void *);
    680  1.37.2.1        ad 	NETBSD32TOP_UAP(alen, int *);
    681      1.24   thorpej 	return (compat_43_sys_getpeername(l, &ua, retval));
    682       1.1       mrg }
    683       1.1       mrg 
    684       1.1       mrg /* signal syscalls */
    685       1.1       mrg int
    686      1.24   thorpej compat_43_netbsd32_osigvec(l, v, retval)
    687      1.24   thorpej 	struct lwp* l;
    688       1.1       mrg 	void *v;
    689       1.1       mrg 	register_t *retval;
    690       1.1       mrg {
    691       1.8       eeh 	struct compat_43_netbsd32_osigvec_args /* {
    692       1.1       mrg 		syscallarg(int) signum;
    693       1.5       mrg 		syscallarg(netbsd32_sigvecp_t) nsv;
    694       1.5       mrg 		syscallarg(netbsd32_sigvecp_t) osv;
    695       1.1       mrg 	} */ *uap = v;
    696      1.16       mrg 	struct netbsd32_sigvec sv32;
    697  1.37.2.4        ad 	struct sigaction nsa, osa;
    698  1.37.2.4        ad 	int error;
    699  1.37.2.4        ad 
    700  1.37.2.4        ad 	if (SCARG(uap, signum) >= 32)
    701  1.37.2.4        ad 		return EINVAL;
    702       1.1       mrg 
    703  1.37.2.1        ad 	if (SCARG_P32(uap, nsv)) {
    704  1.37.2.1        ad 		error = copyin(SCARG_P32(uap, nsv), &sv32, sizeof(sv32));
    705      1.16       mrg 		if (error)
    706  1.37.2.4        ad 			return error;
    707  1.37.2.4        ad 		nsa.sa_handler = NETBSD32PTR64(sv32.sv_handler);
    708  1.37.2.4        ad 		nsa.sa_mask.__bits[0] = sv32.sv_mask;
    709  1.37.2.4        ad 		nsa.sa_mask.__bits[1] = 0;
    710  1.37.2.4        ad 		nsa.sa_mask.__bits[2] = 0;
    711  1.37.2.4        ad 		nsa.sa_mask.__bits[3] = 0;
    712  1.37.2.4        ad 		nsa.sa_flags = sv32.sv_flags ^ SA_RESTART;
    713  1.37.2.4        ad 		error = sigaction1(l, SCARG(uap, signum), &nsa, &osa, NULL, 0);
    714       1.1       mrg 	} else
    715  1.37.2.4        ad 		error = sigaction1(l, SCARG(uap, signum), NULL, &osa, NULL, 0);
    716  1.37.2.4        ad 	if (error)
    717  1.37.2.4        ad 		return error;
    718       1.1       mrg 
    719  1.37.2.1        ad 	if (SCARG_P32(uap, osv)) {
    720  1.37.2.4        ad 		NETBSD32PTR32(sv32.sv_handler, osa.sa_handler);
    721  1.37.2.4        ad 		sv32.sv_mask = osa.sa_mask.__bits[0];
    722  1.37.2.4        ad 		sv32.sv_flags = osa.sa_flags ^ SA_RESTART;
    723  1.37.2.1        ad 		error = copyout(&sv32, SCARG_P32(uap, osv), sizeof(sv32));
    724       1.1       mrg 	}
    725       1.1       mrg 
    726  1.37.2.4        ad 	return error;
    727       1.4       eeh }
    728       1.4       eeh 
    729       1.4       eeh int
    730      1.24   thorpej compat_43_netbsd32_sigblock(l, v, retval)
    731      1.24   thorpej 	struct lwp* l;
    732       1.4       eeh 	void *v;
    733       1.4       eeh 	register_t *retval;
    734       1.4       eeh {
    735       1.8       eeh 	struct compat_43_netbsd32_sigblock_args /* {
    736       1.4       eeh 		syscallarg(int) mask;
    737       1.4       eeh 	} */ *uap = v;
    738       1.4       eeh 	struct compat_43_sys_sigblock_args ua;
    739       1.4       eeh 
    740       1.6       mrg 	NETBSD32TO64_UAP(mask);
    741      1.24   thorpej 	return (compat_43_sys_sigblock(l, &ua, retval));
    742       1.4       eeh }
    743       1.4       eeh 
    744       1.4       eeh int
    745      1.24   thorpej compat_43_netbsd32_sigsetmask(l, v, retval)
    746      1.24   thorpej 	struct lwp* l;
    747       1.4       eeh 	void *v;
    748       1.4       eeh 	register_t *retval;
    749       1.4       eeh {
    750       1.8       eeh 	struct compat_43_netbsd32_sigsetmask_args /* {
    751       1.4       eeh 		syscallarg(int) mask;
    752       1.4       eeh 	} */ *uap = v;
    753       1.4       eeh 	struct compat_43_sys_sigsetmask_args ua;
    754       1.4       eeh 
    755       1.6       mrg 	NETBSD32TO64_UAP(mask);
    756      1.24   thorpej 	return (compat_43_sys_sigsetmask(l, &ua, retval));
    757       1.1       mrg }
    758       1.1       mrg 
    759       1.1       mrg int
    760      1.24   thorpej compat_43_netbsd32_osigstack(l, v, retval)
    761      1.24   thorpej 	struct lwp* l;
    762       1.1       mrg 	void *v;
    763       1.1       mrg 	register_t *retval;
    764       1.1       mrg {
    765       1.8       eeh 	struct compat_43_netbsd32_osigstack_args /* {
    766       1.5       mrg 		syscallarg(netbsd32_sigstackp_t) nss;
    767       1.5       mrg 		syscallarg(netbsd32_sigstackp_t) oss;
    768       1.1       mrg 	} */ *uap = v;
    769      1.16       mrg 	struct netbsd32_sigstack ss32;
    770  1.37.2.4        ad 	struct sigaltstack nsa, osa;
    771  1.37.2.4        ad 	int error;
    772  1.37.2.4        ad 
    773  1.37.2.1        ad 	if (SCARG_P32(uap, nss)) {
    774  1.37.2.1        ad 		error = copyin(SCARG_P32(uap, nss), &ss32, sizeof(ss32));
    775      1.16       mrg 		if (error)
    776  1.37.2.4        ad 			return error;
    777  1.37.2.4        ad 		nsa.ss_sp = NETBSD32PTR64(ss32.ss_sp);
    778  1.37.2.4        ad 		nsa.ss_size = SIGSTKSZ; /* Use the recommended size */
    779  1.37.2.4        ad 		nsa.ss_flags = ss32.ss_onstack ? SS_ONSTACK : 0;
    780  1.37.2.4        ad 		error = sigaltstack1(l, &nsa, &osa);
    781       1.1       mrg 	} else
    782  1.37.2.4        ad 		error = sigaltstack1(l, NULL, &osa);
    783  1.37.2.4        ad 	if (error)
    784  1.37.2.4        ad 		return error;
    785       1.1       mrg 
    786  1.37.2.1        ad 	if (SCARG_P32(uap, oss)) {
    787  1.37.2.4        ad 		NETBSD32PTR32(ss32.ss_sp, osa.ss_sp);
    788  1.37.2.4        ad 		ss32.ss_onstack = (osa.ss_flags & SS_ONSTACK) != 0;
    789  1.37.2.1        ad 		error = copyout(&ss32, SCARG_P32(uap, oss), sizeof(ss32));
    790       1.1       mrg 	}
    791       1.1       mrg 
    792  1.37.2.4        ad 	return error;
    793       1.1       mrg }
    794