Home | History | Annotate | Line # | Download | only in netbsd32
netbsd32_compat_30.c revision 1.4.8.4
      1  1.4.8.4      yamt /*	$NetBSD: netbsd32_compat_30.c,v 1.4.8.4 2006/08/11 15:43:29 yamt Exp $	*/
      2      1.1  christos 
      3      1.1  christos /*
      4      1.1  christos  * Copyright (c) 1998, 2001 Matthew R. Green
      5      1.1  christos  * All rights reserved.
      6      1.1  christos  *
      7      1.1  christos  * Redistribution and use in source and binary forms, with or without
      8      1.1  christos  * modification, are permitted provided that the following conditions
      9      1.1  christos  * are met:
     10      1.1  christos  * 1. Redistributions of source code must retain the above copyright
     11      1.1  christos  *    notice, this list of conditions and the following disclaimer.
     12      1.1  christos  * 2. Redistributions in binary form must reproduce the above copyright
     13      1.1  christos  *    notice, this list of conditions and the following disclaimer in the
     14      1.1  christos  *    documentation and/or other materials provided with the distribution.
     15      1.1  christos  * 3. The name of the author may not be used to endorse or promote products
     16      1.1  christos  *    derived from this software without specific prior written permission.
     17      1.1  christos  *
     18      1.1  christos  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     19      1.1  christos  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     20      1.1  christos  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     21      1.1  christos  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     22      1.1  christos  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
     23      1.1  christos  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
     24      1.1  christos  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
     25      1.1  christos  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
     26      1.1  christos  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     27      1.1  christos  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     28      1.1  christos  * SUCH DAMAGE.
     29      1.1  christos  */
     30      1.1  christos 
     31      1.1  christos #include <sys/cdefs.h>
     32  1.4.8.4      yamt __KERNEL_RCSID(0, "$NetBSD: netbsd32_compat_30.c,v 1.4.8.4 2006/08/11 15:43:29 yamt Exp $");
     33  1.4.8.4      yamt 
     34  1.4.8.4      yamt #include "opt_nfsserver.h"
     35      1.1  christos 
     36      1.1  christos #include <sys/param.h>
     37      1.1  christos #include <sys/systm.h>
     38      1.1  christos #include <sys/malloc.h>
     39      1.1  christos #include <sys/mount.h>
     40      1.1  christos #include <sys/socket.h>
     41      1.1  christos #include <sys/socketvar.h>
     42      1.1  christos #include <sys/stat.h>
     43      1.1  christos #include <sys/time.h>
     44      1.1  christos #include <sys/ktrace.h>
     45      1.1  christos #include <sys/resourcevar.h>
     46      1.1  christos #include <sys/vnode.h>
     47      1.1  christos #include <sys/file.h>
     48      1.1  christos #include <sys/filedesc.h>
     49      1.1  christos #include <sys/namei.h>
     50      1.1  christos #include <sys/sa.h>
     51      1.1  christos #include <sys/statvfs.h>
     52      1.1  christos #include <sys/syscallargs.h>
     53      1.1  christos #include <sys/proc.h>
     54      1.2  christos #include <sys/dirent.h>
     55  1.4.8.2      yamt #include <sys/kauth.h>
     56      1.1  christos 
     57      1.1  christos #include <compat/netbsd32/netbsd32.h>
     58      1.1  christos #include <compat/netbsd32/netbsd32_syscallargs.h>
     59      1.1  christos #include <compat/netbsd32/netbsd32_conv.h>
     60  1.4.8.4      yamt #include <compat/sys/mount.h>
     61      1.1  christos 
     62      1.1  christos 
     63      1.1  christos int
     64      1.1  christos netbsd32_getdents(l, v, retval)
     65      1.1  christos 	struct lwp *l;
     66      1.1  christos 	void *v;
     67      1.1  christos 	register_t *retval;
     68      1.1  christos {
     69      1.1  christos 	struct netbsd32_getdents_args /* {
     70      1.1  christos 		syscallarg(int) fd;
     71      1.1  christos 		syscallarg(netbsd32_charp) buf;
     72      1.1  christos 		syscallarg(netbsd32_size_t) count;
     73      1.1  christos 	} */ *uap = v;
     74      1.1  christos 	struct file *fp;
     75      1.1  christos 	int error, done;
     76      1.1  christos 	char  *buf;
     77  1.4.8.3      yamt 	netbsd32_size_t count;
     78      1.1  christos 	struct proc *p = l->l_proc;
     79      1.1  christos 
     80  1.4.8.3      yamt 	/* Limit the size on any kernel buffers used by VOP_READDIR */
     81  1.4.8.3      yamt 	count = min(MAXBSIZE, SCARG(uap, count));
     82  1.4.8.3      yamt 
     83      1.1  christos 	/* getvnode() will use the descriptor for us */
     84      1.1  christos 	if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0)
     85      1.1  christos 		return (error);
     86      1.1  christos 	if ((fp->f_flag & FREAD) == 0) {
     87      1.1  christos 		error = EBADF;
     88      1.1  christos 		goto out;
     89      1.1  christos 	}
     90  1.4.8.3      yamt 	buf = malloc(count, M_TEMP, M_WAITOK);
     91  1.4.8.3      yamt 	error = vn_readdir(fp, buf, UIO_SYSSPACE, count, &done, l, 0, 0);
     92      1.1  christos 	if (error == 0) {
     93      1.1  christos 		*retval = netbsd32_to_dirent12(buf, done);
     94      1.1  christos 		error = copyout(buf, NETBSD32PTR64(SCARG(uap, buf)), *retval);
     95      1.1  christos 	}
     96      1.1  christos 	free(buf, M_TEMP);
     97      1.1  christos  out:
     98      1.4  christos 	FILE_UNUSE(fp, l);
     99      1.1  christos 	return (error);
    100      1.1  christos }
    101      1.1  christos 
    102      1.1  christos int
    103      1.1  christos netbsd32___stat13(l, v, retval)
    104      1.1  christos 	struct lwp *l;
    105      1.1  christos 	void *v;
    106      1.1  christos 	register_t *retval;
    107      1.1  christos {
    108      1.1  christos 	struct netbsd32___stat13_args /* {
    109      1.1  christos 		syscallarg(const netbsd32_charp) path;
    110      1.1  christos 		syscallarg(netbsd32_stat13p_t) ub;
    111      1.1  christos 	} */ *uap = v;
    112      1.2  christos 	struct netbsd32_stat13 sb32;
    113      1.1  christos 	struct stat sb;
    114      1.1  christos 	int error;
    115      1.1  christos 	struct nameidata nd;
    116      1.1  christos 	caddr_t sg;
    117      1.1  christos 	const char *path;
    118      1.1  christos 	struct proc *p = l->l_proc;
    119      1.1  christos 
    120      1.1  christos 	path = (char *)NETBSD32PTR64(SCARG(uap, path));
    121      1.1  christos 	sg = stackgap_init(p, 0);
    122      1.4  christos 	CHECK_ALT_EXIST(l, &sg, path);
    123      1.1  christos 
    124      1.4  christos 	NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, path, l);
    125      1.1  christos 	if ((error = namei(&nd)) != 0)
    126      1.1  christos 		return (error);
    127      1.4  christos 	error = vn_stat(nd.ni_vp, &sb, l);
    128      1.1  christos 	vput(nd.ni_vp);
    129      1.1  christos 	if (error)
    130      1.1  christos 		return (error);
    131      1.1  christos 	netbsd32_from___stat13(&sb, &sb32);
    132      1.1  christos 	error = copyout(&sb32, (caddr_t)NETBSD32PTR64(SCARG(uap, ub)),
    133      1.1  christos 	    sizeof(sb32));
    134      1.1  christos 	return (error);
    135      1.1  christos }
    136      1.1  christos 
    137      1.1  christos int
    138      1.1  christos netbsd32___fstat13(l, v, retval)
    139      1.1  christos 	struct lwp *l;
    140      1.1  christos 	void *v;
    141      1.1  christos 	register_t *retval;
    142      1.1  christos {
    143      1.1  christos 	struct netbsd32___fstat13_args /* {
    144      1.1  christos 		syscallarg(int) fd;
    145      1.1  christos 		syscallarg(netbsd32_stat13p_t) sb;
    146      1.1  christos 	} */ *uap = v;
    147      1.1  christos 	int fd = SCARG(uap, fd);
    148      1.1  christos 	struct proc *p = l->l_proc;
    149      1.1  christos 	struct filedesc *fdp = p->p_fd;
    150      1.1  christos 	struct file *fp;
    151      1.2  christos 	struct netbsd32_stat13 sb32;
    152      1.1  christos 	struct stat ub;
    153      1.1  christos 	int error = 0;
    154      1.1  christos 
    155      1.1  christos 	if ((fp = fd_getfile(fdp, fd)) == NULL)
    156      1.1  christos 		return (EBADF);
    157      1.1  christos 
    158      1.1  christos 	FILE_USE(fp);
    159      1.4  christos 	error = (*fp->f_ops->fo_stat)(fp, &ub, l);
    160      1.4  christos 	FILE_UNUSE(fp, l);
    161      1.1  christos 
    162      1.1  christos 	if (error == 0) {
    163      1.1  christos 		netbsd32_from___stat13(&ub, &sb32);
    164      1.1  christos 		error = copyout(&sb32, (caddr_t)NETBSD32PTR64(SCARG(uap, sb)),
    165      1.1  christos 		    sizeof(sb32));
    166      1.1  christos 	}
    167      1.1  christos 	return (error);
    168      1.1  christos }
    169      1.1  christos 
    170      1.1  christos int
    171      1.1  christos netbsd32___lstat13(l, v, retval)
    172      1.1  christos 	struct lwp *l;
    173      1.1  christos 	void *v;
    174      1.1  christos 	register_t *retval;
    175      1.1  christos {
    176      1.1  christos 	struct netbsd32___lstat13_args /* {
    177      1.1  christos 		syscallarg(const netbsd32_charp) path;
    178      1.1  christos 		syscallarg(netbsd32_stat13p_t) ub;
    179      1.1  christos 	} */ *uap = v;
    180      1.2  christos 	struct netbsd32_stat13 sb32;
    181      1.1  christos 	struct stat sb;
    182      1.1  christos 	int error;
    183      1.1  christos 	struct nameidata nd;
    184      1.1  christos 	caddr_t sg;
    185      1.1  christos 	const char *path;
    186      1.1  christos 	struct proc *p = l->l_proc;
    187      1.1  christos 
    188      1.1  christos 	path = (char *)NETBSD32PTR64(SCARG(uap, path));
    189      1.1  christos 	sg = stackgap_init(p, 0);
    190      1.4  christos 	CHECK_ALT_EXIST(l, &sg, path);
    191      1.1  christos 
    192      1.4  christos 	NDINIT(&nd, LOOKUP, NOFOLLOW | LOCKLEAF, UIO_USERSPACE, path, l);
    193      1.1  christos 	if ((error = namei(&nd)) != 0)
    194      1.1  christos 		return (error);
    195      1.4  christos 	error = vn_stat(nd.ni_vp, &sb, l);
    196      1.1  christos 	vput(nd.ni_vp);
    197      1.1  christos 	if (error)
    198      1.1  christos 		return (error);
    199      1.1  christos 	netbsd32_from___stat13(&sb, &sb32);
    200      1.1  christos 	error = copyout(&sb32, (caddr_t)NETBSD32PTR64(SCARG(uap, ub)),
    201      1.1  christos 	    sizeof(sb32));
    202      1.1  christos 	return (error);
    203      1.1  christos }
    204  1.4.8.2      yamt 
    205  1.4.8.2      yamt int
    206  1.4.8.2      yamt compat_30_netbsd32_fhstat(l, v, retval)
    207  1.4.8.2      yamt 	struct lwp *l;
    208  1.4.8.2      yamt 	void *v;
    209  1.4.8.2      yamt 	register_t *retval;
    210  1.4.8.2      yamt {
    211  1.4.8.2      yamt 	struct compat_30_netbsd32_fhstat_args /* {
    212  1.4.8.2      yamt 		syscallarg(const netbsd32_fhandlep_t) fhp;
    213  1.4.8.2      yamt 		syscallarg(netbsd32_stat13p_t) sb);
    214  1.4.8.2      yamt 	} */ *uap = v;
    215  1.4.8.2      yamt 	struct stat sb;
    216  1.4.8.2      yamt 	struct netbsd32_stat13 sb32;
    217  1.4.8.2      yamt 	int error;
    218  1.4.8.4      yamt 	struct compat_30_fhandle fh;
    219  1.4.8.2      yamt 	struct mount *mp;
    220  1.4.8.2      yamt 	struct vnode *vp;
    221  1.4.8.2      yamt 
    222  1.4.8.2      yamt 	/*
    223  1.4.8.2      yamt 	 * Must be super user
    224  1.4.8.2      yamt 	 */
    225  1.4.8.4      yamt 	if ((error = kauth_authorize_generic(l->l_cred,
    226  1.4.8.4      yamt 	    KAUTH_GENERIC_ISSUSER, &l->l_acflag)))
    227  1.4.8.2      yamt 		return (error);
    228  1.4.8.2      yamt 
    229  1.4.8.2      yamt 	if ((error = copyin(NETBSD32PTR64(SCARG(uap, fhp)), &fh,
    230  1.4.8.4      yamt 	    sizeof(fh))) != 0)
    231  1.4.8.2      yamt 		return (error);
    232  1.4.8.2      yamt 
    233  1.4.8.2      yamt 	if ((mp = vfs_getvfs(&fh.fh_fsid)) == NULL)
    234  1.4.8.2      yamt 		return (ESTALE);
    235  1.4.8.2      yamt 	if (mp->mnt_op->vfs_fhtovp == NULL)
    236  1.4.8.2      yamt 		return EOPNOTSUPP;
    237  1.4.8.4      yamt 	if ((error = VFS_FHTOVP(mp, (struct fid*)&fh.fh_fid, &vp)))
    238  1.4.8.2      yamt 		return (error);
    239  1.4.8.2      yamt 	error = vn_stat(vp, &sb, l);
    240  1.4.8.2      yamt 	vput(vp);
    241  1.4.8.2      yamt 	if (error)
    242  1.4.8.2      yamt 		return (error);
    243  1.4.8.2      yamt 	netbsd32_from___stat13(&sb, &sb32);
    244  1.4.8.2      yamt 	error = copyout(&sb32, NETBSD32PTR64(SCARG(uap, sb)), sizeof(sb));
    245  1.4.8.2      yamt 	return (error);
    246  1.4.8.2      yamt }
    247  1.4.8.4      yamt 
    248  1.4.8.4      yamt int
    249  1.4.8.4      yamt compat_30_netbsd32_fhstatvfs1(l, v, retval)
    250  1.4.8.4      yamt 	struct lwp *l;
    251  1.4.8.4      yamt 	void *v;
    252  1.4.8.4      yamt 	register_t *retval;
    253  1.4.8.4      yamt {
    254  1.4.8.4      yamt 	struct compat_30_netbsd32_fhstatvfs1_args /* {
    255  1.4.8.4      yamt 		syscallarg(const netbsd32_fhandlep_t) fhp;
    256  1.4.8.4      yamt 		syscallarg(netbsd32_statvfsp_t) buf;
    257  1.4.8.4      yamt 		syscallarg(int) flags;
    258  1.4.8.4      yamt 	} */ *uap = v;
    259  1.4.8.4      yamt 	struct statvfs *sbuf;
    260  1.4.8.4      yamt 	struct netbsd32_statvfs *s32;
    261  1.4.8.4      yamt 	fhandle_t *fh;
    262  1.4.8.4      yamt 	struct vnode *vp;
    263  1.4.8.4      yamt 	int error;
    264  1.4.8.4      yamt 
    265  1.4.8.4      yamt 	/*
    266  1.4.8.4      yamt 	 * Must be super user
    267  1.4.8.4      yamt 	 */
    268  1.4.8.4      yamt 	if ((error = kauth_authorize_generic(l->l_cred,
    269  1.4.8.4      yamt 	    KAUTH_GENERIC_ISSUSER, &l->l_acflag)) != 0)
    270  1.4.8.4      yamt 		return error;
    271  1.4.8.4      yamt 
    272  1.4.8.4      yamt 	if ((error = vfs_copyinfh_alloc(NETBSD32PTR64(SCARG(uap, fhp)),
    273  1.4.8.4      yamt 	    FHANDLE_SIZE_COMPAT, &fh)) != 0)
    274  1.4.8.4      yamt 		goto bad;
    275  1.4.8.4      yamt 	if ((error = vfs_fhtovp(fh, &vp)) != 0)
    276  1.4.8.4      yamt 		goto bad;
    277  1.4.8.4      yamt 
    278  1.4.8.4      yamt 	sbuf = (struct statvfs *)malloc(sizeof(struct statvfs), M_TEMP,
    279  1.4.8.4      yamt 	    M_WAITOK);
    280  1.4.8.4      yamt 	error = dostatvfs(vp->v_mount, sbuf, l, SCARG(uap, flags), 1);
    281  1.4.8.4      yamt 	vput(vp);
    282  1.4.8.4      yamt 	if (error != 0)
    283  1.4.8.4      yamt 		goto out;
    284  1.4.8.4      yamt 
    285  1.4.8.4      yamt 	s32 = (struct netbsd32_statvfs *)
    286  1.4.8.4      yamt 	    malloc(sizeof(struct netbsd32_statvfs), M_TEMP, M_WAITOK);
    287  1.4.8.4      yamt 	netbsd32_from_statvfs(sbuf, s32);
    288  1.4.8.4      yamt 	error = copyout(s32, (caddr_t)NETBSD32PTR64(SCARG(uap, buf)),
    289  1.4.8.4      yamt 	    sizeof(struct netbsd32_statvfs));
    290  1.4.8.4      yamt 	free(s32, M_TEMP);
    291  1.4.8.4      yamt 
    292  1.4.8.4      yamt out:
    293  1.4.8.4      yamt 	free(sbuf, M_TEMP);
    294  1.4.8.4      yamt bad:
    295  1.4.8.4      yamt 	vfs_copyinfh_free(fh);
    296  1.4.8.4      yamt 	return (error);
    297  1.4.8.4      yamt }
    298  1.4.8.4      yamt 
    299  1.4.8.4      yamt int
    300  1.4.8.4      yamt compat_30_netbsd32_socket(l, v, retval)
    301  1.4.8.4      yamt 	struct lwp *l;
    302  1.4.8.4      yamt 	void *v;
    303  1.4.8.4      yamt 	register_t *retval;
    304  1.4.8.4      yamt {
    305  1.4.8.4      yamt 	struct compat_30_netbsd32_socket_args /* {
    306  1.4.8.4      yamt 		syscallarg(int) domain;
    307  1.4.8.4      yamt 		syscallarg(int) type;
    308  1.4.8.4      yamt 		syscallarg(int) protocol;
    309  1.4.8.4      yamt 	} */ *uap = v;
    310  1.4.8.4      yamt 	struct compat_30_sys_socket_args ua;
    311  1.4.8.4      yamt 
    312  1.4.8.4      yamt 	NETBSD32TO64_UAP(domain);
    313  1.4.8.4      yamt 	NETBSD32TO64_UAP(type);
    314  1.4.8.4      yamt 	NETBSD32TO64_UAP(protocol);
    315  1.4.8.4      yamt 	return (compat_30_sys_socket(l, &ua, retval));
    316  1.4.8.4      yamt }
    317  1.4.8.4      yamt 
    318  1.4.8.4      yamt int
    319  1.4.8.4      yamt compat_30_netbsd32_getfh(l, v, retval)
    320  1.4.8.4      yamt 	struct lwp *l;
    321  1.4.8.4      yamt 	void *v;
    322  1.4.8.4      yamt 	register_t *retval;
    323  1.4.8.4      yamt {
    324  1.4.8.4      yamt 	struct compat_30_netbsd32_getfh_args /* {
    325  1.4.8.4      yamt 		syscallarg(const netbsd32_charp) fname;
    326  1.4.8.4      yamt 		syscallarg(netbsd32_compat_30_fhandlep_t) fhp;
    327  1.4.8.4      yamt 	} */ *uap = v;
    328  1.4.8.4      yamt 	struct compat_30_sys_getfh_args ua;
    329  1.4.8.4      yamt 
    330  1.4.8.4      yamt 	NETBSD32TOP_UAP(fname, const char);
    331  1.4.8.4      yamt 	NETBSD32TOP_UAP(fhp, struct compat_30_fhandle);
    332  1.4.8.4      yamt 	/* Lucky for us a fhandle_t doesn't change sizes */
    333  1.4.8.4      yamt 	return (compat_30_sys_getfh(l, &ua, retval));
    334  1.4.8.4      yamt }
    335  1.4.8.4      yamt 
    336  1.4.8.4      yamt 
    337  1.4.8.4      yamt int compat_30_netbsd32_sys___fhstat30(l, v, retval)
    338  1.4.8.4      yamt 	struct lwp *l;
    339  1.4.8.4      yamt 	void *v;
    340  1.4.8.4      yamt 	register_t *retval;
    341  1.4.8.4      yamt {
    342  1.4.8.4      yamt 	struct compat_30_netbsd32_sys___fhstat30_args /* {
    343  1.4.8.4      yamt 		syscallarg(const netbsd32_fhandlep_t) fhp;
    344  1.4.8.4      yamt 		syscallarg(netbsd32_statp_t) sb;
    345  1.4.8.4      yamt 	} */ *uap = v;
    346  1.4.8.4      yamt 	struct stat sb;
    347  1.4.8.4      yamt 	struct netbsd32_stat sb32;
    348  1.4.8.4      yamt 	int error;
    349  1.4.8.4      yamt 	fhandle_t *fh;
    350  1.4.8.4      yamt 	struct vnode *vp;
    351  1.4.8.4      yamt 
    352  1.4.8.4      yamt 	/*
    353  1.4.8.4      yamt 	 * Must be super user
    354  1.4.8.4      yamt 	 */
    355  1.4.8.4      yamt 	if ((error = kauth_authorize_generic(l->l_cred, KAUTH_GENERIC_ISSUSER,
    356  1.4.8.4      yamt 	    &l->l_acflag)))
    357  1.4.8.4      yamt 		return error;
    358  1.4.8.4      yamt 
    359  1.4.8.4      yamt 	if ((error = vfs_copyinfh_alloc(NETBSD32PTR64(SCARG(uap, fhp)),
    360  1.4.8.4      yamt 	    FHANDLE_SIZE_COMPAT, &fh)) != 0)
    361  1.4.8.4      yamt 		goto bad;
    362  1.4.8.4      yamt 
    363  1.4.8.4      yamt 	if ((error = vfs_fhtovp(fh, &vp)) != 0)
    364  1.4.8.4      yamt 		goto bad;
    365  1.4.8.4      yamt 
    366  1.4.8.4      yamt 	error = vn_stat(vp, &sb, l);
    367  1.4.8.4      yamt 	vput(vp);
    368  1.4.8.4      yamt 	if (error)
    369  1.4.8.4      yamt 		goto bad;
    370  1.4.8.4      yamt 	netbsd32_from___stat30(&sb, &sb32);
    371  1.4.8.4      yamt 	error = copyout(&sb32, NETBSD32PTR64(SCARG(uap, sb)), sizeof(sb));
    372  1.4.8.4      yamt bad:
    373  1.4.8.4      yamt 	vfs_copyinfh_free(fh);
    374  1.4.8.4      yamt 	return error;
    375  1.4.8.4      yamt }
    376  1.4.8.4      yamt 
    377  1.4.8.4      yamt /*
    378  1.4.8.4      yamt  * Open a file given a file handle.
    379  1.4.8.4      yamt  *
    380  1.4.8.4      yamt  * Check permissions, allocate an open file structure,
    381  1.4.8.4      yamt  * and call the device open routine if any.
    382  1.4.8.4      yamt  */
    383  1.4.8.4      yamt int
    384  1.4.8.4      yamt compat_30_netbsd32_fhopen(l, v, retval)
    385  1.4.8.4      yamt 	struct lwp *l;
    386  1.4.8.4      yamt 	void *v;
    387  1.4.8.4      yamt 	register_t *retval;
    388  1.4.8.4      yamt {
    389  1.4.8.4      yamt 	struct compat_30_netbsd32_fhopen_args /* {
    390  1.4.8.4      yamt 		syscallarg(const fhandle_t *) fhp;
    391  1.4.8.4      yamt 		syscallarg(int) flags;
    392  1.4.8.4      yamt 	} */ *uap = v;
    393  1.4.8.4      yamt 	struct compat_30_sys_fhopen_args ua;
    394  1.4.8.4      yamt 
    395  1.4.8.4      yamt 	NETBSD32TOP_UAP(fhp, struct compat_30_fhandle);
    396  1.4.8.4      yamt 	NETBSD32TO64_UAP(flags);
    397  1.4.8.4      yamt 	return (compat_30_sys_fhopen(l, &ua, retval));
    398  1.4.8.4      yamt }
    399