Catch up with descriptor handling changes. See kern_descrip.c revision

1.173 for details.
This commit is contained in:
ad 2008-03-21 21:54:58 +00:00
parent c743ad7159
commit a9ca7a3734
147 changed files with 2119 additions and 2630 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: netbsd32_machdep.c,v 1.76 2008/03/14 15:39:18 nakayama Exp $ */
/* $NetBSD: netbsd32_machdep.c,v 1.77 2008/03/21 21:54:58 ad Exp $ */
/*
* Copyright (c) 1998, 2001 Matthew R. Green
@ -29,7 +29,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.76 2008/03/14 15:39:18 nakayama Exp $");
__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.77 2008/03/21 21:54:58 ad Exp $");
#ifdef _KERNEL_OPT
#include "opt_compat_netbsd.h"
@ -53,6 +53,7 @@ __KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.76 2008/03/14 15:39:18 nakaya
#include <sys/select.h>
#include <sys/ucontext.h>
#include <sys/ioctl.h>
#include <sys/kmem.h>
#include <dev/sun/event_var.h>
@ -1117,10 +1118,10 @@ netbsd32_md_ioctl(struct file *fp, netbsd32_u_long cmd, void *data32, struct lwp
case OPIOCNEXTPROP32:
IOCTL_STRUCT_CONV_TO(OPIOCNEXTPROP, opiocdesc);
default:
error = (*fp->f_ops->fo_ioctl)(fp, cmd, data32, l);
error = (*fp->f_ops->fo_ioctl)(fp, cmd, data32);
}
if (memp)
free(memp, M_IOCTLOPS);
kmem_free(memp, size);
return (error);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: vfs_syscalls_12.c,v 1.24 2007/12/20 23:02:45 dsl Exp $ */
/* $NetBSD: vfs_syscalls_12.c,v 1.25 2008/03/21 21:54:58 ad Exp $ */
/*
* Copyright (c) 1989, 1993
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls_12.c,v 1.24 2007/12/20 23:02:45 dsl Exp $");
__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls_12.c,v 1.25 2008/03/21 21:54:58 ad Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -97,13 +97,12 @@ compat_12_sys_getdirentries(struct lwp *l, const struct compat_12_sys_getdirentr
syscallarg(u_int) count;
syscallarg(long *) basep;
} */
struct proc *p = l->l_proc;
struct file *fp;
int error, done;
long loff;
/* getvnode() will use the descriptor for us */
if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0)
if ((error = getvnode(SCARG(uap, fd), &fp)) != 0)
return error;
if ((fp->f_flag & FREAD) == 0) {
error = EBADF;
@ -118,7 +117,7 @@ compat_12_sys_getdirentries(struct lwp *l, const struct compat_12_sys_getdirentr
error = copyout(&loff, SCARG(uap, basep), sizeof(long));
*retval = done;
out:
FILE_UNUSE(fp, l);
fd_putfile(SCARG(uap, fd));
return error;
}
@ -137,7 +136,7 @@ compat_12_sys_stat(struct lwp *l, const struct compat_12_sys_stat_args *uap, reg
struct stat12 osb;
int error;
error = do_sys_stat(l, SCARG(uap, path), FOLLOW, &sb);
error = do_sys_stat(SCARG(uap, path), FOLLOW, &sb);
if (error)
return (error);
compat_12_stat_conv(&sb, &osb);
@ -161,7 +160,7 @@ compat_12_sys_lstat(struct lwp *l, const struct compat_12_sys_lstat_args *uap, r
struct stat12 osb;
int error;
error = do_sys_stat(l, SCARG(uap, path), NOFOLLOW, &sb);
error = do_sys_stat(SCARG(uap, path), NOFOLLOW, &sb);
if (error)
return (error);
compat_12_stat_conv(&sb, &osb);
@ -180,21 +179,16 @@ compat_12_sys_fstat(struct lwp *l, const struct compat_12_sys_fstat_args *uap, r
syscallarg(int) fd;
syscallarg(struct stat12 *) sb;
} */
struct proc *p = l->l_proc;
int fd = SCARG(uap, fd);
struct filedesc *fdp = p->p_fd;
struct file *fp;
struct stat ub;
struct stat12 oub;
int error;
if ((fp = fd_getfile(fdp, fd)) == NULL)
if ((fp = fd_getfile(fd)) == NULL)
return (EBADF);
FILE_USE(fp);
error = (*fp->f_ops->fo_stat)(fp, &ub, l);
FILE_UNUSE(fp, l);
error = (*fp->f_ops->fo_stat)(fp, &ub);
fd_putfile(fd);
if (error == 0) {
compat_12_stat_conv(&ub, &oub);
error = copyout(&oub, SCARG(uap, sb), sizeof (oub));

View File

@ -1,4 +1,4 @@
/* $NetBSD: vfs_syscalls_20.c,v 1.25 2008/01/30 11:46:59 ad Exp $ */
/* $NetBSD: vfs_syscalls_20.c,v 1.26 2008/03/21 21:54:58 ad Exp $ */
/*
* Copyright (c) 1989, 1993
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls_20.c,v 1.25 2008/01/30 11:46:59 ad Exp $");
__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls_20.c,v 1.26 2008/03/21 21:54:58 ad Exp $");
#include "opt_compat_netbsd.h"
#include "opt_compat_43.h"
@ -177,14 +177,13 @@ compat_20_sys_fstatfs(struct lwp *l, const struct compat_20_sys_fstatfs_args *ua
syscallarg(int) fd;
syscallarg(struct statfs12 *) buf;
} */
struct proc *p = l->l_proc;
struct file *fp;
struct mount *mp;
struct statvfs *sbuf;
int error;
/* getvnode() will use the descriptor for us */
if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0)
if ((error = getvnode(SCARG(uap, fd), &fp)) != 0)
return (error);
mp = ((struct vnode *)fp->f_data)->v_mount;
sbuf = malloc(sizeof(*sbuf), M_TEMP, M_WAITOK);
@ -192,7 +191,7 @@ compat_20_sys_fstatfs(struct lwp *l, const struct compat_20_sys_fstatfs_args *ua
goto out;
error = vfs2fs(SCARG(uap, buf), sbuf);
out:
FILE_UNUSE(fp, l);
fd_putfile(SCARG(uap, fd));
free(sbuf, M_TEMP);
return error;
}

View File

@ -1,7 +1,7 @@
/* $NetBSD: vfs_syscalls_30.c,v 1.25 2007/12/20 23:02:45 dsl Exp $ */
/* $NetBSD: vfs_syscalls_30.c,v 1.26 2008/03/21 21:54:58 ad Exp $ */
/*-
* Copyright (c) 2005 The NetBSD Foundation, Inc.
* Copyright (c) 2005, 2008 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@ -36,7 +36,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls_30.c,v 1.25 2007/12/20 23:02:45 dsl Exp $");
__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls_30.c,v 1.26 2008/03/21 21:54:58 ad Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -104,7 +104,7 @@ compat_30_sys___stat13(struct lwp *l, const struct compat_30_sys___stat13_args *
struct stat13 osb;
int error;
error = do_sys_stat(l, SCARG(uap, path), FOLLOW, &sb);
error = do_sys_stat(SCARG(uap, path), FOLLOW, &sb);
if (error)
return error;
cvtstat(&osb, &sb);
@ -128,7 +128,7 @@ compat_30_sys___lstat13(struct lwp *l, const struct compat_30_sys___lstat13_args
struct stat13 osb;
int error;
error = do_sys_stat(l, SCARG(uap, path), NOFOLLOW, &sb);
error = do_sys_stat(SCARG(uap, path), NOFOLLOW, &sb);
if (error)
return error;
cvtstat(&osb, &sb);
@ -167,7 +167,7 @@ compat_30_sys_fhstat(struct lwp *l, const struct compat_30_sys_fhstat_args *uap,
return EOPNOTSUPP;
if ((error = VFS_FHTOVP(mp, (struct fid*)&fh.fh_fid, &vp)))
return (error);
error = vn_stat(vp, &sb, l);
error = vn_stat(vp, &sb);
vput(vp);
if (error)
return (error);
@ -187,21 +187,16 @@ compat_30_sys___fstat13(struct lwp *l, const struct compat_30_sys___fstat13_args
syscallarg(int) fd;
syscallarg(struct stat13 *) sb;
} */
struct proc *p = l->l_proc;
int fd = SCARG(uap, fd);
struct filedesc *fdp = p->p_fd;
struct file *fp;
struct stat sb;
struct stat13 osb;
int error;
if ((fp = fd_getfile(fdp, fd)) == NULL)
if ((fp = fd_getfile(fd)) == NULL)
return EBADF;
FILE_USE(fp);
error = (*fp->f_ops->fo_stat)(fp, &sb, l);
FILE_UNUSE(fp, l);
error = (*fp->f_ops->fo_stat)(fp, &sb);
fd_putfile(fd);
if (error)
return error;
cvtstat(&osb, &sb);
@ -220,7 +215,6 @@ compat_30_sys_getdents(struct lwp *l, const struct compat_30_sys_getdents_args *
syscallarg(char *) buf;
syscallarg(size_t) count;
} */
struct proc *p = l->l_proc;
struct dirent *bdp;
struct vnode *vp;
char *inp, *tbuf; /* BSD-format */
@ -237,7 +231,7 @@ compat_30_sys_getdents(struct lwp *l, const struct compat_30_sys_getdents_args *
int ncookies;
/* getvnode() will use the descriptor for us */
if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0)
if ((error = getvnode(SCARG(uap, fd), &fp)) != 0)
return error;
if ((fp->f_flag & FREAD) == 0) {
@ -245,7 +239,7 @@ compat_30_sys_getdents(struct lwp *l, const struct compat_30_sys_getdents_args *
goto out1;
}
vp = (struct vnode *)fp->f_data;
vp = fp->f_data;
if (vp->v_type != VDIR) {
error = EINVAL;
goto out1;
@ -335,7 +329,7 @@ out:
free(cookiebuf, M_TEMP);
free(tbuf, M_TEMP);
out1:
FILE_UNUSE(fp, l);
fd_putfile(SCARG(uap, fd));
return error;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: vfs_syscalls_43.c,v 1.45 2007/12/20 23:02:45 dsl Exp $ */
/* $NetBSD: vfs_syscalls_43.c,v 1.46 2008/03/21 21:54:58 ad Exp $ */
/*
* Copyright (c) 1989, 1993
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls_43.c,v 1.45 2007/12/20 23:02:45 dsl Exp $");
__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls_43.c,v 1.46 2008/03/21 21:54:58 ad Exp $");
#if defined(_KERNEL_OPT)
#include "fs_union.h"
@ -114,7 +114,7 @@ compat_43_sys_stat(struct lwp *l, const struct compat_43_sys_stat_args *uap, reg
struct stat43 osb;
int error;
error = do_sys_stat(l, SCARG(uap, path), FOLLOW, &sb);
error = do_sys_stat(SCARG(uap, path), FOLLOW, &sb);
if (error)
return (error);
cvtstat(&sb, &osb);
@ -167,18 +167,18 @@ again:
else
vput(dvp);
}
error = vn_stat(vp, &sb, l);
error = vn_stat(vp, &sb);
vput(vp);
if (error)
return (error);
} else {
error = vn_stat(dvp, &sb, l);
error = vn_stat(dvp, &sb);
vput(dvp);
if (error) {
vput(vp);
return (error);
}
error = vn_stat(vp, &sb1, l);
error = vn_stat(vp, &sb1);
vput(vp);
if (error)
return (error);
@ -204,21 +204,16 @@ compat_43_sys_fstat(struct lwp *l, const struct compat_43_sys_fstat_args *uap, r
syscallarg(int) fd;
syscallarg(struct stat43 *) sb;
} */
struct proc *p = l->l_proc;
int fd = SCARG(uap, fd);
struct filedesc *fdp = p->p_fd;
struct file *fp;
struct stat ub;
struct stat43 oub;
int error;
if ((fp = fd_getfile(fdp, fd)) == NULL)
if ((fp = fd_getfile(fd)) == NULL)
return (EBADF);
FILE_USE(fp);
error = (*fp->f_ops->fo_stat)(fp, &ub, l);
FILE_UNUSE(fp, l);
error = (*fp->f_ops->fo_stat)(fp, &ub);
fd_putfile(fd);
if (error == 0) {
cvtstat(&ub, &oub);
error = copyout((void *)&oub, (void *)SCARG(uap, sb),
@ -347,7 +342,6 @@ compat_43_sys_getdirentries(struct lwp *l, const struct compat_43_sys_getdirentr
syscallarg(u_int) count;
syscallarg(long *) basep;
} */
struct proc *p = l->l_proc;
struct vnode *vp;
struct file *fp;
struct uio auio, kuio;
@ -360,7 +354,7 @@ compat_43_sys_getdirentries(struct lwp *l, const struct compat_43_sys_getdirentr
long loff;
/* getvnode() will use the descriptor for us */
if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0)
if ((error = getvnode(SCARG(uap, fd), &fp)) != 0)
return (error);
if ((fp->f_flag & FREAD) == 0) {
error = EBADF;
@ -379,7 +373,7 @@ unionread:
auio.uio_rw = UIO_READ;
auio.uio_resid = count;
KASSERT(l == curlwp);
auio.uio_vmspace = l->l_proc->p_vmspace;
auio.uio_vmspace = curproc->p_vmspace;
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
loff = auio.uio_offset = fp->f_offset;
# if (BYTE_ORDER != LITTLE_ENDIAN)
@ -437,50 +431,6 @@ unionread:
if (error)
goto out;
#ifdef UNION
{
extern int (**union_vnodeop_p)(void *);
extern struct vnode *union_dircache(struct vnode *);
if ((count == auio.uio_resid) &&
(vp->v_op == union_vnodeop_p)) {
struct vnode *lvp;
lvp = union_dircache(vp);
if (lvp != NULLVP) {
struct vattr va;
/*
* If the directory is opaque,
* then don't show lower entries
*/
error = VOP_GETATTR(vp, &va, fp->f_cred);
if (va.va_flags & OPAQUE) {
vput(lvp);
lvp = NULL;
}
}
if (lvp != NULLVP) {
error = VOP_OPEN(lvp, FREAD, fp->f_cred);
VOP_UNLOCK(lvp, 0);
if (error) {
vrele(lvp);
goto out;
}
fp->f_data = (void *) lvp;
fp->f_offset = 0;
error = vn_close(vp, FREAD, fp->f_cred, l);
if (error)
goto out;
vp = lvp;
goto unionread;
}
}
}
#endif /* UNION */
if ((count == auio.uio_resid) &&
(vp->v_vflag & VV_ROOT) &&
(vp->v_mount->mnt_flag & MNT_UNION)) {
@ -496,7 +446,7 @@ unionread:
sizeof(long));
*retval = count - auio.uio_resid;
out:
FILE_UNUSE(fp, l);
fd_putfile(SCARG(uap, fd));
return (error);
}

View File

@ -1,7 +1,7 @@
/* $NetBSD: darwin_attr.c,v 1.22 2007/12/20 23:02:45 dsl Exp $ */
/* $NetBSD: darwin_attr.c,v 1.23 2008/03/21 21:54:58 ad Exp $ */
/*-
* Copyright (c) 2003 The NetBSD Foundation, Inc.
* Copyright (c) 2003, 2008 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: darwin_attr.c,v 1.22 2007/12/20 23:02:45 dsl Exp $");
__KERNEL_RCSID(0, "$NetBSD: darwin_attr.c,v 1.23 2008/03/21 21:54:58 ad Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -157,7 +157,7 @@ darwin_sys_getattrlist(struct lwp *l, const struct darwin_sys_getattrlist_args *
goto out3;
/* Get the informations for path: file related info */
error = vn_stat(vp, &st, l);
error = vn_stat(vp, &st);
if (error != 0)
goto out3;

View File

@ -1,7 +1,7 @@
/* $NetBSD: darwin_ioctl.c,v 1.8 2007/12/20 23:02:46 dsl Exp $ */
/* $NetBSD: darwin_ioctl.c,v 1.9 2008/03/21 21:54:58 ad Exp $ */
/*-
* Copyright (c) 2003 The NetBSD Foundation, Inc.
* Copyright (c) 2003, 2008 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: darwin_ioctl.c,v 1.8 2007/12/20 23:02:46 dsl Exp $");
__KERNEL_RCSID(0, "$NetBSD: darwin_ioctl.c,v 1.9 2008/03/21 21:54:58 ad Exp $");
#include <sys/types.h>
#include <sys/param.h>
@ -75,19 +75,18 @@ darwin_sys_ioctl(struct lwp *l, const struct darwin_sys_ioctl_args *uap, registe
switch (SCARG(uap, com)) {
case DARWIN_FIODTYPE: { /* Get file d_type */
struct proc *p = l->l_proc;
struct file *fp;
file_t *fp;
struct vnode *vp;
int *data = SCARG(uap, data);
int type;
/* getvnode() will use the descriptor for us */
if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)))
if ((error = fd_getvnode(SCARG(uap, fd), &fp)))
return (error);
vp = fp->f_data;
type = vtype_to_dtype(vp->v_type);
FILE_UNUSE(fp, l);
fd_putfile(SCARG(uap, fd));
error = copyout(&type, data, sizeof(*data));

View File

@ -1,9 +1,9 @@
#undef DEBUG_DARWIN
#undef DEBUG_MACH
/* $NetBSD: darwin_mman.c,v 1.27 2007/12/20 23:02:46 dsl Exp $ */
/* $NetBSD: darwin_mman.c,v 1.28 2008/03/21 21:54:58 ad Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
* Copyright (c) 2002, 2008 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@ -39,7 +39,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: darwin_mman.c,v 1.27 2007/12/20 23:02:46 dsl Exp $");
__KERNEL_RCSID(0, "$NetBSD: darwin_mman.c,v 1.28 2008/03/21 21:54:58 ad Exp $");
#include <sys/types.h>
#include <sys/param.h>
@ -77,7 +77,6 @@ darwin_sys_load_shared_file(struct lwp *l, const struct darwin_sys_load_shared_f
syscallarg(int *) flags;
} */
struct file *fp;
struct filedesc *fdp;
struct vnode *vp = NULL;
vaddr_t base;
struct proc *p = l->l_proc;
@ -125,14 +124,12 @@ darwin_sys_load_shared_file(struct lwp *l, const struct darwin_sys_load_shared_f
goto bad1;
fd = (int)fdc;
fdp = p->p_fd;
fp = fd_getfile(fdp, fd);
fp = fd_getfile(fd);
if (fp == NULL) {
error = EBADF;
goto bad2;
goto bad1point5;
}
FILE_USE(fp);
vp = (struct vnode *)fp->f_data;
vp = fp->f_data;
vref(vp);
if (SCARG(uap, count) < 0 ||
@ -230,7 +227,8 @@ bad2:
if (mapp)
free(mapp, M_TEMP);
vrele(vp);
FILE_UNUSE(fp, l);
fd_putfile(fd);
bad1point5:
SCARG(&close_cup, fd) = fd;
if ((error = sys_close(l, &close_cup, retval)) != 0)
goto bad1;

View File

@ -1,7 +1,7 @@
/* $NetBSD: darwin_mount.c,v 1.15 2007/12/20 23:02:46 dsl Exp $ */
/* $NetBSD: darwin_mount.c,v 1.16 2008/03/21 21:54:58 ad Exp $ */
/*-
* Copyright (c) 2003 The NetBSD Foundation, Inc.
* Copyright (c) 2003, 2008 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: darwin_mount.c,v 1.15 2007/12/20 23:02:46 dsl Exp $");
__KERNEL_RCSID(0, "$NetBSD: darwin_mount.c,v 1.16 2008/03/21 21:54:58 ad Exp $");
#include <sys/types.h>
#include <sys/param.h>
@ -69,15 +69,14 @@ darwin_sys_fstatfs(struct lwp *l, const struct darwin_sys_fstatfs_args *uap, reg
syscallarg(int) fd;
syscallarg(struct darwin_statfs *) buf;
} */
struct proc *p = l->l_proc;
struct file *fp;
file_t *fp;
struct mount *mp;
struct statvfs *bs;
struct darwin_statfs ds;
int error;
/* getvnode() will use the descriptor for us */
if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)))
if ((error = fd_getvnode(SCARG(uap, fd), &fp)))
return (error);
mp = ((struct vnode *)fp->f_data)->v_mount;
@ -91,7 +90,7 @@ darwin_sys_fstatfs(struct lwp *l, const struct darwin_sys_fstatfs_args *uap, reg
error = copyout(&ds, SCARG(uap, buf), sizeof(ds));
out:
FILE_UNUSE(fp, l);
fd_putfile(SCARG(uap, fd));
return (error);
}

View File

@ -1,7 +1,7 @@
/* $NetBSD: darwin_socket.c,v 1.18 2007/12/20 23:02:46 dsl Exp $ */
/* $NetBSD: darwin_socket.c,v 1.19 2008/03/21 21:54:58 ad Exp $ */
/*-
* Copyright (c) 2004 The NetBSD Foundation, Inc.
* Copyright (c) 2004, 2008 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: darwin_socket.c,v 1.18 2007/12/20 23:02:46 dsl Exp $");
__KERNEL_RCSID(0, "$NetBSD: darwin_socket.c,v 1.19 2008/03/21 21:54:58 ad Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -243,7 +243,7 @@ darwin_sys_accept(struct lwp *l, const struct darwin_sys_accept_args *uap, regis
syscallarg(struct sockaddr *) name;
syscallarg(unsigned int *) anamelen;
} */
int error;
int error, fd;
struct mbuf *name;
error = do_sys_accept(l, SCARG(uap, s), &name, retval);
@ -256,8 +256,11 @@ darwin_sys_accept(struct lwp *l, const struct darwin_sys_accept_args *uap, regis
MSG_LENUSRSPACE, name);
if (name != NULL)
m_free(name);
if (error != 0)
fdrelease(l, *retval);
if (error != 0) {
fd = (int)*retval;
if (fd_getfile(fd) != NULL)
fd_close(fd);
}
return error;
}

View File

@ -1,7 +1,7 @@
/* $NetBSD: darwin_stat.c,v 1.12 2007/12/20 23:02:46 dsl Exp $ */
/* $NetBSD: darwin_stat.c,v 1.13 2008/03/21 21:54:58 ad Exp $ */
/*-
* Copyright (c) 2003 The NetBSD Foundation, Inc.
* Copyright (c) 2003, 2008 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: darwin_stat.c,v 1.12 2007/12/20 23:02:46 dsl Exp $");
__KERNEL_RCSID(0, "$NetBSD: darwin_stat.c,v 1.13 2008/03/21 21:54:58 ad Exp $");
#include <sys/types.h>
#include <sys/param.h>
@ -73,7 +73,7 @@ darwin_sys_stat(struct lwp *l, const struct darwin_sys_stat_args *uap, register_
struct stat sb;
int error;
error = do_sys_stat(l, SCARG(uap, path), FOLLOW, &sb);
error = do_sys_stat(SCARG(uap, path), FOLLOW, &sb);
if (error != 0)
return error;
@ -95,7 +95,7 @@ darwin_sys_fstat(struct lwp *l, const struct darwin_sys_fstat_args *uap, registe
struct stat sb;
int error;
error = do_sys_fstat(l, SCARG(uap, fd), &sb);
error = do_sys_fstat(SCARG(uap, fd), &sb);
if (error != 0)
return error;
@ -117,7 +117,7 @@ darwin_sys_lstat(struct lwp *l, const struct darwin_sys_lstat_args *uap, registe
struct stat sb;
int error;
error = do_sys_stat(l, SCARG(uap, path), NOFOLLOW, &sb);
error = do_sys_stat(SCARG(uap, path), NOFOLLOW, &sb);
if (error != 0)
return error;

View File

@ -1,4 +1,4 @@
/* $NetBSD: ibcs2_fcntl.c,v 1.33 2007/12/20 23:02:49 dsl Exp $ */
/* $NetBSD: ibcs2_fcntl.c,v 1.34 2008/03/21 21:54:58 ad Exp $ */
/*
* Copyright (c) 1995 Scott Bartram
@ -28,7 +28,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ibcs2_fcntl.c,v 1.33 2007/12/20 23:02:49 dsl Exp $");
__KERNEL_RCSID(0, "$NetBSD: ibcs2_fcntl.c,v 1.34 2008/03/21 21:54:58 ad Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -174,15 +174,13 @@ ibcs2_sys_open(struct lwp *l, const struct ibcs2_sys_open_args *uap, register_t
ret = sys_open(l, &bsd_ua, retval);
if (!ret && !noctty && SESS_LEADER(p) && !(p->p_lflag & PL_CONTROLT)) {
struct filedesc *fdp = p->p_fd;
struct file *fp;
file_t *fp;
if ((fp = fd_getfile(fdp, *retval)) != NULL) {
FILE_USE(fp);
if ((fp = fd_getfile(*retval)) != NULL) {
/* ignore any error, just give it a try */
if (fp->f_type == DTYPE_VNODE)
(fp->f_ops->fo_ioctl)(fp, TIOCSCTTY, NULL, l);
FILE_UNUSE(fp, l);
(fp->f_ops->fo_ioctl)(fp, TIOCSCTTY, NULL);
fd_putfile(*retval);
}
}
return ret;
@ -308,7 +306,7 @@ ibcs2_sys_fcntl(struct lwp *l, const struct ibcs2_sys_fcntl_args *uap, register_
if (error)
return error;
cvt_iflock2flock(&ifl, &fl);
error = do_fcntl_lock(l, SCARG(uap, fd), cmd, &fl);
error = do_fcntl_lock(SCARG(uap, fd), cmd, &fl);
if (cmd != F_GETLK || error != 0)
return error;
cvt_flock2iflock(&fl, &ifl);

View File

@ -1,4 +1,4 @@
/* $NetBSD: ibcs2_ioctl.c,v 1.42 2007/12/20 23:02:49 dsl Exp $ */
/* $NetBSD: ibcs2_ioctl.c,v 1.43 2008/03/21 21:54:58 ad Exp $ */
/*
* Copyright (c) 1994, 1995 Scott Bartram
@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ibcs2_ioctl.c,v 1.42 2007/12/20 23:02:49 dsl Exp $");
__KERNEL_RCSID(0, "$NetBSD: ibcs2_ioctl.c,v 1.43 2008/03/21 21:54:58 ad Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -331,9 +331,8 @@ ibcs2_sys_ioctl(struct lwp *l, const struct ibcs2_sys_ioctl_args *uap, register_
syscallarg(void *) data;
} */
struct proc *p = l->l_proc;
struct filedesc *fdp = p->p_fd;
struct file *fp;
int (*ctl)(struct file *, u_long, void *, struct lwp *);
int (*ctl)(struct file *, u_long, void *);
struct termios bts;
struct ibcs2_termios sts;
struct ibcs2_termio st;
@ -382,13 +381,12 @@ ibcs2_sys_ioctl(struct lwp *l, const struct ibcs2_sys_ioctl_args *uap, register_
break;
}
if ((fp = fd_getfile(fdp, SCARG(uap, fd))) == NULL) {
if ((fp = fd_getfile(SCARG(uap, fd))) == NULL) {
DPRINTF(("ibcs2_ioctl(%d): bad fd %d ", p->p_pid,
SCARG(uap, fd)));
return EBADF;
}
FILE_USE(fp);
if ((fp->f_flag & (FREAD|FWRITE)) == 0) {
DPRINTF(("ibcs2_ioctl(%d): bad fp flag ", p->p_pid));
error = EBADF;
@ -401,7 +399,7 @@ ibcs2_sys_ioctl(struct lwp *l, const struct ibcs2_sys_ioctl_args *uap, register_
case IBCS2_TCGETA:
case IBCS2_XCGETA:
case IBCS2_OXCGETA:
if ((error = (*ctl)(fp, TIOCGETA, &bts, l)) != 0)
if ((error = (*ctl)(fp, TIOCGETA, &bts)) != 0)
goto out;
btios2stios(&bts, &sts);
@ -425,7 +423,7 @@ ibcs2_sys_ioctl(struct lwp *l, const struct ibcs2_sys_ioctl_args *uap, register_
}
/* get full BSD termios so we don't lose information */
if ((error = (*ctl)(fp, TIOCGETA, &bts, l)) != 0) {
if ((error = (*ctl)(fp, TIOCGETA, &bts)) != 0) {
DPRINTF(("ibcs2_ioctl(%d): TCSET ctl failed fd %d ",
p->p_pid, SCARG(uap, fd)));
goto out;
@ -440,7 +438,7 @@ ibcs2_sys_ioctl(struct lwp *l, const struct ibcs2_sys_ioctl_args *uap, register_
stios2btios(&sts, &bts);
t = SCARG(uap, cmd) - IBCS2_TCSETA + TIOCSETA;
error = (*ctl)(fp, t, &bts, l);
error = (*ctl)(fp, t, &bts);
break;
case IBCS2_XCSETA:
@ -451,7 +449,7 @@ ibcs2_sys_ioctl(struct lwp *l, const struct ibcs2_sys_ioctl_args *uap, register_
stios2btios(&sts, &bts);
t = SCARG(uap, cmd) - IBCS2_XCSETA + TIOCSETA;
error = (*ctl)(fp, t, &bts, l);
error = (*ctl)(fp, t, &bts);
break;
case IBCS2_OXCSETA:
@ -461,21 +459,21 @@ ibcs2_sys_ioctl(struct lwp *l, const struct ibcs2_sys_ioctl_args *uap, register_
goto out;
stios2btios(&sts, &bts);
t = SCARG(uap, cmd) - IBCS2_OXCSETA + TIOCSETA;
error = (*ctl)(fp, t, &bts, l);
error = (*ctl)(fp, t, &bts);
break;
case IBCS2_TCSBRK:
t = (int) SCARG(uap, data);
t = (t ? t : 1) * hz * 4;
t /= 10;
if ((error = (*ctl)(fp, TIOCSBRK, NULL, l)) != 0)
if ((error = (*ctl)(fp, TIOCSBRK, NULL)) != 0)
goto out;
error = tsleep(&t, PZERO | PCATCH, "ibcs2_tcsbrk", t);
if (error == EINTR || error == ERESTART) {
(void)(*ctl)(fp, TIOCCBRK, NULL, l);
(void)(*ctl)(fp, TIOCCBRK, NULL);
error = EINTR;
} else
error = (*ctl)(fp, TIOCCBRK, NULL, l);
error = (*ctl)(fp, TIOCCBRK, NULL);
break;
case IBCS2_TCXONC:
@ -486,10 +484,10 @@ ibcs2_sys_ioctl(struct lwp *l, const struct ibcs2_sys_ioctl_args *uap, register_
error = ENOSYS;
break;
case 2:
error = (*ctl)(fp, TIOCSTOP, NULL, l);
error = (*ctl)(fp, TIOCSTOP, NULL);
break;
case 3:
error = (*ctl)(fp, TIOCSTART, (void *)1, l);
error = (*ctl)(fp, TIOCSTART, (void *)1);
break;
default:
error = EINVAL;
@ -512,13 +510,13 @@ ibcs2_sys_ioctl(struct lwp *l, const struct ibcs2_sys_ioctl_args *uap, register_
error = EINVAL;
goto out;
}
error = (*ctl)(fp, TIOCFLUSH, &t, l);
error = (*ctl)(fp, TIOCFLUSH, &t);
break;
case IBCS2_FIONBIO:
if ((error = copyin(SCARG(uap, data), &t, sizeof(t))) != 0)
goto out;
error = (*ctl)(fp, FIONBIO, (void *)&t, l);
error = (*ctl)(fp, FIONBIO, (void *)&t);
break;
default:
@ -527,8 +525,8 @@ ibcs2_sys_ioctl(struct lwp *l, const struct ibcs2_sys_ioctl_args *uap, register_
error = ENOSYS;
break;
}
out:
FILE_UNUSE(fp, l);
out:
fd_putfile(SCARG(uap, fd));
return error;
}
@ -539,31 +537,27 @@ ibcs2_sys_gtty(struct lwp *l, const struct ibcs2_sys_gtty_args *uap, register_t
syscallarg(int) fd;
syscallarg(struct sgttyb *) tb;
} */
struct proc *p = l->l_proc;
struct filedesc *fdp = p->p_fd;
struct file *fp;
struct sgttyb tb;
struct ibcs2_sgttyb itb;
int error;
if ((fp = fd_getfile(fdp, SCARG(uap, fd))) == NULL) {
if ((fp = fd_getfile(SCARG(uap, fd))) == NULL) {
DPRINTF(("ibcs2_sys_gtty(%d): bad fd %d ", p->p_pid,
SCARG(uap, fd)));
return EBADF;
}
FILE_USE(fp);
if ((fp->f_flag & (FREAD|FWRITE)) == 0) {
DPRINTF(("ibcs2_sys_gtty(%d): bad fp flag ", p->p_pid));
error = EBADF;
goto out;
}
error = (*fp->f_ops->fo_ioctl)(fp, TIOCGETP, (void *)&tb, l);
error = (*fp->f_ops->fo_ioctl)(fp, TIOCGETP, (void *)&tb);
if (error)
goto out;
FILE_UNUSE(fp, l);
fd_putfile(SCARG(uap, fd));
itb.sg_ispeed = tb.sg_ispeed;
itb.sg_ospeed = tb.sg_ospeed;
@ -572,6 +566,6 @@ ibcs2_sys_gtty(struct lwp *l, const struct ibcs2_sys_gtty_args *uap, register_t
itb.sg_flags = tb.sg_flags & ~(IBCS2_GHUPCL|IBCS2_GXTABS);
return copyout((void *)&itb, SCARG(uap, tb), sizeof(itb));
out:
FILE_UNUSE(fp, l);
fd_putfile(SCARG(uap, fd));
return error;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: ibcs2_misc.c,v 1.98 2008/01/23 15:04:38 elad Exp $ */
/* $NetBSD: ibcs2_misc.c,v 1.99 2008/03/21 21:54:58 ad Exp $ */
/*
* Copyright (c) 1992, 1993
@ -95,7 +95,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ibcs2_misc.c,v 1.98 2008/01/23 15:04:38 elad Exp $");
__KERNEL_RCSID(0, "$NetBSD: ibcs2_misc.c,v 1.99 2008/03/21 21:54:58 ad Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -371,14 +371,13 @@ ibcs2_sys_getdents(struct lwp *l, const struct ibcs2_sys_getdents_args *uap, reg
syscallarg(char *) buf;
syscallarg(int) nbytes;
} */
struct proc *p = l->l_proc;
struct dirent *bdp;
struct vnode *vp;
char *inp, *tbuf; /* BSD-format */
int len, reclen; /* BSD-format */
char *outp; /* iBCS2-format */
int resid, ibcs2_reclen;/* iBCS2-format */
struct file *fp;
file_t *fp;
struct uio auio;
struct iovec aiov;
struct ibcs2_dirent idb;
@ -389,13 +388,13 @@ ibcs2_sys_getdents(struct lwp *l, const struct ibcs2_sys_getdents_args *uap, reg
int ncookies;
/* getvnode() will use the descriptor for us */
if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0)
if ((error = getvnode(SCARG(uap, fd), &fp)) != 0)
return (error);
if ((fp->f_flag & FREAD) == 0) {
error = EBADF;
goto out1;
}
vp = (struct vnode *)fp->f_data;
vp = fp->f_data;
if (vp->v_type != VDIR) {
error = EINVAL;
goto out1;
@ -486,7 +485,7 @@ out:
free(cookiebuf, M_TEMP);
free(tbuf, M_TEMP);
out1:
FILE_UNUSE(fp, l);
fd_putfile(SCARG(uap, fd));
return (error);
}
@ -498,14 +497,13 @@ ibcs2_sys_read(struct lwp *l, const struct ibcs2_sys_read_args *uap, register_t
syscallarg(char *) buf;
syscallarg(u_int) nbytes;
} */
struct proc *p = l->l_proc;
struct dirent *bdp;
struct vnode *vp;
char *inp, *tbuf; /* BSD-format */
int len, reclen; /* BSD-format */
char *outp; /* iBCS2-format */
int resid, ibcs2_reclen;/* iBCS2-format */
struct file *fp;
file_t *fp;
struct uio auio;
struct iovec aiov;
struct ibcs2_direct {
@ -520,7 +518,7 @@ ibcs2_sys_read(struct lwp *l, const struct ibcs2_sys_read_args *uap, register_t
int ncookies;
/* getvnode() will use the descriptor for us */
if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0) {
if ((error = getvnode(SCARG(uap, fd), &fp)) != 0) {
if (error == EINVAL)
return sys_read(l, (const void *)uap, retval);
else
@ -532,7 +530,7 @@ ibcs2_sys_read(struct lwp *l, const struct ibcs2_sys_read_args *uap, register_t
}
vp = fp->f_data;
if (vp->v_type != VDIR) {
FILE_UNUSE(fp, l);
fd_putfile(SCARG(uap, fd));
return sys_read(l, (const void *)uap, retval);
}
buflen = min(MAXBSIZE, max(DEV_BSIZE, (size_t)SCARG(uap, nbytes)));
@ -616,7 +614,7 @@ out:
free(cookiebuf, M_TEMP);
free(tbuf, M_TEMP);
out1:
FILE_UNUSE(fp, l);
fd_putfile(SCARG(uap, fd));
return (error);
}
@ -1195,15 +1193,14 @@ xenix_sys_rdchk(struct lwp *l, const struct xenix_sys_rdchk_args *uap, register_
/* {
syscallarg(int) fd;
} */
struct file *fp;
file_t *fp;
int nbytes;
int error;
if ((fp = fd_getfile(l->l_proc->p_fd, SCARG(uap, fd))) == NULL)
if ((fp = fd_getfile(SCARG(uap, fd))) == NULL)
return (EBADF);
FILE_USE(fp);
error = (*fp->f_ops->fo_ioctl)(fp, FIONREAD, &nbytes, l);
FILE_UNUSE(fp, l);
error = (*fp->f_ops->fo_ioctl)(fp, FIONREAD, &nbytes);
fd_putfile(SCARG(uap, fd));
if (error != 0)
return error;
@ -1437,5 +1434,5 @@ xenix_sys_locking(struct lwp *l, const struct xenix_sys_locking_args *uap, regis
fl.l_start = 0;
fl.l_whence = SEEK_CUR;
return do_fcntl_lock(l, SCARG(uap, fd), cmd, &fl);
return do_fcntl_lock(SCARG(uap, fd), cmd, &fl);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: ibcs2_stat.c,v 1.44 2007/12/20 23:02:50 dsl Exp $ */
/* $NetBSD: ibcs2_stat.c,v 1.45 2008/03/21 21:54:58 ad Exp $ */
/*
* Copyright (c) 1995, 1998 Scott Bartram
* All rights reserved.
@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ibcs2_stat.c,v 1.44 2007/12/20 23:02:50 dsl Exp $");
__KERNEL_RCSID(0, "$NetBSD: ibcs2_stat.c,v 1.45 2008/03/21 21:54:58 ad Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -163,14 +163,13 @@ ibcs2_sys_fstatfs(struct lwp *l, const struct ibcs2_sys_fstatfs_args *uap, regis
syscallarg(int) len;
syscallarg(int) fstype;
} */
struct proc *p = l->l_proc;
struct file *fp;
file_t *fp;
struct mount *mp;
struct statvfs *sp;
int error;
/* getvnode() will use the descriptor for us */
if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0)
if ((error = getvnode(SCARG(uap, fd), &fp)) != 0)
return (error);
mp = ((struct vnode *)fp->f_data)->v_mount;
sp = &mp->mnt_stat;
@ -179,7 +178,7 @@ ibcs2_sys_fstatfs(struct lwp *l, const struct ibcs2_sys_fstatfs_args *uap, regis
sp->f_flag = mp->mnt_flag & MNT_VISFLAGMASK;
error = cvt_statfs(sp, (void *)SCARG(uap, buf), SCARG(uap, len));
out:
FILE_UNUSE(fp, l);
fd_putfile(SCARG(uap, fd));
return (error);
}
@ -216,14 +215,13 @@ ibcs2_sys_fstatvfs(struct lwp *l, const struct ibcs2_sys_fstatvfs_args *uap, reg
syscallarg(int) fd;
syscallarg(struct ibcs2_statvfs *) buf;
} */
struct proc *p = l->l_proc;
struct file *fp;
file_t *fp;
struct mount *mp;
struct statvfs *sp;
int error;
/* getvnode() will use the descriptor for us */
if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0)
if ((error = getvnode(SCARG(uap, fd), &fp)) != 0)
return (error);
mp = ((struct vnode *)fp->f_data)->v_mount;
sp = &mp->mnt_stat;
@ -232,7 +230,7 @@ ibcs2_sys_fstatvfs(struct lwp *l, const struct ibcs2_sys_fstatvfs_args *uap, reg
sp->f_flag = mp->mnt_flag & MNT_VISFLAGMASK;
error = cvt_statvfs(sp, SCARG(uap, buf), sizeof(struct ibcs2_statvfs));
out:
FILE_UNUSE(fp, l);
fd_putfile(SCARG(uap, fd));
return (error);
}
@ -247,7 +245,7 @@ ibcs2_sys_stat(struct lwp *l, const struct ibcs2_sys_stat_args *uap, register_t
struct ibcs2_stat ibcs2_st;
int error;
error = do_sys_stat(l, SCARG(uap, path), FOLLOW, &sb);
error = do_sys_stat(SCARG(uap, path), FOLLOW, &sb);
if (error != 0)
return error;
@ -266,7 +264,7 @@ ibcs2_sys_lstat(struct lwp *l, const struct ibcs2_sys_lstat_args *uap, register_
struct ibcs2_stat ibcs2_st;
int error;
error = do_sys_stat(l, SCARG(uap, path), NOFOLLOW, &sb);
error = do_sys_stat(SCARG(uap, path), NOFOLLOW, &sb);
if (error != 0)
return error;
@ -286,7 +284,7 @@ ibcs2_sys_fstat(struct lwp *l, const struct ibcs2_sys_fstat_args *uap, register_
struct ibcs2_stat ibcs2_st;
int error;
error = do_sys_fstat(l, SCARG(uap, fd), &sb);
error = do_sys_fstat(SCARG(uap, fd), &sb);
if (error != 0)
return error;

View File

@ -1,7 +1,7 @@
/* $NetBSD: irix_dirent.c,v 1.21 2007/12/20 23:02:50 dsl Exp $ */
/* $NetBSD: irix_dirent.c,v 1.22 2008/03/21 21:54:58 ad Exp $ */
/*-
* Copyright (c) 1994, 2001 The NetBSD Foundation, Inc.
* Copyright (c) 1994, 2001, 2008 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: irix_dirent.c,v 1.21 2007/12/20 23:02:50 dsl Exp $");
__KERNEL_RCSID(0, "$NetBSD: irix_dirent.c,v 1.22 2008/03/21 21:54:58 ad Exp $");
#include <sys/types.h>
#include <sys/signal.h>
@ -79,7 +79,6 @@ irix_sys_ngetdents(struct lwp *l, const struct irix_sys_ngetdents_args *uap, reg
syscallarg(unsigned short) nbyte;
syscallarg(int *) eof;
} */
struct proc *p = l->l_proc;
struct dirent *bdp;
struct vnode *vp;
char *inp, *buf; /* BSD-format */
@ -93,10 +92,10 @@ irix_sys_ngetdents(struct lwp *l, const struct irix_sys_ngetdents_args *uap, reg
off_t off; /* true file offset */
int buflen, error, eofflag;
off_t *cookiebuf = NULL, *cookie;
int ncookies;
int ncookies, fd;
/* getvnode() will use the descriptor for us */
if ((error = getvnode(p->p_fd, SCARG(uap, fildes), &fp)) != 0)
fd = SCARG(uap, fildes);
if ((error = fd_getvnode(fd, &fp)) != 0)
return (error);
if ((fp->f_flag & FREAD) == 0) {
@ -193,7 +192,7 @@ out:
free(cookiebuf, M_TEMP);
free(buf, M_TEMP);
out1:
FILE_UNUSE(fp, l);
fd_putfile(fd);
if (SCARG(uap, eof) != NULL)
error = copyout(&eofflag, SCARG(uap, eof), sizeof(int));
return error;
@ -233,23 +232,22 @@ irix_sys_ngetdents64(struct lwp *l, const struct irix_sys_ngetdents64_args *uap,
syscallarg(int *) eof;
} */
struct dirent *bdp;
struct proc *p = l->l_proc;
struct vnode *vp;
char *inp, *buf; /* BSD-format */
int len, reclen; /* BSD-format */
char *outp; /* SVR4-format */
int resid, svr4_reclen; /* SVR4-format */
struct file *fp;
file_t *fp;
struct uio auio;
struct iovec aiov;
struct irix_dirent64 idb;
off_t off; /* true file offset */
int buflen, error, eofflag;
off_t *cookiebuf = NULL, *cookie;
int ncookies;
int ncookies, fd;
/* getvnode() will use the descriptor for us */
if ((error = getvnode(p->p_fd, SCARG(uap, fildes), &fp)) != 0)
fd = SCARG(uap, fildes);
if ((error = fd_getvnode(fd, &fp)) != 0)
return (error);
if ((fp->f_flag & FREAD) == 0) {
@ -257,7 +255,7 @@ irix_sys_ngetdents64(struct lwp *l, const struct irix_sys_ngetdents64_args *uap,
goto out1;
}
vp = (struct vnode *)fp->f_data;
vp = fp->f_data;
if (vp->v_type != VDIR) {
error = EINVAL;
goto out1;
@ -345,7 +343,7 @@ out:
free(cookiebuf, M_TEMP);
free(buf, M_TEMP);
out1:
FILE_UNUSE(fp, l);
fd_putfile(fd);
if (SCARG(uap, eof) != NULL)
error = copyout(&eofflag, SCARG(uap, eof), sizeof(int));
return error;

View File

@ -1,4 +1,4 @@
/* $NetBSD: irix_fcntl.c,v 1.23 2008/01/26 15:37:35 tsutsui Exp $ */
/* $NetBSD: irix_fcntl.c,v 1.24 2008/03/21 21:54:58 ad Exp $ */
/*-
* Copyright (c) 2001-2002 The NetBSD Foundation, Inc.
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: irix_fcntl.c,v 1.23 2008/01/26 15:37:35 tsutsui Exp $");
__KERNEL_RCSID(0, "$NetBSD: irix_fcntl.c,v 1.24 2008/03/21 21:54:58 ad Exp $");
#include <sys/types.h>
#include <sys/signal.h>
@ -236,19 +236,18 @@ irix_sys_fcntl(struct lwp *l, const struct irix_sys_fcntl_args *uap, register_t
static int
fd_truncate(struct lwp *l, int fd, int whence, off_t start, register_t *retval)
{
struct filedesc *fdp = l->l_proc->p_fd;
struct file *fp;
file_t *fp;
struct vnode *vp;
struct vattr vattr;
struct sys_ftruncate_args ft;
int error;
if ((fp = fd_getfile(fdp, fd)) == NULL)
if ((error = fd_getvnode(fd, &fp)) != 0)
return EBADF;
vp = (struct vnode *)fp->f_data;
if (fp->f_type != DTYPE_VNODE || vp->v_type == VFIFO) {
FILE_UNLOCK(fp);
vp = fp->f_data;
if (vp->v_type == VFIFO) {
fd_putfile(fd);
return ESPIPE;
}
@ -271,7 +270,7 @@ fd_truncate(struct lwp *l, int fd, int whence, off_t start, register_t *retval)
return EINVAL;
break;
}
FILE_UNLOCK(fp);
fd_putfile(fd);
SCARG(&ft, fd) = fd;
return sys_ftruncate(l, &ft, retval);
@ -286,10 +285,9 @@ irix_sys_open(struct lwp *l, const struct irix_sys_open_args *uap, register_t *r
syscallarg(mode_t) mode;
} */
extern const struct cdevsw irix_usema_cdevsw;
struct proc *p = l->l_proc;
int error;
int fd;
struct file *fp;
file_t *fp;
struct vnode *vp;
struct vnode *nvp;
@ -297,12 +295,10 @@ irix_sys_open(struct lwp *l, const struct irix_sys_open_args *uap, register_t *r
return error;
fd = (int)*retval;
if ((fp = fd_getfile(p->p_fd, fd)) == NULL)
if ((fp = fd_getfile(fd)) == NULL)
return EBADF;
FILE_USE(fp);
vp = (struct vnode *)fp->f_data;
vp = fp->f_data;
/*
* A special hook for the usemaclone driver: we need to clone
@ -318,10 +314,8 @@ irix_sys_open(struct lwp *l, const struct irix_sys_open_args *uap, register_t *r
if ((error = getnewvnode(VCHR, vp->v_mount,
irix_usema_vnodeop_p,
(struct vnode **)&fp->f_data)) != 0) {
(void) vn_close(vp, fp->f_flag, fp->f_cred, l);
FILE_UNUSE(fp, l);
ffree(fp);
fdremove(p->p_fd, fd);
(void) vn_close(vp, fp->f_flag, fp->f_cred);
fd_close(fd);
return error;
}
@ -337,7 +331,7 @@ irix_sys_open(struct lwp *l, const struct irix_sys_open_args *uap, register_t *r
nvp->v_data = (void *)vp;
vref(vp);
}
FILE_UNUSE(fp, l);
fd_putfile(fd);
return 0;
}

View File

@ -1,7 +1,7 @@
/* $NetBSD: irix_ioctl.c,v 1.18 2008/01/05 19:14:08 dsl Exp $ */
/* $NetBSD: irix_ioctl.c,v 1.19 2008/03/21 21:54:58 ad Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
* Copyright (c) 2002, 2008 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: irix_ioctl.c,v 1.18 2008/01/05 19:14:08 dsl Exp $");
__KERNEL_RCSID(0, "$NetBSD: irix_ioctl.c,v 1.19 2008/03/21 21:54:58 ad Exp $");
#include <sys/param.h>
#include <sys/proc.h>
@ -79,29 +79,27 @@ irix_sys_ioctl(struct lwp *l, const struct irix_sys_ioctl_args *uap, register_t
syscallarg(void *) data;
} */
extern const struct cdevsw irix_usema_cdevsw;
struct proc *p = l->l_proc;
u_long cmd;
void *data;
struct file *fp;
struct filedesc *fdp;
file_t *fp;
struct vnode *vp;
struct vattr vattr;
struct irix_ioctl_usrdata iiu;
int error, val;
int error, val, fd;
/*
* This duplicates 6 lines from svr4_sys_ioctl()
* It would be nice to merge it.
*/
fdp = p->p_fd;
fd = SCARG(uap, fd);
cmd = SCARG(uap, com);
data = SCARG(uap, data);
if ((fp = fd_getfile(fdp, SCARG(uap, fd))) == NULL)
if ((fp = fd_getfile(fd)) == NULL)
return EBADF;
if ((fp->f_flag & (FREAD | FWRITE)) == 0) {
FILE_UNLOCK(fp);
fd_putfile(fd);
return EBADF;
}
@ -120,11 +118,10 @@ irix_sys_ioctl(struct lwp *l, const struct irix_sys_ioctl_args *uap, register_t
*/
if ((cmd & IRIX_UIOC_MASK) == IRIX_UIOC) {
if (fp->f_type != DTYPE_VNODE) {
FILE_UNLOCK(fp);
fd_putfile(fd);
return ENOTTY;
}
FILE_USE(fp);
vp = (struct vnode*)fp->f_data;
vp = fp->f_data;
if (vp->v_type != VCHR ||
cdevsw_lookup(vp->v_rdev) != &irix_usema_cdevsw ||
minor(vp->v_rdev) != IRIX_USEMACLNDEV_MINOR) {
@ -135,27 +132,26 @@ irix_sys_ioctl(struct lwp *l, const struct irix_sys_ioctl_args *uap, register_t
iiu.iiu_data = data;
iiu.iiu_retval = retval;
error = (*fp->f_ops->fo_ioctl)(fp, cmd, &iiu, l);
error = (*fp->f_ops->fo_ioctl)(fp, cmd, &iiu);
out:
FILE_UNUSE(fp, l);
fd_putfile(fd);
return error;
}
switch (cmd) {
case IRIX_SIOCNREAD: /* number of bytes to read */
error = (*(fp->f_ops->fo_ioctl))(fp, FIONREAD,
SCARG(uap, data), l);
FILE_UNLOCK(fp);
SCARG(uap, data));
fd_putfile(fd);
return error;
case IRIX_MTIOCGETBLKSIZE: /* get tape block size in 512B units */
if (fp->f_type != DTYPE_VNODE) {
FILE_UNLOCK(fp);
fd_putfile(fd);
return ENOSYS;
}
FILE_USE(fp);
vp = (struct vnode*)fp->f_data;
vp = fp->f_data;
switch (vp->v_type) {
case VREG:
@ -179,11 +175,11 @@ out:
break;
}
FILE_UNUSE(fp, l);
fd_putfile(fd);
return error;
default: /* Fallback to the standard SVR4 ioctl's */
FILE_UNLOCK(fp);
fd_putfile(fd);
return svr4_sys_ioctl(l, (const void *)uap, retval);
}
}

View File

@ -1,7 +1,7 @@
/* $NetBSD: irix_mman.c,v 1.20 2008/01/25 14:32:12 ad Exp $ */
/* $NetBSD: irix_mman.c,v 1.21 2008/03/21 21:54:58 ad Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
* Copyright (c) 2002, 2008 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: irix_mman.c,v 1.20 2008/01/25 14:32:12 ad Exp $");
__KERNEL_RCSID(0, "$NetBSD: irix_mman.c,v 1.21 2008/03/21 21:54:58 ad Exp $");
#if defined(_KERNEL_OPT)
#include "opt_sysv.h"
@ -160,12 +160,11 @@ irix_mmap(struct lwp *l, void *addr, size_t len, int prot, int flags, int fd, of
* grow the file to fit the mapping, before mapping it.
*/
if (flags & IRIX_MAP_AUTOGROW) {
struct file *fp;
file_t *fp;
struct vnode *vp;
struct vattr vattr;
/* getvnode does FILE_USE */
if ((error = getvnode(p->p_fd, fd, &fp)) != 0)
if ((error = fd_getvnode(fd, &fp)) != 0)
return error;
if ((fp->f_flag & FWRITE) == 0) {
@ -173,8 +172,8 @@ irix_mmap(struct lwp *l, void *addr, size_t len, int prot, int flags, int fd, of
goto out;
}
vp = (struct vnode *)fp->f_data;
if (fp->f_type != DTYPE_VNODE || vp->v_type == VFIFO) {
vp = fp->f_data;
if (vp->v_type == VFIFO) {
error = ESPIPE;
goto out;
}
@ -198,7 +197,7 @@ irix_mmap(struct lwp *l, void *addr, size_t len, int prot, int flags, int fd, of
VOP_UNLOCK(vp, 0);
}
out:
FILE_UNUSE(fp, l);
fd_putfile(fd);
if (error)
return error;

View File

@ -1,7 +1,7 @@
/* $NetBSD: irix_stat.c,v 1.22 2007/12/20 23:02:51 dsl Exp $ */
/* $NetBSD: irix_stat.c,v 1.23 2008/03/21 21:54:58 ad Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
* Copyright (c) 2001, 2008 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: irix_stat.c,v 1.22 2007/12/20 23:02:51 dsl Exp $");
__KERNEL_RCSID(0, "$NetBSD: irix_stat.c,v 1.23 2008/03/21 21:54:58 ad Exp $");
#include <sys/errno.h>
#include <sys/types.h>
@ -160,7 +160,7 @@ irix_sys_xstat(struct lwp *l, const struct irix_sys_xstat_args *uap, register_t
struct stat st;
int error;
error = do_sys_stat(l, SCARG(uap, path), FOLLOW, &st);
error = do_sys_stat(SCARG(uap, path), FOLLOW, &st);
if (error != 0)
return error;
@ -178,7 +178,7 @@ irix_sys_lxstat(struct lwp *l, const struct irix_sys_lxstat_args *uap, register_
struct stat st;
int error;
error = do_sys_stat(l, SCARG(uap, path), NOFOLLOW, &st);
error = do_sys_stat(SCARG(uap, path), NOFOLLOW, &st);
if (error != 0)
return error;
return convert_irix_stat(&st, SCARG(uap, buf), SCARG(uap, version));
@ -195,7 +195,7 @@ irix_sys_fxstat(struct lwp *l, const struct irix_sys_fxstat_args *uap, register_
struct stat st;
int error;
error = do_sys_fstat(l, SCARG(uap, fd), &st);
error = do_sys_fstat(SCARG(uap, fd), &st);
if (error != 0)
return error;
return convert_irix_stat(&st, SCARG(uap, buf), SCARG(uap, version));

View File

@ -1,7 +1,7 @@
/* $NetBSD: irix_syssgi.c,v 1.46 2007/12/20 23:02:51 dsl Exp $ */
/* $NetBSD: irix_syssgi.c,v 1.47 2008/03/21 21:54:58 ad Exp $ */
/*-
* Copyright (c) 2001-2002 The NetBSD Foundation, Inc.
* Copyright (c) 2001, 2002, 2008 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: irix_syssgi.c,v 1.46 2007/12/20 23:02:51 dsl Exp $");
__KERNEL_RCSID(0, "$NetBSD: irix_syssgi.c,v 1.47 2008/03/21 21:54:58 ad Exp $");
#if defined(_KERNEL_OPT)
#include "opt_ddb.h"
@ -293,8 +293,7 @@ irix_syssgi_mapelf(int fd, Elf_Phdr *ph, int count, struct lwp *l, register_t *r
u_long size;
Elf_Addr uaddr;
Elf_Addr reloc_offset;
struct file *fp;
struct filedesc *fdp;
file_t *fp;
struct exec_vmcmd_set vcset;
struct exec_vmcmd *base_vcp = NULL;
struct vnode *vp;
@ -384,14 +383,12 @@ irix_syssgi_mapelf(int fd, Elf_Phdr *ph, int count, struct lwp *l, register_t *r
}
/* Find the file's vnode */
fdp = l->l_proc->p_fd;
fp = fd_getfile(fdp, fd);
fp = fd_getfile(fd);
if (fp == NULL) {
error = EBADF;
goto bad;
}
FILE_USE(fp);
vp = (struct vnode *)fp->f_data;
vp = fp->f_data;
error = vn_marktext(vp);
if (error)
@ -435,7 +432,7 @@ irix_syssgi_mapelf(int fd, Elf_Phdr *ph, int count, struct lwp *l, register_t *r
*retval = (register_t)kph->p_vaddr;
bad_unuse:
FILE_UNUSE(fp, l);
fd_putfile(fd);
bad:
free(kph, M_TEMP);
return error;

View File

@ -1,7 +1,7 @@
/* $NetBSD: linux_machdep.c,v 1.133 2007/12/20 23:02:52 dsl Exp $ */
/* $NetBSD: linux_machdep.c,v 1.134 2008/03/21 21:54:58 ad Exp $ */
/*-
* Copyright (c) 1995, 2000 The NetBSD Foundation, Inc.
* Copyright (c) 1995, 2000, 2008 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: linux_machdep.c,v 1.133 2007/12/20 23:02:52 dsl Exp $");
__KERNEL_RCSID(0, "$NetBSD: linux_machdep.c,v 1.134 2008/03/21 21:54:58 ad Exp $");
#if defined(_KERNEL_OPT)
#include "opt_vm86.h"
@ -861,30 +861,24 @@ linux_machdepioctl(struct lwp *l, const struct linux_sys_ioctl_args *uap, regist
struct linux_hd_geometry hdg;
struct linux_hd_big_geometry hdg_big;
struct biosdisk_info *bip;
struct filedesc *fdp;
struct file *fp;
file_t *fp;
int fd;
struct disklabel label, *labp;
struct partinfo partp;
int (*ioctlf)(struct file *, u_long, void *, struct lwp *);
int (*ioctlf)(struct file *, u_long, void *);
u_long start, biostotal, realtotal;
u_char heads, sectors;
u_int cylinders;
struct ioctl_pt pt;
struct proc *p = l->l_proc;
fd = SCARG(uap, fd);
SCARG(&bia, fd) = fd;
SCARG(&bia, data) = SCARG(uap, data);
com = SCARG(uap, com);
fdp = p->p_fd;
if ((fp = fd_getfile(fdp, fd)) == NULL)
if ((fp = fd_getfile(fd)) == NULL)
return (EBADF);
FILE_USE(fp);
switch (com) {
#if (NWSDISPLAY > 0)
case LINUX_KDGKBMODE:
@ -925,7 +919,7 @@ linux_machdepioctl(struct lwp *l, const struct linux_sys_ioctl_args *uap, regist
com = VT_OPENQRY;
break;
case LINUX_VT_GETMODE:
error = fp->f_ops->fo_ioctl(fp, VT_GETMODE, &lvt, l);
error = fp->f_ops->fo_ioctl(fp, VT_GETMODE, &lvt);
if (error != 0)
goto out;
lvt.relsig = native_to_linux_signo[lvt.relsig];
@ -940,7 +934,7 @@ linux_machdepioctl(struct lwp *l, const struct linux_sys_ioctl_args *uap, regist
lvt.relsig = linux_to_native_signo[lvt.relsig];
lvt.acqsig = linux_to_native_signo[lvt.acqsig];
lvt.frsig = linux_to_native_signo[lvt.frsig];
error = fp->f_ops->fo_ioctl(fp, VT_SETMODE, &lvt, l);
error = fp->f_ops->fo_ioctl(fp, VT_SETMODE, &lvt);
goto out;
case LINUX_VT_DISALLOCATE:
/* XXX should use WSDISPLAYIO_DELSCREEN */
@ -995,10 +989,10 @@ linux_machdepioctl(struct lwp *l, const struct linux_sys_ioctl_args *uap, regist
* the real geometry) if not found, by returning an
* error. See common/linux_hdio.c
*/
bip = fd2biosinfo(p, fp);
bip = fd2biosinfo(curproc, fp);
ioctlf = fp->f_ops->fo_ioctl;
error = ioctlf(fp, DIOCGDEFLABEL, (void *)&label, l);
error1 = ioctlf(fp, DIOCGPART, (void *)&partp, l);
error = ioctlf(fp, DIOCGDEFLABEL, (void *)&label);
error1 = ioctlf(fp, DIOCGPART, (void *)&partp);
if (error != 0 && error1 != 0) {
error = error1;
goto out;
@ -1048,7 +1042,7 @@ linux_machdepioctl(struct lwp *l, const struct linux_sys_ioctl_args *uap, regist
ioctlf = fp->f_ops->fo_ioctl;
pt.com = SCARG(uap, com);
pt.data = SCARG(uap, data);
error = ioctlf(fp, PTIOCLINUX, (void *)&pt, l);
error = ioctlf(fp, PTIOCLINUX, &pt);
if (error == EJUSTRETURN) {
retval[0] = (register_t)pt.data;
error = 0;
@ -1061,10 +1055,9 @@ linux_machdepioctl(struct lwp *l, const struct linux_sys_ioctl_args *uap, regist
goto out;
}
SCARG(&bia, com) = com;
/* XXX NJWLWP */
error = sys_ioctl(curlwp, &bia, retval);
out:
FILE_UNUSE(fp ,l);
fd_putfile(fd);
return error;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: linux_blkio.c,v 1.16 2007/12/20 23:02:53 dsl Exp $ */
/* $NetBSD: linux_blkio.c,v 1.17 2008/03/21 21:54:58 ad Exp $ */
/*
* Copyright (c) 2001 Wasabi Systems, Inc.
@ -36,7 +36,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: linux_blkio.c,v 1.16 2007/12/20 23:02:53 dsl Exp $");
__KERNEL_RCSID(0, "$NetBSD: linux_blkio.c,v 1.17 2008/03/21 21:54:58 ad Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -63,21 +63,17 @@ int
linux_ioctl_blkio(struct lwp *l, const struct linux_sys_ioctl_args *uap,
register_t *retval)
{
struct proc *p = l->l_proc;
u_long com;
long size;
int error;
struct filedesc *fdp;
struct file *fp;
int (*ioctlf)(struct file *, u_long, void *, struct lwp *);
file_t *fp;
int (*ioctlf)(file_t *, u_long, void *);
struct partinfo partp;
struct disklabel label;
fdp = p->p_fd;
if ((fp = fd_getfile(fdp, SCARG(uap, fd))) == NULL)
if ((fp = fd_getfile(SCARG(uap, fd))) == NULL)
return (EBADF);
FILE_USE(fp);
error = 0;
ioctlf = fp->f_ops->fo_ioctl;
com = SCARG(uap, com);
@ -89,9 +85,9 @@ linux_ioctl_blkio(struct lwp *l, const struct linux_sys_ioctl_args *uap,
* fails, it may be a disk without label; try to get
* the default label and compute the size from it.
*/
error = ioctlf(fp, DIOCGPART, (void *)&partp, l);
error = ioctlf(fp, DIOCGPART, &partp);
if (error != 0) {
error = ioctlf(fp, DIOCGDEFLABEL, (void *)&label, l);
error = ioctlf(fp, DIOCGDEFLABEL, &label);
if (error != 0)
break;
size = label.d_nsectors * label.d_ntracks *
@ -101,7 +97,7 @@ linux_ioctl_blkio(struct lwp *l, const struct linux_sys_ioctl_args *uap,
error = copyout(&size, SCARG(uap, data), sizeof size);
break;
case LINUX_BLKSECTGET:
error = ioctlf(fp, DIOCGDEFLABEL, (void *)&label, l);
error = ioctlf(fp, DIOCGDEFLABEL, &label);
if (error != 0)
break;
error = copyout(&label.d_secsize, SCARG(uap, data),
@ -122,7 +118,7 @@ linux_ioctl_blkio(struct lwp *l, const struct linux_sys_ioctl_args *uap,
error = ENOTTY;
}
FILE_UNUSE(fp, l);
fd_putfile(SCARG(uap, fd));
return error;
}

View File

@ -1,7 +1,7 @@
/* $NetBSD: linux_cdrom.c,v 1.25 2007/12/20 23:02:53 dsl Exp $ */
/* $NetBSD: linux_cdrom.c,v 1.26 2008/03/21 21:54:58 ad Exp $ */
/*
* Copyright (c) 1997 The NetBSD Foundation, Inc.
* Copyright (c) 1997, 2008 The NetBSD Foundation, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: linux_cdrom.c,v 1.25 2007/12/20 23:02:53 dsl Exp $");
__KERNEL_RCSID(0, "$NetBSD: linux_cdrom.c,v 1.26 2008/03/21 21:54:58 ad Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -102,9 +102,8 @@ linux_ioctl_cdrom(struct lwp *l, const struct linux_sys_ioctl_args *uap, registe
} */
int error, idata;
u_long com, ncom;
struct file *fp;
struct filedesc *fdp;
int (*ioctlf)(struct file *, u_long, void *, struct lwp *);
file_t *fp;
int (*ioctlf)(file_t *, u_long, void *);
union {
struct linux_cdrom_blk ll_blk;
@ -149,14 +148,10 @@ linux_ioctl_cdrom(struct lwp *l, const struct linux_sys_ioctl_args *uap, registe
#define t_vol u2->tt_vol
struct cd_toc_entry *entry;
struct proc *p = l->l_proc;
fdp = p->p_fd;
if ((fp = fd_getfile(fdp, SCARG(uap, fd))) == NULL)
if ((fp = fd_getfile(SCARG(uap, fd))) == NULL)
return (EBADF);
FILE_USE(fp);
com = SCARG(uap, com);
ioctlf = fp->f_ops->fo_ioctl;
retval[0] = error = 0;
@ -177,7 +172,7 @@ linux_ioctl_cdrom(struct lwp *l, const struct linux_sys_ioctl_args *uap, registe
t_msf.end_s = l_msf.cdmsf_sec1;
t_msf.end_f = l_msf.cdmsf_frame1;
error = ioctlf(fp, CDIOCPLAYMSF, (void *)&t_msf, l);
error = ioctlf(fp, CDIOCPLAYMSF, &t_msf);
break;
case LINUX_CDROMPLAYTRKIND:
@ -190,11 +185,11 @@ linux_ioctl_cdrom(struct lwp *l, const struct linux_sys_ioctl_args *uap, registe
t_track.end_track = l_ti.cdti_trk1;
t_track.end_index = l_ti.cdti_ind1;
error = ioctlf(fp, CDIOCPLAYTRACKS, (void *)&t_track, l);
error = ioctlf(fp, CDIOCPLAYTRACKS, &t_track);
break;
case LINUX_CDROMREADTOCHDR:
error = ioctlf(fp, CDIOREADTOCHEADER, (void *)&t_header, l);
error = ioctlf(fp, CDIOREADTOCHEADER, &t_header);
if (error)
break;
@ -215,7 +210,7 @@ linux_ioctl_cdrom(struct lwp *l, const struct linux_sys_ioctl_args *uap, registe
t_toc_entry.req.data_len = sizeof *entry;
t_toc_entry.req.data = NULL;
error = ioctlf(fp, CDIOREADTOCENTRIES_BUF, &t_toc_entry, l);
error = ioctlf(fp, CDIOREADTOCENTRIES_BUF, &t_toc_entry);
if (error)
break;
@ -242,11 +237,11 @@ linux_ioctl_cdrom(struct lwp *l, const struct linux_sys_ioctl_args *uap, registe
t_vol.vol[2] = l_volctrl.channel2;
t_vol.vol[3] = l_volctrl.channel3;
error = ioctlf(fp, CDIOCSETVOL, (void *)&t_vol, l);
error = ioctlf(fp, CDIOCSETVOL, &t_vol);
break;
case LINUX_CDROMVOLREAD:
error = ioctlf(fp, CDIOCGETVOL, (void *)&t_vol, l);
error = ioctlf(fp, CDIOCGETVOL, &t_vol);
if (error)
break;
@ -271,7 +266,7 @@ linux_ioctl_cdrom(struct lwp *l, const struct linux_sys_ioctl_args *uap, registe
DPRINTF(("linux_ioctl: CDROMSUBCHNL %d %d\n",
l_subchnl.cdsc_format, l_subchnl.cdsc_trk));
error = ioctlf(fp, CDIOCREADSUBCHANNEL_BUF, &t_subchannel, l);
error = ioctlf(fp, CDIOCREADSUBCHANNEL_BUF, &t_subchannel);
if (error)
break;
@ -313,7 +308,7 @@ linux_ioctl_cdrom(struct lwp *l, const struct linux_sys_ioctl_args *uap, registe
t_blocks.blk = l_blk.from;
t_blocks.len = l_blk.len;
error = ioctlf(fp, CDIOCPLAYBLOCKS, (void *)&t_blocks, l);
error = ioctlf(fp, CDIOCPLAYBLOCKS, &t_blocks);
break;
case LINUX_CDROMEJECT_SW:
@ -325,31 +320,31 @@ linux_ioctl_cdrom(struct lwp *l, const struct linux_sys_ioctl_args *uap, registe
ncom = CDIOCALLOW;
else
ncom = CDIOCPREVENT;
error = ioctlf(fp, ncom, NULL, l);
error = ioctlf(fp, ncom, NULL);
break;
case LINUX_CDROMPAUSE:
error = ioctlf(fp, CDIOCPAUSE, NULL, l);
error = ioctlf(fp, CDIOCPAUSE, NULL);
break;
case LINUX_CDROMRESUME:
error = ioctlf(fp, CDIOCRESUME, NULL, l);
error = ioctlf(fp, CDIOCRESUME, NULL);
break;
case LINUX_CDROMSTOP:
error = ioctlf(fp, CDIOCSTOP, NULL, l);
error = ioctlf(fp, CDIOCSTOP, NULL);
break;
case LINUX_CDROMSTART:
error = ioctlf(fp, CDIOCSTART, NULL, l);
error = ioctlf(fp, CDIOCSTART, NULL);
break;
case LINUX_CDROMEJECT:
error = ioctlf(fp, CDIOCEJECT, NULL, l);
error = ioctlf(fp, CDIOCEJECT, NULL);
break;
case LINUX_CDROMRESET:
error = ioctlf(fp, CDIOCRESET, NULL, l);
error = ioctlf(fp, CDIOCRESET, NULL);
break;
case LINUX_CDROMMULTISESSION:
@ -357,7 +352,7 @@ linux_ioctl_cdrom(struct lwp *l, const struct linux_sys_ioctl_args *uap, registe
if (error)
break;
error = ioctlf(fp, CDIOREADTOCHEADER, (void *)&t_header, l);
error = ioctlf(fp, CDIOREADTOCHEADER, &t_header);
if (error)
break;
@ -366,7 +361,7 @@ linux_ioctl_cdrom(struct lwp *l, const struct linux_sys_ioctl_args *uap, registe
t_toc_entry.req.data_len = sizeof t_toc_entry.entry;
t_toc_entry.req.data = NULL;
error = ioctlf(fp, CDIOREADTOCENTRIES_BUF, &t_toc_entry, l);
error = ioctlf(fp, CDIOREADTOCENTRIES_BUF, &t_toc_entry);
if (error)
break;
@ -383,12 +378,12 @@ linux_ioctl_cdrom(struct lwp *l, const struct linux_sys_ioctl_args *uap, registe
break;
case LINUX_CDROMCLOSETRAY:
error = ioctlf(fp, CDIOCCLOSE, NULL, l);
error = ioctlf(fp, CDIOCCLOSE, NULL);
break;
case LINUX_CDROM_LOCKDOOR:
ncom = SCARG(uap, data) != 0 ? CDIOCPREVENT : CDIOCALLOW;
error = ioctlf(fp, ncom, NULL, l);
error = ioctlf(fp, ncom, NULL);
break;
case LINUX_CDROM_SET_OPTIONS:
@ -398,7 +393,7 @@ linux_ioctl_cdrom(struct lwp *l, const struct linux_sys_ioctl_args *uap, registe
case LINUX_CDROM_DEBUG:
ncom = SCARG(uap, data) != 0 ? CDIOCSETDEBUG : CDIOCCLRDEBUG;
error = ioctlf(fp, ncom, NULL, l);
error = ioctlf(fp, ncom, NULL);
break;
case LINUX_CDROM_SELECT_SPEED:
@ -415,7 +410,7 @@ linux_ioctl_cdrom(struct lwp *l, const struct linux_sys_ioctl_args *uap, registe
error = copyin(SCARG(uap, data), &ds, sizeof ds);
if (error)
break;
error = ioctlf(fp, DVD_READ_STRUCT, (void *)&ds, l);
error = ioctlf(fp, DVD_READ_STRUCT, &ds);
if (error)
break;
error = copyout(&ds, SCARG(uap, data), sizeof ds);
@ -425,7 +420,7 @@ linux_ioctl_cdrom(struct lwp *l, const struct linux_sys_ioctl_args *uap, registe
error = copyin(SCARG(uap, data), &ds, sizeof ds);
if (error)
break;
error = ioctlf(fp, DVD_WRITE_STRUCT, (void *)&ds, l);
error = ioctlf(fp, DVD_WRITE_STRUCT, &ds);
if (error)
break;
error = copyout(&ds, SCARG(uap, data), sizeof ds);
@ -435,7 +430,7 @@ linux_ioctl_cdrom(struct lwp *l, const struct linux_sys_ioctl_args *uap, registe
error = copyin(SCARG(uap, data), &dai, sizeof dai);
if (error)
break;
error = ioctlf(fp, DVD_AUTH, (void *)&dai, l);
error = ioctlf(fp, DVD_AUTH, &dai);
if (error)
break;
error = copyout(&dai, SCARG(uap, data), sizeof dai);
@ -447,7 +442,7 @@ linux_ioctl_cdrom(struct lwp *l, const struct linux_sys_ioctl_args *uap, registe
error = EINVAL;
}
FILE_UNUSE(fp, l);
fd_putfile(SCARG(uap, fd));
free(u1, M_TEMP);
free(u2, M_TEMP);
return error;

View File

@ -1,4 +1,4 @@
/* $NetBSD: linux_fcntl.h,v 1.12 2008/02/02 21:54:01 dsl Exp $ */
/* $NetBSD: linux_fcntl.h,v 1.13 2008/03/21 21:54:58 ad Exp $ */
/*-
* Copyright (c) 1995, 1998 The NetBSD Foundation, Inc.
@ -133,7 +133,7 @@ LINUX##_to_bsd_##FLOCK(struct flock *bfp, const struct LINUX##_##FLOCK *lfp) \
if ((fl_error = copyin(arg, &lfl, sizeof lfl))) \
return fl_error; \
LINUX##_to_bsd_##FLOCK(&bfl, &lfl); \
fl_error = do_fcntl_lock(l, fd, F_GETLK, &bfl); \
fl_error = do_fcntl_lock(fd, F_GETLK, &bfl); \
if (fl_error) \
return fl_error; \
bsd_to_##LINUX##_##FLOCK(&lfl, &bfl); \
@ -147,7 +147,7 @@ LINUX##_to_bsd_##FLOCK(struct flock *bfp, const struct LINUX##_##FLOCK *lfp) \
if ((fl_error = copyin(arg, &lfl, sizeof lfl))) \
return fl_error; \
LINUX##_to_bsd_##FLOCK(&bfl, &lfl); \
return do_fcntl_lock(l, fd, cmd == setlk ? F_SETLK : F_SETLKW, &bfl); \
return do_fcntl_lock(fd, cmd == setlk ? F_SETLK : F_SETLKW, &bfl); \
} while (0)

View File

@ -1,4 +1,4 @@
/* $NetBSD: linux_fdio.c,v 1.12 2007/12/20 23:02:54 dsl Exp $ */
/* $NetBSD: linux_fdio.c,v 1.13 2008/03/21 21:54:58 ad Exp $ */
/*
* Copyright (c) 2000 Wasabi Systems, Inc.
@ -36,7 +36,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: linux_fdio.c,v 1.12 2007/12/20 23:02:54 dsl Exp $");
__KERNEL_RCSID(0, "$NetBSD: linux_fdio.c,v 1.13 2008/03/21 21:54:58 ad Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -67,10 +67,9 @@ int
linux_ioctl_fdio(struct lwp *l, const struct linux_sys_ioctl_args *uap,
register_t *retval)
{
struct filedesc *fdp;
struct file *fp;
file_t *fp;
int error;
int (*ioctlf)(struct file *, u_long, void *, struct lwp *);
int (*ioctlf)(file_t *, u_long, void *);
u_long com;
struct fdformat_parms fparams;
struct linux_floppy_struct lflop;
@ -78,12 +77,9 @@ linux_ioctl_fdio(struct lwp *l, const struct linux_sys_ioctl_args *uap,
com = (u_long)SCARG(uap, data);
fdp = l->l_proc->p_fd;
if ((fp = fd_getfile(fdp, SCARG(uap, fd))) == NULL)
if ((fp = fd_getfile(SCARG(uap, fd))) == NULL)
return (EBADF);
FILE_USE(fp);
com = SCARG(uap, com);
ioctlf = fp->f_ops->fo_ioctl;
@ -108,7 +104,7 @@ linux_ioctl_fdio(struct lwp *l, const struct linux_sys_ioctl_args *uap,
error = copyout(&ldrive, SCARG(uap, data), sizeof ldrive);
break;
case LINUX_FDGETPRM:
error = ioctlf(fp, FDIOCGETFORMAT, (void *)&fparams, l);
error = ioctlf(fp, FDIOCGETFORMAT, &fparams);
if (error != 0)
break;
lflop.size = fparams.ncyl * fparams.nspt * fparams.ntrk;
@ -169,7 +165,7 @@ linux_ioctl_fdio(struct lwp *l, const struct linux_sys_ioctl_args *uap,
error = EINVAL;
}
FILE_UNUSE(fp, l);
fd_putfile(SCARG(uap, fd));
return 0;
}

View File

@ -1,7 +1,7 @@
/* $NetBSD: linux_file.c,v 1.92 2008/02/02 21:54:01 dsl Exp $ */
/* $NetBSD: linux_file.c,v 1.93 2008/03/21 21:54:58 ad Exp $ */
/*-
* Copyright (c) 1995, 1998 The NetBSD Foundation, Inc.
* Copyright (c) 1995, 1998, 2008 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@ -42,7 +42,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: linux_file.c,v 1.92 2008/02/02 21:54:01 dsl Exp $");
__KERNEL_RCSID(0, "$NetBSD: linux_file.c,v 1.93 2008/03/21 21:54:58 ad Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -191,19 +191,16 @@ linux_sys_open(struct lwp *l, const struct linux_sys_open_args *uap, register_t
* this the controlling terminal.
*/
if (!(fl & O_NOCTTY) && SESS_LEADER(p) && !(p->p_lflag & PL_CONTROLT)) {
struct filedesc *fdp = p->p_fd;
struct file *fp;
file_t *fp;
fp = fd_getfile(fdp, *retval);
fp = fd_getfile(*retval);
/* ignore any error, just give it a try */
if (fp != NULL) {
FILE_USE(fp);
if (fp->f_type == DTYPE_VNODE) {
(fp->f_ops->fo_ioctl) (fp, TIOCSCTTY,
(void *) 0, l);
(fp->f_ops->fo_ioctl) (fp, TIOCSCTTY, NULL);
}
FILE_UNUSE(fp, l);
fd_putfile(*retval);
}
}
return 0;
@ -228,8 +225,7 @@ linux_sys_fcntl(struct lwp *l, const struct linux_sys_fcntl_args *uap, register_
u_long val;
void *arg;
struct sys_fcntl_args fca;
struct filedesc *fdp;
struct file *fp;
file_t *fp;
struct vnode *vp;
struct vattr va;
const struct cdevsw *cdev;
@ -265,7 +261,7 @@ linux_sys_fcntl(struct lwp *l, const struct linux_sys_fcntl_args *uap, register_
return 0;
case LINUX_F_SETFL: {
struct file *fp1 = NULL;
file_t *fp1 = NULL;
val = linux_to_bsd_ioflags((unsigned long)SCARG(uap, arg));
/*
@ -285,18 +281,15 @@ linux_sys_fcntl(struct lwp *l, const struct linux_sys_fcntl_args *uap, register_
* so that F_GETFL would report the ASYNC i/o is on.
*/
if (val & O_ASYNC) {
if (((fp1 = fd_getfile(p->p_fd, fd)) == NULL))
if (((fp1 = fd_getfile(fd)) == NULL))
return (EBADF);
FILE_USE(fp1);
if (((fp1->f_type == DTYPE_SOCKET) && fp1->f_data
&& ((struct socket *)fp1->f_data)->so_state & SS_ISAPIPE)
|| (fp1->f_type == DTYPE_PIPE))
val &= ~O_ASYNC;
else {
/* not a pipe, do not modify anything */
FILE_UNUSE(fp1, l);
fd_putfile(fd);
fp1 = NULL;
}
}
@ -309,9 +302,12 @@ linux_sys_fcntl(struct lwp *l, const struct linux_sys_fcntl_args *uap, register_
/* Now set the FASYNC flag for pipes */
if (fp1) {
if (!error)
if (!error) {
mutex_enter(&fp1->f_lock);
fp1->f_flag |= FASYNC;
FILE_UNUSE(fp1, l);
mutex_exit(&fp1->f_lock);
}
fd_putfile(fd);
}
return (error);
@ -332,16 +328,14 @@ linux_sys_fcntl(struct lwp *l, const struct linux_sys_fcntl_args *uap, register_
* restrictive for Linux F_{G,S}ETOWN. For non-tty descriptors,
* this is not a problem.
*/
fdp = p->p_fd;
if ((fp = fd_getfile(fdp, fd)) == NULL)
if ((fp = fd_getfile(fd)) == NULL)
return EBADF;
FILE_USE(fp);
/* Check it's a character device vnode */
if (fp->f_type != DTYPE_VNODE
|| (vp = (struct vnode *)fp->f_data) == NULL
|| vp->v_type != VCHR) {
FILE_UNUSE(fp, l);
fd_putfile(fd);
not_tty:
/* Not a tty, proceed with common fcntl() */
@ -351,7 +345,7 @@ linux_sys_fcntl(struct lwp *l, const struct linux_sys_fcntl_args *uap, register_
error = VOP_GETATTR(vp, &va, l->l_cred);
FILE_UNUSE(fp, l);
fd_putfile(fd);
if (error)
return error;
@ -448,7 +442,7 @@ linux_sys_fstat(struct lwp *l, const struct linux_sys_fstat_args *uap, register_
struct stat tmpst;
int error;
error = do_sys_fstat(l, SCARG(uap, fd), &tmpst);
error = do_sys_fstat(SCARG(uap, fd), &tmpst);
if (error != 0)
return error;
bsd_to_linux_stat(&tmpst, &tmplst);
@ -457,13 +451,13 @@ linux_sys_fstat(struct lwp *l, const struct linux_sys_fstat_args *uap, register_
}
static int
linux_stat1(struct lwp *l, const struct linux_sys_stat_args *uap, register_t *retval, int flags)
linux_stat1(const struct linux_sys_stat_args *uap, register_t *retval, int flags)
{
struct linux_stat tmplst;
struct stat tmpst;
int error;
error = do_sys_stat(l, SCARG(uap, path), flags, &tmpst);
error = do_sys_stat(SCARG(uap, path), flags, &tmpst);
if (error != 0)
return error;
@ -480,7 +474,7 @@ linux_sys_stat(struct lwp *l, const struct linux_sys_stat_args *uap, register_t
syscallarg(struct linux_stat *) sp;
} */
return linux_stat1(l, uap, retval, FOLLOW);
return linux_stat1(uap, retval, FOLLOW);
}
/* Note: this is "newlstat" in the Linux sources */
@ -493,7 +487,7 @@ linux_sys_lstat(struct lwp *l, const struct linux_sys_lstat_args *uap, register_
syscallarg(struct linux_stat *) sp;
} */
return linux_stat1(l, (const void *)uap, retval, NOFOLLOW);
return linux_stat1((const void *)uap, retval, NOFOLLOW);
}
#endif /* !__amd64__ */
@ -524,7 +518,7 @@ linux_sys_unlink(struct lwp *l, const struct linux_sys_unlink_args *uap, registe
if (namei(&nd) == 0) {
struct stat sb;
if (vn_stat(nd.ni_vp, &sb, l) == 0
if (vn_stat(nd.ni_vp, &sb) == 0
&& S_ISDIR(sb.st_mode))
error = EISDIR;

View File

@ -1,7 +1,7 @@
/* $NetBSD: linux_file64.c,v 1.45 2008/02/02 19:37:53 dsl Exp $ */
/* $NetBSD: linux_file64.c,v 1.46 2008/03/21 21:54:58 ad Exp $ */
/*-
* Copyright (c) 1995, 1998, 2000 The NetBSD Foundation, Inc.
* Copyright (c) 1995, 1998, 2000, 2008 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@ -41,7 +41,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: linux_file64.c,v 1.45 2008/02/02 19:37:53 dsl Exp $");
__KERNEL_RCSID(0, "$NetBSD: linux_file64.c,v 1.46 2008/03/21 21:54:58 ad Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -130,7 +130,7 @@ linux_sys_fstat64(struct lwp *l, const struct linux_sys_fstat64_args *uap, regis
struct stat tmpst;
int error;
error = do_sys_fstat(l, SCARG(uap, fd), &tmpst);
error = do_sys_fstat(SCARG(uap, fd), &tmpst);
if (error != 0)
return error;
@ -146,7 +146,7 @@ linux_do_stat64(struct lwp *l, const struct linux_sys_stat64_args *uap, register
struct stat tmpst;
int error;
error = do_sys_stat(l, SCARG(uap, path), flags, &tmpst);
error = do_sys_stat(SCARG(uap, path), flags, &tmpst);
if (error != 0)
return error;
@ -240,7 +240,7 @@ linux_sys_getdents64(struct lwp *l, const struct linux_sys_getdents64_args *uap,
int len, reclen; /* BSD-format */
char *outp; /* Linux-format */
int resid, linux_reclen = 0; /* Linux-format */
struct file *fp;
file_t *fp;
struct uio auio;
struct iovec aiov;
struct linux_dirent64 idb;
@ -251,7 +251,7 @@ linux_sys_getdents64(struct lwp *l, const struct linux_sys_getdents64_args *uap,
int ncookies;
/* getvnode() will use the descriptor for us */
if ((error = getvnode(l->l_proc->p_fd, SCARG(uap, fd), &fp)) != 0)
if ((error = getvnode(SCARG(uap, fd), &fp)) != 0)
return (error);
if ((fp->f_flag & FREAD) == 0) {
@ -355,6 +355,6 @@ out:
free(cookiebuf, M_TEMP);
free(tbuf, M_TEMP);
out1:
FILE_UNUSE(fp, l);
fd_putfile(SCARG(uap, fd));
return error;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: linux_hdio.c,v 1.15 2007/12/20 23:02:54 dsl Exp $ */
/* $NetBSD: linux_hdio.c,v 1.16 2008/03/21 21:54:58 ad Exp $ */
/*
* Copyright (c) 2000 Wasabi Systems, Inc.
@ -36,7 +36,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: linux_hdio.c,v 1.15 2007/12/20 23:02:54 dsl Exp $");
__KERNEL_RCSID(0, "$NetBSD: linux_hdio.c,v 1.16 2008/03/21 21:54:58 ad Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -67,24 +67,19 @@ int
linux_ioctl_hdio(struct lwp *l, const struct linux_sys_ioctl_args *uap,
register_t *retval)
{
struct proc *p = l->l_proc;
u_long com;
int error, error1;
struct filedesc *fdp;
struct file *fp;
int (*ioctlf)(struct file *, u_long, void *, struct lwp *);
int (*ioctlf)(struct file *, u_long, void *);
struct atareq req;
struct disklabel label, *labp;
struct partinfo partp;
struct linux_hd_geometry hdg;
struct linux_hd_big_geometry hdg_big;
fdp = p->p_fd;
if ((fp = fd_getfile(fdp, SCARG(uap, fd))) == NULL)
if ((fp = fd_getfile(SCARG(uap, fd))) == NULL)
return (EBADF);
FILE_USE(fp);
com = SCARG(uap, com);
ioctlf = fp->f_ops->fo_ioctl;
retval[0] = error = 0;
@ -102,7 +97,7 @@ linux_ioctl_hdio(struct lwp *l, const struct linux_sys_ioctl_args *uap,
*/
req.datalen = com == LINUX_HDIO_GET_IDENTITY ? 512 : 142;
req.timeout = 1000;
error = ioctlf(fp, ATAIOCCOMMAND, &req, l);
error = ioctlf(fp, ATAIOCCOMMAND, &req);
if (error != 0)
break;
if (req.retsts != ATACMD_OK)
@ -112,8 +107,8 @@ linux_ioctl_hdio(struct lwp *l, const struct linux_sys_ioctl_args *uap,
error = linux_machdepioctl(l, uap, retval);
if (error == 0)
break;
error = ioctlf(fp, DIOCGDEFLABEL, (void *)&label, l);
error1 = ioctlf(fp, DIOCGPART, (void *)&partp, l);
error = ioctlf(fp, DIOCGDEFLABEL, &label);
error1 = ioctlf(fp, DIOCGPART, &partp);
if (error != 0 && error1 != 0) {
error = error1;
break;
@ -130,8 +125,8 @@ linux_ioctl_hdio(struct lwp *l, const struct linux_sys_ioctl_args *uap,
if (error == 0)
break;
case LINUX_HDIO_GETGEO_BIG_RAW:
error = ioctlf(fp, DIOCGDEFLABEL, (void *)&label, l);
error1 = ioctlf(fp, DIOCGPART, (void *)&partp, l);
error = ioctlf(fp, DIOCGDEFLABEL, &label);
error1 = ioctlf(fp, DIOCGPART, &partp);
if (error != 0 && error1 != 0) {
error = error1;
break;
@ -167,7 +162,7 @@ linux_ioctl_hdio(struct lwp *l, const struct linux_sys_ioctl_args *uap,
error = EINVAL;
}
FILE_UNUSE(fp, l);
fd_putfile(SCARG(uap, fd));
return error;
}

View File

@ -1,7 +1,7 @@
/* $NetBSD: linux_ioctl.c,v 1.52 2007/12/20 23:02:54 dsl Exp $ */
/* $NetBSD: linux_ioctl.c,v 1.53 2008/03/21 21:54:58 ad Exp $ */
/*-
* Copyright (c) 1995, 1998 The NetBSD Foundation, Inc.
* Copyright (c) 1995, 1998, 2008 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: linux_ioctl.c,v 1.52 2007/12/20 23:02:54 dsl Exp $");
__KERNEL_RCSID(0, "$NetBSD: linux_ioctl.c,v 1.53 2008/03/21 21:54:58 ad Exp $");
#if defined(_KERNEL_OPT)
#include "sequencer.h"
@ -119,15 +119,12 @@ linux_sys_ioctl(struct lwp *l, const struct linux_sys_ioctl_args *uap, register_
* device number and check if that is the sequencer entry.
*/
struct file *fp;
struct filedesc *fdp;
struct vnode *vp;
struct vattr va;
extern const struct cdevsw sequencer_cdevsw;
fdp = l->l_proc->p_fd;
if ((fp = fd_getfile(fdp, SCARG(uap, fd))) == NULL)
if ((fp = fd_getfile(SCARG(uap, fd))) == NULL)
return EBADF;
FILE_USE(fp);
if (fp->f_type == DTYPE_VNODE &&
(vp = (struct vnode *)fp->f_data) != NULL &&
vp->v_type == VCHR &&
@ -139,7 +136,7 @@ linux_sys_ioctl(struct lwp *l, const struct linux_sys_ioctl_args *uap, register_
else {
error = linux_ioctl_termios(l, uap, retval);
}
FILE_UNUSE(fp, l);
fd_putfile(SCARG(uap, fd));
#else
error = linux_ioctl_termios(l, uap, retval);
#endif

View File

@ -1,7 +1,7 @@
/* $NetBSD: linux_misc.c,v 1.193 2008/01/15 22:38:34 njoly Exp $ */
/* $NetBSD: linux_misc.c,v 1.194 2008/03/21 21:54:58 ad Exp $ */
/*-
* Copyright (c) 1995, 1998, 1999 The NetBSD Foundation, Inc.
* Copyright (c) 1995, 1998, 1999, 2008 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@ -64,7 +64,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: linux_misc.c,v 1.193 2008/01/15 22:38:34 njoly Exp $");
__KERNEL_RCSID(0, "$NetBSD: linux_misc.c,v 1.194 2008/03/21 21:54:58 ad Exp $");
#if defined(_KERNEL_OPT)
#include "opt_ptrace.h"
@ -713,7 +713,7 @@ linux_sys_getdents(struct lwp *l, const struct linux_sys_getdents_args *uap, reg
int ncookies;
/* getvnode() will use the descriptor for us */
if ((error = getvnode(l->l_proc->p_fd, SCARG(uap, fd), &fp)) != 0)
if ((error = getvnode(SCARG(uap, fd), &fp)) != 0)
return (error);
if ((fp->f_flag & FREAD) == 0) {
@ -841,7 +841,7 @@ out:
free(cookiebuf, M_TEMP);
free(tbuf, M_TEMP);
out1:
FILE_UNUSE(fp, l);
fd_putfile(SCARG(uap, fd));
return error;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: linux_mtio.c,v 1.6 2007/12/20 23:02:55 dsl Exp $ */
/* $NetBSD: linux_mtio.c,v 1.7 2008/03/21 21:54:58 ad Exp $ */
/*
* Copyright (c) 2005 Soren S. Jorvang. All rights reserved.
@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: linux_mtio.c,v 1.6 2007/12/20 23:02:55 dsl Exp $");
__KERNEL_RCSID(0, "$NetBSD: linux_mtio.c,v 1.7 2008/03/21 21:54:58 ad Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -74,20 +74,17 @@ int
linux_ioctl_mtio(struct lwp *l, const struct linux_sys_ioctl_args *uap,
register_t *retval)
{
struct file *fp;
struct filedesc *fdp;
file_t *fp;
u_long com = SCARG(uap, com);
int i, error = 0;
int (*ioctlf)(struct file *, u_long, void *, struct lwp *);
int (*ioctlf)(file_t *, u_long, void *);
struct linux_mtop lmtop;
struct linux_mtget lmtget;
struct mtop mt;
fdp = l->l_proc->p_fd;
if ((fp = fd_getfile(fdp, SCARG(uap, fd))) == NULL)
if ((fp = fd_getfile(SCARG(uap, fd))) == NULL)
return EBADF;
FILE_USE(fp);
ioctlf = fp->f_ops->fo_ioctl;
*retval = 0;
@ -106,7 +103,7 @@ linux_ioctl_mtio(struct lwp *l, const struct linux_sys_ioctl_args *uap,
mt.mt_op = mtop_map[i].op;
mt.mt_count = lmtop.mt_count;
error = ioctlf(fp, MTIOCTOP, (void *)&mt, l);
error = ioctlf(fp, MTIOCTOP, &mt);
break;
case LINUX_MTIOCGET:
lmtget.mt_type = LINUX_MT_ISUNKNOWN;
@ -125,7 +122,7 @@ linux_ioctl_mtio(struct lwp *l, const struct linux_sys_ioctl_args *uap,
break;
}
FILE_UNUSE(fp, l);
fd_putfile(SCARG(uap, fd));
return error;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: linux_sg.c,v 1.12 2007/12/20 23:02:56 dsl Exp $ */
/* $NetBSD: linux_sg.c,v 1.13 2008/03/21 21:54:58 ad Exp $ */
/*
* Copyright (c) 2004 Soren S. Jorvang. All rights reserved.
@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: linux_sg.c,v 1.12 2007/12/20 23:02:56 dsl Exp $");
__KERNEL_RCSID(0, "$NetBSD: linux_sg.c,v 1.13 2008/03/21 21:54:58 ad Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -72,19 +72,16 @@ int
linux_ioctl_sg(struct lwp *l, const struct linux_sys_ioctl_args *uap,
register_t *retval)
{
struct file *fp;
struct filedesc *fdp;
file_t *fp;
u_long com = SCARG(uap, com);
int error = 0;
int (*ioctlf)(struct file *, u_long, void *, struct lwp *);
int (*ioctlf)(file_t *, u_long, void *);
struct linux_sg_io_hdr lreq;
struct scsireq req;
fdp = l->l_proc->p_fd;
if ((fp = fd_getfile(fdp, SCARG(uap, fd))) == NULL)
if ((fp = fd_getfile(SCARG(uap, fd))) == NULL)
return EBADF;
FILE_USE(fp);
ioctlf = fp->f_ops->fo_ioctl;
*retval = 0;
@ -143,7 +140,7 @@ linux_ioctl_sg(struct lwp *l, const struct linux_sys_ioctl_args *uap,
req.datalen = lreq.dxfer_len;
req.databuf = lreq.dxferp;
error = ioctlf(fp, SCIOCCOMMAND, (void *)&req, l);
error = ioctlf(fp, SCIOCCOMMAND, &req);
if (error) {
DPRINTF(("SCIOCCOMMAND failed %d\n", error));
break;
@ -212,8 +209,8 @@ linux_ioctl_sg(struct lwp *l, const struct linux_sys_ioctl_args *uap,
break;
}
done:
FILE_UNUSE(fp, l);
done:
fd_putfile(SCARG(uap, fd));
DPRINTF(("Return=%d\n", error));
return error;

View File

@ -1,7 +1,7 @@
/* $NetBSD: linux_socket.c,v 1.86 2008/02/06 21:57:53 ad Exp $ */
/* $NetBSD: linux_socket.c,v 1.87 2008/03/21 21:54:58 ad Exp $ */
/*-
* Copyright (c) 1995, 1998 The NetBSD Foundation, Inc.
* Copyright (c) 1995, 1998, 2008 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@ -42,7 +42,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: linux_socket.c,v 1.86 2008/02/06 21:57:53 ad Exp $");
__KERNEL_RCSID(0, "$NetBSD: linux_socket.c,v 1.87 2008/03/21 21:54:58 ad Exp $");
#if defined(_KERNEL_OPT)
#include "opt_inet.h"
@ -318,10 +318,9 @@ linux_sys_socket(struct lwp *l, const struct linux_sys_socket_args *uap, registe
* for Linux apps if the sysctl value is set to 1.
*/
if (!error && ip6_v6only && SCARG(&bsa, domain) == PF_INET6) {
struct proc *p = l->l_proc;
struct file *fp;
file_t *fp;
if (getsock(p->p_fd, *retval, &fp) == 0) {
if (getsock(*retval, &fp) == 0) {
struct mbuf *m;
m = m_get(M_WAIT, MT_SOOPTS);
@ -332,7 +331,7 @@ linux_sys_socket(struct lwp *l, const struct linux_sys_socket_args *uap, registe
(void) sosetopt((struct socket *)fp->f_data,
IPPROTO_IPV6, IPV6_V6ONLY, m);
FILE_UNUSE(fp, l);
fd_putfile(*retval);
}
}
#endif
@ -875,7 +874,6 @@ linux_sys_setsockopt(struct lwp *l, const struct linux_sys_setsockopt_args *uap,
syscallarg(void *) optval;
syscallarg(int) optlen;
} */
struct proc *p = l->l_proc;
struct sys_setsockopt_args bsa;
int name;
@ -889,19 +887,19 @@ linux_sys_setsockopt(struct lwp *l, const struct linux_sys_setsockopt_args *uap,
* and returns EOPNOTSUPP for other levels
*/
if (SCARG(&bsa, level) != SOL_SOCKET) {
struct file *fp;
file_t *fp;
struct socket *so;
int error, s, family;
/* getsock() will use the descriptor for us */
if ((error = getsock(p->p_fd, SCARG(&bsa, s), &fp)) != 0)
if ((error = getsock(SCARG(&bsa, s), &fp)) != 0)
return error;
s = splsoftnet();
so = (struct socket *)fp->f_data;
family = so->so_proto->pr_domain->dom_family;
splx(s);
FILE_UNUSE(fp, l);
fd_putfile(SCARG(&bsa, s));
if (family == AF_LOCAL)
return EOPNOTSUPP;
@ -987,9 +985,7 @@ linux_getifhwaddr(struct lwp *l, register_t *retval, u_int fd,
char if_name[IF_NAME_LEN];
struct osockaddr hwaddr;
} lreq;
struct proc *p = l->l_proc;
struct filedesc *fdp;
struct file *fp;
file_t *fp;
struct ifaddr *ifa;
struct ifnet *ifp;
struct sockaddr_dl *sadl;
@ -1007,11 +1003,9 @@ linux_getifhwaddr(struct lwp *l, register_t *retval, u_int fd,
* So, we must duplicate code from sys_ioctl() and ifconf(). Ugh.
*/
fdp = p->p_fd;
if ((fp = fd_getfile(fdp, fd)) == NULL)
if ((fp = fd_getfile(fd)) == NULL)
return (EBADF);
FILE_USE(fp);
if ((fp->f_flag & (FREAD | FWRITE)) == 0) {
error = EBADF;
goto out;
@ -1096,7 +1090,7 @@ linux_getifhwaddr(struct lwp *l, register_t *retval, u_int fd,
}
out:
FILE_UNUSE(fp, l);
fd_putfile(fd);
return error;
}
#undef IF_NAME_LEN
@ -1109,22 +1103,17 @@ linux_ioctl_socket(struct lwp *l, const struct linux_sys_ioctl_args *uap, regist
syscallarg(u_long) com;
syscallarg(void *) data;
} */
struct proc *p = l->l_proc;
u_long com;
int error = 0, isdev = 0, dosys = 1;
struct sys_ioctl_args ia;
struct file *fp;
struct filedesc *fdp;
file_t *fp;
struct vnode *vp;
int (*ioctlf)(struct file *, u_long, void *, struct lwp *);
int (*ioctlf)(file_t *, u_long, void *);
struct ioctl_pt pt;
fdp = p->p_fd;
if ((fp = fd_getfile(fdp, SCARG(uap, fd))) == NULL)
if ((fp = fd_getfile(SCARG(uap, fd))) == NULL)
return (EBADF);
FILE_USE(fp);
if (fp->f_type == DTYPE_VNODE) {
vp = (struct vnode *)fp->f_data;
isdev = vp->v_type == VCHR;
@ -1142,7 +1131,7 @@ linux_ioctl_socket(struct lwp *l, const struct linux_sys_ioctl_args *uap, regist
ioctlf = fp->f_ops->fo_ioctl;
pt.com = SCARG(uap, com);
pt.data = SCARG(uap, data);
error = ioctlf(fp, PTIOCLINUX, (void *)&pt, l);
error = ioctlf(fp, PTIOCLINUX, &pt);
/*
* XXX hack: if the function returns EJUSTRETURN,
* it has stuffed a sysctl return value in pt.data.
@ -1187,20 +1176,19 @@ linux_ioctl_socket(struct lwp *l, const struct linux_sys_ioctl_args *uap, regist
break;
case LINUX_SIOCGIFHWADDR:
error = linux_getifhwaddr(l, retval, SCARG(uap, fd),
SCARG(uap, data));
SCARG(uap, data));
dosys = 0;
break;
default:
error = EINVAL;
}
out:
FILE_UNUSE(fp, l);
out:
fd_putfile(SCARG(uap, fd));
if (error ==0 && dosys) {
SCARG(&ia, fd) = SCARG(uap, fd);
SCARG(&ia, data) = SCARG(uap, data);
/* XXX NJWLWP */
error = sys_ioctl(curlwp, &ia, retval);
}
@ -1226,12 +1214,12 @@ linux_sys_connect(struct lwp *l, const struct linux_sys_connect_args *uap, regis
error = do_sys_connect(l, SCARG(uap, s), nam);
if (error == EISCONN) {
struct file *fp;
file_t *fp;
struct socket *so;
int s, state, prflags, nbio;
/* getsock() will use the descriptor for us */
if (getsock(l->l_proc->p_fd, SCARG(uap, s), &fp) != 0)
if (getsock(SCARG(uap, s), &fp) != 0)
return EISCONN;
s = splsoftnet();
@ -1240,7 +1228,7 @@ linux_sys_connect(struct lwp *l, const struct linux_sys_connect_args *uap, regis
nbio = so->so_nbio;
prflags = so->so_proto->pr_flags;
splx(s);
FILE_UNUSE(fp, l);
fd_putfile(SCARG(uap, s));
/*
* We should only let this call succeed once per
* non-blocking connect; however we don't have
@ -1359,18 +1347,16 @@ linux_get_sa(struct lwp *l, int s, struct mbuf **mp, const struct osockaddr *osa
* This avoid triggering strict family checks in netinet/in_pcb.c et.al.
*/
if (bdom == AF_UNSPEC) {
struct file *fp;
file_t *fp;
struct socket *so;
/* getsock() will use the descriptor for us */
if ((error = getsock(l->l_proc->p_fd, s, &fp)) != 0)
if ((error = getsock(s, &fp)) != 0)
goto bad;
so = (struct socket *)fp->f_data;
bdom = so->so_proto->pr_domain->dom_family;
FILE_UNUSE(fp, l);
DPRINTF(("AF_UNSPEC family adjusted to %d\n", bdom));
}
@ -1398,6 +1384,7 @@ linux_get_sa(struct lwp *l, int s, struct mbuf **mp, const struct osockaddr *osa
"sockaddr_in6 rejected",
p->p_pid, p->p_comm, uid);
error = EINVAL;
fd_putfile(s);
goto bad;
}
salen = sizeof (struct sockaddr_in6);
@ -1422,6 +1409,7 @@ linux_get_sa(struct lwp *l, int s, struct mbuf **mp, const struct osockaddr *osa
#endif
*mp = m;
fd_putfile(s);
return 0;
bad:

View File

@ -1,7 +1,7 @@
/* $NetBSD: linux_termios.c,v 1.33 2007/12/20 23:02:57 dsl Exp $ */
/* $NetBSD: linux_termios.c,v 1.34 2008/03/21 21:54:58 ad Exp $ */
/*-
* Copyright (c) 1995, 1998 The NetBSD Foundation, Inc.
* Copyright (c) 1995, 1998, 2008 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: linux_termios.c,v 1.33 2007/12/20 23:02:57 dsl Exp $");
__KERNEL_RCSID(0, "$NetBSD: linux_termios.c,v 1.34 2008/03/21 21:54:58 ad Exp $");
#if defined(_KERNEL_OPT)
#include "opt_ptm.h"
@ -78,8 +78,7 @@ linux_ioctl_termios(struct lwp *l, const struct linux_sys_ioctl_args *uap, regis
syscallarg(u_long) com;
syscallarg(void *) data;
} */
struct file *fp;
struct filedesc *fdp;
file_t *fp;
u_long com;
struct linux_termio tmplt;
struct linux_termios tmplts;
@ -88,14 +87,11 @@ linux_ioctl_termios(struct lwp *l, const struct linux_sys_ioctl_args *uap, regis
struct sys_ioctl_args ia;
int error;
char tioclinux;
int (*bsdioctl)(struct file *, u_long, void *, struct lwp *);
int (*bsdioctl)(file_t *, u_long, void *);
fdp = l->l_proc->p_fd;
if ((fp = fd_getfile(fdp, SCARG(uap, fd))) == NULL)
if ((fp = fd_getfile(SCARG(uap, fd))) == NULL)
return (EBADF);
FILE_USE(fp);
if ((fp->f_flag & (FREAD | FWRITE)) == 0) {
error = EBADF;
goto out;
@ -107,7 +103,7 @@ linux_ioctl_termios(struct lwp *l, const struct linux_sys_ioctl_args *uap, regis
switch (com) {
case LINUX_TCGETS:
error = (*bsdioctl)(fp, TIOCGETA, (void *)&tmpbts, l);
error = (*bsdioctl)(fp, TIOCGETA, &tmpbts);
if (error)
goto out;
bsd_termios_to_linux_termios(&tmpbts, &tmplts);
@ -120,7 +116,7 @@ linux_ioctl_termios(struct lwp *l, const struct linux_sys_ioctl_args *uap, regis
* First fill in all fields, so that we keep the current
* values for fields that Linux doesn't know about.
*/
error = (*bsdioctl)(fp, TIOCGETA, (void *)&tmpbts, l);
error = (*bsdioctl)(fp, TIOCGETA, &tmpbts);
if (error)
goto out;
error = copyin(SCARG(uap, data), &tmplts, sizeof tmplts);
@ -138,10 +134,10 @@ linux_ioctl_termios(struct lwp *l, const struct linux_sys_ioctl_args *uap, regis
com = TIOCSETAF;
break;
}
error = (*bsdioctl)(fp, com, (void *)&tmpbts, l);
error = (*bsdioctl)(fp, com, &tmpbts);
goto out;
case LINUX_TCGETA:
error = (*bsdioctl)(fp, TIOCGETA, (void *)&tmpbts, l);
error = (*bsdioctl)(fp, TIOCGETA, &tmpbts);
if (error)
goto out;
bsd_termios_to_linux_termio(&tmpbts, &tmplt);
@ -154,7 +150,7 @@ linux_ioctl_termios(struct lwp *l, const struct linux_sys_ioctl_args *uap, regis
* First fill in all fields, so that we keep the current
* values for fields that Linux doesn't know about.
*/
error = (*bsdioctl)(fp, TIOCGETA, (void *)&tmpbts, l);
error = (*bsdioctl)(fp, TIOCGETA, &tmpbts);
if (error)
goto out;
error = copyin(SCARG(uap, data), &tmplt, sizeof tmplt);
@ -172,7 +168,7 @@ linux_ioctl_termios(struct lwp *l, const struct linux_sys_ioctl_args *uap, regis
com = TIOCSETAF;
break;
}
error = (*bsdioctl)(fp, com, (void *)&tmpbts, l);
error = (*bsdioctl)(fp, com, &tmpbts);
goto out;
case LINUX_TCFLSH:
switch((u_long)SCARG(uap, data)) {
@ -189,10 +185,10 @@ linux_ioctl_termios(struct lwp *l, const struct linux_sys_ioctl_args *uap, regis
error = EINVAL;
goto out;
}
error = (*bsdioctl)(fp, TIOCFLUSH, (void *)&idat, l);
error = (*bsdioctl)(fp, TIOCFLUSH, &idat);
goto out;
case LINUX_TIOCGETD:
error = (*bsdioctl)(fp, TIOCGETD, (void *)&idat, l);
error = (*bsdioctl)(fp, TIOCGETD, &idat);
if (error)
goto out;
switch (idat) {
@ -246,7 +242,7 @@ linux_ioctl_termios(struct lwp *l, const struct linux_sys_ioctl_args *uap, regis
error = EINVAL;
goto out;
}
error = (*bsdioctl)(fp, TIOCSETD, (void *)&idat, l);
error = (*bsdioctl)(fp, TIOCSETD, &idat);
goto out;
case LINUX_TIOCLINUX:
error = copyin(SCARG(uap, data), &tioclinux, sizeof tioclinux);
@ -327,7 +323,7 @@ linux_ioctl_termios(struct lwp *l, const struct linux_sys_ioctl_args *uap, regis
{
struct ptmget ptm;
error = (*bsdioctl)(fp, TIOCPTSNAME, &ptm, l);
error = (*bsdioctl)(fp, TIOCPTSNAME, &ptm);
if (error != 0)
goto out;
error = copyout(&ptm.sfd, SCARG(uap, data),
@ -338,7 +334,7 @@ linux_ioctl_termios(struct lwp *l, const struct linux_sys_ioctl_args *uap, regis
#endif /* LINUX_TIOCGPTN */
#ifdef LINUX_TIOCSPTLCK
case LINUX_TIOCSPTLCK:
FILE_UNUSE(fp, l);
fd_putfile(SCARG(uap, fd));
error = copyin(SCARG(uap, data), &idat, sizeof(idat));
if (error)
return error;
@ -352,9 +348,8 @@ linux_ioctl_termios(struct lwp *l, const struct linux_sys_ioctl_args *uap, regis
SCARG(&ia, fd) = SCARG(uap, fd);
SCARG(&ia, data) = SCARG(uap, data);
/* XXX NJWLWP */
error = sys_ioctl(curlwp, &ia, retval);
out:
FILE_UNUSE(fp, l);
fd_putfile(SCARG(uap, fd));
return error;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: linux32_stat.c,v 1.10 2007/12/20 23:02:58 dsl Exp $ */
/* $NetBSD: linux32_stat.c,v 1.11 2008/03/21 21:54:58 ad Exp $ */
/*-
* Copyright (c) 2006 Emmanuel Dreyfus, all rights reserved.
@ -33,7 +33,7 @@
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: linux32_stat.c,v 1.10 2007/12/20 23:02:58 dsl Exp $");
__KERNEL_RCSID(0, "$NetBSD: linux32_stat.c,v 1.11 2008/03/21 21:54:58 ad Exp $");
#include <sys/types.h>
#include <sys/param.h>
@ -120,7 +120,7 @@ linux32_sys_stat64(struct lwp *l, const struct linux32_sys_stat64_args *uap, reg
struct linux32_stat64 *st32p;
const char *path = SCARG_P32(uap, path);
error = do_sys_stat(l, path, FOLLOW, &st);
error = do_sys_stat(path, FOLLOW, &st);
if (error != 0)
return error;
@ -144,7 +144,7 @@ linux32_sys_lstat64(struct lwp *l, const struct linux32_sys_lstat64_args *uap, r
struct linux32_stat64 *st32p;
const char *path = SCARG_P32(uap, path);
error = do_sys_stat(l, path, NOFOLLOW, &st);
error = do_sys_stat(path, NOFOLLOW, &st);
if (error != 0)
return error;
@ -167,7 +167,7 @@ linux32_sys_fstat64(struct lwp *l, const struct linux32_sys_fstat64_args *uap, r
struct linux32_stat64 st32;
struct linux32_stat64 *st32p;
error = do_sys_fstat(l, SCARG(uap, fd), &st);
error = do_sys_fstat(SCARG(uap, fd), &st);
if (error != 0)
return error;

View File

@ -1,7 +1,7 @@
/* $NetBSD: linux32_termios.c,v 1.9 2007/12/20 23:02:59 dsl Exp $ */
/* $NetBSD: linux32_termios.c,v 1.10 2008/03/21 21:54:58 ad Exp $ */
/*-
* Copyright (c) 1995-2006 The NetBSD Foundation, Inc.
* Copyright (c) 1995-2006, 2008 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: linux32_termios.c,v 1.9 2007/12/20 23:02:59 dsl Exp $");
__KERNEL_RCSID(0, "$NetBSD: linux32_termios.c,v 1.10 2008/03/21 21:54:58 ad Exp $");
#include "opt_compat_linux32.h"
@ -76,8 +76,7 @@ linux32_ioctl_termios(struct lwp *l, const struct linux32_sys_ioctl_args *uap, r
syscallarg(netbsd32_u_long) com;
syscallarg(netbsd32_charp) data;
} */
struct file *fp;
struct filedesc *fdp;
file_t *fp;
u_long com;
struct linux32_termio tmplt;
struct linux32_termios tmplts;
@ -86,26 +85,24 @@ linux32_ioctl_termios(struct lwp *l, const struct linux32_sys_ioctl_args *uap, r
struct netbsd32_ioctl_args ia;
int error;
char tioclinux;
int (*bsdioctl)(struct file *, u_long, void *, struct lwp *);
int (*bsdioctl)(file_t *, u_long, void *);
fdp = l->l_proc->p_fd;
if ((fp = fd_getfile(fdp, SCARG(uap, fd))) == NULL)
if ((fp = fd_getfile(SCARG(uap, fd))) == NULL)
return (EBADF);
if ((fp->f_flag & (FREAD | FWRITE)) == 0) {
fd_putfile(SCARG(uap, fd));
error = EBADF;
goto out;
}
FILE_USE(fp);
bsdioctl = fp->f_ops->fo_ioctl;
com = SCARG(uap, com);
retval[0] = 0;
switch (com) {
case LINUX32_TCGETS:
error = (*bsdioctl)(fp, TIOCGETA, (void *)&tmpbts, l);
error = (*bsdioctl)(fp, TIOCGETA, &tmpbts);
if (error)
goto out;
bsd_termios_to_linux32_termios(&tmpbts, &tmplts);
@ -118,7 +115,7 @@ linux32_ioctl_termios(struct lwp *l, const struct linux32_sys_ioctl_args *uap, r
* First fill in all fields, so that we keep the current
* values for fields that Linux doesn't know about.
*/
error = (*bsdioctl)(fp, TIOCGETA, (void *)&tmpbts, l);
error = (*bsdioctl)(fp, TIOCGETA, &tmpbts);
if (error)
goto out;
if ((error = copyin(SCARG_P32(uap, data),
@ -136,10 +133,10 @@ linux32_ioctl_termios(struct lwp *l, const struct linux32_sys_ioctl_args *uap, r
com = TIOCSETAF;
break;
}
error = (*bsdioctl)(fp, com, (void *)&tmpbts, l);
error = (*bsdioctl)(fp, com, &tmpbts);
goto out;
case LINUX32_TCGETA:
error = (*bsdioctl)(fp, TIOCGETA, (void *)&tmpbts, l);
error = (*bsdioctl)(fp, TIOCGETA, &tmpbts);
if (error)
goto out;
bsd_termios_to_linux32_termio(&tmpbts, &tmplt);
@ -152,7 +149,7 @@ linux32_ioctl_termios(struct lwp *l, const struct linux32_sys_ioctl_args *uap, r
* First fill in all fields, so that we keep the current
* values for fields that Linux doesn't know about.
*/
error = (*bsdioctl)(fp, TIOCGETA, (void *)&tmpbts, l);
error = (*bsdioctl)(fp, TIOCGETA, &tmpbts);
if (error)
goto out;
if ((error = copyin(SCARG_P32(uap, data),
@ -170,7 +167,7 @@ linux32_ioctl_termios(struct lwp *l, const struct linux32_sys_ioctl_args *uap, r
com = TIOCSETAF;
break;
}
error = (*bsdioctl)(fp, com, (void *)&tmpbts, l);
error = (*bsdioctl)(fp, com, &tmpbts);
goto out;
case LINUX32_TCFLSH:
switch((u_long)SCARG_P32(uap, data)) {
@ -187,10 +184,10 @@ linux32_ioctl_termios(struct lwp *l, const struct linux32_sys_ioctl_args *uap, r
error = EINVAL;
goto out;
}
error = (*bsdioctl)(fp, TIOCFLUSH, (void *)&idat, l);
error = (*bsdioctl)(fp, TIOCFLUSH, &idat);
goto out;
case LINUX32_TIOCGETD:
error = (*bsdioctl)(fp, TIOCGETD, (void *)&idat, l);
error = (*bsdioctl)(fp, TIOCGETD, &idat);
if (error)
goto out;
switch (idat) {
@ -244,7 +241,7 @@ linux32_ioctl_termios(struct lwp *l, const struct linux32_sys_ioctl_args *uap, r
error = EINVAL;
goto out;
}
error = (*bsdioctl)(fp, TIOCSETD, (void *)&idat, l);
error = (*bsdioctl)(fp, TIOCSETD, &idat);
goto out;
case LINUX32_TIOCLINUX:
if ((error = copyin(SCARG_P32(uap, data),
@ -325,7 +322,7 @@ linux32_ioctl_termios(struct lwp *l, const struct linux32_sys_ioctl_args *uap, r
{
struct ptmget ptm;
error = (*bsdioctl)(fp, TIOCPTSNAME, &ptm, l);
error = (*bsdioctl)(fp, TIOCPTSNAME, &ptm);
if (error != 0)
goto out;
@ -342,9 +339,8 @@ linux32_ioctl_termios(struct lwp *l, const struct linux32_sys_ioctl_args *uap, r
SCARG(&ia, fd) = SCARG(uap, fd);
SCARG(&ia, data) = SCARG(uap, data);
/* XXX NJWLWP */
error = netbsd32_ioctl(curlwp, &ia, retval);
out:
FILE_UNUSE(fp, l);
fdputfile(SCARG(uap, fd));
return error;
}

View File

@ -1,7 +1,7 @@
/* $NetBSD: mach_vm.c,v 1.58 2007/12/20 23:03:00 dsl Exp $ */
/* $NetBSD: mach_vm.c,v 1.59 2008/03/21 21:54:58 ad Exp $ */
/*-
* Copyright (c) 2002-2003 The NetBSD Foundation, Inc.
* Copyright (c) 2002-2003, 2008 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: mach_vm.c,v 1.58 2007/12/20 23:03:00 dsl Exp $");
__KERNEL_RCSID(0, "$NetBSD: mach_vm.c,v 1.59 2008/03/21 21:54:58 ad Exp $");
#include <sys/types.h>
#include <sys/param.h>
@ -349,8 +349,7 @@ mach_sys_map_fd(struct lwp *l, const struct mach_sys_map_fd_args *uap, register_
syscallarg(mach_boolean_t) findspace;
syscallarg(mach_vm_size_t) size;
} */
struct file *fp;
struct filedesc *fdp;
file_t *fp;
struct vnode *vp;
struct exec_vmcmd evc;
struct vm_map_entry *ret;
@ -370,13 +369,11 @@ mach_sys_map_fd(struct lwp *l, const struct mach_sys_map_fd_args *uap, register_
(void)sys_munmap(l, &cup, &dontcare);
}
fdp = p->p_fd;
fp = fd_getfile(fdp, SCARG(uap, fd));
fp = fd_getfile(SCARG(uap, fd));
if (fp == NULL)
return EBADF;
FILE_USE(fp);
vp = (struct vnode *)fp->f_data;
vp = fp->f_data;
vref(vp);
#ifdef DEBUG_MACH_VM
@ -432,7 +429,7 @@ mach_sys_map_fd(struct lwp *l, const struct mach_sys_map_fd_args *uap, register_
}
vput(vp);
FILE_UNUSE(fp, l);
fd_putfile(SCARG(uap, fd));
#ifdef DEBUG_MACH_VM
printf("mach_sys_map_fd: mapping at %p\n", (void *)evc.ev_addr);
#endif
@ -448,7 +445,7 @@ bad1:
VOP_UNLOCK(vp, 0);
bad2:
vrele(vp);
FILE_UNUSE(fp, l);
fd_putfile(SCARG(uap, fd));
#ifdef DEBUG_MACH_VM
printf("mach_sys_map_fd: mapping at %p failed, error = %d\n",
(void *)evc.ev_addr, error);

View File

@ -1,4 +1,4 @@
/* $NetBSD: netbsd32_compat_20.c,v 1.20 2008/01/30 11:46:59 ad Exp $ */
/* $NetBSD: netbsd32_compat_20.c,v 1.21 2008/03/21 21:54:58 ad Exp $ */
/*
* Copyright (c) 1998, 2001 Matthew R. Green
@ -29,7 +29,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: netbsd32_compat_20.c,v 1.20 2008/01/30 11:46:59 ad Exp $");
__KERNEL_RCSID(0, "$NetBSD: netbsd32_compat_20.c,v 1.21 2008/03/21 21:54:58 ad Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -183,15 +183,14 @@ compat_20_netbsd32_fstatfs(struct lwp *l, const struct compat_20_netbsd32_fstatf
syscallarg(int) fd;
syscallarg(netbsd32_statfsp_t) buf;
} */
struct file *fp;
file_t *fp;
struct mount *mp;
struct statvfs *sp;
struct netbsd32_statfs s32;
int error;
struct proc *p = l->l_proc;
/* getvnode() will use the descriptor for us */
if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0)
if ((error = fd_getvnode(SCARG(uap, fd), &fp)) != 0)
return (error);
mp = ((struct vnode *)fp->f_data)->v_mount;
sp = &mp->mnt_stat;
@ -201,7 +200,7 @@ compat_20_netbsd32_fstatfs(struct lwp *l, const struct compat_20_netbsd32_fstatf
compat_20_netbsd32_from_statvfs(sp, &s32);
error = copyout(&s32, SCARG_P32(uap, buf), sizeof(s32));
out:
FILE_UNUSE(fp, l);
fd_putfile(SCARG(uap, fd));
return (error);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: netbsd32_compat_30.c,v 1.23 2007/12/20 23:03:01 dsl Exp $ */
/* $NetBSD: netbsd32_compat_30.c,v 1.24 2008/03/21 21:54:58 ad Exp $ */
/*
* Copyright (c) 1998, 2001 Matthew R. Green
@ -29,7 +29,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: netbsd32_compat_30.c,v 1.23 2007/12/20 23:03:01 dsl Exp $");
__KERNEL_RCSID(0, "$NetBSD: netbsd32_compat_30.c,v 1.24 2008/03/21 21:54:58 ad Exp $");
#include "opt_nfsserver.h"
@ -68,17 +68,16 @@ compat_30_netbsd32_getdents(struct lwp *l, const struct compat_30_netbsd32_getde
syscallarg(netbsd32_charp) buf;
syscallarg(netbsd32_size_t) count;
} */
struct file *fp;
file_t *fp;
int error, done;
char *buf;
netbsd32_size_t count;
struct proc *p = l->l_proc;
/* Limit the size on any kernel buffers used by VOP_READDIR */
count = min(MAXBSIZE, SCARG(uap, count));
/* getvnode() will use the descriptor for us */
if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0)
if ((error = fd_getvnode(SCARG(uap, fd), &fp)) != 0)
return (error);
if ((fp->f_flag & FREAD) == 0) {
error = EBADF;
@ -92,7 +91,7 @@ compat_30_netbsd32_getdents(struct lwp *l, const struct compat_30_netbsd32_getde
}
free(buf, M_TEMP);
out:
FILE_UNUSE(fp, l);
fd_putfile(SCARG(uap, fd));
return (error);
}
@ -110,7 +109,7 @@ compat_30_netbsd32___stat13(struct lwp *l, const struct compat_30_netbsd32___sta
path = SCARG_P32(uap, path);
error = do_sys_stat(l, path, FOLLOW, &sb);
error = do_sys_stat(path, FOLLOW, &sb);
if (error)
return (error);
netbsd32_from___stat13(&sb, &sb32);
@ -126,19 +125,15 @@ compat_30_netbsd32___fstat13(struct lwp *l, const struct compat_30_netbsd32___fs
syscallarg(netbsd32_stat13p_t) sb;
} */
int fd = SCARG(uap, fd);
struct proc *p = l->l_proc;
struct filedesc *fdp = p->p_fd;
struct file *fp;
file_t *fp;
struct netbsd32_stat13 sb32;
struct stat ub;
int error = 0;
if ((fp = fd_getfile(fdp, fd)) == NULL)
if ((fp = fd_getfile(fd)) == NULL)
return (EBADF);
FILE_USE(fp);
error = (*fp->f_ops->fo_stat)(fp, &ub, l);
FILE_UNUSE(fp, l);
error = (*fp->f_ops->fo_stat)(fp, &ub);
fd_putfile(fd);
if (error == 0) {
netbsd32_from___stat13(&ub, &sb32);
@ -161,7 +156,7 @@ compat_30_netbsd32___lstat13(struct lwp *l, const struct compat_30_netbsd32___ls
path = SCARG_P32(uap, path);
error = do_sys_stat(l, path, NOFOLLOW, &sb);
error = do_sys_stat(path, NOFOLLOW, &sb);
if (error)
return (error);
netbsd32_from___stat13(&sb, &sb32);
@ -199,7 +194,7 @@ compat_30_netbsd32_fhstat(struct lwp *l, const struct compat_30_netbsd32_fhstat_
return EOPNOTSUPP;
if ((error = VFS_FHTOVP(mp, (struct fid*)&fh.fh_fid, &vp)))
return (error);
error = vn_stat(vp, &sb, l);
error = vn_stat(vp, &sb);
vput(vp);
if (error)
return (error);

View File

@ -1,4 +1,4 @@
/* $NetBSD: netbsd32_compat_43.c,v 1.48 2008/01/26 21:01:23 dsl Exp $ */
/* $NetBSD: netbsd32_compat_43.c,v 1.49 2008/03/21 21:54:58 ad Exp $ */
/*
* Copyright (c) 1998, 2001 Matthew R. Green
@ -29,7 +29,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: netbsd32_compat_43.c,v 1.48 2008/01/26 21:01:23 dsl Exp $");
__KERNEL_RCSID(0, "$NetBSD: netbsd32_compat_43.c,v 1.49 2008/03/21 21:54:58 ad Exp $");
#if defined(_KERNEL_OPT)
#include "opt_compat_43.h"
@ -143,7 +143,7 @@ compat_43_netbsd32_stat43(struct lwp *l, const struct compat_43_netbsd32_stat43_
struct netbsd32_stat43 sb32;
int error;
error = do_sys_stat(l, SCARG_P32(uap, path), FOLLOW, &sb);
error = do_sys_stat(SCARG_P32(uap, path), FOLLOW, &sb);
if (error == 0) {
netbsd32_from_stat(&sb, &sb32);
error = copyout(&sb32, SCARG_P32(uap, ub), sizeof(sb32));
@ -162,7 +162,7 @@ compat_43_netbsd32_lstat43(struct lwp *l, const struct compat_43_netbsd32_lstat4
struct netbsd32_stat43 sb32;
int error;
error = do_sys_stat(l, SCARG_P32(uap, path), NOFOLLOW, &sb);
error = do_sys_stat(SCARG_P32(uap, path), NOFOLLOW, &sb);
if (error == 0) {
netbsd32_from_stat(&sb, &sb32);
error = copyout(&sb32, SCARG_P32(uap, ub), sizeof(sb32));
@ -181,7 +181,7 @@ compat_43_netbsd32_fstat43(struct lwp *l, const struct compat_43_netbsd32_fstat4
struct netbsd32_stat43 sb32;
int error;
error = do_sys_fstat(l, SCARG(uap, fd), &sb);
error = do_sys_fstat(SCARG(uap, fd), &sb);
if (error == 0) {
netbsd32_from_stat(&sb, &sb32);
error = copyout(&sb32, SCARG_P32(uap, sb), sizeof(sb32));

View File

@ -1,4 +1,4 @@
/* $NetBSD: netbsd32_event.c,v 1.4 2007/12/20 23:03:01 dsl Exp $ */
/* $NetBSD: netbsd32_event.c,v 1.5 2008/03/21 21:54:58 ad Exp $ */
/*
* Copyright (c) 2005 The NetBSD Foundation.
@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: netbsd32_event.c,v 1.4 2007/12/20 23:03:01 dsl Exp $");
__KERNEL_RCSID(0, "$NetBSD: netbsd32_event.c,v 1.5 2008/03/21 21:54:58 ad Exp $");
#include <sys/types.h>
#include <sys/param.h>
@ -120,7 +120,7 @@ netbsd32_kevent(struct lwp *l, const struct netbsd32_kevent_args *uap, register_
malloc(maxalloc * sizeof(struct netbsd32_kevent), M_TEMP,
M_WAITOK);
error = kevent1(l, retval, SCARG(uap, fd),
error = kevent1(retval, SCARG(uap, fd),
NETBSD32PTR64(SCARG(uap, changelist)), nchanges,
NETBSD32PTR64(SCARG(uap, eventlist)), nevents,
NETBSD32PTR64(SCARG(uap, timeout)), &netbsd32_kevent_ops);

View File

@ -1,4 +1,4 @@
/* $NetBSD: netbsd32_fs.c,v 1.50 2008/01/05 19:14:08 dsl Exp $ */
/* $NetBSD: netbsd32_fs.c,v 1.51 2008/03/21 21:54:58 ad Exp $ */
/*
* Copyright (c) 1998, 2001 Matthew R. Green
@ -29,7 +29,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: netbsd32_fs.c,v 1.50 2008/01/05 19:14:08 dsl Exp $");
__KERNEL_RCSID(0, "$NetBSD: netbsd32_fs.c,v 1.51 2008/03/21 21:54:58 ad Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -58,9 +58,9 @@ __KERNEL_RCSID(0, "$NetBSD: netbsd32_fs.c,v 1.50 2008/01/05 19:14:08 dsl Exp $")
#include <compat/sys/mount.h>
static int dofilereadv32(struct lwp *, int, struct file *, struct netbsd32_iovec *,
static int dofilereadv32(int, struct file *, struct netbsd32_iovec *,
int, off_t *, int, register_t *);
static int dofilewritev32(struct lwp *, int, struct file *, struct netbsd32_iovec *,
static int dofilewritev32(int, struct file *, struct netbsd32_iovec *,
int, off_t *, int, register_t *);
struct iovec *
@ -109,28 +109,24 @@ netbsd32_readv(struct lwp *l, const struct netbsd32_readv_args *uap, register_t
syscallarg(int) iovcnt;
} */
int fd = SCARG(uap, fd);
struct proc *p = l->l_proc;
struct file *fp;
struct filedesc *fdp = p->p_fd;
file_t *fp;
if ((fp = fd_getfile(fdp, fd)) == NULL)
if ((fp = fd_getfile(fd)) == NULL)
return (EBADF);
if ((fp->f_flag & FREAD) == 0) {
FILE_UNLOCK(fp);
fd_putfile(fd);
return (EBADF);
}
FILE_USE(fp);
return (dofilereadv32(l, fd, fp,
return (dofilereadv32(fd, fp,
(struct netbsd32_iovec *)SCARG_P32(uap, iovp),
SCARG(uap, iovcnt), &fp->f_offset, FOF_UPDATE_OFFSET, retval));
}
/* Damn thing copies in the iovec! */
int
dofilereadv32(struct lwp *l, int fd, struct file *fp, struct netbsd32_iovec *iovp, int iovcnt, off_t *offset, int flags, register_t *retval)
dofilereadv32(int fd, struct file *fp, struct netbsd32_iovec *iovp, int iovcnt, off_t *offset, int flags, register_t *retval)
{
struct uio auio;
struct iovec *iov;
@ -160,7 +156,7 @@ dofilereadv32(struct lwp *l, int fd, struct file *fp, struct netbsd32_iovec *iov
auio.uio_iov = iov;
auio.uio_iovcnt = iovcnt;
auio.uio_rw = UIO_READ;
auio.uio_vmspace = l->l_proc->p_vmspace;
auio.uio_vmspace = curproc->p_vmspace;
error = netbsd32_to_iovecin(iovp, iov, iovcnt);
if (error)
goto done;
@ -205,7 +201,7 @@ done:
if (needfree)
free(needfree, M_IOV);
out:
FILE_UNUSE(fp, l);
fd_putfile(fd);
return (error);
}
@ -218,33 +214,28 @@ netbsd32_writev(struct lwp *l, const struct netbsd32_writev_args *uap, register_
syscallarg(int) iovcnt;
} */
int fd = SCARG(uap, fd);
struct file *fp;
struct proc *p = l->l_proc;
struct filedesc *fdp = p->p_fd;
file_t *fp;
if ((fp = fd_getfile(fdp, fd)) == NULL)
if ((fp = fd_getfile(fd)) == NULL)
return (EBADF);
if ((fp->f_flag & FWRITE) == 0) {
FILE_UNLOCK(fp);
fd_putfile(fd);
return (EBADF);
}
FILE_USE(fp);
return (dofilewritev32(l, fd, fp,
return (dofilewritev32(fd, fp,
(struct netbsd32_iovec *)SCARG_P32(uap, iovp),
SCARG(uap, iovcnt), &fp->f_offset, FOF_UPDATE_OFFSET, retval));
}
int
dofilewritev32(struct lwp *l, int fd, struct file *fp, struct netbsd32_iovec *iovp, int iovcnt, off_t *offset, int flags, register_t *retval)
dofilewritev32(int fd, struct file *fp, struct netbsd32_iovec *iovp, int iovcnt, off_t *offset, int flags, register_t *retval)
{
struct uio auio;
struct iovec *iov;
struct iovec *needfree;
struct iovec aiov[UIO_SMALLIOV];
struct proc *p = l->l_proc;
long i, cnt, error = 0;
u_int iovlen;
struct iovec *ktriov = NULL;
@ -269,7 +260,7 @@ dofilewritev32(struct lwp *l, int fd, struct file *fp, struct netbsd32_iovec *io
auio.uio_iov = iov;
auio.uio_iovcnt = iovcnt;
auio.uio_rw = UIO_WRITE;
auio.uio_vmspace = l->l_proc->p_vmspace;
auio.uio_vmspace = curproc->p_vmspace;
error = netbsd32_to_iovecin(iovp, iov, iovcnt);
if (error)
goto done;
@ -304,7 +295,7 @@ dofilewritev32(struct lwp *l, int fd, struct file *fp, struct netbsd32_iovec *io
error = 0;
if (error == EPIPE) {
mutex_enter(&proclist_mutex);
psignal(p, SIGPIPE);
psignal(curproc, SIGPIPE);
mutex_exit(&proclist_mutex);
}
}
@ -318,7 +309,7 @@ done:
if (needfree)
free(needfree, M_IOV);
out:
FILE_UNUSE(fp, l);
fd_putfile(fd);
return (error);
}
@ -462,7 +453,7 @@ netbsd32_futimes(struct lwp *l, const struct netbsd32_futimes_args *uap, registe
syscallarg(const netbsd32_timevalp_t) tptr;
} */
int error;
struct file *fp;
file_t *fp;
struct timeval tv[2], *tvp;
error = get_utimes32(SCARG_P32(uap, tptr), tv, &tvp);
@ -470,12 +461,12 @@ netbsd32_futimes(struct lwp *l, const struct netbsd32_futimes_args *uap, registe
return error;
/* getvnode() will use the descriptor for us */
if ((error = getvnode(l->l_proc->p_fd, SCARG(uap, fd), &fp)) != 0)
if ((error = fd_getvnode(SCARG(uap, fd), &fp)) != 0)
return (error);
error = do_sys_utimes(l, fp->f_data, NULL, 0, tvp, UIO_SYSSPACE);
FILE_UNUSE(fp, l);
fd_putfile(SCARG(uap, fd));
return (error);
}
@ -487,12 +478,11 @@ netbsd32_sys___getdents30(struct lwp *l, const struct netbsd32_sys___getdents30_
syscallarg(netbsd32_charp) buf;
syscallarg(netbsd32_size_t) count;
} */
struct file *fp;
file_t *fp;
int error, done;
struct proc *p = l->l_proc;
/* getvnode() will use the descriptor for us */
if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0)
if ((error = fd_getvnode(SCARG(uap, fd), &fp)) != 0)
return (error);
if ((fp->f_flag & FREAD) == 0) {
error = EBADF;
@ -502,7 +492,7 @@ netbsd32_sys___getdents30(struct lwp *l, const struct netbsd32_sys___getdents30_
UIO_USERSPACE, SCARG(uap, count), &done, l, 0, 0);
*retval = done;
out:
FILE_UNUSE(fp, l);
fd_putfile(SCARG(uap, fd));
return (error);
}
@ -538,7 +528,7 @@ netbsd32_sys___stat30(struct lwp *l, const struct netbsd32_sys___stat30_args *ua
path = SCARG_P32(uap, path);
error = do_sys_stat(l, path, FOLLOW, &sb);
error = do_sys_stat(path, FOLLOW, &sb);
if (error)
return (error);
netbsd32_from___stat30(&sb, &sb32);
@ -554,20 +544,15 @@ netbsd32_sys___fstat30(struct lwp *l, const struct netbsd32_sys___fstat30_args *
syscallarg(netbsd32_statp_t) sb;
} */
int fd = SCARG(uap, fd);
struct proc *p = l->l_proc;
struct filedesc *fdp = p->p_fd;
struct file *fp;
file_t *fp;
struct netbsd32_stat sb32;
struct stat ub;
int error = 0;
if ((fp = fd_getfile(fdp, fd)) == NULL)
if ((fp = fd_getfile(fd)) == NULL)
return (EBADF);
FILE_USE(fp);
error = (*fp->f_ops->fo_stat)(fp, &ub, l);
FILE_UNUSE(fp, l);
error = (*fp->f_ops->fo_stat)(fp, &ub);
fd_putfile(fd);
if (error == 0) {
netbsd32_from___stat30(&ub, &sb32);
error = copyout(&sb32, SCARG_P32(uap, sb), sizeof(sb32));
@ -589,7 +574,7 @@ netbsd32_sys___lstat30(struct lwp *l, const struct netbsd32_sys___lstat30_args *
path = SCARG_P32(uap, path);
error = do_sys_stat(l, path, NOFOLLOW, &sb);
error = do_sys_stat(path, NOFOLLOW, &sb);
if (error)
return (error);
netbsd32_from___stat30(&sb, &sb32);
@ -627,24 +612,20 @@ netbsd32_preadv(struct lwp *l, const struct netbsd32_preadv_args *uap, register_
syscallarg(int) pad;
syscallarg(off_t) offset;
} */
struct proc *p = l->l_proc;
struct filedesc *fdp = p->p_fd;
struct file *fp;
file_t *fp;
struct vnode *vp;
off_t offset;
int error, fd = SCARG(uap, fd);
if ((fp = fd_getfile(fdp, fd)) == NULL)
if ((fp = fd_getfile(fd)) == NULL)
return (EBADF);
if ((fp->f_flag & FREAD) == 0) {
FILE_UNLOCK(fp);
fd_putfile(fd);
return (EBADF);
}
FILE_USE(fp);
vp = (struct vnode *)fp->f_data;
vp = fp->f_data;
if (fp->f_type != DTYPE_VNODE || vp->v_type == VFIFO) {
error = ESPIPE;
goto out;
@ -659,11 +640,11 @@ netbsd32_preadv(struct lwp *l, const struct netbsd32_preadv_args *uap, register_
if ((error = VOP_SEEK(vp, fp->f_offset, offset, fp->f_cred)) != 0)
goto out;
return (dofilereadv32(l, fd, fp, SCARG_P32(uap, iovp),
return (dofilereadv32(fd, fp, SCARG_P32(uap, iovp),
SCARG(uap, iovcnt), &offset, 0, retval));
out:
FILE_UNUSE(fp, l);
fd_putfile(fd);
return (error);
}
@ -677,24 +658,20 @@ netbsd32_pwritev(struct lwp *l, const struct netbsd32_pwritev_args *uap, registe
syscallarg(int) pad;
syscallarg(off_t) offset;
} */
struct proc *p = l->l_proc;
struct filedesc *fdp = p->p_fd;
struct file *fp;
file_t *fp;
struct vnode *vp;
off_t offset;
int error, fd = SCARG(uap, fd);
if ((fp = fd_getfile(fdp, fd)) == NULL)
if ((fp = fd_getfile(fd)) == NULL)
return (EBADF);
if ((fp->f_flag & FWRITE) == 0) {
FILE_UNLOCK(fp);
fd_putfile(fd);
return (EBADF);
}
FILE_USE(fp);
vp = (struct vnode *)fp->f_data;
vp = fp->f_data;
if (fp->f_type != DTYPE_VNODE || vp->v_type == VFIFO) {
error = ESPIPE;
goto out;
@ -709,11 +686,11 @@ netbsd32_pwritev(struct lwp *l, const struct netbsd32_pwritev_args *uap, registe
if ((error = VOP_SEEK(vp, fp->f_offset, offset, fp->f_cred)) != 0)
goto out;
return (dofilewritev32(l, fd, fp, SCARG_P32(uap, iovp),
return (dofilewritev32(fd, fp, SCARG_P32(uap, iovp),
SCARG(uap, iovcnt), &offset, 0, retval));
out:
FILE_UNUSE(fp, l);
fd_putfile(fd);
return (error);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: netbsd32_ioctl.c,v 1.37 2007/12/20 23:03:01 dsl Exp $ */
/* $NetBSD: netbsd32_ioctl.c,v 1.38 2008/03/21 21:54:58 ad Exp $ */
/*
* Copyright (c) 1998, 2001 Matthew R. Green
@ -33,7 +33,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: netbsd32_ioctl.c,v 1.37 2007/12/20 23:03:01 dsl Exp $");
__KERNEL_RCSID(0, "$NetBSD: netbsd32_ioctl.c,v 1.38 2008/03/21 21:54:58 ad Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -52,6 +52,7 @@ __KERNEL_RCSID(0, "$NetBSD: netbsd32_ioctl.c,v 1.37 2007/12/20 23:03:01 dsl Exp
#include <sys/mount.h>
#include <sys/syscallargs.h>
#include <sys/ktrace.h>
#include <sys/kmem.h>
#ifdef __sparc__
#include <dev/sun/fbio.h>
@ -317,6 +318,8 @@ netbsd32_ioctl(struct lwp *l, const struct netbsd32_ioctl_args *uap, register_t
u_int size, size32;
void *data, *memp = NULL;
void *data32, *memp32 = NULL;
unsigned fd;
fdfile_t *ff;
int tmp;
#define STK_PARAMS 128
u_long stkbuf[STK_PARAMS/sizeof(u_long)];
@ -340,23 +343,23 @@ printf("netbsd32_ioctl(%d, %x, %x): %s group %c base %d len %d\n",
#endif
fdp = p->p_fd;
if ((fp = fd_getfile(fdp, SCARG(uap, fd))) == NULL)
fd = SCARG(uap, fd);
if ((fp = fd_getfile(fd)) == NULL)
return (EBADF);
FILE_USE(fp);
if ((fp->f_flag & (FREAD | FWRITE)) == 0) {
error = EBADF;
goto out;
}
ff = fdp->fd_ofiles[SCARG(uap, fd)];
switch (com = SCARG(uap, com)) {
case FIONCLEX:
fdp->fd_ofileflags[SCARG(uap, fd)] &= ~UF_EXCLOSE;
ff->ff_exclose = 0;
goto out;
case FIOCLEX:
fdp->fd_ofileflags[SCARG(uap, fd)] |= UF_EXCLOSE;
ff->ff_exclose = 1;
fdp->fd_exclose = 1;
goto out;
}
@ -364,14 +367,14 @@ printf("netbsd32_ioctl(%d, %x, %x): %s group %c base %d len %d\n",
* Interpret high order word to find amount of data to be
* copied to/from the user's address space.
*/
size = 0;
size32 = IOCPARM_LEN(com);
if (size32 > IOCPARM_MAX) {
error = ENOTTY;
goto out;
}
memp = NULL;
if (size32 > sizeof(stkbuf)) {
memp32 = malloc((u_long)size32, M_IOCTLOPS, M_WAITOK);
memp32 = kmem_alloc((size_t)size32, KM_SLEEP);
data32 = memp32;
} else
data32 = (void *)stkbuf32;
@ -380,10 +383,10 @@ printf("netbsd32_ioctl(%d, %x, %x): %s group %c base %d len %d\n",
error = copyin(SCARG_P32(uap, data), data32, size32);
if (error) {
if (memp32)
free(memp32, M_IOCTLOPS);
kmem_free(memp32, (size_t)size32);
goto out;
}
ktrgenio(SCARG(uap, fd), UIO_WRITE, SCARG_P32(uap, data),
ktrgenio(fd, UIO_WRITE, SCARG_P32(uap, data),
size32, 0);
} else
*(void **)data32 = SCARG_P32(uap, data);
@ -402,19 +405,23 @@ printf("netbsd32_ioctl(%d, %x, %x): %s group %c base %d len %d\n",
*/
switch (SCARG(uap, com)) {
case FIONBIO:
mutex_enter(&fp->f_lock);
if ((tmp = *(int *)data32) != 0)
fp->f_flag |= FNONBLOCK;
else
fp->f_flag &= ~FNONBLOCK;
error = (*fp->f_ops->fo_ioctl)(fp, FIONBIO, (void *)&tmp, l);
mutex_exit(&fp->f_lock);
error = (*fp->f_ops->fo_ioctl)(fp, FIONBIO, (void *)&tmp);
break;
case FIOASYNC:
mutex_enter(&fp->f_lock);
if ((tmp = *(int *)data32) != 0)
fp->f_flag |= FASYNC;
else
fp->f_flag &= ~FASYNC;
error = (*fp->f_ops->fo_ioctl)(fp, FIOASYNC, (void *)&tmp, l);
mutex_exit(&fp->f_lock);
error = (*fp->f_ops->fo_ioctl)(fp, FIOASYNC, (void *)&tmp);
break;
case DIOCGPART32:
@ -511,7 +518,7 @@ printf("netbsd32_ioctl(%d, %x, %x): %s group %c base %d len %d\n",
#ifdef NETBSD32_MD_IOCTL
error = netbsd32_md_ioctl(fp, com, data32, l);
#else
error = (*fp->f_ops->fo_ioctl)(fp, com, data32, l);
error = (*fp->f_ops->fo_ioctl)(fp, com, data32);
#endif
break;
}
@ -525,17 +532,16 @@ printf("netbsd32_ioctl(%d, %x, %x): %s group %c base %d len %d\n",
*/
if (error == 0 && (com&IOC_OUT) && size32) {
error = copyout(data32, SCARG_P32(uap, data), size32);
ktrgenio(SCARG(uap, fd), UIO_READ, SCARG_P32(uap, data),
ktrgenio(fd, UIO_READ, SCARG_P32(uap, data),
size32, error);
}
/* if we malloced data, free it here */
if (memp32)
free(memp32, M_IOCTLOPS);
kmem_free(memp32, (size_t)size32);
if (memp)
free(memp, M_IOCTLOPS);
kmem_free(memp, (size_t)size);
out:
FILE_UNUSE(fp, l);
fd_putfile(fd);
return (error);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: netbsd32_ioctl.h,v 1.20 2007/03/16 22:21:41 dsl Exp $ */
/* $NetBSD: netbsd32_ioctl.h,v 1.21 2008/03/21 21:54:58 ad Exp $ */
/*
* Copyright (c) 1998, 2001 Matthew R. Green
@ -32,12 +32,12 @@
#define IOCTL_STRUCT_CONV_TO(cmd, type) \
size = IOCPARM_LEN(cmd); \
if (size > sizeof(stkbuf)) \
data = memp = malloc(size, M_IOCTLOPS, M_WAITOK); \
data = memp = kmem_alloc(size, KM_SLEEP); \
else \
data = (void *)stkbuf; \
__CONCAT(netbsd32_to_, type)((struct __CONCAT(netbsd32_, type) *) \
data32, (struct type *)data, cmd); \
error = (*fp->f_ops->fo_ioctl)(fp, cmd, data, l); \
error = (*fp->f_ops->fo_ioctl)(fp, cmd, data); \
__CONCAT(netbsd32_from_, type)((struct type *)data, \
(struct __CONCAT(netbsd32_, type) *)data32, cmd); \
break

View File

@ -1,4 +1,4 @@
/* $NetBSD: netbsd32_netbsd.c,v 1.142 2008/02/24 15:02:15 martin Exp $ */
/* $NetBSD: netbsd32_netbsd.c,v 1.143 2008/03/21 21:54:58 ad Exp $ */
/*
* Copyright (c) 1998, 2001 Matthew R. Green
@ -29,7 +29,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: netbsd32_netbsd.c,v 1.142 2008/02/24 15:02:15 martin Exp $");
__KERNEL_RCSID(0, "$NetBSD: netbsd32_netbsd.c,v 1.143 2008/03/21 21:54:58 ad Exp $");
#if defined(_KERNEL_OPT)
#include "opt_ddb.h"
@ -2510,8 +2510,8 @@ netbsd32___posix_fadvise50(struct lwp *l,
syscallarg(int) advice;
} */
return do_posix_fadvise(l, SCARG(uap, fd), SCARG(uap, offset),
SCARG(uap, len), SCARG(uap, advice), retval);
return do_posix_fadvise(SCARG(uap, fd), SCARG(uap, offset),
SCARG(uap, len), SCARG(uap, advice));
}
/*

View File

@ -1,4 +1,4 @@
/* $NetBSD: netbsd32_socket.c,v 1.30 2007/12/20 23:03:02 dsl Exp $ */
/* $NetBSD: netbsd32_socket.c,v 1.31 2008/03/21 21:54:58 ad Exp $ */
/*
* Copyright (c) 1998, 2001 Matthew R. Green
@ -29,7 +29,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: netbsd32_socket.c,v 1.30 2007/12/20 23:03:02 dsl Exp $");
__KERNEL_RCSID(0, "$NetBSD: netbsd32_socket.c,v 1.31 2008/03/21 21:54:58 ad Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -98,7 +98,6 @@ done:
int
recvit32(struct lwp *l, int s, struct netbsd32_msghdr *mp, struct iovec *iov, void *namelenp, register_t *retsize)
{
struct file *fp;
struct uio auio;
int i, len, error, iovlen;
struct mbuf *from = 0, *control = 0;
@ -108,7 +107,7 @@ recvit32(struct lwp *l, int s, struct netbsd32_msghdr *mp, struct iovec *iov, vo
p = l->l_proc;
/* getsock() will use the descriptor for us */
if ((error = getsock(p->p_fd, s, &fp)) != 0)
if ((error = fd_getsock(s, &so)) != 0)
return (error);
auio.uio_iov = iov;
auio.uio_iovcnt = mp->msg_iovlen;
@ -143,7 +142,6 @@ recvit32(struct lwp *l, int s, struct netbsd32_msghdr *mp, struct iovec *iov, vo
}
len = auio.uio_resid;
so = (struct socket *)fp->f_data;
error = (*so->so_receive)(so, &from, &auio, NULL,
NETBSD32PTR64(mp->msg_control) ? &control : NULL,
&mp->msg_flags);
@ -213,7 +211,7 @@ recvit32(struct lwp *l, int s, struct netbsd32_msghdr *mp, struct iovec *iov, vo
if (control)
m_freem(control);
out1:
FILE_UNUSE(fp, l);
fd_putfile(s);
return (error);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: osf1_descrip.c,v 1.25 2007/12/20 23:03:02 dsl Exp $ */
/* $NetBSD: osf1_descrip.c,v 1.26 2008/03/21 21:54:58 ad Exp $ */
/*
* Copyright (c) 1999 Christopher G. Demetriou. All rights reserved.
@ -58,7 +58,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: osf1_descrip.c,v 1.25 2007/12/20 23:03:02 dsl Exp $");
__KERNEL_RCSID(0, "$NetBSD: osf1_descrip.c,v 1.26 2008/03/21 21:54:58 ad Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -151,7 +151,7 @@ osf1_sys_fcntl(struct lwp *l, const struct osf1_sys_fcntl_args *uap, register_t
error = osf1_cvt_flock_to_native(&oflock, &nflock);
if (error != 0)
return error;
error = do_fcntl_lock(l, SCARG(uap, fd), SCARG(&a, cmd), &nflock);
error = do_fcntl_lock(SCARG(uap, fd), SCARG(&a, cmd), &nflock);
if (SCARG(&a, cmd) != F_GETLK || error != 0)
return error;
osf1_cvt_flock_from_native(&nflock, &oflock);
@ -216,24 +216,19 @@ osf1_sys_fpathconf(struct lwp *l, const struct osf1_sys_fpathconf_args *uap, reg
int
osf1_sys_fstat(struct lwp *l, const struct osf1_sys_fstat_args *uap, register_t *retval)
{
struct proc *p = l->l_proc;
struct filedesc *fdp = p->p_fd;
struct file *fp;
file_t *fp;
struct stat ub;
struct osf1_stat oub;
int error;
if ((fp = fd_getfile(fdp, SCARG(uap, fd))) == NULL)
if ((fp = fd_getfile(SCARG(uap, fd))) == NULL)
return (EBADF);
FILE_USE(fp);
error = (*fp->f_ops->fo_stat)(fp, &ub, l);
FILE_UNUSE(fp, l);
error = (*fp->f_ops->fo_stat)(fp, &ub);
fd_putfile(SCARG(uap, fd));
osf1_cvt_stat_from_native(&ub, &oub);
if (error == 0)
error = copyout((void *)&oub, (void *)SCARG(uap, sb),
sizeof (oub));
error = copyout(&oub, SCARG(uap, sb), sizeof(oub));
return (error);
}
@ -244,24 +239,19 @@ osf1_sys_fstat(struct lwp *l, const struct osf1_sys_fstat_args *uap, register_t
int
osf1_sys_fstat2(struct lwp *l, const struct osf1_sys_fstat2_args *uap, register_t *retval)
{
struct proc *p = l->l_proc;
struct filedesc *fdp = p->p_fd;
struct file *fp;
file_t *fp;
struct stat ub;
struct osf1_stat2 oub;
int error;
if ((fp = fd_getfile(fdp, SCARG(uap, fd))) == NULL)
if ((fp = fd_getfile(SCARG(uap, fd))) == NULL)
return (EBADF);
FILE_USE(fp);
error = (*fp->f_ops->fo_stat)(fp, &ub, l);
FILE_UNUSE(fp, l);
error = (*fp->f_ops->fo_stat)(fp, &ub);
fd_putfile(SCARG(uap, fd));
osf1_cvt_stat2_from_native(&ub, &oub);
if (error == 0)
error = copyout((void *)&oub, (void *)SCARG(uap, sb),
sizeof (oub));
error = copyout(&oub, SCARG(uap, sb), sizeof(oub));
return (error);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: osf1_file.c,v 1.29 2007/12/20 23:03:02 dsl Exp $ */
/* $NetBSD: osf1_file.c,v 1.30 2008/03/21 21:54:59 ad Exp $ */
/*
* Copyright (c) 1999 Christopher G. Demetriou. All rights reserved.
@ -58,7 +58,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: osf1_file.c,v 1.29 2007/12/20 23:03:02 dsl Exp $");
__KERNEL_RCSID(0, "$NetBSD: osf1_file.c,v 1.30 2008/03/21 21:54:59 ad Exp $");
#if defined(_KERNEL_OPT)
#include "opt_syscall_debug.h"
@ -132,7 +132,7 @@ osf1_sys_lstat(struct lwp *l, const struct osf1_sys_lstat_args *uap, register_t
struct osf1_stat osb;
int error;
error = do_sys_stat(l, SCARG(uap, path), NOFOLLOW, &sb);
error = do_sys_stat(SCARG(uap, path), NOFOLLOW, &sb);
if (error)
return (error);
osf1_cvt_stat_from_native(&sb, &osb);
@ -151,7 +151,7 @@ osf1_sys_lstat2(struct lwp *l, const struct osf1_sys_lstat2_args *uap, register_
struct osf1_stat2 osb;
int error;
error = do_sys_stat(l, SCARG(uap, path), NOFOLLOW, &sb);
error = do_sys_stat(SCARG(uap, path), NOFOLLOW, &sb);
if (error)
return (error);
osf1_cvt_stat2_from_native(&sb, &osb);
@ -229,7 +229,7 @@ osf1_sys_stat(struct lwp *l, const struct osf1_sys_stat_args *uap, register_t *r
struct osf1_stat osb;
int error;
error = do_sys_stat(l, SCARG(uap, path), FOLLOW, &sb);
error = do_sys_stat(SCARG(uap, path), FOLLOW, &sb);
if (error)
return (error);
osf1_cvt_stat_from_native(&sb, &osb);
@ -248,7 +248,7 @@ osf1_sys_stat2(struct lwp *l, const struct osf1_sys_stat2_args *uap, register_t
struct osf1_stat2 osb;
int error;
error = do_sys_stat(l, SCARG(uap, path), FOLLOW, &sb);
error = do_sys_stat(SCARG(uap, path), FOLLOW, &sb);
if (error)
return (error);
osf1_cvt_stat2_from_native(&sb, &osb);

View File

@ -1,4 +1,4 @@
/* $NetBSD: osf1_mount.c,v 1.39 2007/12/20 23:03:03 dsl Exp $ */
/* $NetBSD: osf1_mount.c,v 1.40 2008/03/21 21:54:59 ad Exp $ */
/*
* Copyright (c) 1999 Christopher G. Demetriou. All rights reserved.
@ -58,7 +58,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: osf1_mount.c,v 1.39 2007/12/20 23:03:03 dsl Exp $");
__KERNEL_RCSID(0, "$NetBSD: osf1_mount.c,v 1.40 2008/03/21 21:54:59 ad Exp $");
#if defined(_KERNEL_OPT)
#include "fs_nfs.h"
@ -111,15 +111,14 @@ static int osf1_mount_nfs(struct lwp *, const struct osf1_sys_mount_args *);
int
osf1_sys_fstatfs(struct lwp *l, const struct osf1_sys_fstatfs_args *uap, register_t *retval)
{
struct proc *p = l->l_proc;
struct file *fp;
file_t *fp;
struct mount *mp;
struct statvfs *sp;
struct osf1_statfs osfs;
int error;
/* getvnode() will use the descriptor for us */
if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)))
if ((error = fd_getvnode(SCARG(uap, fd), &fp)))
return (error);
mp = ((struct vnode *)fp->f_data)->v_mount;
sp = &mp->mnt_stat;
@ -130,7 +129,7 @@ osf1_sys_fstatfs(struct lwp *l, const struct osf1_sys_fstatfs_args *uap, registe
error = copyout(&osfs, SCARG(uap, buf), min(sizeof osfs,
SCARG(uap, len)));
out:
FILE_UNUSE(fp, l);
fd_putfile(SCARG(uap, fd));
return (error);
}

View File

@ -1,7 +1,7 @@
/* $NetBSD: ossaudio.c,v 1.61 2007/12/20 23:03:03 dsl Exp $ */
/* $NetBSD: ossaudio.c,v 1.62 2008/03/21 21:54:59 ad Exp $ */
/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
* Copyright (c) 1997, 2008 The NetBSD Foundation, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ossaudio.c,v 1.61 2007/12/20 23:03:03 dsl Exp $");
__KERNEL_RCSID(0, "$NetBSD: ossaudio.c,v 1.62 2008/03/21 21:54:59 ad Exp $");
#include <sys/param.h>
#include <sys/proc.h>
@ -47,7 +47,7 @@ __KERNEL_RCSID(0, "$NetBSD: ossaudio.c,v 1.61 2007/12/20 23:03:03 dsl Exp $");
#include <sys/kernel.h>
#include <sys/audioio.h>
#include <sys/midiio.h>
#include <sys/kauth.h>
#include <sys/syscallargs.h>
#include <compat/ossaudio/ossaudio.h>
@ -63,12 +63,12 @@ int ossdebug = 0;
#define TO_OSSVOL(x) (((x) * 100 + 127) / 255)
#define FROM_OSSVOL(x) ((((x) > 100 ? 100 : (x)) * 255 + 50) / 100)
static struct audiodevinfo *getdevinfo(struct file *, struct lwp *);
static struct audiodevinfo *getdevinfo(file_t *);
static int opaque_to_enum(struct audiodevinfo *di, audio_mixer_name_t *label, int opq);
static int enum_to_ord(struct audiodevinfo *di, int enm);
static int enum_to_mask(struct audiodevinfo *di, int enm);
static void setblocksize(struct file *, struct audio_info *, struct lwp *);
static void setblocksize(file_t *, struct audio_info *);
int
@ -79,9 +79,7 @@ oss_ioctl_audio(struct lwp *l, const struct oss_sys_ioctl_args *uap, register_t
syscallarg(u_long) com;
syscallarg(void *) data;
} */
struct proc *p = l->l_proc;
struct file *fp;
struct filedesc *fdp;
file_t *fp;
u_long com;
struct audio_info tmpinfo;
struct audio_offset tmpoffs;
@ -91,14 +89,11 @@ oss_ioctl_audio(struct lwp *l, const struct oss_sys_ioctl_args *uap, register_t
u_int u;
int idat, idata;
int error = 0;
int (*ioctlf)(struct file *, u_long, void *, struct lwp *);
int (*ioctlf)(file_t *, u_long, void *);
fdp = p->p_fd;
if ((fp = fd_getfile(fdp, SCARG(uap, fd))) == NULL)
if ((fp = fd_getfile(SCARG(uap, fd))) == NULL)
return (EBADF);
FILE_USE(fp);
if ((fp->f_flag & (FREAD | FWRITE)) == 0) {
error = EBADF;
goto out;
@ -112,12 +107,12 @@ oss_ioctl_audio(struct lwp *l, const struct oss_sys_ioctl_args *uap, register_t
ioctlf = fp->f_ops->fo_ioctl;
switch (com) {
case OSS_SNDCTL_DSP_RESET:
error = ioctlf(fp, AUDIO_FLUSH, (void *)0, l);
error = ioctlf(fp, AUDIO_FLUSH, NULL);
if (error)
goto out;
break;
case OSS_SNDCTL_DSP_SYNC:
error = ioctlf(fp, AUDIO_DRAIN, (void *)0, l);
error = ioctlf(fp, AUDIO_DRAIN, NULL);
if (error)
goto out;
break;
@ -131,14 +126,14 @@ oss_ioctl_audio(struct lwp *l, const struct oss_sys_ioctl_args *uap, register_t
goto out;
tmpinfo.play.sample_rate =
tmpinfo.record.sample_rate = idat;
error = ioctlf(fp, AUDIO_SETINFO, (void *)&tmpinfo, l);
error = ioctlf(fp, AUDIO_SETINFO, &tmpinfo);
DPRINTF(("oss_sys_ioctl: SNDCTL_DSP_SPEED %d = %d\n",
idat, error));
if (error)
goto out;
/* fall into ... */
case OSS_SOUND_PCM_READ_RATE:
error = ioctlf(fp, AUDIO_GETBUFINFO, (void *)&tmpinfo, l);
error = ioctlf(fp, AUDIO_GETBUFINFO, &tmpinfo);
if (error)
goto out;
idat = tmpinfo.play.sample_rate;
@ -153,8 +148,8 @@ oss_ioctl_audio(struct lwp *l, const struct oss_sys_ioctl_args *uap, register_t
goto out;
tmpinfo.play.channels =
tmpinfo.record.channels = idat ? 2 : 1;
(void) ioctlf(fp, AUDIO_SETINFO, (void *)&tmpinfo, l);
error = ioctlf(fp, AUDIO_GETBUFINFO, (void *)&tmpinfo, l);
(void) ioctlf(fp, AUDIO_SETINFO, &tmpinfo);
error = ioctlf(fp, AUDIO_GETBUFINFO, &tmpinfo);
if (error)
goto out;
idat = tmpinfo.play.channels - 1;
@ -163,10 +158,10 @@ oss_ioctl_audio(struct lwp *l, const struct oss_sys_ioctl_args *uap, register_t
goto out;
break;
case OSS_SNDCTL_DSP_GETBLKSIZE:
error = ioctlf(fp, AUDIO_GETBUFINFO, (void *)&tmpinfo, l);
error = ioctlf(fp, AUDIO_GETBUFINFO, &tmpinfo);
if (error)
goto out;
setblocksize(fp, &tmpinfo, l);
setblocksize(fp, &tmpinfo);
idat = tmpinfo.blocksize;
error = copyout(&idat, SCARG(uap, data), sizeof idat);
if (error)
@ -230,10 +225,10 @@ oss_ioctl_audio(struct lwp *l, const struct oss_sys_ioctl_args *uap, register_t
error = EINVAL;
goto out;
}
(void) ioctlf(fp, AUDIO_SETINFO, (void *)&tmpinfo, l);
(void) ioctlf(fp, AUDIO_SETINFO, &tmpinfo);
/* fall into ... */
case OSS_SOUND_PCM_READ_BITS:
error = ioctlf(fp, AUDIO_GETBUFINFO, (void *)&tmpinfo, l);
error = ioctlf(fp, AUDIO_GETBUFINFO, &tmpinfo);
if (error)
goto out;
switch (tmpinfo.play.encoding) {
@ -282,10 +277,10 @@ oss_ioctl_audio(struct lwp *l, const struct oss_sys_ioctl_args *uap, register_t
goto out;
tmpinfo.play.channels =
tmpinfo.record.channels = idat;
(void) ioctlf(fp, AUDIO_SETINFO, (void *)&tmpinfo, l);
(void) ioctlf(fp, AUDIO_SETINFO, &tmpinfo);
/* fall into ... */
case OSS_SOUND_PCM_READ_CHANNELS:
error = ioctlf(fp, AUDIO_GETBUFINFO, (void *)&tmpinfo, l);
error = ioctlf(fp, AUDIO_GETBUFINFO, &tmpinfo);
if (error)
goto out;
idat = tmpinfo.play.channels;
@ -301,8 +296,8 @@ oss_ioctl_audio(struct lwp *l, const struct oss_sys_ioctl_args *uap, register_t
error = copyin(SCARG(uap, data), &idat, sizeof idat);
if (error)
goto out;
error = ioctlf(fp, AUDIO_GETBUFINFO, (void *)&tmpinfo, l);
setblocksize(fp, &tmpinfo, l);
error = ioctlf(fp, AUDIO_GETBUFINFO, &tmpinfo);
setblocksize(fp, &tmpinfo);
if (error)
goto out;
if (idat == 0)
@ -310,7 +305,7 @@ oss_ioctl_audio(struct lwp *l, const struct oss_sys_ioctl_args *uap, register_t
idat = (tmpinfo.play.buffer_size / idat) & -4;
AUDIO_INITINFO(&tmpinfo);
tmpinfo.blocksize = idat;
error = ioctlf(fp, AUDIO_SETINFO, (void *)&tmpinfo, l);
error = ioctlf(fp, AUDIO_SETINFO, &tmpinfo);
if (error)
goto out;
idat = tmpinfo.play.buffer_size / tmpinfo.blocksize;
@ -333,8 +328,8 @@ oss_ioctl_audio(struct lwp *l, const struct oss_sys_ioctl_args *uap, register_t
tmpinfo.blocksize, tmpinfo.hiwat));
if (tmpinfo.hiwat == 0) /* 0 means set to max */
tmpinfo.hiwat = 65536;
(void) ioctlf(fp, AUDIO_SETINFO, (void *)&tmpinfo, l);
error = ioctlf(fp, AUDIO_GETBUFINFO, (void *)&tmpinfo, l);
(void) ioctlf(fp, AUDIO_SETINFO, &tmpinfo);
error = ioctlf(fp, AUDIO_GETBUFINFO, &tmpinfo);
if (error)
goto out;
u = tmpinfo.blocksize;
@ -347,7 +342,7 @@ oss_ioctl_audio(struct lwp *l, const struct oss_sys_ioctl_args *uap, register_t
break;
case OSS_SNDCTL_DSP_GETFMTS:
for(idat = 0, tmpenc.index = 0;
ioctlf(fp, AUDIO_GETENC, (void *)&tmpenc, l) == 0;
ioctlf(fp, AUDIO_GETENC, &tmpenc) == 0;
tmpenc.index++) {
switch(tmpenc.encoding) {
case AUDIO_ENCODING_ULAW:
@ -399,10 +394,10 @@ oss_ioctl_audio(struct lwp *l, const struct oss_sys_ioctl_args *uap, register_t
goto out;
break;
case OSS_SNDCTL_DSP_GETOSPACE:
error = ioctlf(fp, AUDIO_GETBUFINFO, (void *)&tmpinfo, l);
error = ioctlf(fp, AUDIO_GETBUFINFO, &tmpinfo);
if (error)
goto out;
setblocksize(fp, &tmpinfo, l);
setblocksize(fp, &tmpinfo);
bufinfo.fragsize = tmpinfo.blocksize;
bufinfo.fragments = tmpinfo.hiwat -
(tmpinfo.play.seek + tmpinfo.blocksize - 1) /
@ -415,10 +410,10 @@ oss_ioctl_audio(struct lwp *l, const struct oss_sys_ioctl_args *uap, register_t
goto out;
break;
case OSS_SNDCTL_DSP_GETISPACE:
error = ioctlf(fp, AUDIO_GETBUFINFO, (void *)&tmpinfo, l);
error = ioctlf(fp, AUDIO_GETBUFINFO, &tmpinfo);
if (error)
goto out;
setblocksize(fp, &tmpinfo, l);
setblocksize(fp, &tmpinfo);
bufinfo.fragsize = tmpinfo.blocksize;
bufinfo.fragments = tmpinfo.hiwat -
(tmpinfo.record.seek + tmpinfo.blocksize - 1) /
@ -435,12 +430,12 @@ oss_ioctl_audio(struct lwp *l, const struct oss_sys_ioctl_args *uap, register_t
break;
case OSS_SNDCTL_DSP_NONBLOCK:
idat = 1;
error = ioctlf(fp, FIONBIO, (void *)&idat, l);
error = ioctlf(fp, FIONBIO, &idat);
if (error)
goto out;
break;
case OSS_SNDCTL_DSP_GETCAPS:
error = ioctlf(fp, AUDIO_GETPROPS, (void *)&idata, l);
error = ioctlf(fp, AUDIO_GETPROPS, &idata);
if (error)
goto out;
idat = OSS_DSP_CAP_TRIGGER; /* pretend we have trigger */
@ -455,7 +450,7 @@ oss_ioctl_audio(struct lwp *l, const struct oss_sys_ioctl_args *uap, register_t
break;
#if 0
case OSS_SNDCTL_DSP_GETTRIGGER:
error = ioctlf(fp, AUDIO_GETBUFINFO, (void *)&tmpinfo, l);
error = ioctlf(fp, AUDIO_GETBUFINFO, &tmpinfo);
if (error)
goto out;
idat = (tmpinfo.play.pause ? 0 : OSS_PCM_ENABLE_OUTPUT) |
@ -465,13 +460,13 @@ oss_ioctl_audio(struct lwp *l, const struct oss_sys_ioctl_args *uap, register_t
goto out;
break;
case OSS_SNDCTL_DSP_SETTRIGGER:
(void) ioctlf(fp, AUDIO_GETBUFINFO, (void *)&tmpinfo, p);
(void) ioctlf(fp, AUDIO_GETBUFINFO, &tmpinfo, p);
error = copyin(SCARG(uap, data), &idat, sizeof idat);
if (error)
goto out;
tmpinfo.play.pause = (idat & OSS_PCM_ENABLE_OUTPUT) == 0;
tmpinfo.record.pause = (idat & OSS_PCM_ENABLE_INPUT) == 0;
(void) ioctlf(fp, AUDIO_SETINFO, (void *)&tmpinfo, l);
(void) ioctlf(fp, AUDIO_SETINFO, &tmpinfo);
error = copyout(&idat, SCARG(uap, data), sizeof idat);
if (error)
goto out;
@ -485,7 +480,7 @@ oss_ioctl_audio(struct lwp *l, const struct oss_sys_ioctl_args *uap, register_t
goto out;
#endif
case OSS_SNDCTL_DSP_GETIPTR:
error = ioctlf(fp, AUDIO_GETIOFFS, (void *)&tmpoffs, l);
error = ioctlf(fp, AUDIO_GETIOFFS, &tmpoffs);
if (error)
goto out;
cntinfo.bytes = tmpoffs.samples;
@ -496,7 +491,7 @@ oss_ioctl_audio(struct lwp *l, const struct oss_sys_ioctl_args *uap, register_t
goto out;
break;
case OSS_SNDCTL_DSP_GETOPTR:
error = ioctlf(fp, AUDIO_GETOOFFS, (void *)&tmpoffs, l);
error = ioctlf(fp, AUDIO_GETOOFFS, &tmpoffs);
if (error)
goto out;
cntinfo.bytes = tmpoffs.samples;
@ -508,7 +503,7 @@ oss_ioctl_audio(struct lwp *l, const struct oss_sys_ioctl_args *uap, register_t
break;
case OSS_SNDCTL_DSP_SETDUPLEX:
idat = 1;
error = ioctlf(fp, AUDIO_SETFD, (void *)&idat, l);
error = ioctlf(fp, AUDIO_SETFD, &idat);
goto out;
case OSS_SNDCTL_DSP_MAPINBUF:
case OSS_SNDCTL_DSP_MAPOUTBUF:
@ -516,7 +511,7 @@ oss_ioctl_audio(struct lwp *l, const struct oss_sys_ioctl_args *uap, register_t
error = EINVAL;
goto out;
case OSS_SNDCTL_DSP_GETODELAY:
error = ioctlf(fp, AUDIO_GETBUFINFO, (void *)&tmpinfo, l);
error = ioctlf(fp, AUDIO_GETBUFINFO, &tmpinfo);
if (error)
goto out;
idat = tmpinfo.play.seek + tmpinfo.blocksize / 2;
@ -535,7 +530,7 @@ oss_ioctl_audio(struct lwp *l, const struct oss_sys_ioctl_args *uap, register_t
}
out:
FILE_UNUSE(fp, l);
fd_putfile(SCARG(uap, fd));
return error;
}
@ -605,7 +600,7 @@ enum_to_mask(struct audiodevinfo *di, int enm)
* to collect the information.
*/
static struct audiodevinfo *
getdevinfo(struct file *fp, struct lwp *l)
getdevinfo(file_t *fp)
{
mixer_devinfo_t mi;
int i, j, e;
@ -635,8 +630,7 @@ getdevinfo(struct file *fp, struct lwp *l)
/* { AudioNmixerout, ?? },*/
{ 0, -1 }
};
int (*ioctlf)(struct file *, u_long, void *, struct lwp *) =
fp->f_ops->fo_ioctl;
int (*ioctlf)(file_t *, u_long, void *) = fp->f_ops->fo_ioctl;
struct vnode *vp;
struct vattr va;
static struct audiodevinfo devcache;
@ -647,10 +641,10 @@ getdevinfo(struct file *fp, struct lwp *l)
* Figure out what device it is so we can check if the
* cached data is valid.
*/
vp = (struct vnode *)fp->f_data;
vp = fp->f_data;
if (vp->v_type != VCHR)
return 0;
if (VOP_GETATTR(vp, &va, l->l_cred))
if (VOP_GETATTR(vp, &va, kauth_cred_get()))
return 0;
if (di->done && di->dev == va.va_rdev)
return di;
@ -671,7 +665,7 @@ getdevinfo(struct file *fp, struct lwp *l)
}
for(i = 0; i < NETBSD_MAXDEVS; i++) {
mi.index = i;
if (ioctlf(fp, AUDIO_MIXER_DEVINFO, (void *)&mi, l) < 0)
if (ioctlf(fp, AUDIO_MIXER_DEVINFO, &mi) < 0)
break;
switch(mi.type) {
case AUDIO_MIXER_VALUE:
@ -699,7 +693,7 @@ getdevinfo(struct file *fp, struct lwp *l)
}
for(i = 0; i < NETBSD_MAXDEVS; i++) {
mi.index = i;
if (ioctlf(fp, AUDIO_MIXER_DEVINFO, (void *)&mi, l) < 0)
if (ioctlf(fp, AUDIO_MIXER_DEVINFO, &mi) < 0)
break;
if (strcmp(mi.label.name, AudioNsource) != 0)
continue;
@ -737,9 +731,7 @@ oss_ioctl_mixer(struct lwp *lwp, const struct oss_sys_ioctl_args *uap, register_
syscallarg(u_long) com;
syscallarg(void *) data;
} */
struct proc *p = lwp->l_proc;
struct file *fp;
struct filedesc *fdp;
file_t *fp;
u_long com;
struct audiodevinfo *di;
mixer_ctrl_t mc;
@ -749,14 +741,11 @@ oss_ioctl_mixer(struct lwp *lwp, const struct oss_sys_ioctl_args *uap, register_
int i;
int error;
int l, r, n, e;
int (*ioctlf)(struct file *, u_long, void *, struct lwp *);
int (*ioctlf)(file_t *, u_long, void *);
fdp = p->p_fd;
if ((fp = fd_getfile(fdp, SCARG(uap, fd))) == NULL)
if ((fp = fd_getfile(SCARG(uap, fd))) == NULL)
return (EBADF);
FILE_USE(fp);
if ((fp->f_flag & (FREAD | FWRITE)) == 0) {
error = EBADF;
goto out;
@ -767,7 +756,7 @@ oss_ioctl_mixer(struct lwp *lwp, const struct oss_sys_ioctl_args *uap, register_
retval[0] = 0;
di = getdevinfo(fp, lwp);
di = getdevinfo(fp);
if (di == 0) {
error = EINVAL;
goto out;
@ -780,7 +769,7 @@ oss_ioctl_mixer(struct lwp *lwp, const struct oss_sys_ioctl_args *uap, register_
break;
case OSS_SOUND_MIXER_INFO:
case OSS_SOUND_OLD_MIXER_INFO:
error = ioctlf(fp, AUDIO_GETDEV, (void *)&adev, lwp);
error = ioctlf(fp, AUDIO_GETDEV, &adev);
if (error)
goto out;
omi.modify_counter = 1;
@ -796,7 +785,7 @@ oss_ioctl_mixer(struct lwp *lwp, const struct oss_sys_ioctl_args *uap, register_
mc.dev = di->source;
if (di->caps & OSS_SOUND_CAP_EXCL_INPUT) {
mc.type = AUDIO_MIXER_ENUM;
error = ioctlf(fp, AUDIO_MIXER_READ, (void *)&mc, lwp);
error = ioctlf(fp, AUDIO_MIXER_READ, &mc);
if (error)
goto out;
e = opaque_to_enum(di, NULL, mc.un.ord);
@ -804,7 +793,7 @@ oss_ioctl_mixer(struct lwp *lwp, const struct oss_sys_ioctl_args *uap, register_
idat = 1 << di->rdevmap[e];
} else {
mc.type = AUDIO_MIXER_SET;
error = ioctlf(fp, AUDIO_MIXER_READ, (void *)&mc, lwp);
error = ioctlf(fp, AUDIO_MIXER_READ, &mc);
if (error)
goto out;
e = opaque_to_enum(di, NULL, mc.un.mask);
@ -858,7 +847,7 @@ oss_ioctl_mixer(struct lwp *lwp, const struct oss_sys_ioctl_args *uap, register_
}
}
}
error = ioctlf(fp, AUDIO_MIXER_WRITE, (void *)&mc, lwp);
error = ioctlf(fp, AUDIO_MIXER_WRITE, &mc);
goto out;
default:
if (OSS_MIXER_READ(OSS_SOUND_MIXER_FIRST) <= com &&
@ -872,7 +861,7 @@ oss_ioctl_mixer(struct lwp *lwp, const struct oss_sys_ioctl_args *uap, register_
mc.dev = di->devmap[n];
mc.type = AUDIO_MIXER_VALUE;
mc.un.value.num_channels = di->stereomask & (1<<n) ? 2 : 1;
error = ioctlf(fp, AUDIO_MIXER_READ, (void *)&mc, lwp);
error = ioctlf(fp, AUDIO_MIXER_READ, &mc);
if (error)
goto out;
if (mc.un.value.num_channels != 2) {
@ -911,7 +900,7 @@ oss_ioctl_mixer(struct lwp *lwp, const struct oss_sys_ioctl_args *uap, register_
}
DPRINTF(("OSS_MIXER_WRITE n=%d (dev=%d) l=%d, r=%d, idat=%04x\n",
n, di->devmap[n], l, r, idat));
error = ioctlf(fp, AUDIO_MIXER_WRITE, (void *)&mc, lwp);
error = ioctlf(fp, AUDIO_MIXER_WRITE, &mc);
if (error)
goto out;
if (OSS_MIXER_WRITE(OSS_SOUND_MIXER_FIRST) <= com &&
@ -930,7 +919,7 @@ oss_ioctl_mixer(struct lwp *lwp, const struct oss_sys_ioctl_args *uap, register_
}
error = copyout(&idat, SCARG(uap, data), sizeof idat);
out:
FILE_UNUSE(fp, lwp);
fd_putfile(SCARG(uap, fd));
return error;
}
@ -943,23 +932,18 @@ oss_ioctl_sequencer(struct lwp *l, const struct oss_sys_ioctl_args *uap, registe
syscallarg(u_long) com;
syscallarg(void *) data;
} */
struct proc *p = l->l_proc;
struct file *fp;
struct filedesc *fdp;
file_t *fp;
u_long com;
int idat, idat1;
struct synth_info si;
struct oss_synth_info osi;
struct oss_seq_event_rec oser;
int error;
int (*ioctlf)(struct file *, u_long, void *, struct lwp *);
int (*ioctlf)(file_t *, u_long, void *);
fdp = p->p_fd;
if ((fp = fd_getfile(fdp, SCARG(uap, fd))) == NULL)
if ((fp = fd_getfile(SCARG(uap, fd))) == NULL)
return (EBADF);
FILE_USE(fp);
if ((fp->f_flag & (FREAD | FWRITE)) == 0) {
error = EBADF;
goto out;
@ -973,17 +957,17 @@ oss_ioctl_sequencer(struct lwp *l, const struct oss_sys_ioctl_args *uap, registe
ioctlf = fp->f_ops->fo_ioctl;
switch (com) {
case OSS_SEQ_RESET:
error = ioctlf(fp, SEQUENCER_RESET, (void *)&idat, l);
error = ioctlf(fp, SEQUENCER_RESET, &idat);
goto out;
case OSS_SEQ_SYNC:
error = ioctlf(fp, SEQUENCER_SYNC, (void *)&idat, l);
error = ioctlf(fp, SEQUENCER_SYNC, &idat);
goto out;
case OSS_SYNTH_INFO:
error = copyin(SCARG(uap, data), &osi, sizeof osi);
if (error)
goto out;
si.device = osi.device;
error = ioctlf(fp, SEQUENCER_INFO, (void *)&si, l);
error = ioctlf(fp, SEQUENCER_INFO, &si);
if (error)
goto out;
strncpy(osi.name, si.name, sizeof osi.name);
@ -1025,31 +1009,31 @@ oss_ioctl_sequencer(struct lwp *l, const struct oss_sys_ioctl_args *uap, registe
error = copyin(SCARG(uap, data), &idat, sizeof idat);
if (error)
goto out;
error = ioctlf(fp, SEQUENCER_CTRLRATE, (void *)&idat, l);
error = ioctlf(fp, SEQUENCER_CTRLRATE, &idat);
if (error)
goto out;
retval[0] = idat;
break;
case OSS_SEQ_GETOUTCOUNT:
error = ioctlf(fp, SEQUENCER_GETOUTCOUNT, (void *)&idat, l);
error = ioctlf(fp, SEQUENCER_GETOUTCOUNT, &idat);
if (error)
goto out;
retval[0] = idat;
break;
case OSS_SEQ_GETINCOUNT:
error = ioctlf(fp, SEQUENCER_GETINCOUNT, (void *)&idat, l);
error = ioctlf(fp, SEQUENCER_GETINCOUNT, &idat);
if (error)
goto out;
retval[0] = idat;
break;
case OSS_SEQ_NRSYNTHS:
error = ioctlf(fp, SEQUENCER_NRSYNTHS, (void *)&idat, l);
error = ioctlf(fp, SEQUENCER_NRSYNTHS, &idat);
if (error)
goto out;
retval[0] = idat;
break;
case OSS_SEQ_NRMIDIS:
error = ioctlf(fp, SEQUENCER_NRMIDIS, (void *)&idat, l);
error = ioctlf(fp, SEQUENCER_NRMIDIS, &idat);
if (error)
goto out;
retval[0] = idat;
@ -1058,30 +1042,30 @@ oss_ioctl_sequencer(struct lwp *l, const struct oss_sys_ioctl_args *uap, registe
error = copyin(SCARG(uap, data), &idat, sizeof idat);
if (error)
goto out;
error = ioctlf(fp, SEQUENCER_THRESHOLD, (void *)&idat, l);
error = ioctlf(fp, SEQUENCER_THRESHOLD, &idat);
goto out;
case OSS_MEMAVL:
error = copyin(SCARG(uap, data), &idat, sizeof idat);
if (error)
goto out;
error = ioctlf(fp, SEQUENCER_MEMAVL, (void *)&idat, l);
error = ioctlf(fp, SEQUENCER_MEMAVL, &idat);
if (error)
goto out;
retval[0] = idat;
break;
case OSS_SEQ_PANIC:
error = ioctlf(fp, SEQUENCER_PANIC, (void *)&idat, l);
error = ioctlf(fp, SEQUENCER_PANIC, &idat);
goto out;
case OSS_SEQ_OUTOFBAND:
error = copyin(SCARG(uap, data), &oser, sizeof oser);
if (error)
goto out;
error = ioctlf(fp, SEQUENCER_OUTOFBAND, (void *)&oser, l);
error = ioctlf(fp, SEQUENCER_OUTOFBAND, &oser);
if (error)
goto out;
break;
case OSS_SEQ_GETTIME:
error = ioctlf(fp, SEQUENCER_GETTIME, (void *)&idat, l);
error = ioctlf(fp, SEQUENCER_GETTIME, &idat);
if (error)
goto out;
retval[0] = idat;
@ -1090,25 +1074,25 @@ oss_ioctl_sequencer(struct lwp *l, const struct oss_sys_ioctl_args *uap, registe
error = copyin(SCARG(uap, data), &idat, sizeof idat);
if (error)
goto out;
error = ioctlf(fp, SEQUENCER_TMR_TIMEBASE, (void *)&idat, l);
error = ioctlf(fp, SEQUENCER_TMR_TIMEBASE, &idat);
if (error)
goto out;
retval[0] = idat;
break;
case OSS_TMR_START:
error = ioctlf(fp, SEQUENCER_TMR_START, (void *)&idat, l);
error = ioctlf(fp, SEQUENCER_TMR_START, &idat);
goto out;
case OSS_TMR_STOP:
error = ioctlf(fp, SEQUENCER_TMR_STOP, (void *)&idat, l);
error = ioctlf(fp, SEQUENCER_TMR_STOP, &idat);
goto out;
case OSS_TMR_CONTINUE:
error = ioctlf(fp, SEQUENCER_TMR_CONTINUE, (void *)&idat, l);
error = ioctlf(fp, SEQUENCER_TMR_CONTINUE, &idat);
goto out;
case OSS_TMR_TEMPO:
error = copyin(SCARG(uap, data), &idat, sizeof idat);
if (error)
goto out;
error = ioctlf(fp, SEQUENCER_TMR_TEMPO, (void *)&idat, l);
error = ioctlf(fp, SEQUENCER_TMR_TEMPO, &idat);
if (error)
goto out;
retval[0] = idat;
@ -1119,7 +1103,7 @@ oss_ioctl_sequencer(struct lwp *l, const struct oss_sys_ioctl_args *uap, registe
goto out;
idat = 0;
if (idat1 & OSS_TMR_INTERNAL) idat |= SEQUENCER_TMR_INTERNAL;
error = ioctlf(fp, SEQUENCER_TMR_SOURCE, (void *)&idat, l);
error = ioctlf(fp, SEQUENCER_TMR_SOURCE, &idat);
if (error)
goto out;
idat1 = idat;
@ -1130,14 +1114,14 @@ oss_ioctl_sequencer(struct lwp *l, const struct oss_sys_ioctl_args *uap, registe
error = copyin(SCARG(uap, data), &idat, sizeof idat);
if (error)
goto out;
error = ioctlf(fp, SEQUENCER_TMR_METRONOME, (void *)&idat, l);
error = ioctlf(fp, SEQUENCER_TMR_METRONOME, &idat);
goto out;
case OSS_TMR_SELECT:
error = copyin(SCARG(uap, data), &idat, sizeof idat);
if (error)
goto out;
retval[0] = idat;
error = ioctlf(fp, SEQUENCER_TMR_SELECT, (void *)&idat, l);
error = ioctlf(fp, SEQUENCER_TMR_SELECT, &idat);
goto out;
default:
error = EINVAL;
@ -1146,7 +1130,7 @@ oss_ioctl_sequencer(struct lwp *l, const struct oss_sys_ioctl_args *uap, registe
error = copyout(&idat, SCARG(uap, data), sizeof idat);
out:
FILE_UNUSE(fp, l);
fd_putfile(SCARG(uap, fd));
return error;
}
@ -1155,7 +1139,7 @@ oss_ioctl_sequencer(struct lwp *l, const struct oss_sys_ioctl_args *uap, registe
* If not, set it to be.
*/
static void
setblocksize(struct file *fp, struct audio_info *info, struct lwp *l)
setblocksize(file_t *fp, struct audio_info *info)
{
struct audio_info set;
int s;
@ -1165,7 +1149,7 @@ setblocksize(struct file *fp, struct audio_info *info, struct lwp *l)
;
AUDIO_INITINFO(&set);
set.blocksize = s;
fp->f_ops->fo_ioctl(fp, AUDIO_SETINFO, (void *)&set, l);
fp->f_ops->fo_ioctl(fp, AUDIO_GETBUFINFO, (void *)info, l);
fp->f_ops->fo_ioctl(fp, AUDIO_SETINFO, &set);
fp->f_ops->fo_ioctl(fp, AUDIO_GETBUFINFO, info);
}
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: sunos_ioctl.c,v 1.59 2007/12/20 23:03:04 dsl Exp $ */
/* $NetBSD: sunos_ioctl.c,v 1.60 2008/03/21 21:54:59 ad Exp $ */
/*
* Copyright (c) 1993 Markus Wild.
@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: sunos_ioctl.c,v 1.59 2007/12/20 23:03:04 dsl Exp $");
__KERNEL_RCSID(0, "$NetBSD: sunos_ioctl.c,v 1.60 2008/03/21 21:54:59 ad Exp $");
#if defined(_KERNEL_OPT)
#include "opt_execfmt.h"
@ -403,18 +403,14 @@ sunos_sys_ioctl(struct lwp *l, const struct sunos_sys_ioctl_args *uap, register_
u_long com;
void * data;
} */
struct proc *p = l->l_proc;
struct filedesc *fdp = p->p_fd;
struct file *fp;
int (*ctl)(struct file *, u_long, void *, struct lwp *);
file_t *fp;
int (*ctl)(struct file *, u_long, void *);
struct sys_ioctl_args pass_ua;
int error;
if ((fp = fd_getfile(fdp, SCARG(uap, fd))) == NULL)
if ((fp = fd_getfile(SCARG(uap, fd))) == NULL)
return EBADF;
FILE_USE(fp);
if ((fp->f_flag & (FREAD|FWRITE)) == 0) {
error = EBADF;
goto out;
@ -445,7 +441,7 @@ sunos_sys_ioctl(struct lwp *l, const struct sunos_sys_ioctl_args *uap, register_
break;
}
error = (*ctl)(fp, TIOCSETD, (void *)&disc, l);
error = (*ctl)(fp, TIOCSETD, &disc);
}
case _IOW('t', 101, int): /* sun SUNOS_TIOCSSOFTCAR */
{
@ -464,7 +460,7 @@ sunos_sys_ioctl(struct lwp *l, const struct sunos_sys_ioctl_args *uap, register_
case _IO('t', 36): /* sun TIOCCONS, no parameters */
{
int on = 1;
error = (*ctl)(fp, TIOCCONS, (void *)&on, l);
error = (*ctl)(fp, TIOCCONS, &on);
break;
}
case _IOW('t', 37, struct sunos_ttysize):
@ -472,7 +468,7 @@ sunos_sys_ioctl(struct lwp *l, const struct sunos_sys_ioctl_args *uap, register_
struct winsize ws;
struct sunos_ttysize ss;
if ((error = (*ctl)(fp, TIOCGWINSZ, (void *)&ws, l)) != 0)
if ((error = (*ctl)(fp, TIOCGWINSZ, &ws)) != 0)
break;
if ((error = copyin (SCARG(uap, data), &ss, sizeof (ss))) != 0)
@ -481,7 +477,7 @@ sunos_sys_ioctl(struct lwp *l, const struct sunos_sys_ioctl_args *uap, register_
ws.ws_row = ss.ts_row;
ws.ws_col = ss.ts_col;
error = (*ctl)(fp, TIOCSWINSZ, (void *)&ws, l);
error = (*ctl)(fp, TIOCSWINSZ, &ws);
break;
}
case _IOW('t', 38, struct sunos_ttysize):
@ -489,7 +485,7 @@ sunos_sys_ioctl(struct lwp *l, const struct sunos_sys_ioctl_args *uap, register_
struct winsize ws;
struct sunos_ttysize ss;
if ((error = (*ctl)(fp, TIOCGWINSZ, (void *)&ws, l)) != 0)
if ((error = (*ctl)(fp, TIOCGWINSZ, &ws)) != 0)
break;
ss.ts_row = ws.ws_row;
@ -502,7 +498,7 @@ sunos_sys_ioctl(struct lwp *l, const struct sunos_sys_ioctl_args *uap, register_
{
int pgrp;
error = (*ctl)(fp, TIOCGPGRP, (void *)&pgrp, l);
error = (*ctl)(fp, TIOCGPGRP, &pgrp);
if (error == 0 && pgrp == 0)
error = EIO;
if (error)
@ -523,7 +519,7 @@ sunos_sys_ioctl(struct lwp *l, const struct sunos_sys_ioctl_args *uap, register_
int pgrp;
struct vnode *vp;
error = (*ctl)(fp, TIOCGPGRP, (void *)&pgrp, l);
error = (*ctl)(fp, TIOCGPGRP, &pgrp);
if (error) {
vp = (struct vnode *)fp->f_data;
if ((error == EIO || (error == 0 && pgrp == 0)) &&
@ -546,7 +542,7 @@ sunos_sys_ioctl(struct lwp *l, const struct sunos_sys_ioctl_args *uap, register_
struct sunos_termios sts;
struct sunos_termio st;
if ((error = (*ctl)(fp, TIOCGETA, (void *)&bts, l)) != 0)
if ((error = (*ctl)(fp, TIOCGETA, &bts)) != 0)
break;
btios2stios (&bts, &sts);
@ -567,12 +563,11 @@ sunos_sys_ioctl(struct lwp *l, const struct sunos_sys_ioctl_args *uap, register_
struct sunos_termios sts;
struct sunos_termio st;
if ((error = copyin(SCARG(uap, data), (void *)&st,
sizeof (st))) != 0)
if ((error = copyin(SCARG(uap, data), &st, sizeof (st))) != 0)
break;
/* get full BSD termios so we don't lose information */
if ((error = (*ctl)(fp, TIOCGETA, (void *)&bts, l)) != 0)
if ((error = (*ctl)(fp, TIOCGETA, &bts)) != 0)
break;
/*
@ -584,7 +579,7 @@ sunos_sys_ioctl(struct lwp *l, const struct sunos_sys_ioctl_args *uap, register_
stios2btios(&sts, &bts);
error = (*ctl)(fp, SCARG(uap, com) - SUNOS_TCSETA + TIOCSETA,
(void *)&bts, l);
&bts);
break;
}
case SUNOS_TCSETS:
@ -599,7 +594,7 @@ sunos_sys_ioctl(struct lwp *l, const struct sunos_sys_ioctl_args *uap, register_
break;
stios2btios (&sts, &bts);
error = (*ctl)(fp, SCARG(uap, com) - SUNOS_TCSETS + TIOCSETA,
(void *)&bts, l);
&bts);
break;
}
/*
@ -611,7 +606,7 @@ sunos_sys_ioctl(struct lwp *l, const struct sunos_sys_ioctl_args *uap, register_
error = copyin (SCARG(uap, data), (void *)&on, sizeof (on));
if (error)
break;
error = (*ctl)(fp, TIOCUCNTL, (void *)&on, l);
error = (*ctl)(fp, TIOCUCNTL, &on);
break;
}
case _IOW('t', 33, int): { /* TIOCSIGNAL */
@ -620,7 +615,7 @@ sunos_sys_ioctl(struct lwp *l, const struct sunos_sys_ioctl_args *uap, register_
error = copyin (SCARG(uap, data), (void *)&sig, sizeof (sig));
if (error)
break;
error = (*ctl)(fp, TIOCSIG, (void *)&sig, l);
error = (*ctl)(fp, TIOCSIG, &sig);
break;
}
@ -632,7 +627,7 @@ sunos_sys_ioctl(struct lwp *l, const struct sunos_sys_ioctl_args *uap, register_
error = copyin (SCARG(uap, data), (void *)&ifreq, sizeof (ifreq)); \
if (error) \
break; \
error = (*ctl)(fp, a, (void *)&ifreq, l); \
error = (*ctl)(fp, a, &ifreq); \
break; \
}
#define IFREQ_INOUT(a) { \
@ -640,7 +635,7 @@ sunos_sys_ioctl(struct lwp *l, const struct sunos_sys_ioctl_args *uap, register_
error = copyin (SCARG(uap, data), (void *)&ifreq, sizeof (ifreq)); \
if (error) \
break; \
if ((error = (*ctl)(fp, a, (void *)&ifreq, l)) != 0) \
if ((error = (*ctl)(fp, a, &ifreq)) != 0) \
break; \
error = copyout ((void *)&ifreq, SCARG(uap, data), sizeof (ifreq)); \
break; \
@ -708,11 +703,10 @@ sunos_sys_ioctl(struct lwp *l, const struct sunos_sys_ioctl_args *uap, register_
* 1. our sockaddr's are variable length, not always sizeof(sockaddr)
* 2. this returns a name per protocol, ie. it returns two "lo0"'s
*/
error = copyin (SCARG(uap, data), (void *)&ifc,
sizeof (ifc));
error = copyin (SCARG(uap, data), &ifc, sizeof (ifc));
if (error)
break;
error = (*ctl)(fp, OOSIOCGIFCONF, (void *)&ifc, l);
error = (*ctl)(fp, OOSIOCGIFCONF, &ifc);
if (error)
break;
error = copyout ((void *)&ifc, SCARG(uap, data),
@ -729,7 +723,7 @@ sunos_sys_ioctl(struct lwp *l, const struct sunos_sys_ioctl_args *uap, register_
struct audio_info aui;
struct sunos_audio_info sunos_aui;
error = (*ctl)(fp, AUDIO_GETINFO, (void *)&aui, l);
error = (*ctl)(fp, AUDIO_GETINFO, &aui);
if (error)
break;
@ -793,14 +787,14 @@ sunos_sys_ioctl(struct lwp *l, const struct sunos_sys_ioctl_args *uap, register_
sunos_aui.record.active != (u_char)~0)
aui.record.pause = 1;
error = (*ctl)(fp, AUDIO_SETINFO, (void *)&aui, l);
error = (*ctl)(fp, AUDIO_SETINFO, &aui);
if (error)
break;
/* Return new state */
goto sunos_au_getinfo;
}
case _IO('A', 3): /* AUDIO_DRAIN */
error = (*ctl)(fp, AUDIO_DRAIN, (void *)0, l);
error = (*ctl)(fp, AUDIO_DRAIN, NULL);
break;
case _IOR('A', 4, int): /* AUDIO_GETDEV */
{
@ -830,7 +824,7 @@ sunos_sys_ioctl(struct lwp *l, const struct sunos_sys_ioctl_args *uap, register_
case SUNOS_S_FLUSHW: tmp = FWRITE;
case SUNOS_S_FLUSHRW: tmp = FREAD|FWRITE;
}
error = (*ctl)(fp, TIOCFLUSH, (void *)&tmp, l);
error = (*ctl)(fp, TIOCFLUSH, &tmp);
break;
}
case _IO('S', 9): /* I_SETSIG */
@ -841,7 +835,7 @@ sunos_sys_ioctl(struct lwp *l, const struct sunos_sys_ioctl_args *uap, register_
error = EOPNOTSUPP;
break;
}
error = (*ctl)(fp, FIOASYNC, (void *)&on, l);
error = (*ctl)(fp, FIOASYNC, &on);
break;
}
/*
@ -853,7 +847,7 @@ sunos_sys_ioctl(struct lwp *l, const struct sunos_sys_ioctl_args *uap, register_
{
struct disklabel dl;
error = (*ctl)(fp, DIOCGDINFO, (void *)&dl, l);
error = (*ctl)(fp, DIOCGDINFO, &dl);
if (error)
break;
@ -881,7 +875,7 @@ sunos_sys_ioctl(struct lwp *l, const struct sunos_sys_ioctl_args *uap, register_
{
struct partinfo pi;
error = (*ctl)(fp, DIOCGPART, (void *)&pi, l);
error = (*ctl)(fp, DIOCGPART, &pi);
if (error)
break;
@ -904,7 +898,7 @@ sunos_sys_ioctl(struct lwp *l, const struct sunos_sys_ioctl_args *uap, register_
}
out:
FILE_UNUSE(fp, l);
fd_putfile(SCARG(uap, fd));
if (error == EPASSTHROUGH) {
SCARG(&pass_ua, fd) = SCARG(uap, fd);
SCARG(&pass_ua, data) = SCARG(uap, data);
@ -1045,7 +1039,7 @@ sunos_sys_fcntl(struct lwp *l, const struct sunos_sys_fcntl_args *uap, register_
return error;
sunos_to_bsd_flock(&ifl, &fl);
error = do_fcntl_lock(l, SCARG(uap, fd), SCARG(uap, cmd), &fl);
error = do_fcntl_lock(SCARG(uap, fd), SCARG(uap, cmd), &fl);
if (error)
return error;

View File

@ -1,4 +1,4 @@
/* $NetBSD: sunos_misc.c,v 1.158 2007/12/27 17:05:28 martin Exp $ */
/* $NetBSD: sunos_misc.c,v 1.159 2008/03/21 21:54:59 ad Exp $ */
/*
* Copyright (c) 1992, 1993
@ -50,7 +50,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: sunos_misc.c,v 1.158 2007/12/27 17:05:28 martin Exp $");
__KERNEL_RCSID(0, "$NetBSD: sunos_misc.c,v 1.159 2008/03/21 21:54:59 ad Exp $");
#if defined(_KERNEL_OPT)
#include "opt_nfsserver.h"
@ -366,7 +366,6 @@ sunos_sys_sigsuspend(struct lwp *l, const struct sunos_sys_sigsuspend_args *uap,
int
sunos_sys_getdents(struct lwp *l, const struct sunos_sys_getdents_args *uap, register_t *retval)
{
struct proc *p = l->l_proc;
struct dirent *bdp;
struct vnode *vp;
char *inp, *buf; /* BSD-format */
@ -382,8 +381,7 @@ sunos_sys_getdents(struct lwp *l, const struct sunos_sys_getdents_args *uap, reg
off_t *cookiebuf, *cookie;
int ncookies;
/* getvnode() will use the descriptor for us */
if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0)
if ((error = fd_getvnode(SCARG(uap, fd), &fp)) != 0)
return (error);
if ((fp->f_flag & FREAD) == 0) {
@ -391,7 +389,7 @@ sunos_sys_getdents(struct lwp *l, const struct sunos_sys_getdents_args *uap, reg
goto out1;
}
vp = (struct vnode *)fp->f_data;
vp = fp->f_data;
if (vp->v_type != VDIR) {
error = EINVAL;
goto out1;
@ -484,7 +482,7 @@ out:
free(cookiebuf, M_TEMP);
free(buf, M_TEMP);
out1:
FILE_UNUSE(fp, l);
fd_putfile(SCARG(uap, fd));
return (error);
}
@ -538,22 +536,20 @@ sunos_sys_mctl(struct lwp *l, const struct sunos_sys_mctl_args *uap, register_t
int
sunos_sys_setsockopt(struct lwp *l, const struct sunos_sys_setsockopt_args *uap, register_t *retval)
{
struct proc *p = l->l_proc;
struct file *fp;
struct socket *so;
struct mbuf *m = NULL;
int name = SCARG(uap, name);
int error;
/* getsock() will use the descriptor for us */
if ((error = getsock(p->p_fd, SCARG(uap, s), &fp)) != 0)
if ((error = fd_getsock(SCARG(uap, s), &so)) != 0)
return (error);
#define SO_DONTLINGER (~SO_LINGER)
if (name == SO_DONTLINGER) {
m = m_get(M_WAIT, MT_SOOPTS);
mtod(m, struct linger *)->l_onoff = 0;
m->m_len = sizeof(struct linger);
error = sosetopt((struct socket *)fp->f_data, SCARG(uap, level),
SO_LINGER, m);
error = sosetopt(so, SCARG(uap, level), SO_LINGER, m);
goto out;
}
if (SCARG(uap, level) == IPPROTO_IP) {
@ -588,10 +584,9 @@ sunos_sys_setsockopt(struct lwp *l, const struct sunos_sys_setsockopt_args *uap,
}
m->m_len = SCARG(uap, valsize);
}
error = sosetopt((struct socket *)fp->f_data, SCARG(uap, level),
name, m);
error = sosetopt(so, SCARG(uap, level), name, m);
out:
FILE_UNUSE(fp, l);
fd_putfile(SCARG(uap, s));
return (error);
}
@ -601,17 +596,15 @@ static inline int
sunos_sys_socket_common(struct lwp *l, register_t *retval, int type)
{
struct socket *so;
struct file *fp;
int error, fd;
/* getsock() will use the descriptor for us */
fd = (int)*retval;
if ((error = getsock(l->l_proc->p_fd, fd, &fp)) == 0) {
so = (struct socket *)fp->f_data;
if ((error = fd_getsock(fd, &so)) == 0) {
if (type == SOCK_DGRAM)
so->so_options |= SO_BROADCAST;
fd_putfile(fd);
}
FILE_UNUSE(fp, l);
return (error);
}
@ -719,17 +712,17 @@ sunos_sys_open(struct lwp *l, const struct sunos_sys_open_args *uap, register_t
/* XXXSMP */
if (!ret && !noctty && SESS_LEADER(p) && !(p->p_lflag & PL_CONTROLT)) {
struct filedesc *fdp = p->p_fd;
struct file *fp;
file_t *fp;
int fd;
fp = fd_getfile(fdp, *retval);
fd = (int)*retval;
fp = fd_getfile(fd);
/* ignore any error, just give it a try */
if (fp != NULL) {
FILE_USE(fp);
if (fp->f_type == DTYPE_VNODE)
(fp->f_ops->fo_ioctl)(fp, TIOCSCTTY, NULL, l);
FILE_UNUSE(fp, l);
(fp->f_ops->fo_ioctl)(fp, TIOCSCTTY, NULL);
fd_putfile(fd);
}
}
return ret;
@ -855,14 +848,13 @@ sunos_sys_statfs(struct lwp *l, const struct sunos_sys_statfs_args *uap, registe
int
sunos_sys_fstatfs(struct lwp *l, const struct sunos_sys_fstatfs_args *uap, register_t *retval)
{
struct proc *p = l->l_proc;
struct file *fp;
file_t *fp;
struct mount *mp;
struct statvfs *sp;
int error;
/* getvnode() will use the descriptor for us */
if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0)
if ((error = fd_getvnode(SCARG(uap, fd), &fp)) != 0)
return (error);
mp = ((struct vnode *)fp->f_data)->v_mount;
sp = &mp->mnt_stat;
@ -871,7 +863,7 @@ sunos_sys_fstatfs(struct lwp *l, const struct sunos_sys_fstatfs_args *uap, regis
sp->f_flag = mp->mnt_flag & MNT_VISFLAGMASK;
error = sunstatfs(sp, (void *)SCARG(uap, buf));
out:
FILE_UNUSE(fp, l);
fd_putfile(SCARG(uap, fd));
return (error);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: sunos32_ioctl.c,v 1.27 2008/01/05 19:14:08 dsl Exp $ */
/* $NetBSD: sunos32_ioctl.c,v 1.28 2008/03/21 21:54:59 ad Exp $ */
/* from: NetBSD: sunos_ioctl.c,v 1.35 2001/02/03 22:20:02 mrg Exp */
/*
@ -56,7 +56,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: sunos32_ioctl.c,v 1.27 2008/01/05 19:14:08 dsl Exp $");
__KERNEL_RCSID(0, "$NetBSD: sunos32_ioctl.c,v 1.28 2008/03/21 21:54:59 ad Exp $");
#if defined(_KERNEL_OPT)
#include "opt_compat_netbsd32.h"
@ -433,26 +433,23 @@ stio2stios(struct sunos_termio *t, struct sunos_termios *ts)
static int
sunos32_do_ioctl(int fd, int cmd, void *arg, struct lwp *l)
{
struct file *fp;
file_t *fp;
struct vnode *vp;
int error;
if ((fp = fd_getfile(l->l_proc->p_fd, fd)) == NULL)
if ((fp = fd_getfile(fd)) == NULL)
return EBADF;
if ((fp->f_flag & (FREAD|FWRITE)) == 0) {
FILE_UNLOCK(fp);
fd_putfile(fd);
return EBADF;
}
FILE_USE(fp);
error = fp->f_ops->fo_ioctl(fp, cmd, arg, l);
error = fp->f_ops->fo_ioctl(fp, cmd, arg);
if (error == EIO && cmd == TIOCGPGRP) {
vp = (struct vnode *)fp->f_data;
if (vp != NULL && vp->v_type == VCHR && major(vp->v_rdev) == 21)
error = ENOTTY;
}
FILE_UNUSE(fp, l);
fd_putfile(fd);
return error;
}
@ -1060,7 +1057,7 @@ sunos32_sys_fcntl(struct lwp *l, const struct sunos32_sys_fcntl_args *uap, regis
return error;
sunos_to_bsd_flock(&ifl, &fl);
error = do_fcntl_lock(l, SCARG(uap, fd), SCARG(uap, cmd), &fl);
error = do_fcntl_lock(SCARG(uap, fd), SCARG(uap, cmd), &fl);
if (error || SCARG(uap, cmd) != F_GETLK)
return error;

View File

@ -1,4 +1,4 @@
/* $NetBSD: sunos32_misc.c,v 1.58 2008/01/05 19:14:08 dsl Exp $ */
/* $NetBSD: sunos32_misc.c,v 1.59 2008/03/21 21:54:59 ad Exp $ */
/* from :NetBSD: sunos_misc.c,v 1.107 2000/12/01 19:25:10 jdolecek Exp */
/*
@ -79,7 +79,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: sunos32_misc.c,v 1.58 2008/01/05 19:14:08 dsl Exp $");
__KERNEL_RCSID(0, "$NetBSD: sunos32_misc.c,v 1.59 2008/03/21 21:54:59 ad Exp $");
#define COMPAT_SUNOS 1
@ -284,7 +284,7 @@ sunos32_sys_stat(struct lwp *l, const struct sunos32_sys_stat_args *uap, registe
path = SCARG_P32(uap, path);
error = do_sys_stat(l, path, FOLLOW, &sb);
error = do_sys_stat(path, FOLLOW, &sb);
if (error)
return (error);
sunos32_from___stat13(&sb, &sb32);
@ -336,18 +336,18 @@ again:
else
vput(dvp);
}
error = vn_stat(vp, &sb, l);
error = vn_stat(vp, &sb);
vput(vp);
if (error)
return (error);
} else {
error = vn_stat(dvp, &sb, l);
error = vn_stat(dvp, &sb);
vput(dvp);
if (error) {
vput(vp);
return (error);
}
error = vn_stat(vp, &sb1, l);
error = vn_stat(vp, &sb1);
vput(vp);
if (error)
return (error);
@ -608,7 +608,6 @@ sunos32_sys_getdents(struct lwp *l, const struct sunos32_sys_getdents_args *uap,
syscallarg(netbsd32_charp) buf;
syscallarg(int) nbytes;
} */
struct proc *p = l->l_proc;
struct dirent *bdp;
struct vnode *vp;
char *inp, *sbuf; /* BSD-format */
@ -625,7 +624,7 @@ sunos32_sys_getdents(struct lwp *l, const struct sunos32_sys_getdents_args *uap,
int ncookies;
/* getvnode() will use the descriptor for us */
if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0)
if ((error = fd_getvnode(SCARG(uap, fd), &fp)) != 0)
return (error);
if ((fp->f_flag & FREAD) == 0) {
@ -633,7 +632,7 @@ sunos32_sys_getdents(struct lwp *l, const struct sunos32_sys_getdents_args *uap,
goto out1;
}
vp = (struct vnode *)fp->f_data;
vp = fp->f_data;
if (vp->v_type != VDIR) {
error = EINVAL;
goto out1;
@ -726,7 +725,7 @@ out:
free(cookiebuf, M_TEMP);
free(sbuf, M_TEMP);
out1:
FILE_UNUSE(fp, l);
fd_putfile(SCARG(uap, fd));
return (error);
}
@ -809,22 +808,20 @@ sunos32_sys_setsockopt(struct lwp *l, const struct sunos32_sys_setsockopt_args *
syscallarg(netbsd32_caddr_t) val;
syscallarg(int) valsize;
} */
struct proc *p = l->l_proc;
struct file *fp;
struct socket *so;
struct mbuf *m = NULL;
int name = SCARG(uap, name);
int error;
/* getsock() will use the descriptor for us */
if ((error = getsock(p->p_fd, SCARG(uap, s), &fp)) != 0)
if ((error = fd_getsock(SCARG(uap, s), &so)) != 0)
return (error);
#define SO_DONTLINGER (~SO_LINGER)
if (name == SO_DONTLINGER) {
m = m_get(M_WAIT, MT_SOOPTS);
mtod(m, struct linger *)->l_onoff = 0;
m->m_len = sizeof(struct linger);
error = sosetopt((struct socket *)fp->f_data, SCARG(uap, level),
SO_LINGER, m);
error = sosetopt(so, SCARG(uap, level), SO_LINGER, m);
goto out;
}
if (SCARG(uap, level) == IPPROTO_IP) {
@ -859,10 +856,9 @@ sunos32_sys_setsockopt(struct lwp *l, const struct sunos32_sys_setsockopt_args *
}
m->m_len = SCARG(uap, valsize);
}
error = sosetopt((struct socket *)fp->f_data, SCARG(uap, level),
name, m);
error = sosetopt(so, SCARG(uap, level), name, m);
out:
FILE_UNUSE(fp, l);
fd_putfile(SCARG(uap, s));
return (error);
}
@ -872,18 +868,15 @@ static inline int
sunos32_sys_socket_common(struct lwp *l, register_t *retval, int type)
{
struct socket *so;
struct proc *p = l->l_proc;
struct file *fp;
int error, fd;
/* getsock() will use the descriptor for us */
fd = (int)*retval;
if ((error = getsock(p->p_fd, fd, &fp)) == 0) {
so = (struct socket *)fp->f_data;
if ((error = fd_getsock(fd, &so)) == 0) {
if (type == SOCK_DGRAM)
so->so_options |= SO_BROADCAST;
fd_putfile(fd);
}
FILE_UNUSE(fp, l);
return (error);
}
@ -1004,17 +997,17 @@ sunos32_sys_open(struct lwp *l, const struct sunos32_sys_open_args *uap, registe
/* XXXSMP unlocked */
if (!ret && !noctty && SESS_LEADER(p) && !(p->p_lflag & PL_CONTROLT)) {
struct filedesc *fdp = p->p_fd;
struct file *fp;
file_t *fp;
int fd;
fp = fd_getfile(fdp, *retval);
fd = (int)*retval;
fp = fd_getfile(fd);
/* ignore any error, just give it a try */
if (fp != NULL) {
FILE_USE(fp);
if (fp->f_type == DTYPE_VNODE)
(fp->f_ops->fo_ioctl)(fp, TIOCSCTTY, (void *)0, l);
FILE_UNUSE(fp, l);
(fp->f_ops->fo_ioctl)(fp, TIOCSCTTY, NULL);
fd_putfile(fd);
}
}
return ret;
@ -1154,14 +1147,13 @@ sunos32_sys_fstatfs(struct lwp *l, const struct sunos32_sys_fstatfs_args *uap, r
syscallarg(int) fd;
syscallarg(sunos32_statfsp_t) buf;
} */
struct proc *p = l->l_proc;
struct file *fp;
file_t *fp;
struct mount *mp;
struct statvfs *sp;
int error;
/* getvnode() will use the descriptor for us */
if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0)
if ((error = fd_getvnode(SCARG(uap, fd), &fp)) != 0)
return (error);
mp = ((struct vnode *)fp->f_data)->v_mount;
sp = &mp->mnt_stat;
@ -1170,7 +1162,7 @@ sunos32_sys_fstatfs(struct lwp *l, const struct sunos32_sys_fstatfs_args *uap, r
sp->f_flag = mp->mnt_flag & MNT_VISFLAGMASK;
error = sunstatfs(sp, SCARG_P32(uap, buf));
out:
FILE_UNUSE(fp, l);
fd_putfile(SCARG(uap, fd));
return (error);
}

View File

@ -1,7 +1,7 @@
/* $NetBSD: svr4_fcntl.c,v 1.68 2008/01/09 13:24:57 gson Exp $ */
/* $NetBSD: svr4_fcntl.c,v 1.69 2008/03/21 21:54:59 ad Exp $ */
/*-
* Copyright (c) 1994, 1997 The NetBSD Foundation, Inc.
* Copyright (c) 1994, 1997, 2008 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: svr4_fcntl.c,v 1.68 2008/01/09 13:24:57 gson Exp $");
__KERNEL_RCSID(0, "$NetBSD: svr4_fcntl.c,v 1.69 2008/03/21 21:54:59 ad Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -223,21 +223,19 @@ svr4_to_bsd_flock64(struct svr4_flock64 *iflp, struct flock *oflp)
static int
fd_revoke(struct lwp *l, int fd, register_t *retval)
{
struct filedesc *fdp = l->l_proc->p_fd;
struct file *fp;
struct vnode *vp;
file_t *fp;
vnode_t *vp;
int error;
if ((fp = fd_getfile(fdp, fd)) == NULL)
if ((fp = fd_getfile(fd)) == NULL)
return EBADF;
if (fp->f_type != DTYPE_VNODE) {
FILE_UNLOCK(fp);
fd_putfile(fd);
return EINVAL;
}
vp = (struct vnode *) fp->f_data;
FILE_USE(fp);
vp = (vnode_t *) fp->f_data;
if (vp->v_type != VCHR && vp->v_type != VBLK) {
error = EINVAL;
goto out;
@ -246,7 +244,7 @@ fd_revoke(struct lwp *l, int fd, register_t *retval)
error = dorevoke(vp, l->l_cred);
out:
vrele(vp);
FILE_UNUSE(fp, l);
fd_putfile(fd);
return error;
}
@ -254,10 +252,9 @@ out:
static int
fd_truncate(struct lwp *l, int fd, struct flock *flp, register_t *retval)
{
struct filedesc *fdp = l->l_proc->p_fd;
struct file *fp;
file_t *fp;
off_t start, length;
struct vnode *vp;
vnode_t *vp;
struct vattr vattr;
int error;
struct sys_ftruncate_args ft;
@ -265,17 +262,16 @@ fd_truncate(struct lwp *l, int fd, struct flock *flp, register_t *retval)
/*
* We only support truncating the file.
*/
if ((fp = fd_getfile(fdp, fd)) == NULL)
if ((fp = fd_getfile(fd)) == NULL)
return EBADF;
vp = (struct vnode *)fp->f_data;
vp = fp->f_data;
if (fp->f_type != DTYPE_VNODE || vp->v_type == VFIFO) {
FILE_UNLOCK(fp);
fd_putfile(fd);
return ESPIPE;
}
FILE_USE(fp);
if ((error = VOP_GETATTR(vp, &vattr, l->l_cred)) != 0) {
FILE_UNUSE(fp, l);
fd_putfile(fd);
return error;
}
@ -295,13 +291,13 @@ fd_truncate(struct lwp *l, int fd, struct flock *flp, register_t *retval)
break;
default:
FILE_UNUSE(fp, l);
fd_putfile(fd);
return EINVAL;
}
if (start + flp->l_len < length) {
/* We don't support free'ing in the middle of the file */
FILE_UNUSE(fp, l);
fd_putfile(fd);
return EINVAL;
}
@ -309,7 +305,7 @@ fd_truncate(struct lwp *l, int fd, struct flock *flp, register_t *retval)
SCARG(&ft, length) = start;
error = sys_ftruncate(l, &ft, retval);
FILE_UNUSE(fp, l);
fd_putfile(fd);
return error;
}
@ -333,17 +329,14 @@ svr4_sys_open(struct lwp *l, const struct svr4_sys_open_args *uap, register_t *r
if (!(SCARG(&cup, flags) & O_NOCTTY) && SESS_LEADER(l->l_proc) &&
!(l->l_proc->p_lflag & PL_CONTROLT)) {
struct filedesc *fdp = l->l_proc->p_fd;
struct file *fp;
fp = fd_getfile(fdp, *retval);
file_t *fp;
fp = fd_getfile(*retval);
/* ignore any error, just give it a try */
if (fp != NULL) {
FILE_USE(fp);
if (fp->f_type == DTYPE_VNODE)
(fp->f_ops->fo_ioctl)(fp, TIOCSCTTY, NULL, l);
FILE_UNUSE(fp, l);
(fp->f_ops->fo_ioctl)(fp, TIOCSCTTY, NULL);
fd_putfile(*retval);
}
}
return 0;
@ -537,7 +530,7 @@ svr4_sys_fcntl(struct lwp *l, const struct svr4_sys_fcntl_args *uap, register_t
return error;
svr4_to_bsd_flock(&ifl, &fl);
error = do_fcntl_lock(l, SCARG(uap, fd), cmd, &fl);
error = do_fcntl_lock(SCARG(uap, fd), cmd, &fl);
if (cmd != F_GETLK || error != 0)
return error;
@ -578,7 +571,7 @@ svr4_sys_fcntl(struct lwp *l, const struct svr4_sys_fcntl_args *uap, register_t
return error;
svr4_to_bsd_flock64(&ifl64, &fl);
error = do_fcntl_lock(l, SCARG(uap, fd), cmd, &fl);
error = do_fcntl_lock(SCARG(uap, fd), cmd, &fl);
if (cmd != F_GETLK || error != 0)
return error;

View File

@ -1,7 +1,7 @@
/* $NetBSD: svr4_filio.c,v 1.19 2008/01/05 19:14:08 dsl Exp $ */
/* $NetBSD: svr4_filio.c,v 1.20 2008/03/21 21:54:59 ad Exp $ */
/*-
* Copyright (c) 1994 The NetBSD Foundation, Inc.
* Copyright (c) 1994, 2008 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: svr4_filio.c,v 1.19 2008/01/05 19:14:08 dsl Exp $");
__KERNEL_RCSID(0, "$NetBSD: svr4_filio.c,v 1.20 2008/03/21 21:54:59 ad Exp $");
#include <sys/param.h>
#include <sys/proc.h>
@ -66,39 +66,38 @@ __KERNEL_RCSID(0, "$NetBSD: svr4_filio.c,v 1.19 2008/01/05 19:14:08 dsl Exp $");
int
svr4_fil_ioctl(struct file *fp, struct lwp *l, register_t *retval, int fd, u_long cmd, void *data)
svr4_fil_ioctl(file_t *fp, struct lwp *l, register_t *retval, int fd, u_long cmd, void *data)
{
struct proc *p = l->l_proc;
int error;
int num;
struct filedesc *fdp = p->p_fd;
int (*ctl)(struct file *, u_long, void *, struct lwp *) =
fp->f_ops->fo_ioctl;
filedesc_t *fdp = p->p_fd;
fdfile_t *ff;
int (*ctl)(file_t *, u_long, void *) = fp->f_ops->fo_ioctl;
*retval = 0;
error = 0;
if ((fp = fd_getfile(fdp, fd)) == NULL)
if ((fp = fd_getfile(fd)) == NULL)
return EBADF;
ff = fdp->fd_ofiles[fd];
switch (cmd) {
case SVR4_FIOCLEX:
fdp->fd_ofileflags[fd] |= UF_EXCLOSE;
FILE_UNLOCK(fp);
return 0;
ff->ff_exclose = 1;
fdp->fd_exclose = 1;
break;
case SVR4_FIONCLEX:
fdp->fd_ofileflags[fd] &= ~UF_EXCLOSE;
FILE_UNLOCK(fp);
return 0;
ff->ff_exclose = 0;
break;
case SVR4_FIOGETOWN:
case SVR4_FIOSETOWN:
case SVR4_FIOASYNC:
case SVR4_FIONBIO:
case SVR4_FIONREAD:
if ((error = copyin(data, &num, sizeof(num))) != 0) {
FILE_UNLOCK(fp);
return error;
}
if ((error = copyin(data, &num, sizeof(num))) != 0)
break;
switch (cmd) {
case SVR4_FIOGETOWN: cmd = FIOGETOWN; break;
@ -108,18 +107,15 @@ svr4_fil_ioctl(struct file *fp, struct lwp *l, register_t *retval, int fd, u_lon
case SVR4_FIONREAD: cmd = FIONREAD; break;
}
FILE_USE(fp);
error = (*ctl)(fp, cmd, (void *) &num, l);
FILE_UNUSE(fp, l);
if (error)
return error;
return copyout(&num, data, sizeof(num));
error = (*ctl)(fp, cmd, &num);
if (error == 0)
error = copyout(&num, data, sizeof(num));
break;
default:
FILE_UNLOCK(fp);
DPRINTF(("Unknown svr4 filio %lx\n", cmd));
return 0; /* ENOSYS really */
break;
}
fd_putfile(fd);
return error;
}

View File

@ -1,7 +1,7 @@
/* $NetBSD: svr4_ioctl.c,v 1.33 2007/12/20 23:03:05 dsl Exp $ */
/* $NetBSD: svr4_ioctl.c,v 1.34 2008/03/21 21:54:59 ad Exp $ */
/*-
* Copyright (c) 1994 The NetBSD Foundation, Inc.
* Copyright (c) 1994, 2008 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: svr4_ioctl.c,v 1.33 2007/12/20 23:03:05 dsl Exp $");
__KERNEL_RCSID(0, "$NetBSD: svr4_ioctl.c,v 1.34 2008/03/21 21:54:59 ad Exp $");
#include <sys/param.h>
#include <sys/proc.h>
@ -100,13 +100,10 @@ svr4_decode_cmd(cmd, dir, c, num, argsiz)
int
svr4_sys_ioctl(struct lwp *l, const struct svr4_sys_ioctl_args *uap, register_t *retval)
{
struct proc *p = l->l_proc;
struct file *fp;
struct filedesc *fdp;
file_t *fp;
u_long cmd;
int error;
int (*fun)(struct file *, struct lwp *, register_t *,
int, u_long, void *);
int (*fun)(file_t *, struct lwp *, register_t *, int, u_long, void *);
#ifdef DEBUG_SVR4
char dir[4];
char c;
@ -118,14 +115,11 @@ svr4_sys_ioctl(struct lwp *l, const struct svr4_sys_ioctl_args *uap, register_t
uprintf("svr4_ioctl(%d, _IO%s(%c, %d, %d), %p);\n", SCARG(uap, fd),
dir, c, num, argsiz, SCARG(uap, data));
#endif
fdp = p->p_fd;
cmd = SCARG(uap, com);
if ((fp = fd_getfile(fdp, SCARG(uap, fd))) == NULL)
if ((fp = fd_getfile(SCARG(uap, fd))) == NULL)
return EBADF;
FILE_USE(fp);
if ((fp->f_flag & (FREAD | FWRITE)) == 0) {
error = EBADF;
goto out;
@ -165,6 +159,6 @@ svr4_sys_ioctl(struct lwp *l, const struct svr4_sys_ioctl_args *uap, register_t
error = (*fun)(fp, l, retval, SCARG(uap, fd), cmd, SCARG(uap, data));
out:
FILE_UNUSE(fp, l);
fd_putfile(SCARG(uap, fd));
return (error);
}

View File

@ -1,7 +1,7 @@
/* $NetBSD: svr4_misc.c,v 1.137 2007/12/26 16:01:35 ad Exp $ */
/* $NetBSD: svr4_misc.c,v 1.138 2008/03/21 21:54:59 ad Exp $ */
/*-
* Copyright (c) 1994 The NetBSD Foundation, Inc.
* Copyright (c) 1994, 2008 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@ -44,7 +44,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: svr4_misc.c,v 1.137 2007/12/26 16:01:35 ad Exp $");
__KERNEL_RCSID(0, "$NetBSD: svr4_misc.c,v 1.138 2008/03/21 21:54:59 ad Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -212,7 +212,6 @@ svr4_sys_time(struct lwp *l, const struct svr4_sys_time_args *uap, register_t *r
int
svr4_sys_getdents64(struct lwp *l, const struct svr4_sys_getdents64_args *uap, register_t *retval)
{
struct proc *p = l->l_proc;
struct dirent *bdp;
struct vnode *vp;
char *inp, *tbuf; /* BSD-format */
@ -229,7 +228,7 @@ svr4_sys_getdents64(struct lwp *l, const struct svr4_sys_getdents64_args *uap, r
int ncookies;
/* getvnode() will use the descriptor for us */
if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0)
if ((error = getvnode(SCARG(uap, fd), &fp)) != 0)
return (error);
if ((fp->f_flag & FREAD) == 0) {
@ -325,7 +324,7 @@ out:
free(cookiebuf, M_TEMP);
free(tbuf, M_TEMP);
out1:
FILE_UNUSE(fp, l);
fd_putfile(SCARG(uap, fd));
return error;
}
@ -333,7 +332,6 @@ out:
int
svr4_sys_getdents(struct lwp *l, const struct svr4_sys_getdents_args *uap, register_t *retval)
{
struct proc *p = l->l_proc;
struct dirent *bdp;
struct vnode *vp;
char *inp, *tbuf; /* BSD-format */
@ -350,7 +348,7 @@ svr4_sys_getdents(struct lwp *l, const struct svr4_sys_getdents_args *uap, regis
int ncookies;
/* getvnode() will use the descriptor for us */
if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0)
if ((error = getvnode(SCARG(uap, fd), &fp)) != 0)
return (error);
if ((fp->f_flag & FREAD) == 0) {
@ -447,7 +445,7 @@ out:
free(cookiebuf, M_TEMP);
free(tbuf, M_TEMP);
out1:
FILE_UNUSE(fp, l);
fd_putfile(SCARG(uap, fd));
return error;
}

View File

@ -1,7 +1,7 @@
/* $NetBSD: svr4_net.c,v 1.50 2007/12/08 18:36:25 dsl Exp $ */
/* $NetBSD: svr4_net.c,v 1.51 2008/03/21 21:54:59 ad Exp $ */
/*-
* Copyright (c) 1994 The NetBSD Foundation, Inc.
* Copyright (c) 1994, 2008 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@ -41,7 +41,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: svr4_net.c,v 1.50 2007/12/08 18:36:25 dsl Exp $");
__KERNEL_RCSID(0, "$NetBSD: svr4_net.c,v 1.51 2008/03/21 21:54:59 ad Exp $");
#define COMPAT_SVR4 1
@ -104,7 +104,7 @@ enum {
int svr4_netattach(int);
int svr4_soo_close(struct file *, struct lwp *);
int svr4_soo_close(file_t *);
static const struct fileops svr4_netops = {
soo_read, soo_write, soo_ioctl, soo_fcntl, soo_poll,
@ -125,10 +125,9 @@ svr4_netattach(int n)
int
svr4_netopen(dev_t dev, int flag, int mode, struct lwp *l)
{
struct proc *p = l->l_proc;
int type, protocol;
int fd;
struct file *fp;
file_t *fp;
struct socket *so;
int error;
int family;
@ -188,19 +187,16 @@ svr4_netopen(dev_t dev, int flag, int mode, struct lwp *l)
return EOPNOTSUPP;
}
/* falloc() will use the descriptor for us */
if ((error = falloc(l, &fp, &fd)) != 0)
if ((error = fd_allocfile(&fp, &fd)) != 0)
return error;
if ((error = socreate(family, &so, type, protocol, l)) != 0) {
DPRINTF(("socreate error %d\n", error));
fdremove(p->p_fd, fd);
FILE_UNUSE(fp, NULL);
ffree(fp);
fd_abort(curproc, fp, fd);
return error;
}
error = fdclone(l, fp, fd, flag, &svr4_netops, so);
error = fd_clone(fp, fd, flag, &svr4_netops, so);
fp->f_type = DTYPE_SOCKET;
(void)svr4_stream_get(fp);
@ -210,18 +206,18 @@ svr4_netopen(dev_t dev, int flag, int mode, struct lwp *l)
int
svr4_soo_close(struct file *fp, struct lwp *l)
svr4_soo_close(file_t *fp)
{
struct socket *so = (struct socket *) fp->f_data;
struct socket *so = fp->f_data;
svr4_delete_socket(l->l_proc, fp);
svr4_delete_socket(curproc, fp);
free(so->so_internal, M_NETADDR);
return soo_close(fp, l);
return soo_close(fp);
}
struct svr4_strm *
svr4_stream_get(struct file *fp)
svr4_stream_get(file_t *fp)
{
struct socket *so;
struct svr4_strm *st;
@ -229,7 +225,7 @@ svr4_stream_get(struct file *fp)
if (fp == NULL || fp->f_type != DTYPE_SOCKET)
return NULL;
so = (struct socket *) fp->f_data;
so = fp->f_data;
if (so->so_internal)
return so->so_internal;

View File

@ -1,7 +1,7 @@
/* $NetBSD: svr4_sockio.c,v 1.33 2007/12/08 18:36:26 dsl Exp $ */
/* $NetBSD: svr4_sockio.c,v 1.34 2008/03/21 21:54:59 ad Exp $ */
/*-
* Copyright (c) 1995 The NetBSD Foundation, Inc.
* Copyright (c) 1995, 2008 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: svr4_sockio.c,v 1.33 2007/12/08 18:36:26 dsl Exp $");
__KERNEL_RCSID(0, "$NetBSD: svr4_sockio.c,v 1.34 2008/03/21 21:54:59 ad Exp $");
#include <sys/param.h>
#include <sys/proc.h>
@ -103,12 +103,11 @@ svr4_count_ifnum(struct ifnet *ifp)
}
int
svr4_sock_ioctl(struct file *fp, struct lwp *l, register_t *retval,
svr4_sock_ioctl(file_t *fp, struct lwp *l, register_t *retval,
int fd, u_long cmd, void *data)
{
int error;
int (*ctl)(struct file *, u_long, void *, struct lwp *) =
fp->f_ops->fo_ioctl;
int (*ctl)(file_t *, u_long, void *) = fp->f_ops->fo_ioctl;
*retval = 0;
@ -168,8 +167,7 @@ svr4_sock_ioctl(struct file *fp, struct lwp *l, register_t *retval,
(void) strncpy(br.ifr_name, sr.svr4_ifr_name,
sizeof(br.ifr_name));
if ((error = (*ctl)(fp, SIOCGIFFLAGS,
(void *) &br, l)) != 0) {
if ((error = (*ctl)(fp, SIOCGIFFLAGS, &br)) != 0) {
DPRINTF(("SIOCGIFFLAGS %s: error %d\n",
sr.svr4_ifr_name, error));
return error;
@ -193,8 +191,7 @@ svr4_sock_ioctl(struct file *fp, struct lwp *l, register_t *retval,
(unsigned long)sizeof(struct svr4_ifreq),
sc.svr4_ifc_len));
if ((error = (*ctl)(fp, OOSIOCGIFCONF,
(void *) &sc, l)) != 0)
if ((error = (*ctl)(fp, OOSIOCGIFCONF, &sc)) != 0)
return error;
DPRINTF(("SIOCGIFCONF\n"));

View File

@ -1,7 +1,7 @@
/* $NetBSD: svr4_stat.c,v 1.66 2007/12/20 23:03:05 dsl Exp $ */
/* $NetBSD: svr4_stat.c,v 1.67 2008/03/21 21:54:59 ad Exp $ */
/*-
* Copyright (c) 1994 The NetBSD Foundation, Inc.
* Copyright (c) 1994, 2008 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: svr4_stat.c,v 1.66 2007/12/20 23:03:05 dsl Exp $");
__KERNEL_RCSID(0, "$NetBSD: svr4_stat.c,v 1.67 2008/03/21 21:54:59 ad Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -186,7 +186,7 @@ svr4_sys_stat(struct lwp *l, const struct svr4_sys_stat_args *uap, register_t *r
struct svr4_stat svr4_st;
int error;
error = do_sys_stat(l, SCARG(uap, path), FOLLOW, &st);
error = do_sys_stat(SCARG(uap, path), FOLLOW, &st);
if (error != 0)
return error;
@ -215,7 +215,7 @@ svr4_sys_lstat(struct lwp *l, const struct svr4_sys_lstat_args *uap, register_t
struct svr4_stat svr4_st;
int error;
error = do_sys_stat(l, SCARG(uap, path), NOFOLLOW, &st);
error = do_sys_stat(SCARG(uap, path), NOFOLLOW, &st);
if (error != 0)
return error;
@ -244,7 +244,7 @@ svr4_sys_fstat(struct lwp *l, const struct svr4_sys_fstat_args *uap, register_t
struct svr4_stat svr4_st;
int error;
error = do_sys_fstat(l, SCARG(uap, fd), &st);
error = do_sys_fstat(SCARG(uap, fd), &st);
if (error != 0)
return error;
@ -262,7 +262,7 @@ svr4_sys_xstat(struct lwp *l, const struct svr4_sys_xstat_args *uap, register_t
struct svr4_xstat svr4_st;
int error;
error = do_sys_stat(l, SCARG(uap, path), FOLLOW, &st);
error = do_sys_stat(SCARG(uap, path), FOLLOW, &st);
if (error != 0)
return error;
@ -282,7 +282,7 @@ svr4_sys_lxstat(struct lwp *l, const struct svr4_sys_lxstat_args *uap, register_
struct svr4_xstat svr4_st;
int error;
error = do_sys_stat(l, SCARG(uap, path), NOFOLLOW, &st);
error = do_sys_stat(SCARG(uap, path), NOFOLLOW, &st);
if (error != 0)
return error;
@ -302,7 +302,7 @@ svr4_sys_fxstat(struct lwp *l, const struct svr4_sys_fxstat_args *uap, register_
struct svr4_xstat svr4_st;
int error;
error = do_sys_fstat(l, SCARG(uap, fd), &st);
error = do_sys_fstat(SCARG(uap, fd), &st);
if (error != 0)
return error;
@ -319,7 +319,7 @@ svr4_sys_stat64(struct lwp *l, const struct svr4_sys_stat64_args *uap, register_
struct svr4_stat64 svr4_st;
int error;
error = do_sys_stat(l, SCARG(uap, path), FOLLOW, &st);
error = do_sys_stat(SCARG(uap, path), FOLLOW, &st);
if (error != 0)
return error;
@ -339,7 +339,7 @@ svr4_sys_lstat64(struct lwp *l, const struct svr4_sys_lstat64_args *uap, registe
struct svr4_stat64 svr4_st;
int error;
error = do_sys_stat(l, SCARG(uap, path), NOFOLLOW, &st);
error = do_sys_stat(SCARG(uap, path), NOFOLLOW, &st);
if (error != 0)
return error;
@ -359,7 +359,7 @@ svr4_sys_fstat64(struct lwp *l, const struct svr4_sys_fstat64_args *uap, registe
struct stat st;
int error;
error = do_sys_fstat(l, SCARG(uap, fd), &st);
error = do_sys_fstat(SCARG(uap, fd), &st);
if (error != 0)
return error;

View File

@ -1,7 +1,7 @@
/* $NetBSD: svr4_stream.c,v 1.74 2008/01/05 19:14:08 dsl Exp $ */
/* $NetBSD: svr4_stream.c,v 1.75 2008/03/21 21:54:59 ad Exp $ */
/*-
* Copyright (c) 1994 The NetBSD Foundation, Inc.
* Copyright (c) 1994, 2008 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@ -46,7 +46,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: svr4_stream.c,v 1.74 2008/01/05 19:14:08 dsl Exp $");
__KERNEL_RCSID(0, "$NetBSD: svr4_stream.c,v 1.75 2008/03/21 21:54:59 ad Exp $");
#include <sys/param.h>
#include <sys/kernel.h>
@ -126,7 +126,7 @@ __KERNEL_RCSID(0, "$NetBSD: svr4_stream.c,v 1.74 2008/01/05 19:14:08 dsl Exp $")
/* Utils */
static int clean_pipe(struct lwp *, const char *);
static void getparm(struct file *, struct svr4_si_sockparms *);
static void getparm(file_t *, struct svr4_si_sockparms *);
/* Address Conversions */
static void sockaddr_to_netaddr_in(struct svr4_strmcmd *,
@ -139,41 +139,41 @@ static void netaddr_to_sockaddr_un(struct sockaddr_un *,
const struct svr4_strmcmd *);
/* stream ioctls */
static int i_nread(struct file *, struct lwp *, register_t *, int,
static int i_nread(file_t *, struct lwp *, register_t *, int,
u_long, void *);
static int i_fdinsert(struct file *, struct lwp *, register_t *, int,
static int i_fdinsert(file_t *, struct lwp *, register_t *, int,
u_long, void *);
static int i_str(struct file *, struct lwp *, register_t *, int,
static int i_str(file_t *, struct lwp *, register_t *, int,
u_long, void *);
static int i_setsig(struct file *, struct lwp *, register_t *, int,
static int i_setsig(file_t *, struct lwp *, register_t *, int,
u_long, void *);
static int i_getsig(struct file *, struct lwp *, register_t *, int,
static int i_getsig(file_t *, struct lwp *, register_t *, int,
u_long, void *);
static int _i_bind_rsvd(struct file *, struct lwp *, register_t *, int,
static int _i_bind_rsvd(file_t *, struct lwp *, register_t *, int,
u_long, void *);
static int _i_rele_rsvd(struct file *, struct lwp *, register_t *, int,
static int _i_rele_rsvd(file_t *, struct lwp *, register_t *, int,
u_long, void *);
/* i_str sockmod calls */
static int sockmod(struct file *, int, struct svr4_strioctl *,
static int sockmod(file_t *, int, struct svr4_strioctl *,
struct lwp *);
static int si_listen(struct file *, int, struct svr4_strioctl *,
static int si_listen(file_t *, int, struct svr4_strioctl *,
struct lwp *);
static int si_ogetudata(struct file *, int, struct svr4_strioctl *,
static int si_ogetudata(file_t *, int, struct svr4_strioctl *,
struct lwp *);
static int si_sockparams(struct file *, int, struct svr4_strioctl *,
static int si_sockparams(file_t *, int, struct svr4_strioctl *,
struct lwp *);
static int si_shutdown(struct file *, int, struct svr4_strioctl *,
static int si_shutdown(file_t *, int, struct svr4_strioctl *,
struct lwp *);
static int si_getudata(struct file *, int, struct svr4_strioctl *,
static int si_getudata(file_t *, int, struct svr4_strioctl *,
struct lwp *);
/* i_str timod calls */
static int timod(struct file *, int, struct svr4_strioctl *,
static int timod(file_t *, int, struct svr4_strioctl *,
struct lwp *);
static int ti_getinfo(struct file *, int, struct svr4_strioctl *,
static int ti_getinfo(file_t *, int, struct svr4_strioctl *,
struct lwp *);
static int ti_bind(struct file *, int, struct svr4_strioctl *,
static int ti_bind(file_t *, int, struct svr4_strioctl *,
struct lwp *);
#ifdef DEBUG_SVR4
@ -408,7 +408,7 @@ netaddr_to_sockaddr_un(struct sockaddr_un *saun, const struct svr4_strmcmd *sc)
static void
getparm(struct file *fp, struct svr4_si_sockparms *pa)
getparm(file_t *fp, struct svr4_si_sockparms *pa)
{
struct svr4_strm *st = svr4_stream_get(fp);
struct socket *so = (struct socket *) fp->f_data;
@ -447,7 +447,7 @@ getparm(struct file *fp, struct svr4_si_sockparms *pa)
static int
si_ogetudata(struct file *fp, int fd, struct svr4_strioctl *ioc,
si_ogetudata(file_t *fp, int fd, struct svr4_strioctl *ioc,
struct lwp *l)
{
int error;
@ -502,7 +502,7 @@ si_ogetudata(struct file *fp, int fd, struct svr4_strioctl *ioc,
static int
si_sockparams(struct file *fp, int fd, struct svr4_strioctl *ioc,
si_sockparams(file_t *fp, int fd, struct svr4_strioctl *ioc,
struct lwp *l)
{
struct svr4_si_sockparms pa;
@ -513,7 +513,7 @@ si_sockparams(struct file *fp, int fd, struct svr4_strioctl *ioc,
static int
si_listen(struct file *fp, int fd, struct svr4_strioctl *ioc, struct lwp *l)
si_listen(file_t *fp, int fd, struct svr4_strioctl *ioc, struct lwp *l)
{
int error;
struct svr4_strm *st = svr4_stream_get(fp);
@ -577,7 +577,7 @@ si_listen(struct file *fp, int fd, struct svr4_strioctl *ioc, struct lwp *l)
static int
si_getudata(struct file *fp, int fd, struct svr4_strioctl *ioc,
si_getudata(file_t *fp, int fd, struct svr4_strioctl *ioc,
struct lwp *l)
{
int error;
@ -631,7 +631,7 @@ si_getudata(struct file *fp, int fd, struct svr4_strioctl *ioc,
static int
si_shutdown(struct file *fp, int fd, struct svr4_strioctl *ioc,
si_shutdown(file_t *fp, int fd, struct svr4_strioctl *ioc,
struct lwp *l)
{
int error;
@ -654,7 +654,7 @@ si_shutdown(struct file *fp, int fd, struct svr4_strioctl *ioc,
static int
sockmod(struct file *fp, int fd, struct svr4_strioctl *ioc, struct lwp *l)
sockmod(file_t *fp, int fd, struct svr4_strioctl *ioc, struct lwp *l)
{
switch (ioc->cmd) {
case SVR4_SI_OGETUDATA:
@ -706,7 +706,7 @@ sockmod(struct file *fp, int fd, struct svr4_strioctl *ioc, struct lwp *l)
static int
ti_getinfo(struct file *fp, int fd, struct svr4_strioctl *ioc,
ti_getinfo(file_t *fp, int fd, struct svr4_strioctl *ioc,
struct lwp *l)
{
int error;
@ -744,7 +744,7 @@ ti_getinfo(struct file *fp, int fd, struct svr4_strioctl *ioc,
static int
ti_bind(struct file *fp, int fd, struct svr4_strioctl *ioc, struct lwp *l)
ti_bind(file_t *fp, int fd, struct svr4_strioctl *ioc, struct lwp *l)
{
int error;
struct svr4_strm *st = svr4_stream_get(fp);
@ -843,7 +843,7 @@ reply:
static int
timod(struct file *fp, int fd, struct svr4_strioctl *ioc, struct lwp *l)
timod(file_t *fp, int fd, struct svr4_strioctl *ioc, struct lwp *l)
{
switch (ioc->cmd) {
case SVR4_TI_GETINFO:
@ -870,7 +870,7 @@ timod(struct file *fp, int fd, struct svr4_strioctl *ioc, struct lwp *l)
int
svr4_stream_ti_ioctl(struct file *fp, struct lwp *l, register_t *retval, int fd, u_long cmd, void *dat)
svr4_stream_ti_ioctl(file_t *fp, struct lwp *l, register_t *retval, int fd, u_long cmd, void *dat)
{
struct svr4_strbuf skb, *sub = (struct svr4_strbuf *) dat;
struct svr4_strm *st = svr4_stream_get(fp);
@ -954,7 +954,7 @@ svr4_stream_ti_ioctl(struct file *fp, struct lwp *l, register_t *retval, int fd,
static int
i_nread(struct file *fp, struct lwp *l, register_t *retval, int fd,
i_nread(file_t *fp, struct lwp *l, register_t *retval, int fd,
u_long cmd, void *dat)
{
int error;
@ -967,8 +967,7 @@ i_nread(struct file *fp, struct lwp *l, register_t *retval, int fd,
* for us, and if we do, then we assume that we have at least one
* message waiting for us.
*/
if ((error = (*fp->f_ops->fo_ioctl)(fp, FIONREAD,
(void *) &nread, l)) != 0)
if ((error = (*fp->f_ops->fo_ioctl)(fp, FIONREAD, &nread)) != 0)
return error;
if (nread != 0)
@ -980,7 +979,7 @@ i_nread(struct file *fp, struct lwp *l, register_t *retval, int fd,
}
static int
i_fdinsert(struct file *fp, struct lwp *l, register_t *retval, int fd,
i_fdinsert(file_t *fp, struct lwp *l, register_t *retval, int fd,
u_long cmd, void *dat)
{
/*
@ -1037,7 +1036,7 @@ i_fdinsert(struct file *fp, struct lwp *l, register_t *retval, int fd,
static int
_i_bind_rsvd(struct file *fp, struct lwp *l, register_t *retval,
_i_bind_rsvd(file_t *fp, struct lwp *l, register_t *retval,
int fd, u_long cmd, void *dat)
{
struct sys_mkfifo_args ap;
@ -1056,7 +1055,7 @@ _i_bind_rsvd(struct file *fp, struct lwp *l, register_t *retval,
}
static int
_i_rele_rsvd(struct file *fp, struct lwp *l, register_t *retval,
_i_rele_rsvd(file_t *fp, struct lwp *l, register_t *retval,
int fd, u_long cmd, void *dat)
{
struct sys_unlink_args ap;
@ -1071,7 +1070,7 @@ _i_rele_rsvd(struct file *fp, struct lwp *l, register_t *retval,
}
static int
i_str(struct file *fp, struct lwp *l, register_t *retval, int fd,
i_str(file_t *fp, struct lwp *l, register_t *retval, int fd,
u_long cmd, void *dat)
{
int error;
@ -1116,7 +1115,7 @@ i_str(struct file *fp, struct lwp *l, register_t *retval, int fd,
}
static int
i_setsig(struct file *fp, struct lwp *l, register_t *retval, int fd,
i_setsig(file_t *fp, struct lwp *l, register_t *retval, int fd,
u_long cmd, void *dat)
{
/*
@ -1178,7 +1177,7 @@ i_setsig(struct file *fp, struct lwp *l, register_t *retval, int fd,
}
static int
i_getsig(struct file *fp, struct lwp *l, register_t *retval,
i_getsig(file_t *fp, struct lwp *l, register_t *retval,
int fd, u_long cmd, void *dat)
{
int error;
@ -1200,7 +1199,7 @@ i_getsig(struct file *fp, struct lwp *l, register_t *retval,
}
int
svr4_stream_ioctl(struct file *fp, struct lwp *l, register_t *retval, int fd, u_long cmd, void *dat)
svr4_stream_ioctl(file_t *fp, struct lwp *l, register_t *retval, int fd, u_long cmd, void *dat)
{
*retval = 0;
@ -1372,8 +1371,7 @@ int
svr4_sys_putmsg(struct lwp *l, const struct svr4_sys_putmsg_args *uap, register_t *retval)
{
struct proc *p = l->l_proc;
struct filedesc *fdp = p->p_fd;
struct file *fp;
file_t *fp;
struct svr4_strbuf dat, ctl;
struct svr4_strmcmd sc;
struct sockaddr_in sain;
@ -1392,11 +1390,9 @@ svr4_sys_putmsg(struct lwp *l, const struct svr4_sys_putmsg_args *uap, register_
SCARG(uap, dat), SCARG(uap, flags));
#endif /* DEBUG_SVR4 */
if ((fp = fd_getfile(fdp, SCARG(uap, fd))) == NULL)
if ((fp = fd_getfile(SCARG(uap, fd))) == NULL)
return EBADF;
FILE_USE(fp);
if (SCARG_PTR(uap, ctl) != NULL) {
if ((error = copyin(SCARG_PTR(uap, ctl),
&ctl, sizeof(ctl))) != 0)
@ -1526,7 +1522,7 @@ svr4_sys_putmsg(struct lwp *l, const struct svr4_sys_putmsg_args *uap, register_
}
out:
FILE_UNUSE(fp, l);
fd_putfile(SCARG(uap, fd));
return error;
}
@ -1534,9 +1530,7 @@ svr4_sys_putmsg(struct lwp *l, const struct svr4_sys_putmsg_args *uap, register_
int
svr4_sys_getmsg(struct lwp *l, const struct svr4_sys_getmsg_args *uap, register_t *retval)
{
struct proc *p = l->l_proc;
struct filedesc *fdp = p->p_fd;
struct file *fp;
file_t *fp;
struct svr4_strbuf dat, ctl;
struct svr4_strmcmd sc;
int error = 0;
@ -1553,11 +1547,9 @@ svr4_sys_getmsg(struct lwp *l, const struct svr4_sys_getmsg_args *uap, register_
SCARG(uap, dat), 0);
#endif /* DEBUG_SVR4 */
if ((fp = fd_getfile(fdp, SCARG(uap, fd))) == NULL)
if ((fp = fd_getfile(SCARG(uap, fd))) == NULL)
return EBADF;
FILE_USE(fp);
if (SCARG_PTR(uap, ctl) != NULL) {
if ((error = copyin(SCARG_PTR(uap, ctl), &ctl,
sizeof(ctl))) != 0)
@ -1846,6 +1838,6 @@ svr4_sys_getmsg(struct lwp *l, const struct svr4_sys_getmsg_args *uap, register_
#endif /* DEBUG_SVR4 */
out:
FILE_UNUSE(fp, l);
fd_putfile(SCARG(uap, fd));
return error;
}

View File

@ -1,7 +1,7 @@
/* $NetBSD: svr4_termios.c,v 1.25 2007/12/08 18:36:26 dsl Exp $ */
/* $NetBSD: svr4_termios.c,v 1.26 2008/03/21 21:54:59 ad Exp $ */
/*-
* Copyright (c) 1994 The NetBSD Foundation, Inc.
* Copyright (c) 1994, 2008 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: svr4_termios.c,v 1.25 2007/12/08 18:36:26 dsl Exp $");
__KERNEL_RCSID(0, "$NetBSD: svr4_termios.c,v 1.26 2008/03/21 21:54:59 ad Exp $");
#include <sys/param.h>
#include <sys/proc.h>
@ -486,21 +486,20 @@ svr4_termios_to_termio(const struct svr4_termios *ts, struct svr4_termio *t)
}
int
svr4_term_ioctl(struct file *fp, struct lwp *l, register_t *retval, int fd, u_long cmd, void *data)
svr4_term_ioctl(file_t *fp, struct lwp *l, register_t *retval, int fd, u_long cmd, void *data)
{
struct termios bt;
struct svr4_termios st;
struct svr4_termio t;
int error, new;
int (*ctl)(struct file *, u_long, void *, struct lwp *) =
fp->f_ops->fo_ioctl;
int (*ctl)(file_t *, u_long, void *) = fp->f_ops->fo_ioctl;
*retval = 0;
switch (cmd) {
case SVR4_TCGETA:
case SVR4_TCGETS:
if ((error = (*ctl)(fp, TIOCGETA, (void *) &bt, l)) != 0)
if ((error = (*ctl)(fp, TIOCGETA, &bt)) != 0)
return error;
memset(&st, 0, sizeof(st));
@ -527,7 +526,7 @@ svr4_term_ioctl(struct file *fp, struct lwp *l, register_t *retval, int fd, u_lo
case SVR4_TCSETAF:
case SVR4_TCSETSF:
/* get full BSD termios so we don't lose information */
if ((error = (*ctl)(fp, TIOCGETA, (void *) &bt, l)) != 0)
if ((error = (*ctl)(fp, TIOCGETA, &bt)) != 0)
return error;
switch (cmd) {
@ -578,13 +577,13 @@ svr4_term_ioctl(struct file *fp, struct lwp *l, register_t *retval, int fd, u_lo
print_svr4_termios(&st);
#endif /* DEBUG_SVR4 */
return (*ctl)(fp, cmd, (void *) &bt, l);
return (*ctl)(fp, cmd, &bt);
case SVR4_TIOCGWINSZ:
{
struct svr4_winsize ws;
error = (*ctl)(fp, TIOCGWINSZ, (void *) &ws, l);
error = (*ctl)(fp, TIOCGWINSZ, &ws);
if (error)
return error;
return copyout(&ws, data, sizeof(ws));
@ -596,7 +595,7 @@ svr4_term_ioctl(struct file *fp, struct lwp *l, register_t *retval, int fd, u_lo
if ((error = copyin(data, &ws, sizeof(ws))) != 0)
return error;
return (*ctl)(fp, TIOCSWINSZ, (void *) &ws, l);
return (*ctl)(fp, TIOCSWINSZ, &ws);
}
default:

View File

@ -1,7 +1,7 @@
/* $NetBSD: svr4_ttold.c,v 1.31 2007/12/08 18:36:26 dsl Exp $ */
/* $NetBSD: svr4_ttold.c,v 1.32 2008/03/21 21:54:59 ad Exp $ */
/*-
* Copyright (c) 1994 The NetBSD Foundation, Inc.
* Copyright (c) 1994, 2008 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: svr4_ttold.c,v 1.31 2007/12/08 18:36:26 dsl Exp $");
__KERNEL_RCSID(0, "$NetBSD: svr4_ttold.c,v 1.32 2008/03/21 21:54:59 ad Exp $");
#include <sys/param.h>
#include <sys/proc.h>
@ -181,12 +181,11 @@ bsd_ltchars_to_svr4_ltchars(const struct ltchars *bl, struct svr4_ltchars *sl)
int
svr4_ttold_ioctl(struct file *fp, struct lwp *l, register_t *retval,
svr4_ttold_ioctl(file_t *fp, struct lwp *l, register_t *retval,
int fd, u_long cmd, void *data)
{
int error;
int (*ctl)(struct file *, u_long, void *, struct lwp *) =
fp->f_ops->fo_ioctl;
int (*ctl)(file_t *, u_long, void *) = fp->f_ops->fo_ioctl;
*retval = 0;
@ -195,8 +194,7 @@ svr4_ttold_ioctl(struct file *fp, struct lwp *l, register_t *retval,
{
pid_t pid;
if ((error = (*ctl)(fp, TIOCGPGRP,
(void *) &pid, l)) != 0)
if ((error = (*ctl)(fp, TIOCGPGRP, &pid)) != 0)
return error;
DPRINTF(("TIOCGPGRP %d\n", pid));
@ -215,15 +213,14 @@ svr4_ttold_ioctl(struct file *fp, struct lwp *l, register_t *retval,
DPRINTF(("TIOCSPGRP %d\n", pid));
return (*ctl)(fp, TIOCSPGRP, (void *) &pid, l);
return (*ctl)(fp, TIOCSPGRP, &pid);
}
case SVR4_TIOCGSID:
{
pid_t pid;
if ((error = (*ctl)(fp, TIOCGSID,
(void *) &pid, l)) != 0)
if ((error = (*ctl)(fp, TIOCGSID, &pid)) != 0)
return error;
DPRINTF(("TIOCGSID %d\n", pid));
@ -236,7 +233,7 @@ svr4_ttold_ioctl(struct file *fp, struct lwp *l, register_t *retval,
struct sgttyb bs;
struct svr4_sgttyb ss;
error = (*ctl)(fp, TIOCGETP, (void *) &bs, l);
error = (*ctl)(fp, TIOCGETP, &bs);
if (error)
return error;
@ -261,7 +258,7 @@ svr4_ttold_ioctl(struct file *fp, struct lwp *l, register_t *retval,
print_svr4_sgttyb("SVR4_TIOCSET{P,N}", &ss);
#endif /* DEBUG_SVR4 */
cmd = (cmd == SVR4_TIOCSETP) ? TIOCSETP : TIOCSETN;
return (*ctl)(fp, cmd, (void *) &bs, l);
return (*ctl)(fp, cmd, &bs);
}
case SVR4_TIOCGETC:
@ -269,7 +266,7 @@ svr4_ttold_ioctl(struct file *fp, struct lwp *l, register_t *retval,
struct tchars bt;
struct svr4_tchars st;
error = (*ctl)(fp, TIOCGETC, (void *) &bt, l);
error = (*ctl)(fp, TIOCGETC, &bt);
if (error)
return error;
@ -292,7 +289,7 @@ svr4_ttold_ioctl(struct file *fp, struct lwp *l, register_t *retval,
#ifdef DEBUG_SVR4
print_svr4_tchars("SVR4_TIOCSETC", &st);
#endif /* DEBUG_SVR4 */
return (*ctl)(fp, TIOCSETC, (void *) &bt, l);
return (*ctl)(fp, TIOCSETC, &bt);
}
case SVR4_TIOCGLTC:
@ -300,7 +297,7 @@ svr4_ttold_ioctl(struct file *fp, struct lwp *l, register_t *retval,
struct ltchars bl;
struct svr4_ltchars sl;
error = (*ctl)(fp, TIOCGLTC, (void *) &bl, l);
error = (*ctl)(fp, TIOCGLTC, &bl);
if (error)
return error;
@ -323,14 +320,13 @@ svr4_ttold_ioctl(struct file *fp, struct lwp *l, register_t *retval,
#ifdef DEBUG_SVR4
print_svr4_ltchars("SVR4_TIOCSLTC", &sl);
#endif /* DEBUG_SVR4 */
return (*ctl)(fp, TIOCSLTC, (void *) &bl, l);
return (*ctl)(fp, TIOCSLTC, &bl);
}
case SVR4_TIOCLGET:
{
int flags;
if ((error = (*ctl)(fp, TIOCLGET,
(void *) &flags, l)) != 0)
if ((error = (*ctl)(fp, TIOCLGET, &flags)) != 0)
return error;
DPRINTF(("SVR4_TIOCLGET %o\n", flags));
return copyout(&flags, data, sizeof(flags));
@ -358,7 +354,7 @@ svr4_ttold_ioctl(struct file *fp, struct lwp *l, register_t *retval,
}
DPRINTF(("SVR4_TIOCL{SET,BIS,BIC} %o\n", flags));
return (*ctl)(fp, cmd, (void *) &flags, l);
return (*ctl)(fp, cmd, &flags);
}
default:

View File

@ -1,7 +1,7 @@
/* $NetBSD: svr4_32_fcntl.c,v 1.32 2008/01/09 20:45:19 tnn Exp $ */
/* $NetBSD: svr4_32_fcntl.c,v 1.33 2008/03/21 21:54:59 ad Exp $ */
/*-
* Copyright (c) 1994, 1997 The NetBSD Foundation, Inc.
* Copyright (c) 1994, 1997, 2008 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: svr4_32_fcntl.c,v 1.32 2008/01/09 20:45:19 tnn Exp $");
__KERNEL_RCSID(0, "$NetBSD: svr4_32_fcntl.c,v 1.33 2008/03/21 21:54:59 ad Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -223,31 +223,27 @@ svr4_32_to_bsd_flock64(struct svr4_32_flock64 *iflp, struct flock *oflp)
static int
fd_revoke(struct lwp *l, int fd, register_t *retval)
{
struct filedesc *fdp = l->l_proc->p_fd;
struct file *fp;
file_t *fp;
struct vnode *vp;
int error;
if ((fp = fd_getfile(fdp, fd)) == NULL)
if ((fp = fd_getfile(fd)) == NULL)
return EBADF;
if (fp->f_type != DTYPE_VNODE) {
FILE_UNLOCK(fp);
fd_putfile(fd);
return EINVAL;
}
FILE_USE(fp);
vp = (struct vnode *) fp->f_data;
vp = fp->f_data;
if (vp->v_type != VCHR && vp->v_type != VBLK) {
error = EINVAL;
goto out;
}
error = dorevoke(vp, l->l_cred);
out:
vrele(vp);
FILE_UNUSE(fp, l);
fd_putfile(fd);
return error;
}
@ -255,8 +251,7 @@ out:
static int
fd_truncate(struct lwp *l, int fd, struct flock *flp, register_t *retval)
{
struct filedesc *fdp = l->l_proc->p_fd;
struct file *fp;
file_t *fp;
off_t start, length;
struct vnode *vp;
struct vattr vattr;
@ -266,17 +261,15 @@ fd_truncate(struct lwp *l, int fd, struct flock *flp, register_t *retval)
/*
* We only support truncating the file.
*/
if ((fp = fd_getfile(fdp, fd)) == NULL)
if ((fp = fd_getfile(fd)) == NULL)
return EBADF;
vp = (struct vnode *)fp->f_data;
vp = fp->f_data;
if (fp->f_type != DTYPE_VNODE || vp->v_type == VFIFO) {
FILE_UNLOCK(fp);
fd_putfile(fd);
return ESPIPE;
}
FILE_USE(fp);
if ((error = VOP_GETATTR(vp, &vattr, l->l_cred)) != 0) {
FILE_UNUSE(fp, l);
fd_putfile(fd);
return error;
}
@ -296,13 +289,13 @@ fd_truncate(struct lwp *l, int fd, struct flock *flp, register_t *retval)
break;
default:
FILE_UNUSE(fp, l);
fd_putfile(fd);
return EINVAL;
}
if (start + flp->l_len < length) {
/* We don't support free'ing in the middle of the file */
FILE_UNUSE(fp, l);
fd_putfile(fd);
return EINVAL;
}
@ -310,7 +303,7 @@ fd_truncate(struct lwp *l, int fd, struct flock *flp, register_t *retval)
SCARG(&ft, length) = start;
error = sys_ftruncate(l, &ft, retval);
FILE_UNUSE(fp, l);
fd_putfile(fd);
return error;
}
@ -334,17 +327,17 @@ svr4_32_sys_open(struct lwp *l, const struct svr4_32_sys_open_args *uap, registe
if (!(SCARG(&cup, flags) & O_NOCTTY) && SESS_LEADER(l->l_proc) &&
!(l->l_proc->p_lflag & PL_CONTROLT)) {
struct filedesc *fdp = l->l_proc->p_fd;
struct file *fp;
file_t *fp;
int fd;
fp = fd_getfile(fdp, *retval);
fd = *retval;
fp = fd_getfile(fd);
/* ignore any error, just give it a try */
if (fp != NULL) {
FILE_USE(fp);
if (fp->f_type == DTYPE_VNODE)
(fp->f_ops->fo_ioctl)(fp, TIOCSCTTY, NULL, l);
FILE_UNUSE(fp, l);
(fp->f_ops->fo_ioctl)(fp, TIOCSCTTY, NULL);
fd_putfile(fd);
}
}
return 0;
@ -524,7 +517,7 @@ svr4_32_sys_fcntl(struct lwp *l, const struct svr4_32_sys_fcntl_args *uap, regis
return error;
svr4_32_to_bsd_flock(&ifl, &fl);
error = do_fcntl_lock(l, SCARG(uap, fd), cmd, &fl);
error = do_fcntl_lock(SCARG(uap, fd), cmd, &fl);
if (cmd != F_GETLK || error != 0)
return error;
@ -565,7 +558,7 @@ svr4_32_sys_fcntl(struct lwp *l, const struct svr4_32_sys_fcntl_args *uap, regis
return error;
svr4_32_to_bsd_flock64(&ifl64, &fl);
error = do_fcntl_lock(l, SCARG(uap, fd), cmd, &fl);
error = do_fcntl_lock(SCARG(uap, fd), cmd, &fl);
if (cmd != F_GETLK || error != 0)
return error;

View File

@ -1,7 +1,7 @@
/* $NetBSD: svr4_32_filio.c,v 1.13 2008/01/05 19:14:09 dsl Exp $ */
/* $NetBSD: svr4_32_filio.c,v 1.14 2008/03/21 21:54:59 ad Exp $ */
/*-
* Copyright (c) 1994 The NetBSD Foundation, Inc.
* Copyright (c) 1994, 2008 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: svr4_32_filio.c,v 1.13 2008/01/05 19:14:09 dsl Exp $");
__KERNEL_RCSID(0, "$NetBSD: svr4_32_filio.c,v 1.14 2008/03/21 21:54:59 ad Exp $");
#include <sys/param.h>
#include <sys/proc.h>
@ -66,28 +66,31 @@ __KERNEL_RCSID(0, "$NetBSD: svr4_32_filio.c,v 1.13 2008/01/05 19:14:09 dsl Exp $
int
svr4_32_fil_ioctl(struct file *fp, struct lwp *l, register_t *retval, int fd, u_long cmd, void *data)
svr4_32_fil_ioctl(file_t *fp, struct lwp *l, register_t *retval, int fd, u_long cmd, void *data)
{
int error;
int num;
struct filedesc *fdp = p->p_fd;
int (*ctl)(struct file *, u_long, void *, struct lwp *) =
fp->f_ops->fo_ioctl;
int (*ctl)(file_t *, u_long, void *) = fp->f_ops->fo_ioctl;
filedesc_t *fdp;
fdfile_t *ff;
*retval = 0;
if ((fp = fd_getfile(fdp, fd)) == NULL)
if ((fp = fd_getfile(fd)) == NULL)
return EBADF;
fdp = curlwp->l_fd;
ff = fdp->fd_ofiles[fd];
error = 0;
switch (cmd) {
case SVR4_FIOCLEX:
fdp->fd_ofileflags[fd] |= UF_EXCLOSE;
FILE_UNLOCK(fp);
return 0;
ff->ff_exclose = 1;
fdp->fd_exclose = 1;
break;
case SVR4_FIONCLEX:
fdp->fd_ofileflags[fd] &= ~UF_EXCLOSE;
FILE_UNLOCK(fp);
return 0;
ff->ff_exclose = 0;
break;
case SVR4_FIOGETOWN:
case SVR4_FIOSETOWN:
@ -102,21 +105,19 @@ svr4_32_fil_ioctl(struct file *fp, struct lwp *l, register_t *retval, int fd, u_
case SVR4_FIONREAD: cmd = FIONREAD; break;
}
FILE_USE(fp);
error = copyin(data, &num, sizeof(num));
if (error == 0)
error = (*ctl)(fp, cmd, &num, p);
FILE_UNUSE(fp, l);
if (error)
return error;
return copyout(&num, data, sizeof(num));
error = (*ctl)(fp, cmd, &num);
if (error == 0)
error = copyout(&num, data, sizeof(num));
break;
default:
FILE_UNLOCK(fp);
DPRINTF(("Unknown svr4_32 filio %lx\n", cmd));
return 0; /* ENOSYS really */
break;
}
fd_putfile(fd);
return error;
}

View File

@ -1,7 +1,7 @@
/* $NetBSD: svr4_32_ioctl.c,v 1.19 2008/01/05 19:14:09 dsl Exp $ */
/* $NetBSD: svr4_32_ioctl.c,v 1.20 2008/03/21 21:54:59 ad Exp $ */
/*-
* Copyright (c) 1994 The NetBSD Foundation, Inc.
* Copyright (c) 1994, 2008 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: svr4_32_ioctl.c,v 1.19 2008/01/05 19:14:09 dsl Exp $");
__KERNEL_RCSID(0, "$NetBSD: svr4_32_ioctl.c,v 1.20 2008/03/21 21:54:59 ad Exp $");
#include <sys/param.h>
#include <sys/proc.h>
@ -101,13 +101,10 @@ svr4_32_decode_cmd(cmd, dir, c, num, argsiz)
int
svr4_32_sys_ioctl(struct lwp *l, const struct svr4_32_sys_ioctl_args *uap, register_t *retval)
{
struct proc *p = l->l_proc;
struct file *fp;
struct filedesc *fdp;
file_t *fp;
u_long cmd;
int error;
int (*fun)(struct file *, struct lwp *, register_t *,
int, u_long, void *);
int (*fun)(file_t *, struct lwp *, register_t *, int, u_long, void *);
#ifdef DEBUG_SVR4
char dir[4];
char c;
@ -119,14 +116,13 @@ svr4_32_sys_ioctl(struct lwp *l, const struct svr4_32_sys_ioctl_args *uap, regis
uprintf("svr4_32_ioctl(%d, _IO%s(%c, %d, %d), %#x);\n", SCARG(uap, fd),
dir, c, num, argsiz, SCARG(uap, data));
#endif
fdp = p->p_fd;
cmd = SCARG(uap, com);
if ((fp = fd_getfile(fdp, SCARG(uap, fd))) == NULL)
if ((fp = fd_getfile(SCARG(uap, fd))) == NULL)
return EBADF;
if ((fp->f_flag & (FREAD | FWRITE)) == 0) {
FILE_UNLOCK(fp);
fd_putfile(SCARG(uap, fd));
return EBADF;
}
@ -153,16 +149,15 @@ svr4_32_sys_ioctl(struct lwp *l, const struct svr4_32_sys_ioctl_args *uap, regis
case SVR4_XIOC:
/* We do not support those */
FILE_UNLOCK(fp);
fd_putfile(SCARG(uap, fd));
return EINVAL;
default:
DPRINTF(("Unimplemented ioctl %lx\n", cmd));
fd_putfile(SCARG(uap, fd));
return 0; /* XXX: really ENOSYS */
}
FILE_USE(fp);
error = (*fun)(fp, l, retval, SCARG(uap, fd), cmd,
SCARG_P32(uap, data));
FILE_UNUSE(fp, l);
error = (*fun)(fp, l, retval, SCARG(uap, fd), cmd, SCARG_P32(uap, data));
fd_putfile(SCARG(uap, fd));
return error;
}

View File

@ -1,7 +1,7 @@
/* $NetBSD: svr4_32_misc.c,v 1.58 2007/12/28 10:00:18 hannken Exp $ */
/* $NetBSD: svr4_32_misc.c,v 1.59 2008/03/21 21:54:59 ad Exp $ */
/*-
* Copyright (c) 1994 The NetBSD Foundation, Inc.
* Copyright (c) 1994, 2008 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@ -44,7 +44,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: svr4_32_misc.c,v 1.58 2007/12/28 10:00:18 hannken Exp $");
__KERNEL_RCSID(0, "$NetBSD: svr4_32_misc.c,v 1.59 2008/03/21 21:54:59 ad Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -212,14 +212,13 @@ svr4_32_sys_time(struct lwp *l, const struct svr4_32_sys_time_args *uap, registe
int
svr4_32_sys_getdents64(struct lwp *l, const struct svr4_32_sys_getdents64_args *uap, register_t *retval)
{
struct proc *p = l->l_proc;
struct dirent *bdp;
struct vnode *vp;
char *inp, *sbuf; /* BSD-format */
int len, reclen; /* BSD-format */
char *outp; /* SVR4-format */
int resid, svr4_32_reclen; /* SVR4-format */
struct file *fp;
file_t *fp;
struct uio auio;
struct iovec aiov;
struct svr4_32_dirent64 idb;
@ -229,7 +228,7 @@ svr4_32_sys_getdents64(struct lwp *l, const struct svr4_32_sys_getdents64_args *
int ncookies;
/* getvnode() will use the descriptor for us */
if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0)
if ((error = fd_getvnode(SCARG(uap, fd), &fp)) != 0)
return (error);
if ((fp->f_flag & FREAD) == 0) {
@ -237,7 +236,7 @@ svr4_32_sys_getdents64(struct lwp *l, const struct svr4_32_sys_getdents64_args *
goto out1;
}
vp = (struct vnode *)fp->f_data;
vp = fp->f_data;
if (vp->v_type != VDIR) {
error = EINVAL;
goto out1;
@ -325,7 +324,7 @@ out:
free(cookiebuf, M_TEMP);
free(sbuf, M_TEMP);
out1:
FILE_UNUSE(fp, l);
fd_putfile(SCARG(uap, fd));
return error;
}
@ -333,14 +332,13 @@ out:
int
svr4_32_sys_getdents(struct lwp *l, const struct svr4_32_sys_getdents_args *uap, register_t *retval)
{
struct proc *p = l->l_proc;
struct dirent *bdp;
struct vnode *vp;
char *inp, *sbuf; /* BSD-format */
int len, reclen; /* BSD-format */
char *outp; /* SVR4-format */
int resid, svr4_reclen; /* SVR4-format */
struct file *fp;
file_t *fp;
struct uio auio;
struct iovec aiov;
struct svr4_32_dirent idb;
@ -350,7 +348,7 @@ svr4_32_sys_getdents(struct lwp *l, const struct svr4_32_sys_getdents_args *uap,
int ncookies;
/* getvnode() will use the descriptor for us */
if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0)
if ((error = fd_getvnode(SCARG(uap, fd), &fp)) != 0)
return (error);
if ((fp->f_flag & FREAD) == 0) {
@ -358,7 +356,7 @@ svr4_32_sys_getdents(struct lwp *l, const struct svr4_32_sys_getdents_args *uap,
goto out1;
}
vp = (struct vnode *)fp->f_data;
vp = fp->f_data;
if (vp->v_type != VDIR) {
error = EINVAL;
goto out1;
@ -447,7 +445,7 @@ out:
free(cookiebuf, M_TEMP);
free(sbuf, M_TEMP);
out1:
FILE_UNUSE(fp, l);
fd_putfile(SCARG(uap, fd));
return error;
}

View File

@ -1,7 +1,7 @@
/* $NetBSD: svr4_32_net.c,v 1.16 2007/12/08 18:36:28 dsl Exp $ */
/* $NetBSD: svr4_32_net.c,v 1.17 2008/03/21 21:54:59 ad Exp $ */
/*-
* Copyright (c) 1994 The NetBSD Foundation, Inc.
* Copyright (c) 1994, 2008 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@ -41,7 +41,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: svr4_32_net.c,v 1.16 2007/12/08 18:36:28 dsl Exp $");
__KERNEL_RCSID(0, "$NetBSD: svr4_32_net.c,v 1.17 2008/03/21 21:54:59 ad Exp $");
#define COMPAT_SVR4 1
@ -98,7 +98,7 @@ enum {
int svr4_32_netattach(int);
int svr4_soo_close(struct file *, struct lwp *);
int svr4_soo_close(file_t *);
int svr4_ptm_alloc(struct proc *);
static const struct fileops svr4_32_netops = {
@ -117,7 +117,7 @@ svr4_32_netattach(int n)
}
struct svr4_strm *
svr4_32_stream_get(struct file *fp)
svr4_32_stream_get(file_t *fp)
{
struct socket *so;
struct svr4_strm *st;

View File

@ -1,7 +1,7 @@
/* $NetBSD: svr4_32_sockio.c,v 1.19 2007/12/08 18:36:29 dsl Exp $ */
/* $NetBSD: svr4_32_sockio.c,v 1.20 2008/03/21 21:54:59 ad Exp $ */
/*-
* Copyright (c) 1995 The NetBSD Foundation, Inc.
* Copyright (c) 1995, 2008 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: svr4_32_sockio.c,v 1.19 2007/12/08 18:36:29 dsl Exp $");
__KERNEL_RCSID(0, "$NetBSD: svr4_32_sockio.c,v 1.20 2008/03/21 21:54:59 ad Exp $");
#include <sys/param.h>
#include <sys/proc.h>
@ -91,11 +91,10 @@ bsd_to_svr4_flags(int bf)
}
int
svr4_32_sock_ioctl(struct file *fp, struct lwp *l, register_t *retval, int fd, u_long cmd, void *data)
svr4_32_sock_ioctl(file_t *fp, struct lwp *l, register_t *retval, int fd, u_long cmd, void *data)
{
int error;
int (*ctl)(struct file *, u_long, void *, struct lwp *) =
fp->f_ops->fo_ioctl;
int (*ctl)(file_t *, u_long, void *) = fp->f_ops->fo_ioctl;
*retval = 0;
@ -135,7 +134,7 @@ svr4_32_sock_ioctl(struct file *fp, struct lwp *l, register_t *retval, int fd, u
(void) strncpy(br.ifr_name, sr.svr4_ifr_name,
sizeof(br.ifr_name));
if ((error = (*ctl)(fp, SIOCGIFFLAGS, &br, l)) != 0) {
if ((error = (*ctl)(fp, SIOCGIFFLAGS, &br)) != 0) {
DPRINTF(("SIOCGIFFLAGS %s: error %d\n",
sr.svr4_ifr_name, error));
return error;
@ -163,7 +162,7 @@ svr4_32_sock_ioctl(struct file *fp, struct lwp *l, register_t *retval, int fd, u
ifc.ifc_len = sc.svr4_32_ifc_len;
ifc.ifc_buf = NETBSD32PTR64(sc.ifc_ifcu.ifcu_buf);
if ((error = (*ctl)(fp, OOSIOCGIFCONF, &ifc, l)) != 0)
if ((error = (*ctl)(fp, OOSIOCGIFCONF, &ifc)) != 0)
return error;
DPRINTF(("SIOCGIFCONF\n"));

View File

@ -1,7 +1,7 @@
/* $NetBSD: svr4_32_stat.c,v 1.33 2008/01/08 22:13:07 elad Exp $ */
/* $NetBSD: svr4_32_stat.c,v 1.34 2008/03/21 21:54:59 ad Exp $ */
/*-
* Copyright (c) 1994 The NetBSD Foundation, Inc.
* Copyright (c) 1994, 2008 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: svr4_32_stat.c,v 1.33 2008/01/08 22:13:07 elad Exp $");
__KERNEL_RCSID(0, "$NetBSD: svr4_32_stat.c,v 1.34 2008/03/21 21:54:59 ad Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -179,7 +179,7 @@ svr4_32_sys_stat(struct lwp *l, const struct svr4_32_sys_stat_args *uap, registe
struct svr4_32_stat svr4_st;
int error;
error = do_sys_stat(l, SCARG(&cup, path), FOLLOW, &st);
error = do_sys_stat(SCARG(&cup, path), FOLLOW, &st);
if (error != 0)
return error;
@ -209,7 +209,7 @@ svr4_32_sys_lstat(struct lwp *l, const struct svr4_32_sys_lstat_args *uap, regis
struct svr4_32_stat svr4_st;
int error;
error = do_sys_stat(l, SCARG(&cup, path), NOFOLLOW, &st);
error = do_sys_stat(SCARG(&cup, path), NOFOLLOW, &st);
if (error != 0)
return error;
@ -239,7 +239,7 @@ svr4_32_sys_fstat(struct lwp *l, const struct svr4_32_sys_fstat_args *uap, regis
struct svr4_32_stat svr4_st;
int error;
error = do_sys_fstat(l, SCARG(uap, fd), &st);
error = do_sys_fstat(SCARG(uap, fd), &st);
if (error != 0)
return error;
@ -259,7 +259,7 @@ svr4_32_sys_xstat(struct lwp *l, const struct svr4_32_sys_xstat_args *uap, regis
int error;
const char *path = SCARG_P32(uap, path);
error = do_sys_stat(l, path, FOLLOW, &st);
error = do_sys_stat(path, FOLLOW, &st);
if (error != 0)
return error;
@ -281,7 +281,7 @@ svr4_32_sys_lxstat(struct lwp *l, const struct svr4_32_sys_lxstat_args *uap, reg
int error;
const char *path = SCARG_P32(uap, path);
error = do_sys_stat(l, path, NOFOLLOW, &st);
error = do_sys_stat(path, NOFOLLOW, &st);
if (error != 0)
return error;
@ -302,7 +302,7 @@ svr4_32_sys_fxstat(struct lwp *l, const struct svr4_32_sys_fxstat_args *uap, reg
struct svr4_32_xstat svr4_st;
int error;
error = do_sys_fstat(l, SCARG(uap, fd), &st);
error = do_sys_fstat(SCARG(uap, fd), &st);
if (error != 0)
return error;
@ -321,7 +321,7 @@ svr4_32_sys_stat64(struct lwp *l, const struct svr4_32_sys_stat64_args *uap, reg
int error;
const char *path = SCARG_P32(uap, path);
error = do_sys_stat(l, path, FOLLOW, &st);
error = do_sys_stat(path, FOLLOW, &st);
if (error != 0)
return error;
@ -343,7 +343,7 @@ svr4_32_sys_lstat64(struct lwp *l, const struct svr4_32_sys_lstat64_args *uap, r
int error;
const char *path = SCARG_P32(uap, path);
error = do_sys_stat(l, path, NOFOLLOW, &st);
error = do_sys_stat(path, NOFOLLOW, &st);
if (error != 0)
return error;
@ -364,7 +364,7 @@ svr4_32_sys_fstat64(struct lwp *l, const struct svr4_32_sys_fstat64_args *uap, r
struct svr4_32_stat64 svr4_st;
int error;
error = do_sys_fstat(l, SCARG(uap, fd), &st);
error = do_sys_fstat(SCARG(uap, fd), &st);
if (error != 0)
return error;

View File

@ -1,7 +1,7 @@
/* $NetBSD: svr4_32_termios.c,v 1.15 2007/12/08 18:36:29 dsl Exp $ */
/* $NetBSD: svr4_32_termios.c,v 1.16 2008/03/21 21:54:59 ad Exp $ */
/*-
* Copyright (c) 1994 The NetBSD Foundation, Inc.
* Copyright (c) 1994, 2008 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: svr4_32_termios.c,v 1.15 2007/12/08 18:36:29 dsl Exp $");
__KERNEL_RCSID(0, "$NetBSD: svr4_32_termios.c,v 1.16 2008/03/21 21:54:59 ad Exp $");
#include <sys/param.h>
#include <sys/proc.h>
@ -492,15 +492,14 @@ svr4_32_term_ioctl(struct file *fp, struct lwp *l, register_t *retval, int fd, u
struct svr4_32_termios st;
struct svr4_termio t;
int error, new;
int (*ctl)(struct file *, u_long, void *, struct lwp *) =
fp->f_ops->fo_ioctl;
int (*ctl)(file_t *, u_long, void *) = fp->f_ops->fo_ioctl;
*retval = 0;
switch (cmd) {
case SVR4_TCGETA:
case SVR4_TCGETS:
if ((error = (*ctl)(fp, TIOCGETA, &bt, l)) != 0)
if ((error = (*ctl)(fp, TIOCGETA, &bt)) != 0)
return error;
memset(&st, 0, sizeof(st));
@ -527,7 +526,7 @@ svr4_32_term_ioctl(struct file *fp, struct lwp *l, register_t *retval, int fd, u
case SVR4_TCSETAF:
case SVR4_TCSETSF:
/* get full BSD termios so we don't lose information */
if ((error = (*ctl)(fp, TIOCGETA, &bt, l)) != 0)
if ((error = (*ctl)(fp, TIOCGETA, &bt)) != 0)
return error;
switch (cmd) {
@ -578,13 +577,13 @@ svr4_32_term_ioctl(struct file *fp, struct lwp *l, register_t *retval, int fd, u
print_svr4_32_termios(&st);
#endif /* DEBUG_SVR4 */
return (*ctl)(fp, cmd, &bt, l);
return (*ctl)(fp, cmd, &bt);
case SVR4_TIOCGWINSZ:
{
struct svr4_winsize ws;
error = (*ctl)(fp, TIOCGWINSZ, &ws, l);
error = (*ctl)(fp, TIOCGWINSZ, &ws);
if (error)
return error;
return copyout(&ws, data, sizeof(ws));
@ -596,7 +595,7 @@ svr4_32_term_ioctl(struct file *fp, struct lwp *l, register_t *retval, int fd, u
if ((error = copyin(data, &ws, sizeof(ws))) != 0)
return error;
return (*ctl)(fp, TIOCSWINSZ, &ws, l);
return (*ctl)(fp, TIOCSWINSZ, &ws);
}
default:

View File

@ -1,4 +1,4 @@
/* $NetBSD: ultrix_ioctl.c,v 1.34 2008/01/05 19:14:09 dsl Exp $ */
/* $NetBSD: ultrix_ioctl.c,v 1.35 2008/03/21 21:54:59 ad Exp $ */
/* from : NetBSD: sunos_ioctl.c,v 1.21 1995/10/07 06:27:31 mycroft Exp */
/*
@ -28,7 +28,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ultrix_ioctl.c,v 1.34 2008/01/05 19:14:09 dsl Exp $");
__KERNEL_RCSID(0, "$NetBSD: ultrix_ioctl.c,v 1.35 2008/03/21 21:54:59 ad Exp $");
#if defined(_KERNEL_OPT)
#include "opt_compat_ultrix.h"
@ -444,20 +444,17 @@ stio2stios(struct emul_termio *t, struct emul_termios *ts)
static int
ultrix_do_ioctl(int fd, int cmd, void *arg, struct lwp *l)
{
struct file *fp;
file_t *fp;
int error;
if ((fp = fd_getfile(l->l_proc->p_fd, fd)) == NULL)
if ((fp = fd_getfile(fd)) == NULL)
return EBADF;
if ((fp->f_flag & (FREAD|FWRITE)) == 0) {
FILE_UNLOCK(fp);
return EBADF;
}
FILE_USE(fp);
error = fp->f_ops->fo_ioctl(fp, cmd, arg, l);
FILE_UNUSE(fp, l);
if ((fp->f_flag & (FREAD|FWRITE)) == 0)
error = EBADF;
else
error = fp->f_ops->fo_ioctl(fp, cmd, arg);
fd_putfile(fd);
return error;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: ultrix_misc.c,v 1.110 2007/12/27 17:18:11 christos Exp $ */
/* $NetBSD: ultrix_misc.c,v 1.111 2008/03/21 21:54:59 ad Exp $ */
/*
* Copyright (c) 1995, 1997 Jonathan Stone (hereinafter referred to as the author)
@ -76,7 +76,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ultrix_misc.c,v 1.110 2007/12/27 17:18:11 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: ultrix_misc.c,v 1.111 2008/03/21 21:54:59 ad Exp $");
#if defined(_KERNEL_OPT)
#include "opt_nfsserver.h"
@ -346,8 +346,7 @@ ultrix_sys_mmap(struct lwp *l, const struct ultrix_sys_mmap_args *uap, register_
int
ultrix_sys_setsockopt(struct lwp *l, const struct ultrix_sys_setsockopt_args *uap, register_t *retval)
{
struct proc *p = l->l_proc;
struct file *fp;
struct socket *so;
struct mbuf *m = NULL;
int error;
struct sys_setsockopt_args ap;
@ -359,15 +358,14 @@ ultrix_sys_setsockopt(struct lwp *l, const struct ultrix_sys_setsockopt_args *ua
SCARG(&ap, valsize) = SCARG(uap, valsize);
/* getsock() will use the descriptor for us */
if ((error = getsock(p->p_fd, SCARG(&ap, s), &fp)) != 0)
if ((error = fd_getsock(SCARG(&ap, s), &so)) != 0)
return error;
#define SO_DONTLINGER (~SO_LINGER)
if (SCARG(&ap, name) == SO_DONTLINGER) {
m = m_get(M_WAIT, MT_SOOPTS);
mtod(m, struct linger *)->l_onoff = 0;
m->m_len = sizeof(struct linger);
error = sosetopt((struct socket *)fp->f_data, SCARG(&ap, level),
SO_LINGER, m);
error = sosetopt(so, SCARG(&ap, level), SO_LINGER, m);
}
if (SCARG(&ap, level) == IPPROTO_IP) {
#define EMUL_IP_MULTICAST_IF 2
@ -402,10 +400,9 @@ ultrix_sys_setsockopt(struct lwp *l, const struct ultrix_sys_setsockopt_args *ua
}
m->m_len = SCARG(&ap, valsize);
}
error = sosetopt((struct socket *)fp->f_data, SCARG(&ap, level),
SCARG(&ap, name), m);
error = sosetopt(so, SCARG(&ap, level), SCARG(&ap, name), m);
out:
FILE_UNUSE(fp, l);
fd_putfile(SCARG(uap, s));
return error;
}
@ -798,7 +795,7 @@ ultrix_sys_fcntl(struct lwp *l, const struct ultrix_sys_fcntl_args *uap, registe
error = ultrix_to_bsd_flock(&ufl, &fl);
if (error)
return error;
error = do_fcntl_lock(l, SCARG(uap, fd), SCARG(uap, cmd), &fl);
error = do_fcntl_lock(SCARG(uap, fd), SCARG(uap, cmd), &fl);
if (SCARG(uap, cmd) != F_GETLK || error != 0)
return error;
bsd_to_ultrix_flock(&fl, &ufl);

View File

@ -1,4 +1,4 @@
/* $NetBSD: ultrix_pathname.c,v 1.33 2008/01/05 19:14:09 dsl Exp $ */
/* $NetBSD: ultrix_pathname.c,v 1.34 2008/03/21 21:54:59 ad Exp $ */
/*
* Copyright (c) 1992, 1993
@ -59,7 +59,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ultrix_pathname.c,v 1.33 2008/01/05 19:14:09 dsl Exp $");
__KERNEL_RCSID(0, "$NetBSD: ultrix_pathname.c,v 1.34 2008/03/21 21:54:59 ad Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -173,17 +173,17 @@ ultrix_sys_open(struct lwp *l, const struct ultrix_sys_open_args *uap, register_
/* XXXSMP */
if (!ret && !noctty && SESS_LEADER(p) && !(p->p_lflag & PL_CONTROLT)) {
struct filedesc *fdp = p->p_fd;
struct file *fp;
file_t *fp;
int fd;
fp = fd_getfile(fdp, *retval);
fd = (int)*retval;
fp = fd_getfile(fd);
/* ignore any error, just give it a try */
if (fp != NULL) {
FILE_USE(fp);
if (fp->f_type == DTYPE_VNODE)
(fp->f_ops->fo_ioctl)(fp, TIOCSCTTY, (void *)0, l);
FILE_UNUSE(fp, l);
(fp->f_ops->fo_ioctl)(fp, TIOCSCTTY, NULL);
fd_putfile(fd);
}
}
return ret;
@ -256,14 +256,13 @@ ultrix_sys_statfs(struct lwp *l, const struct ultrix_sys_statfs_args *uap, regis
int
ultrix_sys_fstatfs(struct lwp *l, const struct ultrix_sys_fstatfs_args *uap, register_t *retval)
{
struct proc *p = l->l_proc;
struct file *fp;
file_t *fp;
struct mount *mp;
struct statvfs *sp;
int error;
/* getvnode() will use the descriptor for us */
if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0)
if ((error = fd_getvnode(SCARG(uap, fd), &fp)) != 0)
return error;
mp = ((struct vnode *)fp->f_data)->v_mount;
sp = &mp->mnt_stat;
@ -272,7 +271,7 @@ ultrix_sys_fstatfs(struct lwp *l, const struct ultrix_sys_fstatfs_args *uap, reg
sp->f_flag = mp->mnt_flag & MNT_VISFLAGMASK;
error = ultrixstatfs(sp, (void *)SCARG(uap, buf));
out:
FILE_UNUSE(fp, l);
fd_putfile(SCARG(uap, fd));
return error;
}

View File

@ -1,4 +1,4 @@
# $NetBSD: files,v 1.894 2008/03/11 05:24:38 mjacob Exp $
# $NetBSD: files,v 1.895 2008/03/21 21:54:59 ad Exp $
# @(#)files.newconf 7.5 (Berkeley) 5/10/93
@ -1428,6 +1428,7 @@ file kern/subr_vmem.c
file kern/subr_workqueue.c
file kern/subr_xcall.c
file kern/sys_aio.c
file kern/sys_descrip.c
file kern/sys_generic.c
file kern/sys_module.c
file kern/sys_mqueue.c

View File

@ -1,4 +1,4 @@
/* $NetBSD: ld_ataraid.c,v 1.24 2008/01/02 21:59:45 ad Exp $ */
/* $NetBSD: ld_ataraid.c,v 1.25 2008/03/21 21:54:59 ad Exp $ */
/*
* Copyright (c) 2003 Wasabi Systems, Inc.
@ -45,7 +45,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ld_ataraid.c,v 1.24 2008/01/02 21:59:45 ad Exp $");
__KERNEL_RCSID(0, "$NetBSD: ld_ataraid.c,v 1.25 2008/03/21 21:54:59 ad Exp $");
#include "rnd.h"
@ -230,7 +230,7 @@ ld_ataraid_attach(struct device *parent, struct device *self,
vp = sc->sc_vnodes[i];
sc->sc_vnodes[i] = NULL;
if (vp != NULL)
(void) vn_close(vp, FREAD|FWRITE, NOCRED, curlwp);
(void) vn_close(vp, FREAD|FWRITE, NOCRED);
}
finish:

View File

@ -1,4 +1,4 @@
/* $NetBSD: ccd.c,v 1.127 2008/02/02 10:40:50 hannken Exp $ */
/* $NetBSD: ccd.c,v 1.128 2008/03/21 21:54:59 ad Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998, 1999, 2007 The NetBSD Foundation, Inc.
@ -125,7 +125,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ccd.c,v 1.127 2008/02/02 10:40:50 hannken Exp $");
__KERNEL_RCSID(0, "$NetBSD: ccd.c,v 1.128 2008/03/21 21:54:59 ad Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -1101,7 +1101,7 @@ ccdioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l)
UIO_USERSPACE)) != 0) {
for (j = 0; j < lookedup; ++j)
(void)vn_close(vpp[j], FREAD|FWRITE,
uc, l);
uc);
free(vpp, M_DEVBUF);
free(cpp, M_DEVBUF);
goto out;
@ -1115,7 +1115,7 @@ ccdioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l)
if ((error = ccdinit(cs, cpp, vpp, l)) != 0) {
for (j = 0; j < lookedup; ++j)
(void)vn_close(vpp[j], FREAD|FWRITE,
uc, l);
uc);
free(vpp, M_DEVBUF);
free(cpp, M_DEVBUF);
goto out;
@ -1183,7 +1183,7 @@ ccdioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l)
cs->sc_cinfo[i].ci_vp);
#endif
(void)vn_close(cs->sc_cinfo[i].ci_vp, FREAD|FWRITE,
uc, l);
uc);
free(cs->sc_cinfo[i].ci_path, M_DEVBUF);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: cgd.c,v 1.50 2008/01/04 21:17:46 ad Exp $ */
/* $NetBSD: cgd.c,v 1.51 2008/03/21 21:54:59 ad Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.50 2008/01/04 21:17:46 ad Exp $");
__KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.51 2008/03/21 21:54:59 ad Exp $");
#include <sys/types.h>
#include <sys/param.h>
@ -575,7 +575,7 @@ cgd_ioctl_set(struct cgd_softc *cs, void *data, struct lwp *l)
bail:
free(inbuf, M_TEMP);
(void)vn_close(vp, FREAD|FWRITE, l->l_cred, l);
(void)vn_close(vp, FREAD|FWRITE, l->l_cred);
return ret;
}
@ -594,7 +594,7 @@ cgd_ioctl_clr(struct cgd_softc *cs, void *data, struct lwp *l)
splx(s);
bufq_free(cs->sc_dksc.sc_bufq);
(void)vn_close(cs->sc_tvn, FREAD|FWRITE, l->l_cred, l);
(void)vn_close(cs->sc_tvn, FREAD|FWRITE, l->l_cred);
cs->sc_cfuncs->cf_destroy(cs->sc_cdata.cf_priv);
free(cs->sc_tpath, M_DEVBUF);
free(cs->sc_data, M_DEVBUF);

View File

@ -1,4 +1,4 @@
/* $NetBSD: dksubr.c,v 1.34 2008/01/30 15:30:12 ad Exp $ */
/* $NetBSD: dksubr.c,v 1.35 2008/03/21 21:54:59 ad Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998, 1999, 2002, 2008 The NetBSD Foundation, Inc.
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: dksubr.c,v 1.34 2008/01/30 15:30:12 ad Exp $");
__KERNEL_RCSID(0, "$NetBSD: dksubr.c,v 1.35 2008/03/21 21:54:59 ad Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -664,6 +664,6 @@ dk_lookup(const char *path, struct lwp *l, struct vnode **vpp,
return 0;
out:
VOP_UNLOCK(vp, 0);
(void) vn_close(vp, FREAD | FWRITE, l->l_cred, l);
(void) vn_close(vp, FREAD | FWRITE, l->l_cred);
return error;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: dk.c,v 1.34 2008/03/04 13:51:18 cube Exp $ */
/* $NetBSD: dk.c,v 1.35 2008/03/21 21:54:59 ad Exp $ */
/*-
* Copyright (c) 2004, 2005, 2006, 2007 The NetBSD Foundation, Inc.
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: dk.c,v 1.34 2008/03/04 13:51:18 cube Exp $");
__KERNEL_RCSID(0, "$NetBSD: dk.c,v 1.35 2008/03/21 21:54:59 ad Exp $");
#include "opt_dkwedge.h"
@ -486,7 +486,7 @@ dkwedge_del(struct dkwedge_info *dkw)
if (sc->sc_parent->dk_rawopens-- == 1) {
KASSERT(sc->sc_parent->dk_rawvp != NULL);
(void) vn_close(sc->sc_parent->dk_rawvp, FREAD | FWRITE,
NOCRED, curlwp);
NOCRED);
sc->sc_parent->dk_rawvp = NULL;
}
sc->sc_dk.dk_openmask = 0;
@ -834,7 +834,7 @@ dkwedge_discover(struct disk *pdk)
}
}
error = vn_close(vp, FREAD, NOCRED, curlwp);
error = vn_close(vp, FREAD, NOCRED);
if (error) {
aprint_error("%s: unable to close device, error = %d\n",
pdk->dk_name, error);
@ -979,7 +979,7 @@ dkclose(dev_t dev, int flags, int fmt, struct lwp *l)
if (sc->sc_parent->dk_rawopens-- == 1) {
KASSERT(sc->sc_parent->dk_rawvp != NULL);
error = vn_close(sc->sc_parent->dk_rawvp,
FREAD | FWRITE, NOCRED, l);
FREAD | FWRITE, NOCRED);
sc->sc_parent->dk_rawvp = NULL;
}
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: drm_drv.c,v 1.9 2008/03/04 11:52:38 drochner Exp $ */
/* $NetBSD: drm_drv.c,v 1.10 2008/03/21 21:54:59 ad Exp $ */
/* drm_drv.h -- Generic driver template -*- linux-c -*-
* Created: Thu Nov 23 03:10:50 2000 by gareth@valinux.com
@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: drm_drv.c,v 1.9 2008/03/04 11:52:38 drochner Exp $");
__KERNEL_RCSID(0, "$NetBSD: drm_drv.c,v 1.10 2008/03/21 21:54:59 ad Exp $");
/*
__FBSDID("$FreeBSD: src/sys/dev/drm/drm_drv.c,v 1.6 2006/09/07 23:04:47 anholt Exp $");
*/
@ -754,12 +754,12 @@ int drm_ioctl(DRM_CDEV kdev, u_long cmd, void *data, int flags,
case SIOCSPGRP:
case TIOCSPGRP:
case FIOSETOWN:
return fsetown(p->l_proc, &dev->buf_pgid, cmd, data);
return fsetown(&dev->buf_pgid, cmd, data);
case SIOCGPGRP:
case TIOCGPGRP:
case FIOGETOWN:
return fgetown(p->l_proc, dev->buf_pgid, cmd, data);
return fgetown(dev->buf_pgid, cmd, data);
}
if (IOCGROUP(cmd) != DRM_IOCTL_BASE) {

View File

@ -1,4 +1,4 @@
/* $NetBSD: firmload.c,v 1.9 2007/12/08 19:29:41 pooka Exp $ */
/* $NetBSD: firmload.c,v 1.10 2008/03/21 21:54:59 ad Exp $ */
/*-
* Copyright (c) 2005, 2006 The NetBSD Foundation, Inc.
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: firmload.c,v 1.9 2007/12/08 19:29:41 pooka Exp $");
__KERNEL_RCSID(0, "$NetBSD: firmload.c,v 1.10 2008/03/21 21:54:59 ad Exp $");
/*
* The firmload API provides an interface for device drivers to access
@ -269,14 +269,14 @@ firmware_open(const char *drvname, const char *imgname, firmware_handle_t *fhp)
error = VOP_GETATTR(vp, &va, kauth_cred_get());
if (error) {
VOP_UNLOCK(vp, 0);
(void)vn_close(vp, FREAD, kauth_cred_get(), curlwp);
(void)vn_close(vp, FREAD, kauth_cred_get());
firmware_handle_free(fh);
return (error);
}
if (va.va_type != VREG) {
VOP_UNLOCK(vp, 0);
(void)vn_close(vp, FREAD, kauth_cred_get(), curlwp);
(void)vn_close(vp, FREAD, kauth_cred_get());
firmware_handle_free(fh);
return (EINVAL);
}
@ -302,7 +302,7 @@ firmware_close(firmware_handle_t fh)
{
int error;
error = vn_close(fh->fh_vp, FREAD, kauth_cred_get(), curlwp);
error = vn_close(fh->fh_vp, FREAD, kauth_cred_get());
firmware_handle_free(fh);
return (error);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: fss.c,v 1.43 2008/01/04 21:17:47 ad Exp $ */
/* $NetBSD: fss.c,v 1.44 2008/03/21 21:54:59 ad Exp $ */
/*-
* Copyright (c) 2003 The NetBSD Foundation, Inc.
@ -43,7 +43,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: fss.c,v 1.43 2008/01/04 21:17:47 ad Exp $");
__KERNEL_RCSID(0, "$NetBSD: fss.c,v 1.44 2008/03/21 21:54:59 ad Exp $");
#include "fss.h"
@ -769,9 +769,9 @@ bad:
fss_softc_free(sc);
if (sc->sc_bs_vp != NULL) {
if (sc->sc_flags & FSS_PERSISTENT)
vn_close(sc->sc_bs_vp, FREAD, l->l_cred, l);
vn_close(sc->sc_bs_vp, FREAD, l->l_cred);
else
vn_close(sc->sc_bs_vp, FREAD|FWRITE, l->l_cred, l);
vn_close(sc->sc_bs_vp, FREAD|FWRITE, l->l_cred);
}
sc->sc_bs_vp = NULL;
@ -797,9 +797,9 @@ fss_delete_snapshot(struct fss_softc *sc, struct lwp *l)
fss_softc_free(sc);
if (sc->sc_flags & FSS_PERSISTENT)
vn_close(sc->sc_bs_vp, FREAD, l->l_cred, l);
vn_close(sc->sc_bs_vp, FREAD, l->l_cred);
else
vn_close(sc->sc_bs_vp, FREAD|FWRITE, l->l_cred, l);
vn_close(sc->sc_bs_vp, FREAD|FWRITE, l->l_cred);
sc->sc_bs_vp = NULL;
sc->sc_flags &= ~FSS_PERSISTENT;

View File

@ -1,4 +1,4 @@
/* $NetBSD: kloader.c,v 1.15 2007/12/15 00:39:26 perry Exp $ */
/* $NetBSD: kloader.c,v 1.16 2008/03/21 21:54:59 ad Exp $ */
/*-
* Copyright (c) 2001, 2002, 2004 The NetBSD Foundation, Inc.
@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: kloader.c,v 1.15 2007/12/15 00:39:26 perry Exp $");
__KERNEL_RCSID(0, "$NetBSD: kloader.c,v 1.16 2008/03/21 21:54:59 ad Exp $");
#include "debug_kloader.h"
@ -623,7 +623,7 @@ kloader_close()
struct vnode *vp = kloader.vp;
VOP_UNLOCK(vp, 0);
vn_close(vp, FREAD, l->l_cred, l);
vn_close(vp, FREAD, l->l_cred);
}
int

View File

@ -1,4 +1,4 @@
/* $NetBSD: kttcp.c,v 1.25 2008/02/06 21:57:54 ad Exp $ */
/* $NetBSD: kttcp.c,v 1.26 2008/03/21 21:54:59 ad Exp $ */
/*
* Copyright (c) 2002 Wasabi Systems, Inc.
@ -42,7 +42,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: kttcp.c,v 1.25 2008/02/06 21:57:54 ad Exp $");
__KERNEL_RCSID(0, "$NetBSD: kttcp.c,v 1.26 2008/03/21 21:54:59 ad Exp $");
#include <sys/param.h>
#include <sys/types.h>
@ -113,7 +113,7 @@ kttcpioctl(dev_t dev, u_long cmd, void *data, int flag,
static int
kttcp_send(struct lwp *l, struct kttcp_io_args *kio)
{
struct file *fp;
struct socket *so;
int error;
struct timeval t0, t1;
unsigned long long len, done;
@ -121,24 +121,17 @@ kttcp_send(struct lwp *l, struct kttcp_io_args *kio)
if (kio->kio_totalsize >= KTTCP_MAX_XMIT)
return EINVAL;
fp = fd_getfile(l->l_proc->p_fd, kio->kio_socket);
if (fp == NULL)
return EBADF;
FILE_USE(fp);
if (fp->f_type != DTYPE_SOCKET) {
FILE_UNUSE(fp, l);
return EFTYPE;
}
if ((error = fd_getsock(kio->kio_socket, &so)) != 0)
return error;
len = kio->kio_totalsize;
microtime(&t0);
do {
error = kttcp_sosend((struct socket *)fp->f_data, len,
&done, l, 0);
error = kttcp_sosend(so, len, &done, l, 0);
len -= done;
} while (error == 0 && len > 0);
FILE_UNUSE(fp, l);
fd_putfile(kio->kio_socket);
microtime(&t1);
if (error != 0)
@ -153,7 +146,7 @@ kttcp_send(struct lwp *l, struct kttcp_io_args *kio)
static int
kttcp_recv(struct lwp *l, struct kttcp_io_args *kio)
{
struct file *fp;
struct socket *so;
int error;
struct timeval t0, t1;
unsigned long long len, done;
@ -163,23 +156,16 @@ kttcp_recv(struct lwp *l, struct kttcp_io_args *kio)
if (kio->kio_totalsize > KTTCP_MAX_XMIT)
return EINVAL;
fp = fd_getfile(l->l_proc->p_fd, kio->kio_socket);
if (fp == NULL)
return EBADF;
FILE_USE(fp);
if (fp->f_type != DTYPE_SOCKET) {
FILE_UNUSE(fp, l);
return EBADF;
}
if ((error = fd_getsock(kio->kio_socket, &so)) != 0)
return error;
len = kio->kio_totalsize;
microtime(&t0);
do {
error = kttcp_soreceive((struct socket *)fp->f_data,
len, &done, l, NULL);
error = kttcp_soreceive(so, len, &done, l, NULL);
len -= done;
} while (error == 0 && len > 0 && done > 0);
FILE_UNUSE(fp, l);
fd_putfile(kio->kio_socket);
microtime(&t1);
if (error == EPIPE)

View File

@ -1,4 +1,4 @@
/* $NetBSD: putter.c,v 1.8 2008/03/01 14:16:50 rmind Exp $ */
/* $NetBSD: putter.c,v 1.9 2008/03/21 21:54:59 ad Exp $ */
/*
* Copyright (c) 2006, 2007 Antti Kantee. All Rights Reserved.
@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: putter.c,v 1.8 2008/03/01 14:16:50 rmind Exp $");
__KERNEL_RCSID(0, "$NetBSD: putter.c,v 1.9 2008/03/21 21:54:59 ad Exp $");
#include <sys/param.h>
#include <sys/conf.h>
@ -163,14 +163,14 @@ putter_destroy()
/*
* fd routines, for cloner
*/
static int putter_fop_read(struct file *, off_t *, struct uio *,
static int putter_fop_read(file_t *, off_t *, struct uio *,
kauth_cred_t, int);
static int putter_fop_write(struct file *, off_t *, struct uio *,
static int putter_fop_write(file_t *, off_t *, struct uio *,
kauth_cred_t, int);
static int putter_fop_ioctl(struct file*, u_long, void *, struct lwp *);
static int putter_fop_poll(struct file *, int, struct lwp *);
static int putter_fop_close(struct file *, struct lwp *);
static int putter_fop_kqfilter(struct file *, struct knote *);
static int putter_fop_ioctl(file_t*, u_long, void *);
static int putter_fop_poll(file_t *, int);
static int putter_fop_close(file_t *);
static int putter_fop_kqfilter(file_t *, struct knote *);
static const struct fileops putter_fileops = {
@ -185,7 +185,7 @@ static const struct fileops putter_fileops = {
};
static int
putter_fop_read(struct file *fp, off_t *off, struct uio *uio,
putter_fop_read(file_t *fp, off_t *off, struct uio *uio,
kauth_cred_t cred, int flags)
{
struct putter_instance *pi = fp->f_data;
@ -225,7 +225,7 @@ putter_fop_read(struct file *fp, off_t *off, struct uio *uio,
}
static int
putter_fop_write(struct file *fp, off_t *off, struct uio *uio,
putter_fop_write(file_t *fp, off_t *off, struct uio *uio,
kauth_cred_t cred, int flags)
{
struct putter_instance *pi = fp->f_data;
@ -269,7 +269,7 @@ putter_fop_write(struct file *fp, off_t *off, struct uio *uio,
*/
#define PUTTERPOLL_EVSET (POLLIN | POLLRDNORM | POLLRDBAND | POLLPRI)
static int
putter_fop_poll(struct file *fp, int events, struct lwp *l)
putter_fop_poll(file_t *fp, int events)
{
struct putter_instance *pi = fp->f_data;
int revents;
@ -287,7 +287,7 @@ putter_fop_poll(struct file *fp, int events, struct lwp *l)
if (pi->pi_pop->pop_waitcount(pi->pi_private))
revents |= PUTTERPOLL_EVSET;
else
selrecord(l, &pi->pi_sel);
selrecord(curlwp, &pi->pi_sel);
return revents;
}
@ -298,7 +298,7 @@ putter_fop_poll(struct file *fp, int events, struct lwp *l)
* unmounting is a frightfully complex operation to avoid races
*/
static int
putter_fop_close(struct file *fp, struct lwp *l)
putter_fop_close(file_t *fp)
{
struct putter_instance *pi = fp->f_data;
int rv;
@ -357,7 +357,7 @@ putter_fop_close(struct file *fp, struct lwp *l)
}
static int
putter_fop_ioctl(struct file *fp, u_long cmd, void *data, struct lwp *l)
putter_fop_ioctl(file_t *fp, u_long cmd, void *data)
{
/*
@ -405,7 +405,7 @@ static const struct filterops putter_filtops =
{ 1, NULL, filt_putterdetach, filt_putter };
static int
putter_fop_kqfilter(struct file *fp, struct knote *kn)
putter_fop_kqfilter(file_t *fp, struct knote *kn)
{
struct putter_instance *pi = fp->f_data;
struct klist *klist;
@ -450,14 +450,16 @@ int
puttercdopen(dev_t dev, int flags, int fmt, struct lwp *l)
{
struct putter_instance *pi;
struct file *fp;
file_t *fp;
int error, fd, idx;
proc_t *p;
p = curproc;
pi = kmem_alloc(sizeof(struct putter_instance), KM_SLEEP);
mutex_enter(&pi_mtx);
idx = get_pi_idx(pi);
pi->pi_pid = l->l_proc->p_pid;
pi->pi_pid = p->p_pid;
pi->pi_idx = idx;
pi->pi_curput = NULL;
pi->pi_curres = 0;
@ -465,7 +467,7 @@ puttercdopen(dev_t dev, int flags, int fmt, struct lwp *l)
selinit(&pi->pi_sel);
mutex_exit(&pi_mtx);
if ((error = falloc(l, &fp, &fd)) != 0)
if ((error = fd_allocfile(&fp, &fd)) != 0)
goto bad1;
if ((error = putter_configure(dev, flags, fmt, fd)) != 0)
@ -474,14 +476,12 @@ puttercdopen(dev_t dev, int flags, int fmt, struct lwp *l)
DPRINTF(("puttercdopen: registered embryonic pmp for pid: %d\n",
pi->pi_pid));
error = fdclone(l, fp, fd, FREAD|FWRITE, &putter_fileops, pi);
error = fd_clone(fp, fd, FREAD|FWRITE, &putter_fileops, pi);
KASSERT(error = EMOVEFD);
return error;
bad2:
FILE_UNUSE(fp, l);
fdremove(l->l_proc->p_fd, fd);
ffree(fp);
fd_abort(p, fp, fd);
bad1:
putter_detach(pi);
kmem_free(pi, sizeof(struct putter_instance));

View File

@ -1,6 +1,6 @@
/* $NetBSD: rf_netbsdkintf.c,v 1.243 2008/01/04 21:18:05 ad Exp $ */
/* $NetBSD: rf_netbsdkintf.c,v 1.244 2008/03/21 21:54:59 ad Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
* Copyright (c) 1996, 1997, 1998, 2008 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@ -146,7 +146,7 @@
***********************************************************/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.243 2008/01/04 21:18:05 ad Exp $");
__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.244 2008/03/21 21:54:59 ad Exp $");
#include <sys/param.h>
#include <sys/errno.h>
@ -2664,7 +2664,7 @@ rf_close_component(RF_Raid_t *raidPtr, struct vnode *vp, int auto_configured)
vput(vp);
} else {
(void) vn_close(vp, FREAD | FWRITE, curlwp->l_cred, curlwp);
(void) vn_close(vp, FREAD | FWRITE, curlwp->l_cred);
}
}
}

View File

@ -1,7 +1,7 @@
/* $NetBSD: vnd.c,v 1.176 2008/03/04 23:03:29 cube Exp $ */
/* $NetBSD: vnd.c,v 1.177 2008/03/21 21:54:59 ad Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
* Copyright (c) 1996, 1997, 1998, 2008 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@ -137,7 +137,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.176 2008/03/04 23:03:29 cube Exp $");
__KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.177 2008/03/21 21:54:59 ad Exp $");
#if defined(_KERNEL_OPT)
#include "fs_nfs.h"
@ -1215,7 +1215,7 @@ vndioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l)
break;
close_and_exit:
(void) vn_close(nd.ni_vp, fflags, l->l_cred, l);
(void) vn_close(nd.ni_vp, fflags, l->l_cred);
unlock_and_exit:
#ifdef VND_COMPRESSION
/* free any allocated memory (for compressed file) */
@ -1493,7 +1493,6 @@ static void
vndclear(struct vnd_softc *vnd, int myminor)
{
struct vnode *vp = vnd->sc_vp;
struct lwp *l = curlwp;
int fflags = FREAD;
int bmaj, cmaj, i, mn;
int s;
@ -1548,7 +1547,7 @@ vndclear(struct vnd_softc *vnd, int myminor)
| VNF_VUNCONF | VNF_COMP);
if (vp == (struct vnode *)0)
panic("vndclear: null vp");
(void) vn_close(vp, fflags, vnd->sc_cred, l);
(void) vn_close(vp, fflags, vnd->sc_cred);
kauth_cred_free(vnd->sc_cred);
vnd->sc_vp = (struct vnode *)0;
vnd->sc_cred = (kauth_cred_t)0;

View File

@ -1,4 +1,4 @@
/* $NetBSD: smbfs_kq.c,v 1.19 2008/02/05 14:19:52 ad Exp $ */
/* $NetBSD: smbfs_kq.c,v 1.20 2008/03/21 21:54:59 ad Exp $ */
/*-
* Copyright (c) 2003, 2008 The NetBSD Foundation, Inc.
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: smbfs_kq.c,v 1.19 2008/02/05 14:19:52 ad Exp $");
__KERNEL_RCSID(0, "$NetBSD: smbfs_kq.c,v 1.20 2008/03/21 21:54:59 ad Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -376,7 +376,7 @@ filt_smbfsread(struct knote *kn, long hint)
} else
rv = 0;
} else {
kn->kn_data = vp->v_size - kn->kn_fp->f_offset;
kn->kn_data = vp->v_size - ((file_t *)kn->kn_obj)->f_offset;
rv = (kn->kn_data != 0);
}
if (hint == 0) {

View File

@ -1,4 +1,4 @@
/* $NetBSD: union_subr.c,v 1.32 2008/02/27 19:59:48 matt Exp $ */
/* $NetBSD: union_subr.c,v 1.33 2008/03/21 21:55:00 ad Exp $ */
/*
* Copyright (c) 1994
@ -72,7 +72,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: union_subr.c,v 1.32 2008/02/27 19:59:48 matt Exp $");
__KERNEL_RCSID(0, "$NetBSD: union_subr.c,v 1.33 2008/03/21 21:55:00 ad Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -1184,7 +1184,7 @@ union_readdirhook(struct vnode **vpp, struct file *fp, struct lwp *l)
VOP_UNLOCK(lvp, 0);
fp->f_data = lvp;
fp->f_offset = 0;
error = vn_close(vp, FREAD, fp->f_cred, l);
error = vn_close(vp, FREAD, fp->f_cred);
if (error)
return (error);
*vpp = lvp;

View File

@ -1,4 +1,4 @@
/* $NetBSD: exec_script.c,v 1.61 2008/01/02 19:44:37 yamt Exp $ */
/* $NetBSD: exec_script.c,v 1.62 2008/03/21 21:55:00 ad Exp $ */
/*
* Copyright (c) 1993, 1994, 1996 Christopher G. Demetriou
@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: exec_script.c,v 1.61 2008/01/02 19:44:37 yamt Exp $");
__KERNEL_RCSID(0, "$NetBSD: exec_script.c,v 1.62 2008/03/21 21:55:00 ad Exp $");
#if defined(SETUIDSCRIPTS) && !defined(FDSCRIPTS)
#define FDSCRIPTS /* Need this for safe set-id scripts. */
@ -191,20 +191,17 @@ check_shell:
panic("exec_script_makecmds: epp already has a fd");
#endif
/* falloc() will use the descriptor for us */
if ((error = falloc(l, &fp, &epp->ep_fd)) != 0) {
if ((error = fd_allocfile(&fp, &epp->ep_fd)) != 0) {
scriptvp = NULL;
shellargp = NULL;
goto fail;
}
epp->ep_flags |= EXEC_HASFD;
fp->f_type = DTYPE_VNODE;
fp->f_ops = &vnops;
fp->f_data = (void *) epp->ep_vp;
fp->f_flag = FREAD;
FILE_SET_MATURE(fp);
FILE_UNUSE(fp, l);
fd_affix(curproc, fp, epp->ep_fd);
}
#endif
@ -308,7 +305,7 @@ fail:
/* kill the opened file descriptor, else close the file */
if (epp->ep_flags & EXEC_HASFD) {
epp->ep_flags &= ~EXEC_HASFD;
(void) fdrelease(l, epp->ep_fd);
fd_close(epp->ep_fd);
} else if (scriptvp) {
vn_lock(scriptvp, LK_EXCLUSIVE | LK_RETRY);
VOP_CLOSE(scriptvp, FREAD, l->l_cred);

View File

@ -1,4 +1,4 @@
/* $NetBSD: init_main.c,v 1.342 2008/03/09 15:39:14 rmind Exp $ */
/* $NetBSD: init_main.c,v 1.343 2008/03/21 21:55:00 ad Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1991, 1992, 1993
@ -71,7 +71,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.342 2008/03/09 15:39:14 rmind Exp $");
__KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.343 2008/03/21 21:55:00 ad Exp $");
#include "opt_ipsec.h"
#include "opt_ntp.h"
@ -133,6 +133,7 @@ __KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.342 2008/03/09 15:39:14 rmind Exp $"
#include <sys/mqueue.h>
#include <sys/msgbuf.h>
#include <sys/module.h>
#include <sys/event.h>
#ifdef FAST_IPSEC
#include <netipsec/ipsec.h>
#endif
@ -381,10 +382,11 @@ main(void)
fstrans_init();
/* Initialize the file descriptor system. */
filedesc_init();
fd_sys_init();
/* Initialize the select()/poll() system calls. */
/* Initialize the select()/poll() system calls, and kqueue. */
selsysinit();
kqueue_init();
/* Initialize asynchronous I/O. */
aio_sysinit();

View File

@ -1,4 +1,4 @@
/* $NetBSD: init_sysctl.c,v 1.123 2008/02/27 19:57:18 matt Exp $ */
/* $NetBSD: init_sysctl.c,v 1.124 2008/03/21 21:55:00 ad Exp $ */
/*-
* Copyright (c) 2003, 2007, 2008 The NetBSD Foundation, Inc.
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: init_sysctl.c,v 1.123 2008/02/27 19:57:18 matt Exp $");
__KERNEL_RCSID(0, "$NetBSD: init_sysctl.c,v 1.124 2008/03/21 21:55:00 ad Exp $");
#include "opt_sysv.h"
#include "opt_posix.h"
@ -192,8 +192,8 @@ static int sysctl_hw_cnmagic(SYSCTLFN_PROTO);
static u_int sysctl_map_flags(const u_int *, u_int);
static void fill_kproc2(struct proc *, struct kinfo_proc2 *);
static void fill_lwp(struct lwp *l, struct kinfo_lwp *kl);
static void fill_file(struct kinfo_file *, const struct file *, struct proc *,
int);
static void fill_file(struct kinfo_file *, const file_t *, const fdfile_t *,
int, pid_t);
/*
* ********************************************************************
@ -1925,6 +1925,7 @@ sysctl_kern_file2(SYSCTLFN_ARGS)
u_int i, op;
size_t len, needed, elem_size, out_size;
int error, arg, elem_count;
fdfile_t *ff;
if (namelen == 1 && name[0] == CTL_QUERY)
return (sysctl_query(SYSCTLFN_CALL(rnode)));
@ -1978,7 +1979,7 @@ sysctl_kern_file2(SYSCTLFN_ARGS)
continue;
}
if (len >= elem_size && elem_count > 0) {
fill_file(&kf, fp, NULL, 0);
fill_file(&kf, fp, NULL, 0, 0);
LIST_INSERT_AFTER(fp, tp, f_list);
mutex_exit(&fp->f_lock);
mutex_exit(&filelist_lock);
@ -2040,29 +2041,30 @@ sysctl_kern_file2(SYSCTLFN_ARGS)
/* XXX Do we need to check permission per file? */
fd = p->p_fd;
rw_enter(&fd->fd_lock, RW_READER);
mutex_enter(&fd->fd_lock);
for (i = 0; i < fd->fd_nfiles; i++) {
fp = fd->fd_ofiles[i];
if (fp == NULL) {
if ((ff = fd->fd_ofiles[i]) == NULL) {
continue;
}
mutex_enter(&fp->f_lock);
if (!FILE_IS_USABLE(fp)) {
mutex_exit(&fp->f_lock);
mutex_enter(&ff->ff_lock);
if ((fp = ff->ff_file) == NULL) {
mutex_exit(&ff->ff_lock);
continue;
}
if (len >= elem_size && elem_count > 0) {
fill_file(&kf, fd->fd_ofiles[i], p, i);
fill_file(&kf, fp, ff, i, p->p_pid);
mutex_exit(&fp->f_lock);
rw_exit(&fd->fd_lock);
mutex_exit(&ff->ff_lock);
mutex_exit(&fd->fd_lock);
error = dcopyout(l, &kf, dp, out_size);
rw_enter(&fd->fd_lock, RW_READER);
mutex_enter(&fd->fd_lock);
if (error)
break;
dp += elem_size;
len -= elem_size;
} else {
mutex_exit(&fp->f_lock);
mutex_exit(&ff->ff_lock);
}
if (elem_count > 0) {
needed += elem_size;
@ -2070,7 +2072,7 @@ sysctl_kern_file2(SYSCTLFN_ARGS)
elem_count--;
}
}
rw_exit(&fd->fd_lock);
mutex_exit(&fd->fd_lock);
/*
* Release reference to process.
@ -2093,7 +2095,8 @@ sysctl_kern_file2(SYSCTLFN_ARGS)
}
static void
fill_file(struct kinfo_file *kp, const struct file *fp, struct proc *p, int i)
fill_file(struct kinfo_file *kp, const file_t *fp, const fdfile_t *ff,
int i, pid_t pid)
{
memset(kp, 0, sizeof(*kp));
@ -2104,7 +2107,6 @@ fill_file(struct kinfo_file *kp, const struct file *fp, struct proc *p, int i)
kp->ki_ftype = fp->f_type;
kp->ki_count = fp->f_count;
kp->ki_msgcount = fp->f_msgcount;
kp->ki_usecount = fp->f_usecount;
kp->ki_fucred = PTRTOUINT64(fp->f_cred);
kp->ki_fuid = kauth_cred_geteuid(fp->f_cred);
kp->ki_fgid = kauth_cred_getegid(fp->f_cred);
@ -2124,12 +2126,11 @@ fill_file(struct kinfo_file *kp, const struct file *fp, struct proc *p, int i)
}
/* process information when retrieved via KERN_FILE_BYPID */
if (p) {
KASSERT(rw_lock_held(&p->p_fd->fd_lock));
kp->ki_pid = p->p_pid;
if (ff != NULL) {
kp->ki_pid = pid;
kp->ki_fd = i;
kp->ki_ofileflags = p->p_fd->fd_ofileflags[i];
kp->ki_ofileflags = ff->ff_exclose;
kp->ki_usecount = ff->ff_refcnt;
}
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: kern_acct.c,v 1.83 2008/01/25 14:32:14 ad Exp $ */
/* $NetBSD: kern_acct.c,v 1.84 2008/03/21 21:55:00 ad Exp $ */
/*-
* Copyright (c) 1982, 1986, 1989, 1993
@ -71,7 +71,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: kern_acct.c,v 1.83 2008/01/25 14:32:14 ad Exp $");
__KERNEL_RCSID(0, "$NetBSD: kern_acct.c,v 1.84 2008/03/21 21:55:00 ad Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -215,7 +215,7 @@ acct_stop(void)
KASSERT(rw_write_held(&acct_lock));
if (acct_vp != NULLVP && acct_vp->v_type != VBAD) {
error = vn_close(acct_vp, FWRITE, acct_cred, NULL);
error = vn_close(acct_vp, FWRITE, acct_cred);
#ifdef DIAGNOSTIC
if (error != 0)
printf("acct_stop: failed to close, errno = %d\n",
@ -374,7 +374,7 @@ sys_acct(struct lwp *l, const struct sys_acct_args *uap, register_t *retval)
rw_exit(&acct_lock);
return (error);
bad:
vn_close(nd.ni_vp, FWRITE, l->l_cred, l);
vn_close(nd.ni_vp, FWRITE, l->l_cred);
return error;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: kern_core.c,v 1.9 2008/01/25 14:32:14 ad Exp $ */
/* $NetBSD: kern_core.c,v 1.10 2008/03/21 21:55:00 ad Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1991, 1993
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: kern_core.c,v 1.9 2008/01/25 14:32:14 ad Exp $");
__KERNEL_RCSID(0, "$NetBSD: kern_core.c,v 1.10 2008/03/21 21:55:00 ad Exp $");
#include "opt_coredump.h"
@ -194,7 +194,7 @@ coredump(struct lwp *l, const char *pattern)
error = (*p->p_execsw->es_coredump)(l, &io);
out:
VOP_UNLOCK(vp, 0);
error1 = vn_close(vp, FWRITE, cred, l);
error1 = vn_close(vp, FWRITE, cred);
if (error == 0)
error = error1;
done:

View File

@ -1,4 +1,4 @@
/* $NetBSD: kern_exec.c,v 1.269 2008/02/24 21:46:04 christos Exp $ */
/* $NetBSD: kern_exec.c,v 1.270 2008/03/21 21:55:00 ad Exp $ */
/*-
* Copyright (C) 1993, 1994, 1996 Christopher G. Demetriou
@ -33,7 +33,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: kern_exec.c,v 1.269 2008/02/24 21:46:04 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: kern_exec.c,v 1.270 2008/03/21 21:55:00 ad Exp $");
#include "opt_ktrace.h"
#include "opt_syscall_debug.h"
@ -826,7 +826,7 @@ execve1(struct lwp *l, const char *path, char * const *args,
goto exec_abort;
}
fdcloseexec(l); /* handle close on exec */
fd_closeexec(); /* handle close on exec */
execsigs(p); /* reset catched signals */
l->l_ctxlink = NULL; /* reset ucontext link */
@ -879,7 +879,7 @@ execve1(struct lwp *l, const char *path, char * const *args,
proc_crmod_leave(NULL, NULL, true);
/* Make sure file descriptors 0..2 are in use. */
if ((error = fdcheckstd(l)) != 0) {
if ((error = fd_checkstd()) != 0) {
DPRINTF(("execve: fdcheckstd failed %d\n", error));
goto exec_abort;
}
@ -1054,7 +1054,7 @@ execve1(struct lwp *l, const char *path, char * const *args,
/* kill any opened file descriptor, if necessary */
if (pack.ep_flags & EXEC_HASFD) {
pack.ep_flags &= ~EXEC_HASFD;
(void) fdrelease(l, pack.ep_fd);
fd_close(pack.ep_fd);
}
/* close and put the exec'd file */
vn_lock(pack.ep_vp, LK_EXCLUSIVE | LK_RETRY);

View File

@ -1,4 +1,4 @@
/* $NetBSD: kern_exit.c,v 1.199 2008/01/28 12:22:46 yamt Exp $ */
/* $NetBSD: kern_exit.c,v 1.200 2008/03/21 21:55:00 ad Exp $ */
/*-
* Copyright (c) 1998, 1999, 2006, 2007 The NetBSD Foundation, Inc.
@ -74,7 +74,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: kern_exit.c,v 1.199 2008/01/28 12:22:46 yamt Exp $");
__KERNEL_RCSID(0, "$NetBSD: kern_exit.c,v 1.200 2008/03/21 21:55:00 ad Exp $");
#include "opt_ktrace.h"
#include "opt_perfctrs.h"
@ -276,7 +276,7 @@ exit1(struct lwp *l, int rv)
* Close open files, release open-file table and free signal
* actions. This may block!
*/
fdfree(l);
fd_free();
cwdfree(p->p_cwdi);
p->p_cwdi = NULL;
doexithooks(p);

View File

@ -1,7 +1,7 @@
/* $NetBSD: kern_fork.c,v 1.158 2008/02/24 18:30:07 dsl Exp $ */
/* $NetBSD: kern_fork.c,v 1.159 2008/03/21 21:55:00 ad Exp $ */
/*-
* Copyright (c) 1999, 2001, 2004, 2006, 2007 The NetBSD Foundation, Inc.
* Copyright (c) 1999, 2001, 2004, 2006, 2007, 2008 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@ -74,7 +74,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: kern_fork.c,v 1.158 2008/02/24 18:30:07 dsl Exp $");
__KERNEL_RCSID(0, "$NetBSD: kern_fork.c,v 1.159 2008/03/21 21:55:00 ad Exp $");
#include "opt_ktrace.h"
#include "opt_multiprocessor.h"
@ -338,16 +338,16 @@ fork1(struct lwp *l1, int flags, int exitsig, void *stack, size_t stacksize,
VREF(p2->p_textvp);
if (flags & FORK_SHAREFILES)
fdshare(p1, p2);
fd_share(p2);
else if (flags & FORK_CLEANFILES)
p2->p_fd = fdinit(p1);
p2->p_fd = fd_init(NULL);
else
p2->p_fd = fdcopy(p1);
p2->p_fd = fd_copy();
if (flags & FORK_SHARECWD)
cwdshare(p1, p2);
cwdshare(p2);
else
p2->p_cwdi = cwdinit(p1);
p2->p_cwdi = cwdinit();
/*
* p_limit (rlimit stuff) is usually copy-on-write, so we just need

Some files were not shown because too many files have changed in this diff Show More