summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorad <ad@NetBSD.org>2008-03-21 21:54:58 +0000
committerad <ad@NetBSD.org>2008-03-21 21:54:58 +0000
commita9ca7a3734751f09c9dc4e1f645cd528fd403e8c (patch)
treeff26aca94a1a611e6be984fcff411406b466507f /sys
parentc743ad71591a886accf44c9e93c1ff677b45a41f (diff)
Catch up with descriptor handling changes. See kern_descrip.c revision
1.173 for details.
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/sparc64/sparc64/netbsd32_machdep.c9
-rw-r--r--sys/compat/common/vfs_syscalls_12.c24
-rw-r--r--sys/compat/common/vfs_syscalls_20.c9
-rw-r--r--sys/compat/common/vfs_syscalls_30.c30
-rw-r--r--sys/compat/common/vfs_syscalls_43.c74
-rw-r--r--sys/compat/darwin/darwin_attr.c8
-rw-r--r--sys/compat/darwin/darwin_ioctl.c13
-rw-r--r--sys/compat/darwin/darwin_mman.c18
-rw-r--r--sys/compat/darwin/darwin_mount.c13
-rw-r--r--sys/compat/darwin/darwin_socket.c15
-rw-r--r--sys/compat/darwin/darwin_stat.c12
-rw-r--r--sys/compat/ibcs2/ibcs2_fcntl.c16
-rw-r--r--sys/compat/ibcs2/ibcs2_ioctl.c50
-rw-r--r--sys/compat/ibcs2/ibcs2_misc.c33
-rw-r--r--sys/compat/ibcs2/ibcs2_stat.c24
-rw-r--r--sys/compat/irix/irix_dirent.c28
-rw-r--r--sys/compat/irix/irix_fcntl.c34
-rw-r--r--sys/compat/irix/irix_ioctl.c40
-rw-r--r--sys/compat/irix/irix_mman.c17
-rw-r--r--sys/compat/irix/irix_stat.c12
-rw-r--r--sys/compat/irix/irix_syssgi.c17
-rw-r--r--sys/compat/linux/arch/i386/linux_machdep.c33
-rw-r--r--sys/compat/linux/common/linux_blkio.c22
-rw-r--r--sys/compat/linux/common/linux_cdrom.c65
-rw-r--r--sys/compat/linux/common/linux_fcntl.h6
-rw-r--r--sys/compat/linux/common/linux_fdio.c18
-rw-r--r--sys/compat/linux/common/linux_file.c56
-rw-r--r--sys/compat/linux/common/linux_file64.c16
-rw-r--r--sys/compat/linux/common/linux_hdio.c25
-rw-r--r--sys/compat/linux/common/linux_ioctl.c13
-rw-r--r--sys/compat/linux/common/linux_misc.c10
-rw-r--r--sys/compat/linux/common/linux_mtio.c17
-rw-r--r--sys/compat/linux/common/linux_sg.c19
-rw-r--r--sys/compat/linux/common/linux_socket.c64
-rw-r--r--sys/compat/linux/common/linux_termios.c41
-rw-r--r--sys/compat/linux32/common/linux32_stat.c10
-rw-r--r--sys/compat/linux32/common/linux32_termios.c40
-rw-r--r--sys/compat/mach/mach_vm.c19
-rw-r--r--sys/compat/netbsd32/netbsd32_compat_20.c11
-rw-r--r--sys/compat/netbsd32/netbsd32_compat_30.c29
-rw-r--r--sys/compat/netbsd32/netbsd32_compat_43.c10
-rw-r--r--sys/compat/netbsd32/netbsd32_event.c6
-rw-r--r--sys/compat/netbsd32/netbsd32_fs.c109
-rw-r--r--sys/compat/netbsd32/netbsd32_ioctl.c46
-rw-r--r--sys/compat/netbsd32/netbsd32_ioctl.h6
-rw-r--r--sys/compat/netbsd32/netbsd32_netbsd.c8
-rw-r--r--sys/compat/netbsd32/netbsd32_socket.c10
-rw-r--r--sys/compat/osf1/osf1_descrip.c36
-rw-r--r--sys/compat/osf1/osf1_file.c12
-rw-r--r--sys/compat/osf1/osf1_mount.c11
-rw-r--r--sys/compat/ossaudio/ossaudio.c188
-rw-r--r--sys/compat/sunos/sunos_ioctl.c70
-rw-r--r--sys/compat/sunos/sunos_misc.c50
-rw-r--r--sys/compat/sunos32/sunos32_ioctl.c19
-rw-r--r--sys/compat/sunos32/sunos32_misc.c58
-rw-r--r--sys/compat/svr4/svr4_fcntl.c55
-rw-r--r--sys/compat/svr4/svr4_filio.c52
-rw-r--r--sys/compat/svr4/svr4_ioctl.c20
-rw-r--r--sys/compat/svr4/svr4_misc.c16
-rw-r--r--sys/compat/svr4/svr4_net.c32
-rw-r--r--sys/compat/svr4/svr4_sockio.c17
-rw-r--r--sys/compat/svr4/svr4_stat.c24
-rw-r--r--sys/compat/svr4/svr4_stream.c100
-rw-r--r--sys/compat/svr4/svr4_termios.c21
-rw-r--r--sys/compat/svr4/svr4_ttold.c36
-rw-r--r--sys/compat/svr4_32/svr4_32_fcntl.c55
-rw-r--r--sys/compat/svr4_32/svr4_32_filio.c49
-rw-r--r--sys/compat/svr4_32/svr4_32_ioctl.c27
-rw-r--r--sys/compat/svr4_32/svr4_32_misc.c24
-rw-r--r--sys/compat/svr4_32/svr4_32_net.c10
-rw-r--r--sys/compat/svr4_32/svr4_32_sockio.c15
-rw-r--r--sys/compat/svr4_32/svr4_32_stat.c24
-rw-r--r--sys/compat/svr4_32/svr4_32_termios.c19
-rw-r--r--sys/compat/ultrix/ultrix_ioctl.c21
-rw-r--r--sys/compat/ultrix/ultrix_misc.c19
-rw-r--r--sys/compat/ultrix/ultrix_pathname.c23
-rw-r--r--sys/conf/files3
-rw-r--r--sys/dev/ata/ld_ataraid.c6
-rw-r--r--sys/dev/ccd.c10
-rw-r--r--sys/dev/cgd.c8
-rw-r--r--sys/dev/dksubr.c6
-rw-r--r--sys/dev/dkwedge/dk.c10
-rw-r--r--sys/dev/drm/drm_drv.c8
-rw-r--r--sys/dev/firmload.c10
-rw-r--r--sys/dev/fss.c12
-rw-r--r--sys/dev/kloader.c6
-rw-r--r--sys/dev/kttcp.c38
-rw-r--r--sys/dev/putter/putter.c44
-rw-r--r--sys/dev/raidframe/rf_netbsdkintf.c8
-rw-r--r--sys/dev/vnd.c11
-rw-r--r--sys/fs/smbfs/smbfs_kq.c6
-rw-r--r--sys/fs/union/union_subr.c6
-rw-r--r--sys/kern/exec_script.c13
-rw-r--r--sys/kern/init_main.c10
-rw-r--r--sys/kern/init_sysctl.c45
-rw-r--r--sys/kern/kern_acct.c8
-rw-r--r--sys/kern/kern_core.c6
-rw-r--r--sys/kern/kern_exec.c10
-rw-r--r--sys/kern/kern_exit.c6
-rw-r--r--sys/kern/kern_fork.c16
-rw-r--r--sys/kern/kern_ktrace.c95
-rw-r--r--sys/kern/kern_lwp.c9
-rw-r--r--sys/kern/kern_proc.c10
-rw-r--r--sys/kern/kern_sig.c22
-rw-r--r--sys/kern/subr_kobj.c6
-rw-r--r--sys/kern/subr_log.c11
-rw-r--r--sys/kern/sys_aio.c26
-rw-r--r--sys/kern/sys_generic.c127
-rw-r--r--sys/kern/sys_mqueue.c58
-rw-r--r--sys/kern/sys_pipe.c76
-rw-r--r--sys/kern/sys_socket.c67
-rw-r--r--sys/kern/tty_ptm.c44
-rw-r--r--sys/kern/uipc_domain.c11
-rw-r--r--sys/kern/uipc_socket.c28
-rw-r--r--sys/kern/uipc_syscalls.c252
-rw-r--r--sys/kern/uipc_usrreq.c282
-rw-r--r--sys/kern/vfs_syscalls.c299
-rw-r--r--sys/kern/vfs_vnops.c98
-rw-r--r--sys/kern/vfs_xattr.c38
-rw-r--r--sys/miscfs/fdesc/fdesc_vnops.c69
-rw-r--r--sys/miscfs/fifofs/fifo_vnops.c12
-rw-r--r--sys/miscfs/genfs/genfs_vnops.c10
-rw-r--r--sys/miscfs/portal/portal_vfsops.c15
-rw-r--r--sys/miscfs/portal/portal_vnops.c6
-rw-r--r--sys/miscfs/procfs/procfs_fd.c27
-rw-r--r--sys/miscfs/procfs/procfs_subr.c20
-rw-r--r--sys/miscfs/procfs/procfs_vnops.c45
-rw-r--r--sys/net/bpf.c32
-rw-r--r--sys/net/if_gre.c69
-rw-r--r--sys/net/if_tap.c48
-rw-r--r--sys/net/if_tun.c8
-rw-r--r--sys/netsmb/smb_dev.c17
-rw-r--r--sys/nfs/nfs_kq.c8
-rw-r--r--sys/nfs/nfs_syscalls.c21
-rw-r--r--sys/opencrypto/cryptodev.c38
-rw-r--r--sys/rump/fs/lib/libsyspuffs/puffs_rumpglue.c10
-rw-r--r--sys/rump/librump/rumpkern/Makefile4
-rw-r--r--sys/rump/librump/rumpkern/emul.c4
-rw-r--r--sys/rump/librump/rumpkern/rump.c22
-rw-r--r--sys/sys/cpu_data.h4
-rw-r--r--sys/sys/lwp.h3
-rw-r--r--sys/sys/socketvar.h18
-rw-r--r--sys/sys/vfs_syscalls.h4
-rw-r--r--sys/sys/vnode.h8
-rw-r--r--sys/ufs/ufs/ufs_extattr.c8
-rw-r--r--sys/ufs/ufs/ufs_quota.c8
-rw-r--r--sys/uvm/uvm_mmap.c36
147 files changed, 2118 insertions, 2629 deletions
diff --git a/sys/arch/sparc64/sparc64/netbsd32_machdep.c b/sys/arch/sparc64/sparc64/netbsd32_machdep.c
index 4a004c4218c..7a17b4c0501 100644
--- a/sys/arch/sparc64/sparc64/netbsd32_machdep.c
+++ b/sys/arch/sparc64/sparc64/netbsd32_machdep.c
@@ -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);
}
diff --git a/sys/compat/common/vfs_syscalls_12.c b/sys/compat/common/vfs_syscalls_12.c
index babf00f136d..c45621341b3 100644
--- a/sys/compat/common/vfs_syscalls_12.c
+++ b/sys/compat/common/vfs_syscalls_12.c
@@ -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));
diff --git a/sys/compat/common/vfs_syscalls_20.c b/sys/compat/common/vfs_syscalls_20.c
index 0b970d62027..c2b79e61e3b 100644
--- a/sys/compat/common/vfs_syscalls_20.c
+++ b/sys/compat/common/vfs_syscalls_20.c
@@ -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;
}
diff --git a/sys/compat/common/vfs_syscalls_30.c b/sys/compat/common/vfs_syscalls_30.c
index 67a36c8fd85..5fa06b1b158 100644
--- a/sys/compat/common/vfs_syscalls_30.c
+++ b/sys/compat/common/vfs_syscalls_30.c
@@ -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;
}
diff --git a/sys/compat/common/vfs_syscalls_43.c b/sys/compat/common/vfs_syscalls_43.c
index 01d31eff9de..94bebdf4dab 100644
--- a/sys/compat/common/vfs_syscalls_43.c
+++ b/sys/compat/common/vfs_syscalls_43.c
@@ -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);
}
diff --git a/sys/compat/darwin/darwin_attr.c b/sys/compat/darwin/darwin_attr.c
index a9cc87a355f..9ac09fdf5bd 100644
--- a/sys/compat/darwin/darwin_attr.c
+++ b/sys/compat/darwin/darwin_attr.c
@@ -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;
diff --git a/sys/compat/darwin/darwin_ioctl.c b/sys/compat/darwin/darwin_ioctl.c
index 3a77f6f9cd5..ec35680a892 100644
--- a/sys/compat/darwin/darwin_ioctl.c
+++ b/sys/compat/darwin/darwin_ioctl.c
@@ -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));
diff --git a/sys/compat/darwin/darwin_mman.c b/sys/compat/darwin/darwin_mman.c
index 8ecaed328ac..77d3247a034 100644
--- a/sys/compat/darwin/darwin_mman.c
+++ b/sys/compat/darwin/darwin_mman.c
@@ -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;
diff --git a/sys/compat/darwin/darwin_mount.c b/sys/compat/darwin/darwin_mount.c
index 8390d74f900..27fd578f1a9 100644
--- a/sys/compat/darwin/darwin_mount.c
+++ b/sys/compat/darwin/darwin_mount.c
@@ -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);
}
diff --git a/sys/compat/darwin/darwin_socket.c b/sys/compat/darwin/darwin_socket.c
index 93077cc43f0..5f7c2d86443 100644
--- a/sys/compat/darwin/darwin_socket.c
+++ b/sys/compat/darwin/darwin_socket.c
@@ -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;
}
diff --git a/sys/compat/darwin/darwin_stat.c b/sys/compat/darwin/darwin_stat.c
index 82b8bb14a8a..09dcaad54cd 100644
--- a/sys/compat/darwin/darwin_stat.c
+++ b/sys/compat/darwin/darwin_stat.c
@@ -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;
diff --git a/sys/compat/ibcs2/ibcs2_fcntl.c b/sys/compat/ibcs2/ibcs2_fcntl.c
index 80e88370c17..a004769257d 100644
--- a/sys/compat/ibcs2/ibcs2_fcntl.c
+++ b/sys/compat/ibcs2/ibcs2_fcntl.c
@@ -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);
diff --git a/sys/compat/ibcs2/ibcs2_ioctl.c b/sys/compat/ibcs2/ibcs2_ioctl.c
index aa508bce0ce..4bd96340f94 100644
--- a/sys/compat/ibcs2/ibcs2_ioctl.c
+++ b/sys/compat/ibcs2/ibcs2_ioctl.c
@@ -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;
}
diff --git a/sys/compat/ibcs2/ibcs2_misc.c b/sys/compat/ibcs2/ibcs2_misc.c
index defb51b7492..31c06adc995 100644
--- a/sys/compat/ibcs2/ibcs2_misc.c
+++ b/sys/compat/ibcs2/ibcs2_misc.c
@@ -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);
}
diff --git a/sys/compat/ibcs2/ibcs2_stat.c b/sys/compat/ibcs2/ibcs2_stat.c
index 60549f983d3..53b9ddd5e45 100644
--- a/sys/compat/ibcs2/ibcs2_stat.c
+++ b/sys/compat/ibcs2/ibcs2_stat.c
@@ -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;
diff --git a/sys/compat/irix/irix_dirent.c b/sys/compat/irix/irix_dirent.c
index c2ab6f0b233..0b0b874e10c 100644
--- a/sys/compat/irix/irix_dirent.c
+++ b/sys/compat/irix/irix_dirent.c
@@ -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;
diff --git a/sys/compat/irix/irix_fcntl.c b/sys/compat/irix/irix_fcntl.c
index c6998fdcb3e..b0c4a1804e7 100644
--- a/sys/compat/irix/irix_fcntl.c
+++ b/sys/compat/irix/irix_fcntl.c
@@ -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;
}
diff --git a/sys/compat/irix/irix_ioctl.c b/sys/compat/irix/irix_ioctl.c
index de17682830b..b80e16980d1 100644
--- a/sys/compat/irix/irix_ioctl.c
+++ b/sys/compat/irix/irix_ioctl.c
@@ -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);
}
}
diff --git a/sys/compat/irix/irix_mman.c b/sys/compat/irix/irix_mman.c
index 6f90e958602..84648a232e0 100644
--- a/sys/compat/irix/irix_mman.c
+++ b/sys/compat/irix/irix_mman.c
@@ -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;
diff --git a/sys/compat/irix/irix_stat.c b/sys/compat/irix/irix_stat.c
index c318dd0f839..38945e3f34b 100644
--- a/sys/compat/irix/irix_stat.c
+++ b/sys/compat/irix/irix_stat.c
@@ -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));
diff --git a/sys/compat/irix/irix_syssgi.c b/sys/compat/irix/irix_syssgi.c
index 860ca8dbf6b..ab34c287d9b 100644
--- a/sys/compat/irix/irix_syssgi.c
+++ b/sys/compat/irix/irix_syssgi.c
@@ -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;
diff --git a/sys/compat/linux/arch/i386/linux_machdep.c b/sys/compat/linux/arch/i386/linux_machdep.c
index 5848b9e4ffa..a0e1902343f 100644
--- a/sys/compat/linux/arch/i386/linux_machdep.c
+++ b/sys/compat/linux/arch/i386/linux_machdep.c
@@ -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;
}
diff --git a/sys/compat/linux/common/linux_blkio.c b/sys/compat/linux/common/linux_blkio.c
index dc0c4b3bceb..c6b512f47e2 100644
--- a/sys/compat/linux/common/linux_blkio.c
+++ b/sys/compat/linux/common/linux_blkio.c
@@ -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;
}
diff --git a/sys/compat/linux/common/linux_cdrom.c b/sys/compat/linux/common/linux_cdrom.c
index c08329bf41c..0e92e684370 100644
--- a/sys/compat/linux/common/linux_cdrom.c
+++ b/sys/compat/linux/common/linux_cdrom.c
@@ -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;
diff --git a/sys/compat/linux/common/linux_fcntl.h b/sys/compat/linux/common/linux_fcntl.h
index ad95b62b05c..6f7101c351d 100644
--- a/sys/compat/linux/common/linux_fcntl.h
+++ b/sys/compat/linux/common/linux_fcntl.h
@@ -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)
diff --git a/sys/compat/linux/common/linux_fdio.c b/sys/compat/linux/common/linux_fdio.c
index 0ab183f8724..bf9b5be0590 100644
--- a/sys/compat/linux/common/linux_fdio.c
+++ b/sys/compat/linux/common/linux_fdio.c
@@ -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;
}
diff --git a/sys/compat/linux/common/linux_file.c b/sys/compat/linux/common/linux_file.c
index 365ebca6bbf..003e8d000e6 100644
--- a/sys/compat/linux/common/linux_file.c
+++ b/sys/compat/linux/common/linux_file.c
@@ -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;
diff --git a/sys/compat/linux/common/linux_file64.c b/sys/compat/linux/common/linux_file64.c
index 72646b2c5d5..1724b7a3e5a 100644
--- a/sys/compat/linux/common/linux_file64.c
+++ b/sys/compat/linux/common/linux_file64.c
@@ -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;
}
diff --git a/sys/compat/linux/common/linux_hdio.c b/sys/compat/linux/common/linux_hdio.c
index c112d36d203..80437eadb35 100644
--- a/sys/compat/linux/common/linux_hdio.c
+++ b/sys/compat/linux/common/linux_hdio.c
@@ -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;
}
diff --git a/sys/compat/linux/common/linux_ioctl.c b/sys/compat/linux/common/linux_ioctl.c
index 7cb6b082426..45b8c9ebbcd 100644
--- a/sys/compat/linux/common/linux_ioctl.c
+++ b/sys/compat/linux/common/linux_ioctl.c
@@ -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
diff --git a/sys/compat/linux/common/linux_misc.c b/sys/compat/linux/common/linux_misc.c
index 58d97e7c31f..6abbf6b2860 100644
--- a/sys/compat/linux/common/linux_misc.c
+++ b/sys/compat/linux/common/linux_misc.c
@@ -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;
}
diff --git a/sys/compat/linux/common/linux_mtio.c b/sys/compat/linux/common/linux_mtio.c
index b2ca1cc1fdf..b92051d65f2 100644
--- a/sys/compat/linux/common/linux_mtio.c
+++ b/sys/compat/linux/common/linux_mtio.c
@@ -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;
}
diff --git a/sys/compat/linux/common/linux_sg.c b/sys/compat/linux/common/linux_sg.c
index f604ab9f915..68cf20e9175 100644
--- a/sys/compat/linux/common/linux_sg.c
+++ b/sys/compat/linux/common/linux_sg.c
@@ -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;
diff --git a/sys/compat/linux/common/linux_socket.c b/sys/compat/linux/common/linux_socket.c
index 7f186120675..3089c4d336e 100644
--- a/sys/compat/linux/common/linux_socket.c
+++ b/sys/compat/linux/common/linux_socket.c
@@ -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:
diff --git a/sys/compat/linux/common/linux_termios.c b/sys/compat/linux/common/linux_termios.c
index aa26f40edce..49cf504f695 100644
--- a/sys/compat/linux/common/linux_termios.c
+++ b/sys/compat/linux/common/linux_termios.c
@@ -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;
}
diff --git a/sys/compat/linux32/common/linux32_stat.c b/sys/compat/linux32/common/linux32_stat.c
index 36cb63ea006..010705872c9 100644
--- a/sys/compat/linux32/common/linux32_stat.c
+++ b/sys/compat/linux32/common/linux32_stat.c
@@ -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;
diff --git a/sys/compat/linux32/common/linux32_termios.c b/sys/compat/linux32/common/linux32_termios.c
index 1d2e9b4a596..3ece7463078 100644
--- a/sys/compat/linux32/common/linux32_termios.c
+++ b/sys/compat/linux32/common/linux32_termios.c
@@ -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;
}
diff --git a/sys/compat/mach/mach_vm.c b/sys/compat/mach/mach_vm.c
index 0fdf5e87b28..b19d6e15ffd 100644
--- a/sys/compat/mach/mach_vm.c
+++ b/sys/compat/mach/mach_vm.c
@@ -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);
diff --git a/sys/compat/netbsd32/netbsd32_compat_20.c b/sys/compat/netbsd32/netbsd32_compat_20.c
index b572247ff95..d2db514ced5 100644
--- a/sys/compat/netbsd32/netbsd32_compat_20.c
+++ b/sys/compat/netbsd32/netbsd32_compat_20.c
@@ -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);
}
diff --git a/sys/compat/netbsd32/netbsd32_compat_30.c b/sys/compat/netbsd32/netbsd32_compat_30.c
index 34beef8e43a..ba3c1d7d3b9 100644
--- a/sys/compat/netbsd32/netbsd32_compat_30.c
+++ b/sys/compat/netbsd32/netbsd32_compat_30.c
@@ -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);
diff --git a/sys/compat/netbsd32/netbsd32_compat_43.c b/sys/compat/netbsd32/netbsd32_compat_43.c
index 8b6e2c29126..c80b1839578 100644
--- a/sys/compat/netbsd32/netbsd32_compat_43.c
+++ b/sys/compat/netbsd32/netbsd32_compat_43.c
@@ -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));
diff --git a/sys/compat/netbsd32/netbsd32_event.c b/sys/compat/netbsd32/netbsd32_event.c
index 4355e8affeb..cdedd11445c 100644
--- a/sys/compat/netbsd32/netbsd32_event.c
+++ b/sys/compat/netbsd32/netbsd32_event.c
@@ -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);
diff --git a/sys/compat/netbsd32/netbsd32_fs.c b/sys/compat/netbsd32/netbsd32_fs.c
index de1be62c99b..55efe92dd54 100644
--- a/sys/compat/netbsd32/netbsd32_fs.c
+++ b/sys/compat/netbsd32/netbsd32_fs.c
@@ -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);
}
diff --git a/sys/compat/netbsd32/netbsd32_ioctl.c b/sys/compat/netbsd32/netbsd32_ioctl.c
index 6441f9970d0..6f77b61ca6a 100644
--- a/sys/compat/netbsd32/netbsd32_ioctl.c
+++ b/sys/compat/netbsd32/netbsd32_ioctl.c
@@ -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);
}
diff --git a/sys/compat/netbsd32/netbsd32_ioctl.h b/sys/compat/netbsd32/netbsd32_ioctl.h
index 27db5673383..2ee650cefd8 100644
--- a/sys/compat/netbsd32/netbsd32_ioctl.h
+++ b/sys/compat/netbsd32/netbsd32_ioctl.h
@@ -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
diff --git a/sys/compat/netbsd32/netbsd32_netbsd.c b/sys/compat/netbsd32/netbsd32_netbsd.c
index c310934a4bc..f0dfb01ce40 100644
--- a/sys/compat/netbsd32/netbsd32_netbsd.c
+++ b/sys/compat/netbsd32/netbsd32_netbsd.c
@@ -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));
}
/*
diff --git a/sys/compat/netbsd32/netbsd32_socket.c b/sys/compat/netbsd32/netbsd32_socket.c
index 0d4f4b92270..9bb264f8b4d 100644
--- a/sys/compat/netbsd32/netbsd32_socket.c
+++ b/sys/compat/netbsd32/netbsd32_socket.c
@@ -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);
}
diff --git a/sys/compat/osf1/osf1_descrip.c b/sys/compat/osf1/osf1_descrip.c
index 7a68eead497..9697c875abc 100644
--- a/sys/compat/osf1/osf1_descrip.c
+++ b/sys/compat/osf1/osf1_descrip.c
@@ -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);
}
diff --git a/sys/compat/osf1/osf1_file.c b/sys/compat/osf1/osf1_file.c
index e2d8057a121..a1fd846b3ce 100644
--- a/sys/compat/osf1/osf1_file.c
+++ b/sys/compat/osf1/osf1_file.c
@@ -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);
diff --git a/sys/compat/osf1/osf1_mount.c b/sys/compat/osf1/osf1_mount.c
index 24f71c6ed72..402c61f1c3b 100644
--- a/sys/compat/osf1/osf1_mount.c
+++ b/sys/compat/osf1/osf1_mount.c
@@ -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);
}
diff --git a/sys/compat/ossaudio/ossaudio.c b/sys/compat/ossaudio/ossaudio.c
index 024c480e16c..82cb4829813 100644
--- a/sys/compat/ossaudio/ossaudio.c
+++ b/sys/compat/ossaudio/ossaudio.c
@@ -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);
}
}
diff --git a/sys/compat/sunos/sunos_ioctl.c b/sys/compat/sunos/sunos_ioctl.c
index 67303ac4b12..4b9663d87f3 100644
--- a/sys/compat/sunos/sunos_ioctl.c
+++ b/sys/compat/sunos/sunos_ioctl.c
@@ -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;
diff --git a/sys/compat/sunos/sunos_misc.c b/sys/compat/sunos/sunos_misc.c
index df3f59f127f..bb7246bd22b 100644
--- a/sys/compat/sunos/sunos_misc.c
+++ b/sys/compat/sunos/sunos_misc.c
@@ -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);
}
diff --git a/sys/compat/sunos32/sunos32_ioctl.c b/sys/compat/sunos32/sunos32_ioctl.c
index e46881fb282..31de3d874d0 100644
--- a/sys/compat/sunos32/sunos32_ioctl.c
+++ b/sys/compat/sunos32/sunos32_ioctl.c
@@ -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;
diff --git a/sys/compat/sunos32/sunos32_misc.c b/sys/compat/sunos32/sunos32_misc.c
index 6a42bfc06c3..a1511cc6999 100644
--- a/sys/compat/sunos32/sunos32_misc.c
+++ b/sys/compat/sunos32/sunos32_misc.c
@@ -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);
}
diff --git a/sys/compat/svr4/svr4_fcntl.c b/sys/compat/svr4/svr4_fcntl.c
index 407bde87953..78d3255cfc6 100644
--- a/sys/compat/svr4/svr4_fcntl.c
+++ b/sys/compat/svr4/svr4_fcntl.c
@@ -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;
diff --git a/sys/compat/svr4/svr4_filio.c b/sys/compat/svr4/svr4_filio.c
index 1af4be4ad92..ae58f1dbca2 100644
--- a/sys/compat/svr4/svr4_filio.c
+++ b/sys/compat/svr4/svr4_filio.c
@@ -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;
}
diff --git a/sys/compat/svr4/svr4_ioctl.c b/sys/compat/svr4/svr4_ioctl.c
index 148834f9c1f..b2135bf1363 100644
--- a/sys/compat/svr4/svr4_ioctl.c
+++ b/sys/compat/svr4/svr4_ioctl.c
@@ -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);
}
diff --git a/sys/compat/svr4/svr4_misc.c b/sys/compat/svr4/svr4_misc.c
index 59dbf0d5f42..d495ba6ab7f 100644
--- a/sys/compat/svr4/svr4_misc.c
+++ b/sys/compat/svr4/svr4_misc.c
@@ -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;
}
diff --git a/sys/compat/svr4/svr4_net.c b/sys/compat/svr4/svr4_net.c
index 8ec72913145..36860ca0dee 100644
--- a/sys/compat/svr4/svr4_net.c
+++ b/sys/compat/svr4/svr4_net.c
@@ -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;
diff --git a/sys/compat/svr4/svr4_sockio.c b/sys/compat/svr4/svr4_sockio.c
index 83561cc04a6..53973f86275 100644
--- a/sys/compat/svr4/svr4_sockio.c
+++ b/sys/compat/svr4/svr4_sockio.c
@@ -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"));
diff --git a/sys/compat/svr4/svr4_stat.c b/sys/compat/svr4/svr4_stat.c
index 841a81acf10..ef28eb23f07 100644
--- a/sys/compat/svr4/svr4_stat.c
+++ b/sys/compat/svr4/svr4_stat.c
@@ -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;
diff --git a/sys/compat/svr4/svr4_stream.c b/sys/compat/svr4/svr4_stream.c
index 6f7cca9cc7a..2560e64e8d4 100644
--- a/sys/compat/svr4/svr4_stream.c
+++ b/sys/compat/svr4/svr4_stream.c
@@ -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;
}
diff --git a/sys/compat/svr4/svr4_termios.c b/sys/compat/svr4/svr4_termios.c
index 17e2b82b318..6f41985c9de 100644
--- a/sys/compat/svr4/svr4_termios.c
+++ b/sys/compat/svr4/svr4_termios.c
@@ -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:
diff --git a/sys/compat/svr4/svr4_ttold.c b/sys/compat/svr4/svr4_ttold.c
index cf1b23ff60f..278c79a5ad4 100644
--- a/sys/compat/svr4/svr4_ttold.c
+++ b/sys/compat/svr4/svr4_ttold.c
@@ -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:
diff --git a/sys/compat/svr4_32/svr4_32_fcntl.c b/sys/compat/svr4_32/svr4_32_fcntl.c
index 3898b51ebf8..5ce96826597 100644
--- a/sys/compat/svr4_32/svr4_32_fcntl.c
+++ b/sys/compat/svr4_32/svr4_32_fcntl.c
@@ -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;
diff --git a/sys/compat/svr4_32/svr4_32_filio.c b/sys/compat/svr4_32/svr4_32_filio.c
index d643483c3d5..471ba64c21f 100644
--- a/sys/compat/svr4_32/svr4_32_filio.c
+++ b/sys/compat/svr4_32/svr4_32_filio.c
@@ -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;
}
diff --git a/sys/compat/svr4_32/svr4_32_ioctl.c b/sys/compat/svr4_32/svr4_32_ioctl.c
index 9001c4511e6..139791bbe6d 100644
--- a/sys/compat/svr4_32/svr4_32_ioctl.c
+++ b/sys/compat/svr4_32/svr4_32_ioctl.c
@@ -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;
}
diff --git a/sys/compat/svr4_32/svr4_32_misc.c b/sys/compat/svr4_32/svr4_32_misc.c
index 45d4f6afca5..8ffd5448807 100644
--- a/sys/compat/svr4_32/svr4_32_misc.c
+++ b/sys/compat/svr4_32/svr4_32_misc.c
@@ -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;
}
diff --git a/sys/compat/svr4_32/svr4_32_net.c b/sys/compat/svr4_32/svr4_32_net.c
index 0de9482cf61..5e12fdcee97 100644
--- a/sys/compat/svr4_32/svr4_32_net.c
+++ b/sys/compat/svr4_32/svr4_32_net.c
@@ -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;
diff --git a/sys/compat/svr4_32/svr4_32_sockio.c b/sys/compat/svr4_32/svr4_32_sockio.c
index f30d4d3e55c..8688ecfcb95 100644
--- a/sys/compat/svr4_32/svr4_32_sockio.c
+++ b/sys/compat/svr4_32/svr4_32_sockio.c
@@ -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"));
diff --git a/sys/compat/svr4_32/svr4_32_stat.c b/sys/compat/svr4_32/svr4_32_stat.c
index 6e2970c1ea9..516fe7f3fb1 100644
--- a/sys/compat/svr4_32/svr4_32_stat.c
+++ b/sys/compat/svr4_32/svr4_32_stat.c
@@ -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;
diff --git a/sys/compat/svr4_32/svr4_32_termios.c b/sys/compat/svr4_32/svr4_32_termios.c
index cb40760b4dc..a9e743f96f6 100644
--- a/sys/compat/svr4_32/svr4_32_termios.c
+++ b/sys/compat/svr4_32/svr4_32_termios.c
@@ -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:
diff --git a/sys/compat/ultrix/ultrix_ioctl.c b/sys/compat/ultrix/ultrix_ioctl.c
index d96f705a589..08bd621e1ec 100644
--- a/sys/compat/ultrix/ultrix_ioctl.c
+++ b/sys/compat/ultrix/ultrix_ioctl.c
@@ -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;
}
diff --git a/sys/compat/ultrix/ultrix_misc.c b/sys/compat/ultrix/ultrix_misc.c
index a0a26500053..ecd789a782e 100644
--- a/sys/compat/ultrix/ultrix_misc.c
+++ b/sys/compat/ultrix/ultrix_misc.c
@@ -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);
diff --git a/sys/compat/ultrix/ultrix_pathname.c b/sys/compat/ultrix/ultrix_pathname.c
index d1f9797887d..173a7340d2a 100644
--- a/sys/compat/ultrix/ultrix_pathname.c
+++ b/sys/compat/ultrix/ultrix_pathname.c
@@ -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;
}
diff --git a/sys/conf/files b/sys/conf/files
index dd18b0d20ac..ede9b248f3d 100644
--- a/sys/conf/files
+++ b/sys/conf/files
@@ -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
diff --git a/sys/dev/ata/ld_ataraid.c b/sys/dev/ata/ld_ataraid.c
index 4fc71b7f2c2..51b1828ef25 100644
--- a/sys/dev/ata/ld_ataraid.c
+++ b/sys/dev/ata/ld_ataraid.c
@@ -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:
diff --git a/sys/dev/ccd.c b/sys/dev/ccd.c
index fad431917eb..74d7c758815 100644
--- a/sys/dev/ccd.c
+++ b/sys/dev/ccd.c
@@ -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);
}
diff --git a/sys/dev/cgd.c b/sys/dev/cgd.c
index 2b58692eba6..61717e9655f 100644
--- a/sys/dev/cgd.c
+++ b/sys/dev/cgd.c
@@ -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);
diff --git a/sys/dev/dksubr.c b/sys/dev/dksubr.c
index 62a83f0b8b5..2c6939a2089 100644
--- a/sys/dev/dksubr.c
+++ b/sys/dev/dksubr.c
@@ -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;
}
diff --git a/sys/dev/dkwedge/dk.c b/sys/dev/dkwedge/dk.c
index 82ea5330217..9bf1d9b7e3d 100644
--- a/sys/dev/dkwedge/dk.c
+++ b/sys/dev/dkwedge/dk.c
@@ -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;
}
}
diff --git a/sys/dev/drm/drm_drv.c b/sys/dev/drm/drm_drv.c
index f91d0b3d238..05f78e21ee3 100644
--- a/sys/dev/drm/drm_drv.c
+++ b/sys/dev/drm/drm_drv.c
@@ -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) {
diff --git a/sys/dev/firmload.c b/sys/dev/firmload.c
index 0e4f1732e2d..2b55941ab29 100644
--- a/sys/dev/firmload.c
+++ b/sys/dev/firmload.c
@@ -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);
}
diff --git a/sys/dev/fss.c b/sys/dev/fss.c
index ff44d1d836b..4cac5d47506 100644
--- a/sys/dev/fss.c
+++ b/sys/dev/fss.c
@@ -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;
diff --git a/sys/dev/kloader.c b/sys/dev/kloader.c
index 6ad5cdbba86..1410d5a7781 100644
--- a/sys/dev/kloader.c
+++ b/sys/dev/kloader.c
@@ -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
diff --git a/sys/dev/kttcp.c b/sys/dev/kttcp.c
index 62ed87b8a33..10b04586251 100644
--- a/sys/dev/kttcp.c
+++ b/sys/dev/kttcp.c
@@ -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)
diff --git a/sys/dev/putter/putter.c b/sys/dev/putter/putter.c
index 7bb53b94796..038cb06e00e 100644
--- a/sys/dev/putter/putter.c
+++ b/sys/dev/putter/putter.c
@@ -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));
diff --git a/sys/dev/raidframe/rf_netbsdkintf.c b/sys/dev/raidframe/rf_netbsdkintf.c
index 44e077e7733..1009883696a 100644
--- a/sys/dev/raidframe/rf_netbsdkintf.c
+++ b/sys/dev/raidframe/rf_netbsdkintf.c
@@ -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);
}
}
}
diff --git a/sys/dev/vnd.c b/sys/dev/vnd.c
index 3551e893fc0..57e5888c955 100644
--- a/sys/dev/vnd.c
+++ b/sys/dev/vnd.c
@@ -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;
diff --git a/sys/fs/smbfs/smbfs_kq.c b/sys/fs/smbfs/smbfs_kq.c
index 0aa91bb09f9..55fc8995556 100644
--- a/sys/fs/smbfs/smbfs_kq.c
+++ b/sys/fs/smbfs/smbfs_kq.c
@@ -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) {
diff --git a/sys/fs/union/union_subr.c b/sys/fs/union/union_subr.c
index d9a627502c4..4c3c734a344 100644
--- a/sys/fs/union/union_subr.c
+++ b/sys/fs/union/union_subr.c
@@ -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;
diff --git a/sys/kern/exec_script.c b/sys/kern/exec_script.c
index 45a0e19d36a..806ddae6095 100644
--- a/sys/kern/exec_script.c
+++ b/sys/kern/exec_script.c
@@ -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);
diff --git a/sys/kern/init_main.c b/sys/kern/init_main.c
index ca5750cf413..2a196d7c3cb 100644
--- a/sys/kern/init_main.c
+++ b/sys/kern/init_main.c
@@ -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();
diff --git a/sys/kern/init_sysctl.c b/sys/kern/init_sysctl.c
index ac3552ef4ea..107d4496533 100644
--- a/sys/kern/init_sysctl.c
+++ b/sys/kern/init_sysctl.c
@@ -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;
}
}
diff --git a/sys/kern/kern_acct.c b/sys/kern/kern_acct.c
index a1ff992a911..92598f45ba5 100644
--- a/sys/kern/kern_acct.c
+++ b/sys/kern/kern_acct.c
@@ -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;
}
diff --git a/sys/kern/kern_core.c b/sys/kern/kern_core.c
index 6c7ade80104..ec67a1b8601 100644
--- a/sys/kern/kern_core.c
+++ b/sys/kern/kern_core.c
@@ -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:
diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c
index bed1701246e..91c1ccf9bfa 100644
--- a/sys/kern/kern_exec.c
+++ b/sys/kern/kern_exec.c
@@ -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);
diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c
index 82a95500c5d..bc610992477 100644
--- a/sys/kern/kern_exit.c
+++ b/sys/kern/kern_exit.c
@@ -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);
diff --git a/sys/kern/kern_fork.c b/sys/kern/kern_fork.c
index 6a7537cbff2..4e06fe41be3 100644
--- a/sys/kern/kern_fork.c
+++ b/sys/kern/kern_fork.c
@@ -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
diff --git a/sys/kern/kern_ktrace.c b/sys/kern/kern_ktrace.c
index bf276cd0e3d..1198f3ee51b 100644
--- a/sys/kern/kern_ktrace.c
+++ b/sys/kern/kern_ktrace.c
@@ -1,7 +1,7 @@
-/* $NetBSD: kern_ktrace.c,v 1.139 2008/02/24 18:30:07 dsl Exp $ */
+/* $NetBSD: kern_ktrace.c,v 1.140 2008/03/21 21:55:00 ad Exp $ */
/*-
- * Copyright (c) 2006, 2007 The NetBSD Foundation, Inc.
+ * Copyright (c) 2006, 2007, 2008 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@@ -68,7 +68,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_ktrace.c,v 1.139 2008/02/24 18:30:07 dsl Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_ktrace.c,v 1.140 2008/03/21 21:55:00 ad Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -127,7 +127,7 @@ struct ktr_desc {
int ktd_wakedelay; /* delay of wakeup in *tick* */
int ktd_intrwakdl; /* ditto, but when interactive */
- struct file *ktd_fp; /* trace output file */
+ file_t *ktd_fp; /* trace output file */
lwp_t *ktd_lwp; /* our kernel thread */
TAILQ_HEAD(, ktrace_entry) ktd_queue;
callout_t ktd_wakch; /* delayed wakeup */
@@ -138,18 +138,18 @@ struct ktr_desc {
static int ktealloc(struct ktrace_entry **, void **, lwp_t *, int,
size_t);
static void ktrwrite(struct ktr_desc *, struct ktrace_entry *);
-static int ktrace_common(lwp_t *, int, int, int, struct file *);
+static int ktrace_common(lwp_t *, int, int, int, file_t *);
static int ktrops(lwp_t *, struct proc *, int, int,
struct ktr_desc *);
static int ktrsetchildren(lwp_t *, struct proc *, int, int,
struct ktr_desc *);
static int ktrcanset(lwp_t *, struct proc *);
-static int ktrsamefile(struct file *, struct file *);
+static int ktrsamefile(file_t *, file_t *);
static void ktr_kmem(lwp_t *, int, const void *, size_t);
static void ktr_io(lwp_t *, int, enum uio_rw, struct iovec *, size_t);
static struct ktr_desc *
- ktd_lookup(struct file *);
+ ktd_lookup(file_t *);
static void ktdrel(struct ktr_desc *);
static void ktdref(struct ktr_desc *);
static void ktraddentry(lwp_t *, struct ktrace_entry *, int);
@@ -286,7 +286,7 @@ ktdref(struct ktr_desc *ktd)
}
struct ktr_desc *
-ktd_lookup(struct file *fp)
+ktd_lookup(file_t *fp)
{
struct ktr_desc *ktd;
@@ -424,7 +424,7 @@ ktefree(struct ktrace_entry *kte)
*/
int
-ktrsamefile(struct file *f1, struct file *f2)
+ktrsamefile(file_t *f1, file_t *f2)
{
return ((f1 == f2) ||
@@ -1007,7 +1007,7 @@ ktr_mib(const int *name, u_int namelen)
/* Interface and common routines */
int
-ktrace_common(lwp_t *curl, int ops, int facs, int pid, struct file *fp)
+ktrace_common(lwp_t *curl, int ops, int facs, int pid, file_t *fp)
{
struct proc *curp;
struct proc *p;
@@ -1055,6 +1055,7 @@ ktrace_common(lwp_t *curl, int ops, int facs, int pid, struct file *fp)
ktd->ktd_wakedelay = mstohz(ktd_wakedelay);
ktd->ktd_intrwakdl = mstohz(ktd_intrwakdl);
ktd->ktd_ref = 0;
+ ktd->ktd_fp = fp;
mutex_enter(&ktrace_lock);
ktdref(ktd);
mutex_exit(&ktrace_lock);
@@ -1066,18 +1067,19 @@ ktrace_common(lwp_t *curl, int ops, int facs, int pid, struct file *fp)
if (fp->f_type == DTYPE_PIPE)
ktd->ktd_flags |= KTDF_INTERACTIVE;
+ mutex_enter(&fp->f_lock);
+ fp->f_count++;
+ mutex_exit(&fp->f_lock);
error = kthread_create(PRI_NONE, KTHREAD_MPSAFE, NULL,
ktrace_thread, ktd, &ktd->ktd_lwp, "ktrace");
if (error != 0) {
kmem_free(ktd, sizeof(*ktd));
+ mutex_enter(&fp->f_lock);
+ fp->f_count--;
+ mutex_exit(&fp->f_lock);
goto done;
}
- FILE_LOCK(fp);
- fp->f_count++;
- FILE_UNLOCK(fp);
- ktd->ktd_fp = fp;
-
mutex_enter(&ktrace_lock);
if (ktd_lookup(fp) != NULL) {
ktdrel(ktd);
@@ -1172,24 +1174,18 @@ sys_fktrace(struct lwp *l, const struct sys_fktrace_args *uap, register_t *retva
syscallarg(int) facs;
syscallarg(int) pid;
} */
- struct file *fp = NULL;
- struct filedesc *fdp = l->l_proc->p_fd;
- int error;
+ file_t *fp;
+ int error, fd;
- fdp = l->l_proc->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 & FWRITE) == 0)
error = EBADF;
else
error = ktrace_common(l, SCARG(uap, ops),
SCARG(uap, facs), SCARG(uap, pid), fp);
-
- FILE_UNUSE(fp, l);
-
+ fd_putfile(fd);
return error;
}
@@ -1207,7 +1203,7 @@ sys_ktrace(struct lwp *l, const struct sys_ktrace_args *uap, register_t *retval)
syscallarg(int) pid;
} */
struct vnode *vp = NULL;
- struct file *fp = NULL;
+ file_t *fp = NULL;
struct nameidata nd;
int error = 0;
int fd;
@@ -1227,39 +1223,36 @@ sys_ktrace(struct lwp *l, const struct sys_ktrace_args *uap, register_t *retval)
vp = nd.ni_vp;
VOP_UNLOCK(vp, 0);
if (vp->v_type != VREG) {
- (void) vn_close(vp, FREAD|FWRITE, l->l_cred, l);
+ vn_close(vp, FREAD|FWRITE, l->l_cred);
ktrexit(l);
return (EACCES);
}
/*
- * XXX This uses up a file descriptor slot in the
+ * This uses up a file descriptor slot in the
* tracing process for the duration of this syscall.
- * This is not expected to be a problem. If
- * falloc(NULL, ...) DTRT we could skip that part, but
- * that would require changing its interface to allow
- * the caller to pass in a ucred..
- *
- * This will FILE_USE the fp it returns, if any.
- * Keep it in use until we return.
+ * This is not expected to be a problem.
*/
- if ((error = falloc(l, &fp, &fd)) != 0)
- goto done;
-
+ if ((error = fd_allocfile(&fp, &fd)) != 0) {
+ vn_close(vp, FWRITE, l->l_cred);
+ ktrexit(l);
+ return error;
+ }
fp->f_flag = FWRITE;
fp->f_type = DTYPE_VNODE;
fp->f_ops = &vnops;
fp->f_data = (void *)vp;
- FILE_SET_MATURE(fp);
vp = NULL;
}
error = ktrace_common(l, SCARG(uap, ops), SCARG(uap, facs),
SCARG(uap, pid), fp);
-done:
- if (vp != NULL)
- (void) vn_close(vp, FWRITE, l->l_cred, l);
if (fp != NULL) {
- FILE_UNUSE(fp, l); /* release file */
- fdrelease(l, fd); /* release fd table slot */
+ if (error != 0) {
+ /* File unused. */
+ fd_abort(curproc, fp, fd);
+ } else {
+ /* File was used. */
+ fd_abort(curproc, NULL, fd);
+ }
}
return (error);
}
@@ -1370,7 +1363,7 @@ ktrwrite(struct ktr_desc *ktd, struct ktrace_entry *kte)
struct iovec aiov[64], *iov;
struct ktrace_entry *top = kte;
struct ktr_header *kth;
- struct file *fp = ktd->ktd_fp;
+ file_t *fp = ktd->ktd_fp;
int error;
next:
auio.uio_iov = iov = &aiov[0];
@@ -1403,11 +1396,8 @@ next:
auio.uio_iovcnt < sizeof(aiov) / sizeof(aiov[0]) - 1);
again:
- FILE_LOCK(fp);
- FILE_USE(fp);
error = (*fp->f_ops->fo_write)(fp, &fp->f_offset, &auio,
fp->f_cred, FOF_UPDATE_OFFSET);
- FILE_UNUSE(fp, NULL);
switch (error) {
case 0:
@@ -1446,7 +1436,7 @@ void
ktrace_thread(void *arg)
{
struct ktr_desc *ktd = arg;
- struct file *fp = ktd->ktd_fp;
+ file_t *fp = ktd->ktd_fp;
struct ktrace_entry *kte;
int ktrerr, errcnt;
@@ -1482,16 +1472,13 @@ ktrace_thread(void *arg)
TAILQ_REMOVE(&ktdq, ktd, ktd_list);
mutex_exit(&ktrace_lock);
- FILE_LOCK(fp);
- FILE_USE(fp);
-
/*
* ktrace file descriptor can't be watched (are not visible to
* userspace), so no kqueue stuff here
* XXX: The above comment is wrong, because the fktrace file
* descriptor is available in userland.
*/
- closef(fp, NULL);
+ closef(fp);
callout_stop(&ktd->ktd_wakch);
callout_destroy(&ktd->ktd_wakch);
diff --git a/sys/kern/kern_lwp.c b/sys/kern/kern_lwp.c
index 3064e6b6b7e..844c68bb67e 100644
--- a/sys/kern/kern_lwp.c
+++ b/sys/kern/kern_lwp.c
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_lwp.c,v 1.96 2008/03/17 16:54:51 ad Exp $ */
+/* $NetBSD: kern_lwp.c,v 1.97 2008/03/21 21:55:00 ad Exp $ */
/*-
* Copyright (c) 2001, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -205,7 +205,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_lwp.c,v 1.96 2008/03/17 16:54:51 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_lwp.c,v 1.97 2008/03/21 21:55:00 ad Exp $");
#include "opt_ddb.h"
#include "opt_multiprocessor.h"
@@ -583,6 +583,7 @@ lwp_create(lwp_t *l1, proc_t *p2, vaddr_t uaddr, bool inmem, int flags,
l2->l_cpu = l1->l_cpu;
l2->l_flag = inmem ? LW_INMEM : 0;
l2->l_pflag = LP_MPSAFE;
+ l2->l_fd = p2->p_fd;
if (p2->p_flag & PK_SYSTEM) {
/* Mark it as a system LWP and not a candidate for swapping */
@@ -829,12 +830,10 @@ lwp_exit_switchaway(struct lwp *l)
struct cpu_info *ci;
struct lwp *idlelwp;
- /* Unlocked, but is for statistics only. */
- uvmexp.swtch++;
-
(void)splsched();
l->l_flag &= ~LW_RUNNING;
ci = curcpu();
+ ci->ci_data.cpu_nswtch++;
idlelwp = ci->ci_data.cpu_idlelwp;
idlelwp->l_stat = LSONPROC;
diff --git a/sys/kern/kern_proc.c b/sys/kern/kern_proc.c
index 6bd9176d885..030323b6593 100644
--- a/sys/kern/kern_proc.c
+++ b/sys/kern/kern_proc.c
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_proc.c,v 1.131 2008/03/17 00:52:56 ad Exp $ */
+/* $NetBSD: kern_proc.c,v 1.132 2008/03/21 21:55:00 ad Exp $ */
/*-
* Copyright (c) 1999, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -69,7 +69,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_proc.c,v 1.131 2008/03/17 00:52:56 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_proc.c,v 1.132 2008/03/21 21:55:00 ad Exp $");
#include "opt_kstack.h"
#include "opt_maxuprc.h"
@@ -207,7 +207,7 @@ struct pgrp pgrp0 = {
.pg_members = LIST_HEAD_INITIALIZER(&pgrp0.pg_members),
.pg_session = &session0,
};
-struct filedesc0 filedesc0;
+filedesc_t filedesc0;
struct cwdinfo cwdi0 = {
.cwdi_cmask = CMASK, /* see cmask below */
.cwdi_refcnt = 1,
@@ -244,7 +244,7 @@ struct proc proc0 = {
.p_emul = &emul_netbsd,
.p_cwdi = &cwdi0,
.p_limit = &limit0,
- .p_fd = &filedesc0.fd_fd,
+ .p_fd = &filedesc0,
.p_vmspace = &vmspace0,
.p_stats = &pstat0,
.p_sigacts = &sigacts0,
@@ -411,7 +411,7 @@ proc0_init(void)
uvm_init_limits(p);
/* Initialize file descriptor table for proc0. */
- fdinit1(&filedesc0);
+ fd_init(&filedesc0);
/*
* Initialize proc0's vmspace, which uses the kernel pmap.
diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c
index edd383cf94b..12e495be6e4 100644
--- a/sys/kern/kern_sig.c
+++ b/sys/kern/kern_sig.c
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_sig.c,v 1.273 2008/03/08 07:56:53 yamt Exp $ */
+/* $NetBSD: kern_sig.c,v 1.274 2008/03/21 21:55:00 ad Exp $ */
/*-
* Copyright (c) 2006, 2007 The NetBSD Foundation, Inc.
@@ -73,7 +73,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_sig.c,v 1.273 2008/03/08 07:56:53 yamt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_sig.c,v 1.274 2008/03/21 21:55:00 ad Exp $");
#include "opt_ptrace.h"
#include "opt_multiprocessor.h"
@@ -975,19 +975,23 @@ psignal(struct proc *p, int signo)
void
kpsignal(struct proc *p, ksiginfo_t *ksi, void *data)
{
+ fdfile_t *ff;
+ file_t *fp;
KASSERT(mutex_owned(&proclist_mutex));
- /* XXXSMP Why is this here? */
if ((p->p_sflag & PS_WEXIT) == 0 && data) {
size_t fd;
- struct filedesc *fdp = p->p_fd;
+ filedesc_t *fdp = p->p_fd;
+ /* XXXSMP locking */
ksi->ksi_fd = -1;
for (fd = 0; fd < fdp->fd_nfiles; fd++) {
- struct file *fp = fdp->fd_ofiles[fd];
- /* XXX: lock? */
- if (fp && fp->f_data == data) {
+ if ((ff = fdp->fd_ofiles[fd]) == NULL)
+ continue;
+ if ((fp = ff->ff_file) == NULL)
+ continue;
+ if (fp->f_data == data) {
ksi->ksi_fd = fd;
break;
}
@@ -2151,7 +2155,7 @@ filt_sigattach(struct knote *kn)
{
struct proc *p = curproc;
- kn->kn_ptr.p_proc = p;
+ kn->kn_obj = p;
kn->kn_flags |= EV_CLEAR; /* automatically set */
mutex_enter(&p->p_smutex);
@@ -2164,7 +2168,7 @@ filt_sigattach(struct knote *kn)
static void
filt_sigdetach(struct knote *kn)
{
- struct proc *p = kn->kn_ptr.p_proc;
+ struct proc *p = kn->kn_obj;
mutex_enter(&p->p_smutex);
SLIST_REMOVE(&p->p_klist, kn, knote, kn_selnext);
diff --git a/sys/kern/subr_kobj.c b/sys/kern/subr_kobj.c
index f65f7133e97..c321e753160 100644
--- a/sys/kern/subr_kobj.c
+++ b/sys/kern/subr_kobj.c
@@ -1,4 +1,4 @@
-/* $NetBSD: subr_kobj.c,v 1.9 2008/01/17 22:32:49 rumble Exp $ */
+/* $NetBSD: subr_kobj.c,v 1.10 2008/03/21 21:55:00 ad Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -69,7 +69,7 @@
#include "opt_modular.h"
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: subr_kobj.c,v 1.9 2008/01/17 22:32:49 rumble Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_kobj.c,v 1.10 2008/03/21 21:55:00 ad Exp $");
#define ELFSIZE ARCH_ELFSIZE
@@ -248,7 +248,7 @@ kobj_close(kobj_t ko)
switch (ko->ko_type) {
case KT_VNODE:
VOP_UNLOCK(ko->ko_source, 0);
- vn_close(ko->ko_source, FREAD, kauth_cred_get(), curlwp);
+ vn_close(ko->ko_source, FREAD, kauth_cred_get());
break;
case KT_MEMORY:
/* nothing */
diff --git a/sys/kern/subr_log.c b/sys/kern/subr_log.c
index 9c161b9c087..30b77e0cb0b 100644
--- a/sys/kern/subr_log.c
+++ b/sys/kern/subr_log.c
@@ -1,7 +1,7 @@
-/* $NetBSD: subr_log.c,v 1.48 2008/03/01 14:16:51 rmind Exp $ */
+/* $NetBSD: subr_log.c,v 1.49 2008/03/21 21:55:00 ad Exp $ */
/*-
- * Copyright (c) 2007 The NetBSD Foundation, Inc.
+ * Copyright (c) 2007, 2008 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@@ -72,7 +72,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: subr_log.c,v 1.48 2008/03/01 14:16:51 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_log.c,v 1.49 2008/03/21 21:55:00 ad Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -332,7 +332,6 @@ logsoftintr(void *cookie)
static int
logioctl(dev_t dev, u_long com, void *data, int flag, struct lwp *lwp)
{
- struct proc *p = lwp->l_proc;
long l;
switch (com) {
@@ -357,11 +356,11 @@ logioctl(dev_t dev, u_long com, void *data, int flag, struct lwp *lwp)
case TIOCSPGRP:
case FIOSETOWN:
- return fsetown(p, &log_pgid, com, data);
+ return fsetown(&log_pgid, com, data);
case TIOCGPGRP:
case FIOGETOWN:
- return fgetown(p, log_pgid, com, data);
+ return fgetown(log_pgid, com, data);
default:
return (EPASSTHROUGH);
diff --git a/sys/kern/sys_aio.c b/sys/kern/sys_aio.c
index 7e694e69d4c..e125e142d59 100644
--- a/sys/kern/sys_aio.c
+++ b/sys/kern/sys_aio.c
@@ -1,4 +1,4 @@
-/* $NetBSD: sys_aio.c,v 1.15 2007/12/21 12:04:19 ad Exp $ */
+/* $NetBSD: sys_aio.c,v 1.16 2008/03/21 21:55:00 ad Exp $ */
/*
* Copyright (c) 2007, Mindaugas Rasiukevicius <rmind at NetBSD org>
@@ -33,7 +33,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sys_aio.c,v 1.15 2007/12/21 12:04:19 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_aio.c,v 1.16 2008/03/21 21:55:00 ad Exp $");
#include "opt_ddb.h"
@@ -269,11 +269,9 @@ aio_process(struct aio_job *a_job)
struct proc *p = curlwp->l_proc;
struct aiocb *aiocbp = &a_job->aiocbp;
struct file *fp;
- struct filedesc *fdp = p->p_fd;
int fd = aiocbp->aio_fildes;
int error = 0;
- KASSERT(fdp != NULL);
KASSERT(a_job->aio_op != 0);
if ((a_job->aio_op & (AIO_READ | AIO_WRITE)) != 0) {
@@ -285,7 +283,7 @@ aio_process(struct aio_job *a_job)
goto done;
}
- fp = fd_getfile(fdp, fd);
+ fp = fd_getfile(fd);
if (fp == NULL) {
error = EBADF;
goto done;
@@ -298,7 +296,6 @@ aio_process(struct aio_job *a_job)
auio.uio_resid = aiocbp->aio_nbytes;
auio.uio_vmspace = p->p_vmspace;
- FILE_USE(fp);
if (a_job->aio_op & AIO_READ) {
/*
* Perform a Read operation
@@ -306,7 +303,7 @@ aio_process(struct aio_job *a_job)
KASSERT((a_job->aio_op & AIO_WRITE) == 0);
if ((fp->f_flag & FREAD) == 0) {
- FILE_UNUSE(fp, curlwp);
+ fd_putfile(fd);
error = EBADF;
goto done;
}
@@ -320,7 +317,7 @@ aio_process(struct aio_job *a_job)
KASSERT(a_job->aio_op & AIO_WRITE);
if ((fp->f_flag & FWRITE) == 0) {
- FILE_UNUSE(fp, curlwp);
+ fd_putfile(fd);
error = EBADF;
goto done;
}
@@ -328,7 +325,7 @@ aio_process(struct aio_job *a_job)
error = (*fp->f_ops->fo_write)(fp, &aiocbp->aio_offset,
&auio, fp->f_cred, FOF_UPDATE_OFFSET);
}
- FILE_UNUSE(fp, curlwp);
+ fd_putfile(fd);
/* Store the result value */
a_job->aiocbp.aio_nbytes -= auio.uio_resid;
@@ -341,11 +338,11 @@ aio_process(struct aio_job *a_job)
*/
struct vnode *vp;
- if ((error = getvnode(fdp, fd, &fp)) != 0)
+ if ((error = fd_getvnode(fd, &fp)) != 0)
goto done;
if ((fp->f_flag & FWRITE) == 0) {
- FILE_UNUSE(fp, curlwp);
+ fd_putfile(fd);
error = EBADF;
goto done;
}
@@ -364,7 +361,7 @@ aio_process(struct aio_job *a_job)
bioopsp->io_fsync(vp, 0);
}
VOP_UNLOCK(vp, 0);
- FILE_UNUSE(fp, curlwp);
+ fd_putfile(fd);
/* Store the result value */
a_job->aiocbp._retval = (error == 0) ? 0 : -1;
@@ -555,7 +552,10 @@ sys_aio_cancel(struct lwp *l, const struct sys_aio_cancel_args *uap, register_t
/* Check for invalid file descriptor */
fildes = (unsigned int)SCARG(uap, fildes);
- if (fildes >= fdp->fd_nfiles || fdp->fd_ofiles[fildes] == NULL)
+ if (fildes >= fdp->fd_nfiles)
+ return EBADF;
+ membar_consumer();
+ if (fdp->fd_ofiles[fildes] == NULL || fdp->fd_ofiles[fildes]->ff_file == NULL)
return EBADF;
/* Check if AIO structure is initialized */
diff --git a/sys/kern/sys_generic.c b/sys/kern/sys_generic.c
index 764aba0d0ea..22cb22c3a8c 100644
--- a/sys/kern/sys_generic.c
+++ b/sys/kern/sys_generic.c
@@ -1,4 +1,4 @@
-/* $NetBSD: sys_generic.c,v 1.114 2008/03/17 18:01:44 ad Exp $ */
+/* $NetBSD: sys_generic.c,v 1.115 2008/03/21 21:55:00 ad Exp $ */
/*-
* Copyright (c) 2007, 2008 The NetBSD Foundation, Inc.
@@ -77,7 +77,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sys_generic.c,v 1.114 2008/03/17 18:01:44 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_generic.c,v 1.115 2008/03/21 21:55:00 ad Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -124,25 +124,19 @@ sys_read(struct lwp *l, const struct sys_read_args *uap, register_t *retval)
syscallarg(void *) buf;
syscallarg(size_t) nbyte;
} */
- int fd;
- struct file *fp;
- proc_t *p;
- struct filedesc *fdp;
+ file_t *fp;
+ int fd;
fd = SCARG(uap, fd);
- p = l->l_proc;
- fdp = p->p_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);
-
/* dofileread() will unuse the descriptor for us */
return (dofileread(fd, fp, SCARG(uap, buf), SCARG(uap, nbyte),
&fp->f_offset, FOF_UPDATE_OFFSET, retval));
@@ -188,7 +182,7 @@ dofileread(int fd, struct file *fp, void *buf, size_t nbyte,
ktrgenio(fd, UIO_READ, buf, cnt, error);
*retval = cnt;
out:
- FILE_UNUSE(fp, l);
+ fd_putfile(fd);
return (error);
}
@@ -219,23 +213,18 @@ do_filereadv(int fd, const struct iovec *iovp, int iovcnt,
u_int iovlen;
struct file *fp;
struct iovec *ktriov = NULL;
- lwp_t *l;
if (iovcnt == 0)
return EINVAL;
- l = curlwp;
-
- if ((fp = fd_getfile(l->l_proc->p_fd, 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);
-
if (offset == NULL)
offset = &fp->f_offset;
else {
@@ -279,7 +268,7 @@ do_filereadv(int fd, const struct iovec *iovp, int iovcnt,
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;
auio.uio_resid = 0;
for (i = 0; i < iovcnt; i++, iov++) {
@@ -322,7 +311,7 @@ do_filereadv(int fd, const struct iovec *iovp, int iovcnt,
if (needfree)
kmem_free(needfree, iovlen);
out:
- FILE_UNUSE(fp, l);
+ fd_putfile(fd);
return (error);
}
@@ -337,21 +326,19 @@ sys_write(struct lwp *l, const struct sys_write_args *uap, register_t *retval)
syscallarg(const void *) buf;
syscallarg(size_t) nbyte;
} */
- int fd;
- struct file *fp;
+ file_t *fp;
+ int fd;
fd = SCARG(uap, fd);
- if ((fp = fd_getfile(curproc->p_fd, 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);
-
/* dofilewrite() will unuse the descriptor for us */
return (dofilewrite(fd, fp, SCARG(uap, buf), SCARG(uap, nbyte),
&fp->f_offset, FOF_UPDATE_OFFSET, retval));
@@ -365,9 +352,6 @@ dofilewrite(int fd, struct file *fp, const void *buf,
struct uio auio;
size_t cnt;
int error;
- lwp_t *l;
-
- l = curlwp;
aiov.iov_base = __UNCONST(buf); /* XXXUNCONST kills const */
aiov.iov_len = nbyte;
@@ -375,7 +359,7 @@ dofilewrite(int fd, struct file *fp, const void *buf,
auio.uio_iovcnt = 1;
auio.uio_resid = nbyte;
auio.uio_rw = UIO_WRITE;
- auio.uio_vmspace = l->l_proc->p_vmspace;
+ auio.uio_vmspace = curproc->p_vmspace;
/*
* Writes return ssize_t because -1 is returned on error. Therefore
@@ -395,7 +379,7 @@ dofilewrite(int fd, struct file *fp, const void *buf,
error = 0;
if (error == EPIPE) {
mutex_enter(&proclist_mutex);
- psignal(l->l_proc, SIGPIPE);
+ psignal(curproc, SIGPIPE);
mutex_exit(&proclist_mutex);
}
}
@@ -403,7 +387,7 @@ dofilewrite(int fd, struct file *fp, const void *buf,
ktrgenio(fd, UIO_WRITE, buf, cnt, error);
*retval = cnt;
out:
- FILE_UNUSE(fp, l);
+ fd_putfile(fd);
return (error);
}
@@ -434,23 +418,18 @@ do_filewritev(int fd, const struct iovec *iovp, int iovcnt,
u_int iovlen;
struct file *fp;
struct iovec *ktriov = NULL;
- lwp_t *l;
-
- l = curlwp;
if (iovcnt == 0)
return EINVAL;
- if ((fp = fd_getfile(l->l_proc->p_fd, 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);
-
if (offset == NULL)
offset = &fp->f_offset;
else {
@@ -527,7 +506,7 @@ do_filewritev(int fd, const struct iovec *iovp, int iovcnt,
error = 0;
if (error == EPIPE) {
mutex_enter(&proclist_mutex);
- psignal(l->l_proc, SIGPIPE);
+ psignal(curproc, SIGPIPE);
mutex_exit(&proclist_mutex);
}
}
@@ -543,7 +522,7 @@ do_filewritev(int fd, const struct iovec *iovp, int iovcnt,
if (needfree)
kmem_free(needfree, iovlen);
out:
- FILE_UNUSE(fp, l);
+ fd_putfile(fd);
return (error);
}
@@ -568,33 +547,30 @@ sys_ioctl(struct lwp *l, const struct sys_ioctl_args *uap, register_t *retval)
void *data, *memp;
#define STK_PARAMS 128
u_long stkbuf[STK_PARAMS/sizeof(u_long)];
+ fdfile_t *ff;
error = 0;
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);
-
if ((fp->f_flag & (FREAD | FWRITE)) == 0) {
error = EBADF;
com = 0;
goto out;
}
+ ff = fdp->fd_ofiles[SCARG(uap, fd)];
switch (com = SCARG(uap, com)) {
case FIONCLEX:
- rw_enter(&fdp->fd_lock, RW_WRITER);
- fdp->fd_ofileflags[SCARG(uap, fd)] &= ~UF_EXCLOSE;
- rw_exit(&fdp->fd_lock);
+ ff->ff_exclose = 0;
goto out;
case FIOCLEX:
- rw_enter(&fdp->fd_lock, RW_WRITER);
- fdp->fd_ofileflags[SCARG(uap, fd)] |= UF_EXCLOSE;
- rw_exit(&fdp->fd_lock);
+ ff->ff_exclose = 1;
+ fdp->fd_exclose = 1;
goto out;
}
@@ -643,7 +619,7 @@ sys_ioctl(struct lwp *l, const struct sys_ioctl_args *uap, register_t *retval)
else
fp->f_flag &= ~FNONBLOCK;
FILE_UNLOCK(fp);
- error = (*fp->f_ops->fo_ioctl)(fp, FIONBIO, data, l);
+ error = (*fp->f_ops->fo_ioctl)(fp, FIONBIO, data);
break;
case FIOASYNC:
@@ -653,11 +629,11 @@ sys_ioctl(struct lwp *l, const struct sys_ioctl_args *uap, register_t *retval)
else
fp->f_flag &= ~FASYNC;
FILE_UNLOCK(fp);
- error = (*fp->f_ops->fo_ioctl)(fp, FIOASYNC, data, l);
+ error = (*fp->f_ops->fo_ioctl)(fp, FIOASYNC, data);
break;
default:
- error = (*fp->f_ops->fo_ioctl)(fp, com, data, l);
+ error = (*fp->f_ops->fo_ioctl)(fp, com, data);
/*
* Copy any data to user, size was
* already set and checked above.
@@ -672,7 +648,7 @@ sys_ioctl(struct lwp *l, const struct sys_ioctl_args *uap, register_t *retval)
if (memp)
kmem_free(memp, size);
out:
- FILE_UNUSE(fp, l);
+ fd_putfile(SCARG(uap, fd));
switch (error) {
case -1:
printf("sys_ioctl: _IO%s%s('%c', %lu, %lu) returned -1: "
@@ -887,13 +863,10 @@ selscan(lwp_t *l, fd_mask *ibitp, fd_mask *obitp, int nfd,
static const int flag[3] = { POLLRDNORM | POLLHUP | POLLERR,
POLLWRNORM | POLLHUP | POLLERR,
POLLRDBAND };
- proc_t *p = l->l_proc;
- struct filedesc *fdp;
int msk, i, j, fd, n;
fd_mask ibits, obits;
- struct file *fp;
+ file_t *fp;
- fdp = p->p_fd;
n = 0;
for (msk = 0; msk < 3; msk++) {
for (i = 0; i < nfd; i += NFDBITS) {
@@ -901,14 +874,13 @@ selscan(lwp_t *l, fd_mask *ibitp, fd_mask *obitp, int nfd,
obits = 0;
while ((j = ffs(ibits)) && (fd = i + --j) < nfd) {
ibits &= ~(1 << j);
- if ((fp = fd_getfile(fdp, fd)) == NULL)
+ if ((fp = fd_getfile(fd)) == NULL)
return (EBADF);
- FILE_USE(fp);
- if ((*fp->f_ops->fo_poll)(fp, flag[msk], l)) {
+ if ((*fp->f_ops->fo_poll)(fp, flag[msk])) {
obits |= (1 << j);
n++;
}
- FILE_UNUSE(fp, l);
+ fd_putfile(fd);
}
*obitp++ = obits;
}
@@ -1063,31 +1035,22 @@ pollcommon(lwp_t *l, register_t *retval,
int
pollscan(lwp_t *l, struct pollfd *fds, int nfd, register_t *retval)
{
- proc_t *p = l->l_proc;
- struct filedesc *fdp;
- int i, n;
- struct file *fp;
+ int i, n;
+ file_t *fp;
- fdp = p->p_fd;
n = 0;
for (i = 0; i < nfd; i++, fds++) {
- if (fds->fd >= fdp->fd_nfiles) {
+ if (fds->fd < 0) {
+ fds->revents = 0;
+ } else if ((fp = fd_getfile(fds->fd)) == NULL) {
fds->revents = POLLNVAL;
n++;
- } else if (fds->fd < 0) {
- fds->revents = 0;
} else {
- if ((fp = fd_getfile(fdp, fds->fd)) == NULL) {
- fds->revents = POLLNVAL;
+ fds->revents = (*fp->f_ops->fo_poll)(fp,
+ fds->events | POLLERR | POLLHUP);
+ if (fds->revents != 0)
n++;
- } else {
- FILE_USE(fp);
- fds->revents = (*fp->f_ops->fo_poll)(fp,
- fds->events | POLLERR | POLLHUP, l);
- if (fds->revents != 0)
- n++;
- FILE_UNUSE(fp, l);
- }
+ fd_putfile(fds->fd);
}
}
*retval = n;
diff --git a/sys/kern/sys_mqueue.c b/sys/kern/sys_mqueue.c
index 62e741e059b..ec2ad698ee7 100644
--- a/sys/kern/sys_mqueue.c
+++ b/sys/kern/sys_mqueue.c
@@ -1,4 +1,4 @@
-/* $NetBSD: sys_mqueue.c,v 1.6 2007/12/20 23:03:10 dsl Exp $ */
+/* $NetBSD: sys_mqueue.c,v 1.7 2008/03/21 21:55:00 ad Exp $ */
/*
* Copyright (c) 2007, Mindaugas Rasiukevicius <rmind at NetBSD org>
@@ -45,11 +45,10 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sys_mqueue.c,v 1.6 2007/12/20 23:03:10 dsl Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_mqueue.c,v 1.7 2008/03/21 21:55:00 ad Exp $");
#include <sys/param.h>
#include <sys/types.h>
-
#include <sys/condvar.h>
#include <sys/errno.h>
#include <sys/fcntl.h>
@@ -84,7 +83,7 @@ static struct pool mqmsg_poll;
static LIST_HEAD(, mqueue) mqueue_head =
LIST_HEAD_INITIALIZER(mqueue_head);
-static int mq_close_fop(struct file *, struct lwp *);
+static int mq_close_fop(file_t *);
static const struct fileops mqops = {
fbadop_read, fbadop_write, fbadop_ioctl, fnullop_fcntl, fnullop_poll,
@@ -172,19 +171,17 @@ mqueue_access(struct lwp *l, struct mqueue *mq, mode_t acc_mode)
* => increments the reference on file entry
*/
static int
-mqueue_get(struct lwp *l, mqd_t mqd, mode_t acc_mode, struct file **fpr)
+mqueue_get(struct lwp *l, mqd_t mqd, mode_t acc_mode, file_t **fpr)
{
- const struct proc *p = l->l_proc;
- struct file *fp;
+ file_t *fp;
struct mqueue *mq;
/* Get the file and descriptor */
- fp = fd_getfile(p->p_fd, (int)mqd);
+ fp = fd_getfile((int)mqd);
if (fp == NULL)
return EBADF;
/* Increment the reference of file entry, and lock the mqueue */
- FILE_USE(fp);
mq = fp->f_data;
*fpr = fp;
mutex_enter(&mq->mq_mtx);
@@ -194,7 +191,7 @@ mqueue_get(struct lwp *l, mqd_t mqd, mode_t acc_mode, struct file **fpr)
return 0;
if ((acc_mode & fp->f_flag) == 0 || mqueue_access(l, mq, acc_mode)) {
mutex_exit(&mq->mq_mtx);
- FILE_UNUSE(fp, l);
+ fd_putfile((int)mqd);
return EPERM;
}
@@ -226,9 +223,9 @@ abstimeout2timo(const void *uaddr, int *timo)
}
static int
-mq_close_fop(struct file *fp, struct lwp *l)
+mq_close_fop(file_t *fp)
{
- struct proc *p = l->l_proc;
+ struct proc *p = curproc;
struct mqueue *mq = fp->f_data;
bool destroy;
@@ -277,7 +274,7 @@ sys_mq_open(struct lwp *l, const struct sys_mq_open_args *uap, register_t *retva
} */
struct proc *p = l->l_proc;
struct mqueue *mq, *mq_new = NULL;
- struct file *fp;
+ file_t *fp;
char *name;
int mqd, error, oflag;
@@ -346,7 +343,7 @@ sys_mq_open(struct lwp *l, const struct sys_mq_open_args *uap, register_t *retva
}
/* Allocate file structure and descriptor */
- error = falloc(l, &fp, &mqd);
+ error = fd_allocfile(&fp, &mqd);
if (error) {
if (mq_new)
mqueue_destroy(mq_new);
@@ -383,9 +380,7 @@ sys_mq_open(struct lwp *l, const struct sys_mq_open_args *uap, register_t *retva
if ((oflag & O_CREAT) == 0) {
mutex_exit(&mqlist_mtx);
KASSERT(mq_new == NULL);
- FILE_UNUSE(fp, l);
- ffree(fp);
- fdremove(p->p_fd, mqd);
+ fd_abort(p, fp, mqd);
kmem_free(name, MQ_NAMELEN);
return ENOENT;
}
@@ -407,19 +402,18 @@ sys_mq_open(struct lwp *l, const struct sys_mq_open_args *uap, register_t *retva
p->p_mqueue_cnt++;
mq->mq_refcnt++;
fp->f_data = mq;
- FILE_SET_MATURE(fp);
exit:
mutex_exit(&mq->mq_mtx);
mutex_exit(&mqlist_mtx);
- FILE_UNUSE(fp, l);
if (mq_new)
mqueue_destroy(mq_new);
if (error) {
- ffree(fp);
- fdremove(p->p_fd, mqd);
- } else
+ fd_abort(p, fp, mqd);
+ } else {
+ fd_affix(p, fp, mqd);
*retval = mqd;
+ }
kmem_free(name, MQ_NAMELEN);
return error;
@@ -439,7 +433,7 @@ static int
mq_receive1(struct lwp *l, mqd_t mqdes, void *msg_ptr, size_t msg_len,
unsigned *msg_prio, int t, ssize_t *mlen)
{
- struct file *fp = NULL;
+ file_t *fp = NULL;
struct mqueue *mq;
struct mq_msg *msg = NULL;
int error;
@@ -489,7 +483,7 @@ mq_receive1(struct lwp *l, mqd_t mqdes, void *msg_ptr, size_t msg_len,
cv_signal(&mq->mq_recv_cv);
error:
mutex_exit(&mq->mq_mtx);
- FILE_UNUSE(fp, l);
+ fd_putfile((int)mqdes);
if (error)
return error;
@@ -563,7 +557,7 @@ static int
mq_send1(struct lwp *l, mqd_t mqdes, const char *msg_ptr, size_t msg_len,
unsigned msg_prio, int t)
{
- struct file *fp = NULL;
+ file_t *fp = NULL;
struct mqueue *mq;
struct mq_msg *msg, *pos_msg;
struct proc *notify = NULL;
@@ -654,7 +648,7 @@ mq_send1(struct lwp *l, mqd_t mqdes, const char *msg_ptr, size_t msg_len,
cv_signal(&mq->mq_send_cv);
error:
mutex_exit(&mq->mq_mtx);
- FILE_UNUSE(fp, l);
+ fd_putfile((int)mqdes);
if (error) {
mqueue_freemsg(msg, size);
@@ -713,7 +707,7 @@ sys_mq_notify(struct lwp *l, const struct sys_mq_notify_args *uap, register_t *r
syscallarg(mqd_t) mqdes;
syscallarg(const struct sigevent *) notification;
} */
- struct file *fp = NULL;
+ file_t *fp = NULL;
struct mqueue *mq;
struct sigevent sig;
int error;
@@ -746,7 +740,7 @@ sys_mq_notify(struct lwp *l, const struct sys_mq_notify_args *uap, register_t *r
mq->mq_notify_proc = NULL;
}
mutex_exit(&mq->mq_mtx);
- FILE_UNUSE(fp, l);
+ fd_putfile((int)SCARG(uap, mqdes));
return error;
}
@@ -758,7 +752,7 @@ sys_mq_getattr(struct lwp *l, const struct sys_mq_getattr_args *uap, register_t
syscallarg(mqd_t) mqdes;
syscallarg(struct mq_attr *) mqstat;
} */
- struct file *fp = NULL;
+ file_t *fp = NULL;
struct mqueue *mq;
struct mq_attr attr;
int error;
@@ -770,7 +764,7 @@ sys_mq_getattr(struct lwp *l, const struct sys_mq_getattr_args *uap, register_t
mq = fp->f_data;
memcpy(&attr, &mq->mq_attrib, sizeof(struct mq_attr));
mutex_exit(&mq->mq_mtx);
- FILE_UNUSE(fp, l);
+ fd_putfile((int)SCARG(uap, mqdes));
return copyout(&attr, SCARG(uap, mqstat), sizeof(struct mq_attr));
}
@@ -783,7 +777,7 @@ sys_mq_setattr(struct lwp *l, const struct sys_mq_setattr_args *uap, register_t
syscallarg(const struct mq_attr *) mqstat;
syscallarg(struct mq_attr *) omqstat;
} */
- struct file *fp = NULL;
+ file_t *fp = NULL;
struct mqueue *mq;
struct mq_attr attr;
int error, nonblock;
@@ -810,7 +804,7 @@ sys_mq_setattr(struct lwp *l, const struct sys_mq_setattr_args *uap, register_t
mq->mq_attrib.mq_flags &= ~O_NONBLOCK;
mutex_exit(&mq->mq_mtx);
- FILE_UNUSE(fp, l);
+ fd_putfile((int)SCARG(uap, mqdes));
/*
* Copy the data to the user-space.
diff --git a/sys/kern/sys_pipe.c b/sys/kern/sys_pipe.c
index 0f3c83a4ece..02df7131d82 100644
--- a/sys/kern/sys_pipe.c
+++ b/sys/kern/sys_pipe.c
@@ -1,4 +1,4 @@
-/* $NetBSD: sys_pipe.c,v 1.98 2008/03/01 14:16:51 rmind Exp $ */
+/* $NetBSD: sys_pipe.c,v 1.99 2008/03/21 21:55:00 ad Exp $ */
/*-
* Copyright (c) 2003, 2007, 2008 The NetBSD Foundation, Inc.
@@ -83,7 +83,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sys_pipe.c,v 1.98 2008/03/01 14:16:51 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_pipe.c,v 1.99 2008/03/21 21:55:00 ad Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -123,12 +123,11 @@ static int pipe_read(struct file *fp, off_t *offset, struct uio *uio,
kauth_cred_t cred, int flags);
static int pipe_write(struct file *fp, off_t *offset, struct uio *uio,
kauth_cred_t cred, int flags);
-static int pipe_close(struct file *fp, struct lwp *l);
-static int pipe_poll(struct file *fp, int events, struct lwp *l);
+static int pipe_close(struct file *fp);
+static int pipe_poll(struct file *fp, int events);
static int pipe_kqfilter(struct file *fp, struct knote *kn);
-static int pipe_stat(struct file *fp, struct stat *sb, struct lwp *l);
-static int pipe_ioctl(struct file *fp, u_long cmd, void *data,
- struct lwp *l);
+static int pipe_stat(struct file *fp, struct stat *sb);
+static int pipe_ioctl(struct file *fp, u_long cmd, void *data);
static const struct fileops pipeops = {
pipe_read, pipe_write, pipe_ioctl, fnullop_fcntl, pipe_poll,
@@ -254,7 +253,9 @@ sys_pipe(struct lwp *l, const void *v, register_t *retval)
struct pipe *rpipe, *wpipe;
struct pipe_mutex *mutex;
int fd, error;
+ proc_t *p;
+ p = curproc;
rpipe = wpipe = NULL;
mutex = pool_cache_get(pipe_mutex_cache, PR_WAITOK);
if (mutex == NULL)
@@ -265,15 +266,7 @@ sys_pipe(struct lwp *l, const void *v, register_t *retval)
return (ENFILE);
}
- /*
- * Note: the file structure returned from falloc() is marked
- * as 'larval' initially. Unless we mark it as 'mature' by
- * FILE_SET_MATURE(), any attempt to do anything with it would
- * return EBADF, including e.g. dup(2) or close(2). This avoids
- * file descriptor races if we block in the second falloc().
- */
-
- error = falloc(l, &rf, &fd);
+ error = fd_allocfile(&rf, &fd);
if (error)
goto free2;
retval[0] = fd;
@@ -282,7 +275,7 @@ sys_pipe(struct lwp *l, const void *v, register_t *retval)
rf->f_data = (void *)rpipe;
rf->f_ops = &pipeops;
- error = falloc(l, &wf, &fd);
+ error = fd_allocfile(&wf, &fd);
if (error)
goto free3;
retval[1] = fd;
@@ -294,15 +287,11 @@ sys_pipe(struct lwp *l, const void *v, register_t *retval)
rpipe->pipe_peer = wpipe;
wpipe->pipe_peer = rpipe;
- FILE_SET_MATURE(rf);
- FILE_SET_MATURE(wf);
- FILE_UNUSE(rf, l);
- FILE_UNUSE(wf, l);
+ fd_affix(p, rf, (int)retval[0]);
+ fd_affix(p, wf, (int)retval[1]);
return (0);
free3:
- FILE_UNUSE(rf, l);
- ffree(rf);
- fdremove(l->l_proc->p_fd, retval[0]);
+ fd_abort(p, rf, (int)retval[0]);
free2:
pipeclose(NULL, wpipe);
pipeclose(NULL, rpipe);
@@ -1065,10 +1054,9 @@ pipe_write(struct file *fp, off_t *offset, struct uio *uio, kauth_cred_t cred,
* we implement a very minimal set of ioctls for compatibility with sockets.
*/
int
-pipe_ioctl(struct file *fp, u_long cmd, void *data, struct lwp *l)
+pipe_ioctl(struct file *fp, u_long cmd, void *data)
{
- struct pipe *pipe = (struct pipe *)fp->f_data;
- struct proc *p = l->l_proc;
+ struct pipe *pipe = fp->f_data;
kmutex_t *lock = pipe->pipe_lock;
switch (cmd) {
@@ -1131,20 +1119,20 @@ pipe_ioctl(struct file *fp, u_long cmd, void *data, struct lwp *l)
case TIOCSPGRP:
case FIOSETOWN:
- return fsetown(p, &pipe->pipe_pgid, cmd, data);
+ return fsetown(&pipe->pipe_pgid, cmd, data);
case TIOCGPGRP:
case FIOGETOWN:
- return fgetown(p, pipe->pipe_pgid, cmd, data);
+ return fgetown(pipe->pipe_pgid, cmd, data);
}
return (EPASSTHROUGH);
}
int
-pipe_poll(struct file *fp, int events, struct lwp *l)
+pipe_poll(struct file *fp, int events)
{
- struct pipe *rpipe = (struct pipe *)fp->f_data;
+ struct pipe *rpipe = fp->f_data;
struct pipe *wpipe;
int eof = 0;
int revents = 0;
@@ -1181,10 +1169,10 @@ pipe_poll(struct file *fp, int events, struct lwp *l)
if (revents == 0) {
if (events & (POLLIN | POLLRDNORM))
- selrecord(l, &rpipe->pipe_sel);
+ selrecord(curlwp, &rpipe->pipe_sel);
if (events & (POLLOUT | POLLWRNORM))
- selrecord(l, &wpipe->pipe_sel);
+ selrecord(curlwp, &wpipe->pipe_sel);
}
mutex_exit(rpipe->pipe_lock);
@@ -1192,9 +1180,9 @@ pipe_poll(struct file *fp, int events, struct lwp *l)
}
static int
-pipe_stat(struct file *fp, struct stat *ub, struct lwp *l)
+pipe_stat(struct file *fp, struct stat *ub)
{
- struct pipe *pipe = (struct pipe *)fp->f_data;
+ struct pipe *pipe = fp->f_data;
memset((void *)ub, 0, sizeof(*ub));
ub->st_mode = S_IFIFO | S_IRUSR | S_IWUSR;
@@ -1218,9 +1206,9 @@ pipe_stat(struct file *fp, struct stat *ub, struct lwp *l)
/* ARGSUSED */
static int
-pipe_close(struct file *fp, struct lwp *l)
+pipe_close(struct file *fp)
{
- struct pipe *pipe = (struct pipe *)fp->f_data;
+ struct pipe *pipe = fp->f_data;
fp->f_data = NULL;
pipeclose(fp, pipe);
@@ -1264,6 +1252,12 @@ pipeclose(struct file *fp, struct pipe *pipe)
if (pipe == NULL)
return;
+
+ KASSERT(cv_is_valid(&pipe->pipe_rcv));
+ KASSERT(cv_is_valid(&pipe->pipe_wcv));
+ KASSERT(cv_is_valid(&pipe->pipe_draincv));
+ KASSERT(cv_is_valid(&pipe->pipe_lkcv));
+
lock = pipe->pipe_lock;
mutex_enter(lock);
pipeselwakeup(pipe, pipe, POLL_HUP);
@@ -1317,7 +1311,7 @@ filt_pipedetach(struct knote *kn)
struct pipe *pipe;
kmutex_t *lock;
- pipe = (struct pipe *)kn->kn_fp->f_data;
+ pipe = ((file_t *)kn->kn_obj)->f_data;
lock = pipe->pipe_lock;
mutex_enter(lock);
@@ -1352,7 +1346,7 @@ filt_pipedetach(struct knote *kn)
static int
filt_piperead(struct knote *kn, long hint)
{
- struct pipe *rpipe = (struct pipe *)kn->kn_fp->f_data;
+ struct pipe *rpipe = ((file_t *)kn->kn_obj)->f_data;
struct pipe *wpipe;
if ((hint & NOTE_SUBMIT) == 0) {
@@ -1383,7 +1377,7 @@ filt_piperead(struct knote *kn, long hint)
static int
filt_pipewrite(struct knote *kn, long hint)
{
- struct pipe *rpipe = (struct pipe *)kn->kn_fp->f_data;
+ struct pipe *rpipe = ((file_t *)kn->kn_obj)->f_data;
struct pipe *wpipe;
if ((hint & NOTE_SUBMIT) == 0) {
@@ -1421,7 +1415,7 @@ pipe_kqfilter(struct file *fp, struct knote *kn)
struct pipe *pipe;
kmutex_t *lock;
- pipe = (struct pipe *)kn->kn_fp->f_data;
+ pipe = ((file_t *)kn->kn_obj)->f_data;
lock = pipe->pipe_lock;
mutex_enter(lock);
diff --git a/sys/kern/sys_socket.c b/sys/kern/sys_socket.c
index b214bbd224c..51b057e28cf 100644
--- a/sys/kern/sys_socket.c
+++ b/sys/kern/sys_socket.c
@@ -1,4 +1,4 @@
-/* $NetBSD: sys_socket.c,v 1.54 2008/03/20 19:23:15 ad Exp $ */
+/* $NetBSD: sys_socket.c,v 1.55 2008/03/21 21:55:00 ad Exp $ */
/*
* Copyright (c) 1982, 1986, 1990, 1993
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sys_socket.c,v 1.54 2008/03/20 19:23:15 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_socket.c,v 1.55 2008/03/21 21:55:00 ad Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -58,41 +58,40 @@ const struct fileops socketops = {
/* ARGSUSED */
int
-soo_read(struct file *fp, off_t *offset, struct uio *uio, kauth_cred_t cred,
- int flags)
+soo_read(file_t *fp, off_t *offset, struct uio *uio, kauth_cred_t cred,
+ int flags)
{
- struct socket *so = (struct socket *) fp->f_data;
+ struct socket *so = fp->f_data;
int error;
- KERNEL_LOCK(1, curlwp);
+ KERNEL_LOCK(1, NULL);
error = (*so->so_receive)(so, (struct mbuf **)0,
uio, (struct mbuf **)0, (struct mbuf **)0, (int *)0);
- KERNEL_UNLOCK_ONE(curlwp);
+ KERNEL_UNLOCK_ONE(NULL);
return error;
}
/* ARGSUSED */
int
-soo_write(struct file *fp, off_t *offset, struct uio *uio, kauth_cred_t cred,
- int flags)
+soo_write(file_t *fp, off_t *offset, struct uio *uio, kauth_cred_t cred,
+ int flags)
{
- struct socket *so = (struct socket *) fp->f_data;
+ struct socket *so = fp->f_data;
int error;
- KERNEL_LOCK(1, curlwp);
+ KERNEL_LOCK(1, NULL);
error = (*so->so_send)(so, (struct mbuf *)0,
uio, (struct mbuf *)0, (struct mbuf *)0, 0, curlwp);
- KERNEL_UNLOCK_ONE(curlwp);
+ KERNEL_UNLOCK_ONE(NULL);
return error;
}
int
-soo_ioctl(struct file *fp, u_long cmd, void *data, struct lwp *l)
+soo_ioctl(file_t *fp, u_long cmd, void *data)
{
- struct socket *so = (struct socket *)fp->f_data;
- struct proc *p = l->l_proc;
+ struct socket *so = fp->f_data;
int error = 0;
if (cmd == FIONBIO) {
@@ -100,7 +99,7 @@ soo_ioctl(struct file *fp, u_long cmd, void *data, struct lwp *l)
return 0;
}
- KERNEL_LOCK(1, curlwp);
+ KERNEL_LOCK(1, NULL);
switch (cmd) {
@@ -141,13 +140,13 @@ soo_ioctl(struct file *fp, u_long cmd, void *data, struct lwp *l)
case SIOCSPGRP:
case FIOSETOWN:
case TIOCSPGRP:
- error = fsetown(p, &so->so_pgid, cmd, data);
+ error = fsetown(&so->so_pgid, cmd, data);
break;
case SIOCGPGRP:
case FIOGETOWN:
case TIOCGPGRP:
- error = fgetown(p, so->so_pgid, cmd, data);
+ error = fgetown(so->so_pgid, cmd, data);
break;
case SIOCATMARK:
@@ -161,22 +160,23 @@ soo_ioctl(struct file *fp, u_long cmd, void *data, struct lwp *l)
* different entry since a socket's unnecessary
*/
if (IOCGROUP(cmd) == 'i')
- error = ifioctl(so, cmd, data, l);
+ error = ifioctl(so, cmd, data, curlwp);
else if (IOCGROUP(cmd) == 'r')
- error = rtioctl(cmd, data, l);
+ error = rtioctl(cmd, data, curlwp);
else
error = (*so->so_proto->pr_usrreq)(so, PRU_CONTROL,
- (struct mbuf *)cmd, (struct mbuf *)data, NULL, l);
+ (struct mbuf *)cmd, (struct mbuf *)data, NULL,
+ curlwp);
break;
}
- KERNEL_UNLOCK_ONE(curlwp);
+ KERNEL_UNLOCK_ONE(NULL);
return error;
}
int
-soo_fcntl(struct file *fp, u_int cmd, void *data, struct lwp *l)
+soo_fcntl(file_t *fp, u_int cmd, void *data)
{
if (cmd == F_SETFL)
@@ -186,40 +186,41 @@ soo_fcntl(struct file *fp, u_int cmd, void *data, struct lwp *l)
}
int
-soo_poll(struct file *fp, int events, struct lwp *l)
+soo_poll(file_t *fp, int events)
{
return sopoll(fp->f_data, events);
}
int
-soo_stat(struct file *fp, struct stat *ub, struct lwp *l)
+soo_stat(file_t *fp, struct stat *ub)
{
- struct socket *so = (struct socket *)fp->f_data;
+ struct socket *so = fp->f_data;
int error;
memset((void *)ub, 0, sizeof(*ub));
ub->st_mode = S_IFSOCK;
- KERNEL_LOCK(1, curlwp);
+ KERNEL_LOCK(1, NULL);
error = (*so->so_proto->pr_usrreq)(so, PRU_SENSE,
- (struct mbuf *)ub, (struct mbuf *)0, (struct mbuf *)0, l);
- KERNEL_UNLOCK_ONE(curlwp);
+ (struct mbuf *)ub, (struct mbuf *)0, (struct mbuf *)0,
+ curlwp);
+ KERNEL_UNLOCK_ONE(NULL);
return error;
}
/* ARGSUSED */
int
-soo_close(struct file *fp, struct lwp *l)
+soo_close(file_t *fp)
{
int error = 0;
- KERNEL_LOCK(1, curlwp);
+ KERNEL_LOCK(1, NULL);
if (fp->f_data)
- error = soclose((struct socket *)fp->f_data);
+ error = soclose(fp->f_data);
fp->f_data = 0;
- KERNEL_UNLOCK_ONE(curlwp);
+ KERNEL_UNLOCK_ONE(NULL);
return error;
}
diff --git a/sys/kern/tty_ptm.c b/sys/kern/tty_ptm.c
index ef28e654208..2d2d3fa9a01 100644
--- a/sys/kern/tty_ptm.c
+++ b/sys/kern/tty_ptm.c
@@ -1,4 +1,4 @@
-/* $NetBSD: tty_ptm.c,v 1.23 2008/01/24 17:32:54 ad Exp $ */
+/* $NetBSD: tty_ptm.c,v 1.24 2008/03/21 21:55:00 ad Exp $ */
/*-
* Copyright (c) 2004 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tty_ptm.c,v 1.23 2008/01/24 17:32:54 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tty_ptm.c,v 1.24 2008/03/21 21:55:00 ad Exp $");
#include "opt_ptm.h"
@@ -141,8 +141,8 @@ pty_alloc_master(struct lwp *l, int *fd, dev_t *dev)
struct vnode *vp;
int md;
- if ((error = falloc(l, &fp, fd)) != 0) {
- DPRINTF(("falloc %d\n", error));
+ if ((error = fd_allocfile(&fp, fd)) != 0) {
+ DPRINTF(("fd_allocfile %d\n", error));
return error;
}
retry:
@@ -183,13 +183,10 @@ retry:
fp->f_ops = &vnops;
fp->f_data = vp;
VOP_UNLOCK(vp, 0);
- FILE_SET_MATURE(fp);
- FILE_UNUSE(fp, l);
+ fd_affix(curproc, fp, *fd);
return 0;
bad:
- FILE_UNUSE(fp, l);
- fdremove(l->l_proc->p_fd, *fd);
- ffree(fp);
+ fd_abort(curproc, fp, *fd);
return error;
}
@@ -243,8 +240,8 @@ pty_alloc_slave(struct lwp *l, int *fd, dev_t dev)
struct vnode *vp;
/* Grab a filedescriptor for the slave */
- if ((error = falloc(l, &fp, fd)) != 0) {
- DPRINTF(("falloc %d\n", error));
+ if ((error = fd_allocfile(&fp, fd)) != 0) {
+ DPRINTF(("fd_allocfile %d\n", error));
return error;
}
@@ -263,13 +260,10 @@ pty_alloc_slave(struct lwp *l, int *fd, dev_t dev)
fp->f_ops = &vnops;
fp->f_data = vp;
VOP_UNLOCK(vp, 0);
- FILE_SET_MATURE(fp);
- FILE_UNUSE(fp, l);
+ fd_affix(curproc, fp, *fd);
return 0;
bad:
- FILE_UNUSE(fp, l);
- fdremove(l->l_proc->p_fd, *fd);
- ffree(fp);
+ fd_abort(curproc, fp, *fd);
return error;
}
@@ -335,12 +329,9 @@ ptmopen(dev_t dev, int flag, int mode, struct lwp *l)
* a new linux module.
*/
if ((error = pty_grant_slave(l, ttydev)) != 0) {
- struct file *fp =
- fd_getfile(l->l_proc->p_fd, fd);
+ file_t *fp = fd_getfile(fd);
if (fp != NULL) {
- FILE_UNUSE(fp, l);
- fdremove(l->l_proc->p_fd, fd);
- ffree(fp);
+ fd_close(fd);
}
return error;
}
@@ -369,8 +360,7 @@ ptmioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l)
int error;
dev_t newdev;
int cfd, sfd;
- struct file *fp;
- struct proc *p = l->l_proc;
+ file_t *fp;
error = 0;
switch (cmd) {
@@ -390,12 +380,10 @@ ptmioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l)
DPRINTF(("ptmioctl EINVAL\n"));
return EINVAL;
}
-bad:
- fp = fd_getfile(p->p_fd, cfd);
+ bad:
+ fp = fd_getfile(cfd);
if (fp != NULL) {
- FILE_UNUSE(fp, l);
- fdremove(p->p_fd, cfd);
- ffree(fp);
+ fd_close(cfd);
}
return error;
}
diff --git a/sys/kern/uipc_domain.c b/sys/kern/uipc_domain.c
index f0116946c1c..362dd561584 100644
--- a/sys/kern/uipc_domain.c
+++ b/sys/kern/uipc_domain.c
@@ -1,4 +1,4 @@
-/* $NetBSD: uipc_domain.c,v 1.74 2008/01/07 16:12:54 ad Exp $ */
+/* $NetBSD: uipc_domain.c,v 1.75 2008/03/21 21:55:00 ad Exp $ */
/*
* Copyright (c) 1982, 1986, 1993
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uipc_domain.c,v 1.74 2008/01/07 16:12:54 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_domain.c,v 1.75 2008/03/21 21:55:00 ad Exp $");
#include <sys/param.h>
#include <sys/socket.h>
@@ -439,13 +439,14 @@ sysctl_unpcblist(SYSCTLFN_ARGS)
if (so->so_proto->pr_domain->dom_family != pf)
continue;
if (len >= elem_size && elem_count > 0) {
- FILE_LOCK(fp);
- FILE_USE(fp);
+ mutex_enter(&fp->f_lock);
+ fp->f_count++;
+ mutex_exit(&fp->f_lock);
LIST_INSERT_AFTER(fp, dfp, f_list);
mutex_exit(&filelist_lock);
sysctl_dounpcb(&pcb, so);
error = copyout(&pcb, dp, out_size);
- FILE_UNUSE(fp, NULL);
+ closef(fp);
mutex_enter(&filelist_lock);
np = LIST_NEXT(dfp, f_list);
LIST_REMOVE(dfp, f_list);
diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c
index 9f9a5911308..dfb3eaab570 100644
--- a/sys/kern/uipc_socket.c
+++ b/sys/kern/uipc_socket.c
@@ -1,4 +1,4 @@
-/* $NetBSD: uipc_socket.c,v 1.154 2008/03/20 19:23:15 ad Exp $ */
+/* $NetBSD: uipc_socket.c,v 1.155 2008/03/21 21:55:00 ad Exp $ */
/*-
* Copyright (c) 2002, 2007, 2008 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uipc_socket.c,v 1.154 2008/03/20 19:23:15 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_socket.c,v 1.155 2008/03/21 21:55:00 ad Exp $");
#include "opt_sock_counters.h"
#include "opt_sosend_loan.h"
@@ -540,29 +540,23 @@ int
fsocreate(int domain, struct socket **sop, int type, int protocol,
struct lwp *l, int *fdout)
{
- struct filedesc *fdp;
struct socket *so;
struct file *fp;
int fd, error;
- fdp = l->l_proc->p_fd;
- /* falloc() will use the desciptor for us */
- if ((error = falloc(l, &fp, &fd)) != 0)
+ if ((error = fd_allocfile(&fp, &fd)) != 0)
return (error);
fp->f_flag = FREAD|FWRITE;
fp->f_type = DTYPE_SOCKET;
fp->f_ops = &socketops;
error = socreate(domain, &so, type, protocol, l);
if (error != 0) {
- FILE_UNUSE(fp, l);
- fdremove(fdp, fd);
- ffree(fp);
+ fd_abort(curproc, fp, fd);
} else {
if (sop != NULL)
*sop = so;
fp->f_data = so;
- FILE_SET_MATURE(fp);
- FILE_UNUSE(fp, l);
+ fd_affix(curproc, fp, fd);
*fdout = fd;
}
return error;
@@ -1692,7 +1686,7 @@ filt_sordetach(struct knote *kn)
{
struct socket *so;
- so = (struct socket *)kn->kn_fp->f_data;
+ so = ((file_t *)kn->kn_obj)->f_data;
SLIST_REMOVE(&so->so_rcv.sb_sel.sel_klist, kn, knote, kn_selnext);
if (SLIST_EMPTY(&so->so_rcv.sb_sel.sel_klist))
so->so_rcv.sb_flags &= ~SB_KNOTE;
@@ -1704,7 +1698,7 @@ filt_soread(struct knote *kn, long hint)
{
struct socket *so;
- so = (struct socket *)kn->kn_fp->f_data;
+ so = ((file_t *)kn->kn_obj)->f_data;
kn->kn_data = so->so_rcv.sb_cc;
if (so->so_state & SS_CANTRCVMORE) {
kn->kn_flags |= EV_EOF;
@@ -1723,7 +1717,7 @@ filt_sowdetach(struct knote *kn)
{
struct socket *so;
- so = (struct socket *)kn->kn_fp->f_data;
+ so = ((file_t *)kn->kn_obj)->f_data;
SLIST_REMOVE(&so->so_snd.sb_sel.sel_klist, kn, knote, kn_selnext);
if (SLIST_EMPTY(&so->so_snd.sb_sel.sel_klist))
so->so_snd.sb_flags &= ~SB_KNOTE;
@@ -1735,7 +1729,7 @@ filt_sowrite(struct knote *kn, long hint)
{
struct socket *so;
- so = (struct socket *)kn->kn_fp->f_data;
+ so = ((file_t *)kn->kn_obj)->f_data;
kn->kn_data = sbspace(&so->so_snd);
if (so->so_state & SS_CANTSENDMORE) {
kn->kn_flags |= EV_EOF;
@@ -1758,7 +1752,7 @@ filt_solisten(struct knote *kn, long hint)
{
struct socket *so;
- so = (struct socket *)kn->kn_fp->f_data;
+ so = ((file_t *)kn->kn_obj)->f_data;
/*
* Set kn_data to number of incoming connections, not
@@ -1781,7 +1775,7 @@ soo_kqfilter(struct file *fp, struct knote *kn)
struct socket *so;
struct sockbuf *sb;
- so = (struct socket *)kn->kn_fp->f_data;
+ so = ((file_t *)kn->kn_obj)->f_data;
switch (kn->kn_filter) {
case EVFILT_READ:
if (so->so_options & SO_ACCEPTCONN)
diff --git a/sys/kern/uipc_syscalls.c b/sys/kern/uipc_syscalls.c
index 33658cfff74..5b4717a61ee 100644
--- a/sys/kern/uipc_syscalls.c
+++ b/sys/kern/uipc_syscalls.c
@@ -1,4 +1,4 @@
-/* $NetBSD: uipc_syscalls.c,v 1.127 2008/02/06 21:57:54 ad Exp $ */
+/* $NetBSD: uipc_syscalls.c,v 1.128 2008/03/21 21:55:00 ad Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1990, 1993
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uipc_syscalls.c,v 1.127 2008/02/06 21:57:54 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_syscalls.c,v 1.128 2008/03/21 21:55:00 ad Exp $");
#include "opt_pipe.h"
@@ -100,20 +100,19 @@ sys_bind(struct lwp *l, const struct sys_bind_args *uap, register_t *retval)
}
int
-do_sys_bind(struct lwp *l, int s, struct mbuf *nam)
+do_sys_bind(struct lwp *l, int fd, struct mbuf *nam)
{
- struct file *fp;
+ struct socket *so;
int error;
- /* getsock() will use the descriptor for us */
- if ((error = getsock(l->l_proc->p_fd, s, &fp)) != 0) {
+ if ((error = fd_getsock(fd, &so)) != 0) {
m_freem(nam);
return (error);
}
- MCLAIM(nam, ((struct socket *)fp->f_data)->so_mowner);
- error = sobind(fp->f_data, nam, l);
+ MCLAIM(nam, so->so_mowner);
+ error = sobind(so, nam, l);
m_freem(nam);
- FILE_UNUSE(fp, l);
+ fd_putfile(fd);
return error;
}
@@ -125,46 +124,46 @@ sys_listen(struct lwp *l, const struct sys_listen_args *uap, register_t *retval)
syscallarg(int) s;
syscallarg(int) backlog;
} */
- struct file *fp;
+ struct socket *so;
int error;
- /* getsock() will use the descriptor for us */
- if ((error = getsock(l->l_proc->p_fd, SCARG(uap, s), &fp)) != 0)
+ if ((error = fd_getsock(SCARG(uap, s), &so)) != 0)
return (error);
- error = solisten(fp->f_data, SCARG(uap, backlog), l);
- FILE_UNUSE(fp, l);
+ error = solisten(so, SCARG(uap, backlog), l);
+ fd_putfile(SCARG(uap, s));
return error;
}
int
do_sys_accept(struct lwp *l, int sock, struct mbuf **name, register_t *new_sock)
{
- struct filedesc *fdp;
- struct file *fp;
+ file_t *fp, *fp2;
struct mbuf *nam;
int error, s, fd;
- struct socket *so;
- int fflag;
-
- fdp = l->l_proc->p_fd;
+ struct socket *so, *so2;
- /* getsock() will use the descriptor for us */
- if ((error = getsock(fdp, sock, &fp)) != 0)
+ if ((fp = fd_getfile(sock)) == NULL)
+ return (EBADF);
+ if (fp->f_type != DTYPE_SOCKET)
+ return (ENOTSOCK);
+ if ((error = fd_allocfile(&fp2, &fd)) != 0)
return (error);
+ nam = m_get(M_WAIT, MT_SONAME);
+ *new_sock = fd;
s = splsoftnet();
- so = (struct socket *)fp->f_data;
- FILE_UNUSE(fp, l);
+ so = fp->f_data;
+ fd_putfile(sock); /* XXX wrong, socket can disappear */
if (!(so->so_proto->pr_flags & PR_LISTEN)) {
- splx(s);
- return (EOPNOTSUPP);
+ error = EOPNOTSUPP;
+ goto bad;
}
if ((so->so_options & SO_ACCEPTCONN) == 0) {
- splx(s);
- return (EINVAL);
+ error = EINVAL;
+ goto bad;
}
if (so->so_nbio && so->so_qlen == 0) {
- splx(s);
- return (EWOULDBLOCK);
+ error = EWOULDBLOCK;
+ goto bad;
}
while (so->so_qlen == 0 && so->so_error == 0) {
if (so->so_state & SS_CANTRCVMORE) {
@@ -174,51 +173,43 @@ do_sys_accept(struct lwp *l, int sock, struct mbuf **name, register_t *new_sock)
error = tsleep(&so->so_timeo, PSOCK | PCATCH,
netcon, 0);
if (error) {
- splx(s);
- return (error);
+ goto bad;
}
}
if (so->so_error) {
error = so->so_error;
so->so_error = 0;
- splx(s);
- return (error);
- }
- fflag = fp->f_flag;
- /* falloc() will use the descriptor for us */
- if ((error = falloc(l, &fp, &fd)) != 0) {
- splx(s);
- return (error);
+ goto bad;
}
- *new_sock = fd;
-
/* connection has been removed from the listen queue */
KNOTE(&so->so_rcv.sb_sel.sel_klist, 0);
-
- { struct socket *aso = TAILQ_FIRST(&so->so_q);
- if (soqremque(aso, 1) == 0)
+ so2 = TAILQ_FIRST(&so->so_q);
+ if (soqremque(so2, 1) == 0)
panic("accept");
- so = aso;
- }
- fp->f_type = DTYPE_SOCKET;
- fp->f_flag = fflag;
- fp->f_ops = &socketops;
- fp->f_data = so;
- nam = m_get(M_WAIT, MT_SONAME);
- error = soaccept(so, nam);
-
+ fp2->f_type = DTYPE_SOCKET;
+ fp2->f_flag = fp->f_flag;
+ fp2->f_ops = &socketops;
+ fp2->f_data = so2;
+ error = soaccept(so2, nam);
+ splx(s);
if (error) {
/* an error occurred, free the file descriptor and mbuf */
m_freem(nam);
- fdremove(fdp, fd);
- closef(fp, l);
+ mutex_enter(&fp2->f_lock);
+ fp2->f_count++;
+ mutex_exit(&fp2->f_lock);
+ closef(fp2);
+ fd_abort(curproc, NULL, fd);
} else {
- FILE_SET_MATURE(fp);
- FILE_UNUSE(fp, l);
+ fd_affix(curproc, fp2, fd);
*name = nam;
}
- splx(s);
return (error);
+ bad:
+ splx(s);
+ m_freem(nam);
+ fd_abort(curproc, fp2, fd);
+ return (error);
}
int
@@ -229,19 +220,21 @@ sys_accept(struct lwp *l, const struct sys_accept_args *uap, register_t *retval)
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);
if (error != 0)
return error;
-
error = copyout_sockname(SCARG(uap, name), SCARG(uap, anamelen),
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)
+ (void)fd_close(fd);
+ }
return error;
}
@@ -265,19 +258,17 @@ sys_connect(struct lwp *l, const struct sys_connect_args *uap, register_t *retva
}
int
-do_sys_connect(struct lwp *l, int s, struct mbuf *nam)
+do_sys_connect(struct lwp *l, int fd, struct mbuf *nam)
{
- struct file *fp;
struct socket *so;
int error;
int interrupted = 0;
+ int s;
- /* getsock() will use the descriptor for us */
- if ((error = getsock(l->l_proc->p_fd, s, &fp)) != 0) {
+ if ((error = fd_getsock(fd, &so)) != 0) {
m_freem(nam);
return (error);
}
- so = fp->f_data;
MCLAIM(nam, so->so_mowner);
if (so->so_state & SS_ISCONNECTING) {
error = EALREADY;
@@ -312,7 +303,7 @@ do_sys_connect(struct lwp *l, int s, struct mbuf *nam)
if (error == ERESTART)
error = EINTR;
out:
- FILE_UNUSE(fp, l);
+ fd_putfile(fd);
m_freem(nam);
return (error);
}
@@ -326,12 +317,12 @@ sys_socketpair(struct lwp *l, const struct sys_socketpair_args *uap, register_t
syscallarg(int) protocol;
syscallarg(int *) rsv;
} */
- struct filedesc *fdp;
- struct file *fp1, *fp2;
+ file_t *fp1, *fp2;
struct socket *so1, *so2;
int fd, error, sv[2];
+ proc_t *p;
- fdp = l->l_proc->p_fd;
+ p = curproc;
error = socreate(SCARG(uap, domain), &so1, SCARG(uap, type),
SCARG(uap, protocol), l);
if (error)
@@ -340,15 +331,14 @@ sys_socketpair(struct lwp *l, const struct sys_socketpair_args *uap, register_t
SCARG(uap, protocol), l);
if (error)
goto free1;
- /* falloc() will use the descriptor for us */
- if ((error = falloc(l, &fp1, &fd)) != 0)
+ if ((error = fd_allocfile(&fp1, &fd)) != 0)
goto free2;
sv[0] = fd;
fp1->f_flag = FREAD|FWRITE;
fp1->f_type = DTYPE_SOCKET;
fp1->f_ops = &socketops;
fp1->f_data = so1;
- if ((error = falloc(l, &fp2, &fd)) != 0)
+ if ((error = fd_allocfile(&fp2, &fd)) != 0)
goto free3;
fp2->f_flag = FREAD|FWRITE;
fp2->f_type = DTYPE_SOCKET;
@@ -365,19 +355,13 @@ sys_socketpair(struct lwp *l, const struct sys_socketpair_args *uap, register_t
goto free4;
}
error = copyout(sv, SCARG(uap, rsv), 2 * sizeof(int));
- FILE_SET_MATURE(fp1);
- FILE_SET_MATURE(fp2);
- FILE_UNUSE(fp1, l);
- FILE_UNUSE(fp2, l);
+ fd_affix(p, fp2, sv[1]);
+ fd_affix(p, fp1, sv[0]);
return (error);
free4:
- FILE_UNUSE(fp2, l);
- ffree(fp2);
- fdremove(fdp, sv[1]);
+ fd_abort(p, fp2, sv[1]);
free3:
- FILE_UNUSE(fp1, l);
- ffree(fp1);
- fdremove(fdp, sv[0]);
+ fd_abort(p, fp1, sv[0]);
free2:
(void)soclose(so2);
free1:
@@ -433,7 +417,6 @@ int
do_sys_sendmsg(struct lwp *l, int s, struct msghdr *mp, int flags,
register_t *retsize)
{
- struct file *fp;
struct uio auio;
int i, len, error, iovlen;
struct mbuf *to, *control;
@@ -527,10 +510,8 @@ do_sys_sendmsg(struct lwp *l, int s, struct msghdr *mp, int flags,
memcpy(ktriov, auio.uio_iov, iovlen);
}
- /* getsock() will use the descriptor for us */
- if ((error = getsock(l->l_proc->p_fd, s, &fp)) != 0)
+ if ((error = fd_getsock(s, &so)) != 0)
goto bad;
- so = (struct socket *)fp->f_data;
if (mp->msg_name)
MCLAIM(to, so->so_mowner);
@@ -544,7 +525,7 @@ do_sys_sendmsg(struct lwp *l, int s, struct msghdr *mp, int flags,
/* Protocol is responsible for freeing 'control' */
control = NULL;
- FILE_UNUSE(fp, l);
+ fd_putfile(s);
if (error) {
if (auio.uio_resid != len && (error == ERESTART ||
@@ -656,7 +637,7 @@ sys_recvmsg(struct lwp *l, const struct sys_recvmsg_args *uap, register_t *retva
* m is the mbuf holding the (already externalized) SCM_RIGHTS message.
*/
static void
-free_rights(struct mbuf *m, struct lwp *l)
+free_rights(struct mbuf *m)
{
int nfd;
int i;
@@ -665,8 +646,10 @@ free_rights(struct mbuf *m, struct lwp *l)
nfd = m->m_len < CMSG_SPACE(sizeof(int)) ? 0
: (m->m_len - CMSG_SPACE(sizeof(int))) / sizeof(int) + 1;
fdv = (int *) CMSG_DATA(mtod(m,struct cmsghdr *));
- for (i = 0; i < nfd; i++)
- fdrelease(l, fdv[i]);
+ for (i = 0; i < nfd; i++) {
+ if (fd_getfile(fdv[i]) != NULL)
+ (void)fd_close(fdv[i]);
+ }
}
void
@@ -682,7 +665,7 @@ free_control_mbuf(struct lwp *l, struct mbuf *control, struct mbuf *uncopied)
do_free_rights = true;
if (do_free_rights && cmsg->cmsg_level == SOL_SOCKET
&& cmsg->cmsg_type == SCM_RIGHTS)
- free_rights(control, l);
+ free_rights(control);
next = control->m_next;
m_free(control);
control = next;
@@ -744,7 +727,6 @@ int
do_sys_recvmsg(struct lwp *l, int s, struct msghdr *mp, struct mbuf **from,
struct mbuf **control, register_t *retsize)
{
- struct file *fp;
struct uio auio;
struct iovec aiov[UIO_SMALLIOV], *iov = aiov;
struct iovec *tiov;
@@ -758,10 +740,8 @@ do_sys_recvmsg(struct lwp *l, int s, struct msghdr *mp, struct mbuf **from,
if (control != NULL)
*control = NULL;
- /* getsock() will use the descriptor for us */
- if ((error = getsock(l->l_proc->p_fd, s, &fp)) != 0)
+ if ((error = fd_getsock(s, &so)) != 0)
return (error);
- so = (struct socket *)fp->f_data;
if (mp->msg_flags & MSG_IOVUSRSPACE) {
if ((unsigned int)mp->msg_iovlen > UIO_SMALLIOV) {
@@ -845,7 +825,7 @@ do_sys_recvmsg(struct lwp *l, int s, struct msghdr *mp, struct mbuf **from,
out:
if (iov != aiov)
free(iov, M_TEMP);
- FILE_UNUSE(fp, l);
+ fd_putfile(s);
return (error);
}
@@ -858,16 +838,13 @@ sys_shutdown(struct lwp *l, const struct sys_shutdown_args *uap, register_t *ret
syscallarg(int) s;
syscallarg(int) how;
} */
- struct proc *p;
- struct file *fp;
+ struct socket *so;
int error;
- p = l->l_proc;
- /* 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);
- error = soshutdown((struct socket *)fp->f_data, SCARG(uap, how));
- FILE_UNUSE(fp, l);
+ error = soshutdown(so, SCARG(uap, how));
+ fd_putfile(SCARG(uap, s));
return (error);
}
@@ -883,7 +860,6 @@ sys_setsockopt(struct lwp *l, const struct sys_setsockopt_args *uap, register_t
syscallarg(unsigned int) valsize;
} */
struct proc *p;
- struct file *fp;
struct mbuf *m;
struct socket *so;
int error;
@@ -891,10 +867,8 @@ sys_setsockopt(struct lwp *l, const struct sys_setsockopt_args *uap, register_t
p = l->l_proc;
m = NULL;
- /* 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);
- so = (struct socket *)fp->f_data;
len = SCARG(uap, valsize);
if (len > MCLBYTES) {
error = EINVAL;
@@ -913,7 +887,7 @@ sys_setsockopt(struct lwp *l, const struct sys_setsockopt_args *uap, register_t
}
error = sosetopt(so, SCARG(uap, level), SCARG(uap, name), m);
out:
- FILE_UNUSE(fp, l);
+ fd_putfile(SCARG(uap, s));
return (error);
}
@@ -928,15 +902,14 @@ sys_getsockopt(struct lwp *l, const struct sys_getsockopt_args *uap, register_t
syscallarg(void *) val;
syscallarg(unsigned int *) avalsize;
} */
- struct file *fp;
+ struct socket *so;
struct mbuf *m;
unsigned int op, i, valsize;
int error;
char *val = SCARG(uap, val);
m = NULL;
- /* getsock() will use the descriptor for us */
- if ((error = getsock(l->l_proc->p_fd, SCARG(uap, s), &fp)) != 0)
+ if ((error = fd_getsock(SCARG(uap, s), &so)) != 0)
return (error);
if (val != NULL) {
error = copyin(SCARG(uap, avalsize),
@@ -945,9 +918,8 @@ sys_getsockopt(struct lwp *l, const struct sys_getsockopt_args *uap, register_t
goto out;
} else
valsize = 0;
- if ((error = sogetopt((struct socket *)fp->f_data, SCARG(uap, level),
- SCARG(uap, name), &m)) == 0 && val != NULL && valsize &&
- m != NULL) {
+ error = sogetopt(so, SCARG(uap, level), SCARG(uap, name), &m);
+ if (error == 0 && val != NULL && valsize && m != NULL) {
op = 0;
while (m && !error && op < valsize) {
i = min(m->m_len, (valsize - op));
@@ -964,7 +936,7 @@ sys_getsockopt(struct lwp *l, const struct sys_getsockopt_args *uap, register_t
if (m != NULL)
(void) m_freem(m);
out:
- FILE_UNUSE(fp, l);
+ fd_putfile(SCARG(uap, s));
return (error);
}
@@ -973,12 +945,12 @@ sys_getsockopt(struct lwp *l, const struct sys_getsockopt_args *uap, register_t
int
sys_pipe(struct lwp *l, const void *v, register_t *retval)
{
- struct filedesc *fdp;
- struct file *rf, *wf;
+ file_t *rf, *wf;
struct socket *rso, *wso;
int fd, error;
+ proc_t *p;
- fdp = l->l_proc->p_fd;
+ p = curproc;
if ((error = socreate(AF_LOCAL, &rso, SOCK_STREAM, 0, l)) != 0)
return (error);
if ((error = socreate(AF_LOCAL, &wso, SOCK_STREAM, 0, l)) != 0)
@@ -986,15 +958,14 @@ sys_pipe(struct lwp *l, const void *v, register_t *retval)
/* remember this socket pair implements a pipe */
wso->so_state |= SS_ISAPIPE;
rso->so_state |= SS_ISAPIPE;
- /* falloc() will use the descriptor for us */
- if ((error = falloc(l, &rf, &fd)) != 0)
+ if ((error = fd_allocfile(&rf, &fd)) != 0)
goto free2;
retval[0] = fd;
rf->f_flag = FREAD;
rf->f_type = DTYPE_SOCKET;
rf->f_ops = &socketops;
rf->f_data = rso;
- if ((error = falloc(l, &wf, &fd)) != 0)
+ if ((error = fd_allocfile(&wf, &fd)) != 0)
goto free3;
wf->f_flag = FWRITE;
wf->f_type = DTYPE_SOCKET;
@@ -1003,19 +974,13 @@ sys_pipe(struct lwp *l, const void *v, register_t *retval)
retval[1] = fd;
if ((error = unp_connect2(wso, rso, PRU_CONNECT2)) != 0)
goto free4;
- FILE_SET_MATURE(rf);
- FILE_SET_MATURE(wf);
- FILE_UNUSE(rf, l);
- FILE_UNUSE(wf, l);
+ fd_affix(p, wf, (int)retval[1]);
+ fd_affix(p, rf, (int)retval[0]);
return (0);
free4:
- FILE_UNUSE(wf, l);
- ffree(wf);
- fdremove(fdp, retval[1]);
+ fd_abort(p, wf, (int)retval[1]);
free3:
- FILE_UNUSE(rf, l);
- ffree(rf);
- fdremove(fdp, retval[0]);
+ fd_abort(p, rf, (int)retval[0]);
free2:
(void)soclose(wso);
free1:
@@ -1031,15 +996,12 @@ sys_pipe(struct lwp *l, const void *v, register_t *retval)
int
do_sys_getsockname(struct lwp *l, int fd, int which, struct mbuf **nam)
{
- struct file *fp;
struct socket *so;
struct mbuf *m;
int error;
- /* getsock() will use the descriptor for us */
- if ((error = getsock(l->l_proc->p_fd, fd, &fp)) != 0)
+ if ((error = fd_getsock(fd, &so)) != 0)
return error;
- so = (struct socket *)fp->f_data;
if (which == PRU_PEERADDR
&& (so->so_state & (SS_ISCONNECTED | SS_ISCONFIRMING)) == 0) {
@@ -1054,8 +1016,8 @@ do_sys_getsockname(struct lwp *l, int fd, int which, struct mbuf **nam)
m, (struct mbuf *)0, (struct lwp *)0);
if (error != 0)
m_free(m);
- bad:
- FILE_UNUSE(fp, l);
+ bad:
+ fd_putfile(fd);
return error;
}
@@ -1205,17 +1167,15 @@ sockargs(struct mbuf **mp, const void *bf, size_t buflen, int type)
}
int
-getsock(struct filedesc *fdp, int fdes, struct file **fpp)
+getsock(int fdes, struct file **fpp)
{
- struct file *fp;
+ file_t *fp;
- if ((fp = fd_getfile(fdp, fdes)) == NULL)
+ if ((fp = fd_getfile(fdes)) == NULL)
return (EBADF);
- FILE_USE(fp);
-
if (fp->f_type != DTYPE_SOCKET) {
- FILE_UNUSE(fp, NULL);
+ fd_putfile(fdes);
return (ENOTSOCK);
}
*fpp = fp;
diff --git a/sys/kern/uipc_usrreq.c b/sys/kern/uipc_usrreq.c
index 5e44a4375d0..4d508a66742 100644
--- a/sys/kern/uipc_usrreq.c
+++ b/sys/kern/uipc_usrreq.c
@@ -1,7 +1,7 @@
-/* $NetBSD: uipc_usrreq.c,v 1.105 2008/01/25 14:32:14 ad Exp $ */
+/* $NetBSD: uipc_usrreq.c,v 1.106 2008/03/21 21:55:00 ad Exp $ */
/*-
- * Copyright (c) 1998, 2000, 2004 The NetBSD Foundation, Inc.
+ * Copyright (c) 1998, 2000, 2004, 2008 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@@ -103,7 +103,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uipc_usrreq.c,v 1.105 2008/01/25 14:32:14 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_usrreq.c,v 1.106 2008/03/21 21:55:00 ad Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -122,6 +122,7 @@ __KERNEL_RCSID(0, "$NetBSD: uipc_usrreq.c,v 1.105 2008/01/25 14:32:14 ad Exp $")
#include <sys/mbuf.h>
#include <sys/kauth.h>
#include <sys/kmem.h>
+#include <sys/atomic.h>
/*
* Unix communications domain.
@@ -543,7 +544,7 @@ u_long unpst_recvspace = PIPSIZ;
u_long unpdg_sendspace = 2*1024; /* really max datagram size */
u_long unpdg_recvspace = 4*1024;
-int unp_rights; /* file descriptors in flight */
+u_int unp_rights; /* file descriptors in flight */
int
unp_attach(struct socket *so)
@@ -614,7 +615,7 @@ int
unp_bind(struct unpcb *unp, struct mbuf *nam, struct lwp *l)
{
struct sockaddr_un *sun;
- struct vnode *vp;
+ vnode_t *vp;
struct vattr vattr;
size_t addrlen;
struct proc *p;
@@ -679,7 +680,7 @@ int
unp_connect(struct socket *so, struct mbuf *nam, struct lwp *l)
{
struct sockaddr_un *sun;
- struct vnode *vp;
+ vnode_t *vp;
struct socket *so2, *so3;
struct unpcb *unp, *unp2, *unp3;
size_t addrlen;
@@ -871,20 +872,20 @@ unp_externalize(struct mbuf *rights, struct lwp *l)
struct cmsghdr *cm = mtod(rights, struct cmsghdr *);
struct proc *p = l->l_proc;
int i, *fdp;
- struct file **rp;
- struct file *fp;
+ file_t **rp;
+ file_t *fp;
int nfds, error = 0;
nfds = (cm->cmsg_len - CMSG_ALIGN(sizeof(*cm))) /
- sizeof(struct file *);
- rp = (struct file **)CMSG_DATA(cm);
+ sizeof(file_t *);
+ rp = (file_t **)CMSG_DATA(cm);
fdp = malloc(nfds * sizeof(int), M_TEMP, M_WAITOK);
rw_enter(&p->p_cwdi->cwdi_lock, RW_READER);
/* Make sure the recipient should be able to see the descriptors.. */
if (p->p_cwdi->cwdi_rdir != NULL) {
- rp = (struct file **)CMSG_DATA(cm);
+ rp = (file_t **)CMSG_DATA(cm);
for (i = 0; i < nfds; i++) {
fp = *rp++;
/*
@@ -894,7 +895,7 @@ unp_externalize(struct mbuf *rights, struct lwp *l)
* to access.
*/
if (fp->f_type == DTYPE_VNODE) {
- struct vnode *vp = (struct vnode *)fp->f_data;
+ vnode_t *vp = (vnode_t *)fp->f_data;
if ((vp->v_type == VDIR) &&
!vn_isunder(vp, p->p_cwdi->cwdi_rdir, l)) {
error = EPERM;
@@ -905,7 +906,7 @@ unp_externalize(struct mbuf *rights, struct lwp *l)
}
restart:
- rp = (struct file **)CMSG_DATA(cm);
+ rp = (file_t **)CMSG_DATA(cm);
if (error != 0) {
for (i = 0; i < nfds; i++) {
fp = *rp;
@@ -925,15 +926,15 @@ unp_externalize(struct mbuf *rights, struct lwp *l)
*/
for (i = 0; i < nfds; i++) {
fp = *rp++;
- if ((error = fdalloc(p, 0, &fdp[i])) != 0) {
+ if ((error = fd_alloc(p, 0, &fdp[i])) != 0) {
/*
* Back out what we've done so far.
*/
- for (--i; i >= 0; i--)
- fdremove(p->p_fd, fdp[i]);
-
+ for (--i; i >= 0; i--) {
+ fd_abort(p, NULL, fdp[i]);
+ }
if (error == ENOSPC) {
- fdexpand(p);
+ fd_tryexpand(p);
error = 0;
} else {
/*
@@ -945,31 +946,31 @@ unp_externalize(struct mbuf *rights, struct lwp *l)
}
goto restart;
}
-
- /*
- * Make the slot reference the descriptor so that
- * fdalloc() works properly.. We finalize it all
- * in the loop below.
- */
- rw_enter(&p->p_fd->fd_lock, RW_WRITER);
- p->p_fd->fd_ofiles[fdp[i]] = fp;
- rw_exit(&p->p_fd->fd_lock);
}
/*
* Now that adding them has succeeded, update all of the
- * descriptor passing state.
- */
- rp = (struct file **)CMSG_DATA(cm);
+ * descriptor passing state. */
+ rp = (file_t **)CMSG_DATA(cm);
for (i = 0; i < nfds; i++) {
fp = *rp++;
+ atomic_dec_uint(&unp_rights);
+ fd_affix(p, fp, fdp[i]);
+ mutex_enter(&fp->f_lock);
fp->f_msgcount--;
- unp_rights--;
+ mutex_exit(&fp->f_lock);
+ /*
+ * Note that fd_affix() adds a reference to the file.
+ * The file may already have been closed by another
+ * LWP in the process, so we must drop the reference
+ * added by unp_internalize() with closef().
+ */
+ closef(fp);
}
/*
* Copy temporary array to message and adjust length, in case of
- * transition from large struct file pointers to ints.
+ * transition from large file_t pointers to ints.
*/
memcpy(CMSG_DATA(cm), fdp, nfds * sizeof(int));
cm->cmsg_len = CMSG_LEN(nfds * sizeof(int));
@@ -983,89 +984,88 @@ unp_externalize(struct mbuf *rights, struct lwp *l)
int
unp_internalize(struct mbuf *control, struct lwp *l)
{
- struct proc *p = l->l_proc;
- struct filedesc *fdescp = p->p_fd;
+ struct filedesc *fdescp = curlwp->l_fd;
struct cmsghdr *newcm, *cm = mtod(control, struct cmsghdr *);
- struct file **rp, **files;
- struct file *fp;
+ file_t **rp, **files;
+ file_t *fp;
int i, fd, *fdp;
- int nfds;
- u_int neededspace;
+ int nfds, error;
+
+ KASSERT(l == curlwp);
+
+ error = 0;
+ newcm = NULL;
- /* Sanity check the control message header */
+ /* Sanity check the control message header. */
if (cm->cmsg_type != SCM_RIGHTS || cm->cmsg_level != SOL_SOCKET ||
cm->cmsg_len != control->m_len)
return (EINVAL);
- /* Verify that the file descriptors are valid */
+ /*
+ * Verify that the file descriptors are valid, and acquire
+ * a reference to each.
+ */
nfds = (cm->cmsg_len - CMSG_ALIGN(sizeof(*cm))) / sizeof(int);
fdp = (int *)CMSG_DATA(cm);
for (i = 0; i < nfds; i++) {
fd = *fdp++;
- if ((fp = fd_getfile(fdescp, fd)) == NULL)
- return (EBADF);
- /* XXXSMP grab reference to file */
- FILE_UNLOCK(fp);
+ if ((fp = fd_getfile(fd)) == NULL) {
+ nfds = i + 1;
+ error = EBADF;
+ goto out;
+ }
}
- /* Make sure we have room for the struct file pointers */
- neededspace = CMSG_SPACE(nfds * sizeof(struct file *)) -
- control->m_len;
- if (neededspace > M_TRAILINGSPACE(control)) {
-
- /* allocate new space and copy header into it */
- newcm = malloc(
- CMSG_SPACE(nfds * sizeof(struct file *)),
- M_MBUF, M_WAITOK);
- if (newcm == NULL) {
- /* XXXSMP drop references to files */
- return (E2BIG);
- }
- memcpy(newcm, cm, sizeof(struct cmsghdr));
- files = (struct file **)CMSG_DATA(newcm);
- } else {
- /* we can convert in-place */
- newcm = NULL;
- files = (struct file **)CMSG_DATA(cm);
+ /* Allocate new space and copy header into it. */
+ newcm = malloc(CMSG_SPACE(nfds * sizeof(file_t *)), M_MBUF, M_WAITOK);
+ if (newcm == NULL) {
+ error = E2BIG;
+ goto out;
}
+ memcpy(newcm, cm, sizeof(struct cmsghdr));
+ files = (file_t **)CMSG_DATA(newcm);
/*
- * Transform the file descriptors into struct file pointers, in
+ * Transform the file descriptors into file_t pointers, in
* reverse order so that if pointers are bigger than ints, the
- * int won't get until we're done.
+ * int won't get until we're done. No need to lock, as we have
+ * already validated the descriptors with fd_getfile().
*/
- rw_enter(&fdescp->fd_lock, RW_READER);
fdp = (int *)CMSG_DATA(cm) + nfds;
rp = files + nfds;
for (i = 0; i < nfds; i++) {
- fp = fdescp->fd_ofiles[*--fdp];
- FILE_LOCK(fp);
-#ifdef DIAGNOSTIC
- if (fp->f_iflags & FIF_WANTCLOSE)
- panic("unp_internalize: file already closed");
-#endif
+ fp = fdescp->fd_ofiles[*--fdp]->ff_file;
+ KASSERT(fp != NULL);
+ mutex_enter(&fp->f_lock);
*--rp = fp;
fp->f_count++;
fp->f_msgcount++;
- FILE_UNLOCK(fp);
- unp_rights++;
+ mutex_exit(&fp->f_lock);
+ atomic_inc_uint(&unp_rights);
+ }
+
+ out:
+ /* Release descriptor references. */
+ fdp = (int *)CMSG_DATA(cm);
+ for (i = 0; i < nfds; i++) {
+ fd_putfile(*fdp++);
}
- rw_exit(&fdescp->fd_lock);
- if (newcm) {
+ if (error == 0) {
if (control->m_flags & M_EXT)
MEXTREMOVE(control);
- MEXTADD(control, newcm,
- CMSG_SPACE(nfds * sizeof(struct file *)),
+ MEXTADD(control, newcm, CMSG_SPACE(nfds * sizeof(file_t *)),
M_MBUF, NULL, NULL);
cm = newcm;
+ /*
+ * Adjust message & mbuf to note amount of space
+ * actually used.
+ */
+ cm->cmsg_len = CMSG_LEN(nfds * sizeof(file_t *));
+ control->m_len = CMSG_SPACE(nfds * sizeof(file_t *));
}
- /* adjust message & mbuf to note amount of space actually used. */
- cm->cmsg_len = CMSG_LEN(nfds * sizeof(struct file *));
- control->m_len = CMSG_SPACE(nfds * sizeof(struct file *));
-
- return (0);
+ return error;
}
struct mbuf *
@@ -1141,31 +1141,29 @@ extern struct domain unixdomain;
* We also make an extra pass *before* the GC to clear the mark bits,
* which could have been cleared at almost no cost during the previous
* sweep.
- *
- * XXX MP: this needs to run with locks such that no other thread of
- * control can create or destroy references to file descriptors. it
- * may be necessary to defer the GC until later (when the locking
- * situation is more hospitable); it may be necessary to push this
- * into a separate thread.
*/
void
unp_gc(void)
{
- struct file *fp, *nextfp;
+ file_t *fp, *nextfp;
struct socket *so, *so1;
- struct file **extra_ref, **fpp;
- int nunref, i;
+ file_t **extra_ref, **fpp;
+ int nunref, nslots, i;
- if (unp_gcing)
+ if (atomic_swap_uint(&unp_gcing, 1) == 1)
return;
- unp_gcing = 1;
- unp_defer = 0;
+
+ restart:
+ nslots = nfiles * 2;
+ extra_ref = kmem_alloc(nslots * sizeof(file_t *), KM_SLEEP);
mutex_enter(&filelist_lock);
+ unp_defer = 0;
/* Clear mark bits */
- LIST_FOREACH(fp, &filehead, f_list)
- fp->f_flag &= ~(FMARK|FDEFER);
+ LIST_FOREACH(fp, &filehead, f_list) {
+ atomic_and_uint(&fp->f_flag, ~(FMARK|FDEFER));
+ }
/*
* Iterate over the set of descriptors, marking ones believed
@@ -1174,29 +1172,26 @@ unp_gc(void)
*/
do {
LIST_FOREACH(fp, &filehead, f_list) {
- FILE_LOCK(fp);
- if (fp->f_flag & FDEFER) {
- fp->f_flag &= ~FDEFER;
+ mutex_enter(&fp->f_lock);
+ if (fp->f_flag & FDEFER) {
+ atomic_and_uint(&fp->f_flag, ~FDEFER);
unp_defer--;
-#ifdef DIAGNOSTIC
- if (fp->f_count == 0)
- panic("unp_gc: deferred unreferenced socket");
-#endif
+ KASSERT(fp->f_count != 0);
} else {
if (fp->f_count == 0 ||
(fp->f_flag & FMARK) ||
fp->f_count == fp->f_msgcount) {
- FILE_UNLOCK(fp);
+ mutex_exit(&fp->f_lock);
continue;
}
}
- fp->f_flag |= FMARK;
+ atomic_or_uint(&fp->f_flag, FMARK);
if (fp->f_type != DTYPE_SOCKET ||
- (so = (struct socket *)fp->f_data) == 0 ||
+ (so = (struct socket *)fp->f_data) == NULL ||
so->so_proto->pr_domain != &unixdomain ||
(so->so_proto->pr_flags&PR_RIGHTS) == 0) {
- FILE_UNLOCK(fp);
+ mutex_exit(&fp->f_lock);
continue;
}
#ifdef notdef
@@ -1215,11 +1210,12 @@ unp_gc(void)
goto restart;
}
#endif
- FILE_UNLOCK(fp);
+ mutex_exit(&fp->f_lock);
unp_scan(so->so_rcv.sb_mb, unp_mark, 0);
/*
- * mark descriptors referenced from sockets queued on the accept queue as well.
+ * Mark descriptors referenced from sockets queued
+ * on the accept queue as well.
*/
if (so->so_options & SO_ACCEPTCONN) {
TAILQ_FOREACH(so1, &so->so_q0, so_qe) {
@@ -1232,8 +1228,6 @@ unp_gc(void)
}
} while (unp_defer);
- mutex_exit(&filelist_lock);
-
/*
* Sweep pass. Find unmarked descriptors, and free them.
*
@@ -1276,39 +1270,34 @@ unp_gc(void)
*
* 91/09/19, bsy@cs.cmu.edu
*/
- extra_ref = kmem_alloc(nfiles * sizeof(struct file *), KM_SLEEP);
-
- mutex_enter(&filelist_lock);
+ if (nslots < nfiles) {
+ kmem_free(extra_ref, nslots * sizeof(file_t *));
+ goto restart;
+ }
for (nunref = 0, fp = LIST_FIRST(&filehead), fpp = extra_ref; fp != 0;
fp = nextfp) {
nextfp = LIST_NEXT(fp, f_list);
- FILE_LOCK(fp);
+ mutex_enter(&fp->f_lock);
if (fp->f_count != 0 &&
fp->f_count == fp->f_msgcount && !(fp->f_flag & FMARK)) {
*fpp++ = fp;
nunref++;
fp->f_count++;
}
- FILE_UNLOCK(fp);
+ mutex_exit(&fp->f_lock);
}
mutex_exit(&filelist_lock);
for (i = nunref, fpp = extra_ref; --i >= 0; ++fpp) {
fp = *fpp;
- FILE_LOCK(fp);
- FILE_USE(fp);
if (fp->f_type == DTYPE_SOCKET)
- sorflush((struct socket *)fp->f_data);
- FILE_UNUSE(fp, NULL);
+ sorflush(fp->f_data);
}
for (i = nunref, fpp = extra_ref; --i >= 0; ++fpp) {
- fp = *fpp;
- FILE_LOCK(fp);
- FILE_USE(fp);
- (void) closef(fp, (struct lwp *)0);
+ closef(*fpp);
}
- kmem_free(extra_ref, nfiles * sizeof(struct file *));
- unp_gcing = 0;
+ kmem_free(extra_ref, nslots * sizeof(file_t *));
+ atomic_swap_uint(&unp_gcing, 0);
}
void
@@ -1320,10 +1309,10 @@ unp_dispose(struct mbuf *m)
}
void
-unp_scan(struct mbuf *m0, void (*op)(struct file *), int discard)
+unp_scan(struct mbuf *m0, void (*op)(file_t *), int discard)
{
struct mbuf *m;
- struct file **rp;
+ file_t **rp;
struct cmsghdr *cm;
int i;
int qfds;
@@ -1337,10 +1326,10 @@ unp_scan(struct mbuf *m0, void (*op)(struct file *), int discard)
cm->cmsg_type != SCM_RIGHTS)
continue;
qfds = (cm->cmsg_len - CMSG_ALIGN(sizeof(*cm)))
- / sizeof(struct file *);
- rp = (struct file **)CMSG_DATA(cm);
+ / sizeof(file_t *);
+ rp = (file_t **)CMSG_DATA(cm);
for (i = 0; i < qfds; i++) {
- struct file *fp = *rp;
+ file_t *fp = *rp;
if (discard)
*rp = 0;
(*op)(fp);
@@ -1354,16 +1343,16 @@ unp_scan(struct mbuf *m0, void (*op)(struct file *), int discard)
}
void
-unp_mark(struct file *fp)
+unp_mark(file_t *fp)
{
if (fp == NULL)
return;
/* If we're already deferred, don't screw up the defer count */
- FILE_LOCK(fp);
+ mutex_enter(&fp->f_lock);
if (fp->f_flag & (FMARK | FDEFER)) {
- FILE_UNLOCK(fp);
+ mutex_exit(&fp->f_lock);
return;
}
@@ -1375,25 +1364,26 @@ unp_mark(struct file *fp)
*/
if (fp->f_type == DTYPE_SOCKET) {
unp_defer++;
- if (fp->f_count == 0)
- panic("unp_mark: queued unref");
- fp->f_flag |= FDEFER;
+ KASSERT(fp->f_count != 0);
+ atomic_or_uint(&fp->f_flag, FDEFER);
} else {
- fp->f_flag |= FMARK;
+ atomic_or_uint(&fp->f_flag, FMARK);
}
- FILE_UNLOCK(fp);
+ mutex_exit(&fp->f_lock);
return;
}
void
-unp_discard(struct file *fp)
+unp_discard(file_t *fp)
{
+
if (fp == NULL)
return;
- FILE_LOCK(fp);
- fp->f_usecount++; /* i.e. FILE_USE(fp) sans locking */
+
+ mutex_enter(&fp->f_lock);
+ KASSERT(fp->f_count > 0);
fp->f_msgcount--;
- FILE_UNLOCK(fp);
- unp_rights--;
- (void) closef(fp, (struct lwp *)0);
+ mutex_exit(&fp->f_lock);
+ atomic_dec_uint(&unp_rights);
+ (void)closef(fp);
}
diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c
index 8079df6fca3..549688c7885 100644
--- a/sys/kern/vfs_syscalls.c
+++ b/sys/kern/vfs_syscalls.c
@@ -1,4 +1,4 @@
-/* $NetBSD: vfs_syscalls.c,v 1.345 2008/01/30 11:47:01 ad Exp $ */
+/* $NetBSD: vfs_syscalls.c,v 1.346 2008/03/21 21:55:00 ad Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -70,7 +70,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls.c,v 1.345 2008/01/30 11:47:01 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls.c,v 1.346 2008/03/21 21:55:00 ad Exp $");
#include "opt_compat_netbsd.h"
#include "opt_compat_43.h"
@@ -101,6 +101,7 @@ __KERNEL_RCSID(0, "$NetBSD: vfs_syscalls.c,v 1.345 2008/01/30 11:47:01 ad Exp $"
#endif /* FILEASSOC */
#include <sys/verified_exec.h>
#include <sys/kauth.h>
+#include <sys/atomic.h>
#include <miscfs/genfs/genfs.h>
#include <miscfs/syncfs/syncfs.h>
@@ -933,17 +934,16 @@ sys_statvfs1(struct lwp *l, const struct sys_statvfs1_args *uap, register_t *ret
int
do_sys_fstatvfs(struct lwp *l, int fd, int flags, struct statvfs *sb)
{
- struct proc *p = l->l_proc;
- struct file *fp;
+ file_t *fp;
struct mount *mp;
int error;
- /* getvnode() will use the descriptor for us */
- if ((error = getvnode(p->p_fd, fd, &fp)) != 0)
+ /* fd_getvnode() will use the descriptor for us */
+ if ((error = fd_getvnode(fd, &fp)) != 0)
return (error);
mp = ((struct vnode *)fp->f_data)->v_mount;
- error = dostatvfs(mp, sb, l, flags, 1);
- FILE_UNUSE(fp, l);
+ error = dostatvfs(mp, sb, curlwp, flags, 1);
+ fd_putfile(fd);
return error;
}
@@ -1061,17 +1061,17 @@ sys_fchdir(struct lwp *l, const struct sys_fchdir_args *uap, register_t *retval)
syscallarg(int) fd;
} */
struct proc *p = l->l_proc;
- struct filedesc *fdp = p->p_fd;
struct cwdinfo *cwdi;
struct vnode *vp, *tdp;
struct mount *mp;
- struct file *fp;
- int error;
+ file_t *fp;
+ int error, fd;
- /* getvnode() will use the descriptor for us */
- if ((error = getvnode(fdp, SCARG(uap, fd), &fp)) != 0)
+ /* fd_getvnode() will use the descriptor for us */
+ fd = SCARG(uap, fd);
+ if ((error = fd_getvnode(fd, &fp)) != 0)
return (error);
- vp = (struct vnode *)fp->f_data;
+ vp = fp->f_data;
VREF(vp);
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
@@ -1111,7 +1111,7 @@ sys_fchdir(struct lwp *l, const struct sys_fchdir_args *uap, register_t *retval)
rw_exit(&cwdi->cwdi_lock);
out:
- FILE_UNUSE(fp, l);
+ fd_putfile(fd);
return (error);
}
@@ -1123,19 +1123,18 @@ int
sys_fchroot(struct lwp *l, const struct sys_fchroot_args *uap, register_t *retval)
{
struct proc *p = l->l_proc;
- struct filedesc *fdp = p->p_fd;
struct cwdinfo *cwdi;
struct vnode *vp;
- struct file *fp;
- int error;
+ file_t *fp;
+ int error, fd = SCARG(uap, fd);
if ((error = kauth_authorize_system(l->l_cred, KAUTH_SYSTEM_CHROOT,
KAUTH_REQ_SYSTEM_CHROOT_FCHROOT, NULL, NULL, NULL)) != 0)
return error;
- /* getvnode() will use the descriptor for us */
- if ((error = getvnode(fdp, SCARG(uap, fd), &fp)) != 0)
+ /* fd_getvnode() will use the descriptor for us */
+ if ((error = fd_getvnode(SCARG(uap, fd), &fp)) != 0)
return error;
- vp = (struct vnode *) fp->f_data;
+ vp = fp->f_data;
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
if (vp->v_type != VDIR)
error = ENOTDIR;
@@ -1169,7 +1168,7 @@ sys_fchroot(struct lwp *l, const struct sys_fchroot_args *uap, register_t *retva
rw_exit(&cwdi->cwdi_lock);
out:
- FILE_UNUSE(fp, l);
+ fd_putfile(fd);
return (error);
}
@@ -1288,8 +1287,7 @@ sys_open(struct lwp *l, const struct sys_open_args *uap, register_t *retval)
} */
struct proc *p = l->l_proc;
struct cwdinfo *cwdi = p->p_cwdi;
- struct filedesc *fdp = p->p_fd;
- struct file *fp;
+ file_t *fp;
struct vnode *vp;
int flags, cmode;
int type, indx, error;
@@ -1299,8 +1297,7 @@ sys_open(struct lwp *l, const struct sys_open_args *uap, register_t *retval)
flags = FFLAGS(SCARG(uap, flags));
if ((flags & (FREAD | FWRITE)) == 0)
return (EINVAL);
- /* falloc() will use the file descriptor for us */
- if ((error = falloc(l, &fp, &indx)) != 0)
+ if ((error = fd_allocfile(&fp, &indx)) != 0)
return (error);
/* We're going to read cwdi->cwdi_cmask unlocked here. */
cmode = ((SCARG(uap, mode) &~ cwdi->cwdi_cmask) & ALLPERMS) &~ S_ISTXT;
@@ -1308,21 +1305,16 @@ sys_open(struct lwp *l, const struct sys_open_args *uap, register_t *retval)
SCARG(uap, path));
l->l_dupfd = -indx - 1; /* XXX check for fdopen */
if ((error = vn_open(&nd, flags, cmode)) != 0) {
- rw_enter(&fdp->fd_lock, RW_WRITER);
- FILE_UNUSE(fp, l);
- fdp->fd_ofiles[indx] = NULL;
- rw_exit(&fdp->fd_lock);
- ffree(fp);
+ fd_abort(p, fp, indx);
if ((error == EDUPFD || error == EMOVEFD) &&
l->l_dupfd >= 0 && /* XXX from fdopen */
(error =
- dupfdopen(l, indx, l->l_dupfd, flags, error)) == 0) {
+ fd_dupopen(l->l_dupfd, &indx, flags, error)) == 0) {
*retval = indx;
return (0);
}
if (error == ERESTART)
error = EINTR;
- fdremove(fdp, indx);
return (error);
}
@@ -1346,19 +1338,16 @@ sys_open(struct lwp *l, const struct sys_open_args *uap, register_t *retval)
VOP_UNLOCK(vp, 0);
error = VOP_ADVLOCK(vp, fp, F_SETLK, &lf, type);
if (error) {
- (void) vn_close(vp, fp->f_flag, fp->f_cred, l);
- FILE_UNUSE(fp, l);
- ffree(fp);
- fdremove(fdp, indx);
+ (void) vn_close(vp, fp->f_flag, fp->f_cred);
+ fd_abort(p, fp, indx);
return (error);
}
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
- fp->f_flag |= FHASLOCK;
+ atomic_or_uint(&fp->f_flag, FHASLOCK);
}
VOP_UNLOCK(vp, 0);
*retval = indx;
- FILE_SET_MATURE(fp);
- FILE_UNUSE(fp, l);
+ fd_affix(p, fp, indx);
return (0);
}
@@ -1599,16 +1588,18 @@ int
dofhopen(struct lwp *l, const void *ufhp, size_t fhsize, int oflags,
register_t *retval)
{
- struct filedesc *fdp = l->l_proc->p_fd;
- struct file *fp;
+ file_t *fp;
struct vnode *vp = NULL;
kauth_cred_t cred = l->l_cred;
- struct file *nfp;
+ file_t *nfp;
int type, indx, error=0;
struct flock lf;
struct vattr va;
fhandle_t *fh;
int flags;
+ proc_t *p;
+
+ p = curproc;
/*
* Must be super user
@@ -1622,8 +1613,7 @@ dofhopen(struct lwp *l, const void *ufhp, size_t fhsize, int oflags,
return (EINVAL);
if ((flags & O_CREAT))
return (EINVAL);
- /* falloc() will use the file descriptor for us */
- if ((error = falloc(l, &nfp, &indx)) != 0)
+ if ((error = fd_allocfile(&nfp, &indx)) != 0)
return (error);
fp = nfp;
error = vfs_copyinfh_alloc(ufhp, fhsize, &fh);
@@ -1655,8 +1645,11 @@ dofhopen(struct lwp *l, const void *ufhp, size_t fhsize, int oflags,
}
if ((error = VOP_OPEN(vp, flags, cred)) != 0)
goto bad;
- if (flags & FWRITE)
+ if (flags & FWRITE) {
+ mutex_enter(&vp->v_interlock);
vp->v_writecount++;
+ mutex_exit(&vp->v_interlock);
+ }
/* done with modified vn_open, now finish what sys_open does. */
@@ -1678,26 +1671,21 @@ dofhopen(struct lwp *l, const void *ufhp, size_t fhsize, int oflags,
VOP_UNLOCK(vp, 0);
error = VOP_ADVLOCK(vp, fp, F_SETLK, &lf, type);
if (error) {
- (void) vn_close(vp, fp->f_flag, fp->f_cred, l);
- FILE_UNUSE(fp, l);
- ffree(fp);
- fdremove(fdp, indx);
+ (void) vn_close(vp, fp->f_flag, fp->f_cred);
+ fd_abort(p, fp, indx);
return (error);
}
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
- fp->f_flag |= FHASLOCK;
+ atomic_or_uint(&fp->f_flag, FHASLOCK);
}
VOP_UNLOCK(vp, 0);
*retval = indx;
- FILE_SET_MATURE(fp);
- FILE_UNUSE(fp, l);
+ fd_affix(p, fp, indx);
vfs_copyinfh_free(fh);
return (0);
bad:
- FILE_UNUSE(fp, l);
- ffree(fp);
- fdremove(fdp, indx);
+ fd_abort(p, fp, indx);
if (vp != NULL)
vput(vp);
vfs_copyinfh_free(fh);
@@ -1740,7 +1728,7 @@ do_fhstat(struct lwp *l, const void *ufhp, size_t fhsize, struct stat *sb)
if (error != 0)
return error;
- error = vn_stat(vp, sb, l);
+ error = vn_stat(vp, sb);
vput(vp);
return error;
}
@@ -2163,55 +2151,47 @@ sys_lseek(struct lwp *l, const struct sys_lseek_args *uap, register_t *retval)
syscallarg(off_t) offset;
syscallarg(int) whence;
} */
- struct proc *p = l->l_proc;
kauth_cred_t cred = l->l_cred;
- struct filedesc *fdp = p->p_fd;
- struct file *fp;
+ file_t *fp;
struct vnode *vp;
struct vattr vattr;
off_t newoff;
- int error;
+ int error, fd;
- if ((fp = fd_getfile(fdp, SCARG(uap, fd))) == NULL)
+ fd = SCARG(uap, fd);
+
+ 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) {
error = ESPIPE;
- FILE_UNLOCK(fp);
goto out;
}
switch (SCARG(uap, whence)) {
case SEEK_CUR:
newoff = fp->f_offset + SCARG(uap, offset);
- FILE_USE(fp);
break;
case SEEK_END:
- FILE_USE(fp);
error = VOP_GETATTR(vp, &vattr, cred);
if (error) {
- FILE_UNUSE(fp, l);
goto out;
}
newoff = SCARG(uap, offset) + vattr.va_size;
break;
case SEEK_SET:
- FILE_USE(fp);
newoff = SCARG(uap, offset);
break;
default:
- FILE_UNLOCK(fp);
error = EINVAL;
goto out;
}
if ((error = VOP_SEEK(vp, fp->f_offset, newoff, cred)) == 0) {
- FILE_LOCK(fp);
*(off_t *)retval = fp->f_offset = newoff;
- FILE_UNLOCK(fp);
}
- FILE_UNUSE(fp, l);
out:
+ fd_putfile(fd);
return (error);
}
@@ -2227,24 +2207,20 @@ sys_pread(struct lwp *l, const struct sys_pread_args *uap, register_t *retval)
syscallarg(size_t) nbyte;
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;
@@ -2264,7 +2240,7 @@ sys_pread(struct lwp *l, const struct sys_pread_args *uap, register_t *retval)
&offset, 0, retval));
out:
- FILE_UNUSE(fp, l);
+ fd_putfile(fd);
return (error);
}
@@ -2298,24 +2274,20 @@ sys_pwrite(struct lwp *l, const struct sys_pwrite_args *uap, register_t *retval)
syscallarg(size_t) nbyte;
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;
@@ -2335,7 +2307,7 @@ sys_pwrite(struct lwp *l, const struct sys_pwrite_args *uap, register_t *retval)
&offset, 0, retval));
out:
- FILE_UNUSE(fp, l);
+ fd_putfile(fd);
return (error);
}
@@ -2407,8 +2379,7 @@ out:
* Common code for all sys_stat functions, including compat versions.
*/
int
-do_sys_stat(struct lwp *l, const char *path, unsigned int nd_flags,
- struct stat *sb)
+do_sys_stat(const char *path, unsigned int nd_flags, struct stat *sb)
{
int error;
struct nameidata nd;
@@ -2418,7 +2389,7 @@ do_sys_stat(struct lwp *l, const char *path, unsigned int nd_flags,
error = namei(&nd);
if (error != 0)
return error;
- error = vn_stat(nd.ni_vp, sb, l);
+ error = vn_stat(nd.ni_vp, sb);
vput(nd.ni_vp);
return error;
}
@@ -2437,7 +2408,7 @@ sys___stat30(struct lwp *l, const struct sys___stat30_args *uap, register_t *ret
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)
return error;
return copyout(&sb, SCARG(uap, ub), sizeof(sb));
@@ -2457,7 +2428,7 @@ sys___lstat30(struct lwp *l, const struct sys___lstat30_args *uap, register_t *r
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)
return error;
return copyout(&sb, SCARG(uap, ub), sizeof(sb));
@@ -2565,18 +2536,17 @@ sys_fchflags(struct lwp *l, const struct sys_fchflags_args *uap, register_t *ret
syscallarg(int) fd;
syscallarg(u_long) flags;
} */
- struct proc *p = l->l_proc;
struct vnode *vp;
- struct file *fp;
+ file_t *fp;
int error;
- /* getvnode() will use the descriptor for us */
- if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0)
+ /* fd_getvnode() will use the descriptor for us */
+ if ((error = fd_getvnode(SCARG(uap, fd), &fp)) != 0)
return (error);
- vp = (struct vnode *)fp->f_data;
+ vp = fp->f_data;
error = change_flags(vp, SCARG(uap, flags), l);
VOP_UNLOCK(vp, 0);
- FILE_UNUSE(fp, l);
+ fd_putfile(SCARG(uap, fd));
return (error);
}
@@ -2670,16 +2640,14 @@ sys_fchmod(struct lwp *l, const struct sys_fchmod_args *uap, register_t *retval)
syscallarg(int) fd;
syscallarg(int) mode;
} */
- struct proc *p = l->l_proc;
- struct file *fp;
+ file_t *fp;
int error;
- /* getvnode() will use the descriptor for us */
- if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0)
+ /* fd_getvnode() will use the descriptor for us */
+ if ((error = fd_getvnode(SCARG(uap, fd), &fp)) != 0)
return (error);
-
- error = change_mode((struct vnode *)fp->f_data, SCARG(uap, mode), l);
- FILE_UNUSE(fp, l);
+ error = change_mode(fp->f_data, SCARG(uap, mode), l);
+ fd_putfile(SCARG(uap, fd));
return (error);
}
@@ -2790,17 +2758,15 @@ sys_fchown(struct lwp *l, const struct sys_fchown_args *uap, register_t *retval)
syscallarg(uid_t) uid;
syscallarg(gid_t) gid;
} */
- struct proc *p = l->l_proc;
int error;
- struct file *fp;
+ file_t *fp;
- /* getvnode() will use the descriptor for us */
- if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0)
+ /* fd_getvnode() will use the descriptor for us */
+ if ((error = fd_getvnode(SCARG(uap, fd), &fp)) != 0)
return (error);
-
- error = change_owner((struct vnode *)fp->f_data, SCARG(uap, uid),
- SCARG(uap, gid), l, 0);
- FILE_UNUSE(fp, l);
+ error = change_owner(fp->f_data, SCARG(uap, uid), SCARG(uap, gid),
+ l, 0);
+ fd_putfile(SCARG(uap, fd));
return (error);
}
@@ -2816,17 +2782,15 @@ sys___posix_fchown(struct lwp *l, const struct sys___posix_fchown_args *uap, reg
syscallarg(uid_t) uid;
syscallarg(gid_t) gid;
} */
- struct proc *p = l->l_proc;
int error;
- struct file *fp;
+ file_t *fp;
- /* getvnode() will use the descriptor for us */
- if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0)
+ /* fd_getvnode() will use the descriptor for us */
+ if ((error = fd_getvnode(SCARG(uap, fd), &fp)) != 0)
return (error);
-
- error = change_owner((struct vnode *)fp->f_data, SCARG(uap, uid),
- SCARG(uap, gid), l, 1);
- FILE_UNUSE(fp, l);
+ error = change_owner(fp->f_data, SCARG(uap, uid), SCARG(uap, gid),
+ l, 1);
+ fd_putfile(SCARG(uap, fd));
return (error);
}
@@ -2951,7 +2915,7 @@ sys_utimes(struct lwp *l, const struct sys_utimes_args *uap, register_t *retval)
} */
return do_sys_utimes(l, NULL, SCARG(uap, path), FOLLOW,
- SCARG(uap, tptr), UIO_USERSPACE);
+ SCARG(uap, tptr), UIO_USERSPACE);
}
/*
@@ -2966,16 +2930,14 @@ sys_futimes(struct lwp *l, const struct sys_futimes_args *uap, register_t *retva
syscallarg(const struct timeval *) tptr;
} */
int error;
- struct file *fp;
+ file_t *fp;
- /* getvnode() will use the descriptor for us */
- if ((error = getvnode(l->l_proc->p_fd, SCARG(uap, fd), &fp)) != 0)
+ /* fd_getvnode() will use the descriptor for us */
+ if ((error = fd_getvnode(SCARG(uap, fd), &fp)) != 0)
return (error);
-
- error = do_sys_utimes(l, fp->f_data, NULL, 0,
- SCARG(uap, tptr), UIO_USERSPACE);
-
- FILE_UNUSE(fp, l);
+ error = do_sys_utimes(l, fp->f_data, NULL, 0, SCARG(uap, tptr),
+ UIO_USERSPACE);
+ fd_putfile(SCARG(uap, fd));
return (error);
}
@@ -2992,7 +2954,7 @@ sys_lutimes(struct lwp *l, const struct sys_lutimes_args *uap, register_t *retva
} */
return do_sys_utimes(l, NULL, SCARG(uap, path), NOFOLLOW,
- SCARG(uap, tptr), UIO_USERSPACE);
+ SCARG(uap, tptr), UIO_USERSPACE);
}
/*
@@ -3089,20 +3051,19 @@ sys_ftruncate(struct lwp *l, const struct sys_ftruncate_args *uap, register_t *r
syscallarg(int) pad;
syscallarg(off_t) length;
} */
- struct proc *p = l->l_proc;
struct vattr vattr;
struct vnode *vp;
- struct file *fp;
+ file_t *fp;
int error;
- /* getvnode() will use the descriptor for us */
- if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0)
+ /* fd_getvnode() will use the descriptor for us */
+ if ((error = fd_getvnode(SCARG(uap, fd), &fp)) != 0)
return (error);
if ((fp->f_flag & FWRITE) == 0) {
error = EINVAL;
goto out;
}
- vp = (struct vnode *)fp->f_data;
+ vp = fp->f_data;
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
if (vp->v_type == VDIR)
error = EISDIR;
@@ -3113,7 +3074,7 @@ sys_ftruncate(struct lwp *l, const struct sys_ftruncate_args *uap, register_t *r
}
VOP_UNLOCK(vp, 0);
out:
- FILE_UNUSE(fp, l);
+ fd_putfile(SCARG(uap, fd));
return (error);
}
@@ -3127,22 +3088,21 @@ sys_fsync(struct lwp *l, const struct sys_fsync_args *uap, register_t *retval)
/* {
syscallarg(int) fd;
} */
- struct proc *p = l->l_proc;
struct vnode *vp;
- struct file *fp;
+ file_t *fp;
int error;
- /* getvnode() will use the descriptor for us */
- if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0)
+ /* fd_getvnode() will use the descriptor for us */
+ if ((error = fd_getvnode(SCARG(uap, fd), &fp)) != 0)
return (error);
- vp = (struct vnode *)fp->f_data;
+ vp = fp->f_data;
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
error = VOP_FSYNC(vp, fp->f_cred, FSYNC_WAIT, 0, 0);
if (error == 0 && bioopsp != NULL &&
vp->v_mount && (vp->v_mount->mnt_flag & MNT_SOFTDEP))
(*bioopsp->io_fsync)(vp, 0);
VOP_UNLOCK(vp, 0);
- FILE_UNUSE(fp, l);
+ fd_putfile(SCARG(uap, fd));
return (error);
}
@@ -3163,15 +3123,14 @@ sys_fsync_range(struct lwp *l, const struct sys_fsync_range_args *uap, register_
syscallarg(off_t) start;
syscallarg(off_t) length;
} */
- struct proc *p = l->l_proc;
struct vnode *vp;
- struct file *fp;
+ file_t *fp;
int flags, nflags;
off_t s, e, len;
int error;
- /* getvnode() will use the descriptor for us */
- if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0)
+ /* fd_getvnode() will use the descriptor for us */
+ if ((error = fd_getvnode(SCARG(uap, fd), &fp)) != 0)
return (error);
if ((fp->f_flag & FWRITE) == 0) {
@@ -3207,7 +3166,7 @@ sys_fsync_range(struct lwp *l, const struct sys_fsync_range_args *uap, register_
s = 0;
}
- vp = (struct vnode *)fp->f_data;
+ vp = fp->f_data;
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
error = VOP_FSYNC(vp, fp->f_cred, nflags, s, e);
@@ -3217,7 +3176,7 @@ sys_fsync_range(struct lwp *l, const struct sys_fsync_range_args *uap, register_
VOP_UNLOCK(vp, 0);
out:
- FILE_UNUSE(fp, l);
+ fd_putfile(SCARG(uap, fd));
return (error);
}
@@ -3231,23 +3190,22 @@ sys_fdatasync(struct lwp *l, const struct sys_fdatasync_args *uap, register_t *r
/* {
syscallarg(int) fd;
} */
- struct proc *p = l->l_proc;
struct vnode *vp;
- struct file *fp;
+ file_t *fp;
int error;
- /* getvnode() will use the descriptor for us */
- if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0)
+ /* fd_getvnode() will use the descriptor for us */
+ if ((error = fd_getvnode(SCARG(uap, fd), &fp)) != 0)
return (error);
if ((fp->f_flag & FWRITE) == 0) {
- FILE_UNUSE(fp, l);
+ fd_putfile(SCARG(uap, fd));
return (EBADF);
}
- vp = (struct vnode *)fp->f_data;
+ vp = fp->f_data;
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
error = VOP_FSYNC(vp, fp->f_cred, FSYNC_WAIT|FSYNC_DATAONLY, 0, 0);
VOP_UNLOCK(vp, 0);
- FILE_UNUSE(fp, l);
+ fd_putfile(SCARG(uap, fd));
return (error);
}
@@ -3543,12 +3501,11 @@ sys___getdents30(struct lwp *l, const struct sys___getdents30_args *uap, registe
syscallarg(char *) buf;
syscallarg(size_t) count;
} */
- struct proc *p = l->l_proc;
- struct file *fp;
+ file_t *fp;
int error, done;
- /* getvnode() will use the descriptor for us */
- if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0)
+ /* fd_getvnode() will use the descriptor for us */
+ if ((error = fd_getvnode(SCARG(uap, fd), &fp)) != 0)
return (error);
if ((fp->f_flag & FREAD) == 0) {
error = EBADF;
@@ -3559,7 +3516,7 @@ sys___getdents30(struct lwp *l, const struct sys___getdents30_args *uap, registe
ktrgenio(SCARG(uap, fd), UIO_READ, SCARG(uap, buf), done, error);
*retval = done;
out:
- FILE_UNUSE(fp, l);
+ fd_putfile(SCARG(uap, fd));
return (error);
}
@@ -3635,24 +3592,22 @@ sys_revoke(struct lwp *l, const struct sys_revoke_args *uap, register_t *retval)
* Convert a user file descriptor to a kernel file entry.
*/
int
-getvnode(struct filedesc *fdp, int fd, struct file **fpp)
+getvnode(int fd, file_t **fpp)
{
struct vnode *vp;
- struct file *fp;
+ file_t *fp;
- if ((fp = fd_getfile(fdp, fd)) == NULL)
+ if ((fp = fd_getfile(fd)) == NULL)
return (EBADF);
- FILE_USE(fp);
-
if (fp->f_type != DTYPE_VNODE) {
- FILE_UNUSE(fp, NULL);
+ fd_putfile(fd);
return (EINVAL);
}
- vp = (struct vnode *)fp->f_data;
+ vp = fp->f_data;
if (vp->v_type == VBAD) {
- FILE_UNUSE(fp, NULL);
+ fd_putfile(fd);
return (EBADF);
}
diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c
index ef5a6badf98..fe7d5d29f11 100644
--- a/sys/kern/vfs_vnops.c
+++ b/sys/kern/vfs_vnops.c
@@ -1,4 +1,4 @@
-/* $NetBSD: vfs_vnops.c,v 1.154 2008/01/30 09:50:22 ad Exp $ */
+/* $NetBSD: vfs_vnops.c,v 1.155 2008/03/21 21:55:00 ad Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1993
@@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_vnops.c,v 1.154 2008/01/30 09:50:22 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_vnops.c,v 1.155 2008/03/21 21:55:00 ad Exp $");
#include "fs_union.h"
#include "veriexec.h"
@@ -77,15 +77,15 @@ int (*vn_union_readdir_hook) (struct vnode **, struct file *, struct lwp *);
#include <sys/verified_exec.h>
-static int vn_read(struct file *fp, off_t *offset, struct uio *uio,
+static int vn_read(file_t *fp, off_t *offset, struct uio *uio,
kauth_cred_t cred, int flags);
-static int vn_write(struct file *fp, off_t *offset, struct uio *uio,
+static int vn_write(file_t *fp, off_t *offset, struct uio *uio,
kauth_cred_t cred, int flags);
-static int vn_closefile(struct file *fp, struct lwp *l);
-static int vn_poll(struct file *fp, int events, struct lwp *l);
-static int vn_fcntl(struct file *fp, u_int com, void *data, struct lwp *l);
-static int vn_statfile(struct file *fp, struct stat *sb, struct lwp *l);
-static int vn_ioctl(struct file *fp, u_long com, void *data, struct lwp *l);
+static int vn_closefile(file_t *fp);
+static int vn_poll(file_t *fp, int events);
+static int vn_fcntl(file_t *fp, u_int com, void *data);
+static int vn_statfile(file_t *fp, struct stat *sb);
+static int vn_ioctl(file_t *fp, u_long com, void *data);
const struct fileops vnops = {
vn_read, vn_write, vn_ioctl, vn_fcntl, vn_poll,
@@ -289,7 +289,7 @@ vn_marktext(struct vnode *vp)
* Note: takes an unlocked vnode, while VOP_CLOSE takes a locked node.
*/
int
-vn_close(struct vnode *vp, int flags, kauth_cred_t cred, struct lwp *l)
+vn_close(struct vnode *vp, int flags, kauth_cred_t cred)
{
int error;
@@ -350,7 +350,7 @@ vn_rdwr(enum uio_rw rw, struct vnode *vp, void *base, int len, off_t offset,
}
int
-vn_readdir(struct file *fp, char *bf, int segflg, u_int count, int *done,
+vn_readdir(file_t *fp, char *bf, int segflg, u_int count, int *done,
struct lwp *l, off_t **cookies, int *ncookies)
{
struct vnode *vp = (struct vnode *)fp->f_data;
@@ -419,23 +419,22 @@ unionread:
* File table vnode read routine.
*/
static int
-vn_read(struct file *fp, off_t *offset, struct uio *uio, kauth_cred_t cred,
+vn_read(file_t *fp, off_t *offset, struct uio *uio, kauth_cred_t cred,
int flags)
{
struct vnode *vp = (struct vnode *)fp->f_data;
- int count, error, ioflag;
+ int count, error, ioflag, fflag;
- FILE_LOCK(fp);
ioflag = IO_ADV_ENCODE(fp->f_advice);
- if (fp->f_flag & FNONBLOCK)
+ fflag = fp->f_flag;
+ if (fflag & FNONBLOCK)
ioflag |= IO_NDELAY;
- if ((fp->f_flag & (FFSYNC | FRSYNC)) == (FFSYNC | FRSYNC))
+ if ((fflag & (FFSYNC | FRSYNC)) == (FFSYNC | FRSYNC))
ioflag |= IO_SYNC;
- if (fp->f_flag & FALTIO)
+ if (fflag & FALTIO)
ioflag |= IO_ALTSEMANTICS;
- if (fp->f_flag & FDIRECT)
+ if (fflag & FDIRECT)
ioflag |= IO_DIRECT;
- FILE_UNLOCK(fp);
vn_lock(vp, LK_SHARED | LK_RETRY);
uio->uio_offset = *offset;
count = uio->uio_resid;
@@ -450,28 +449,27 @@ vn_read(struct file *fp, off_t *offset, struct uio *uio, kauth_cred_t cred,
* File table vnode write routine.
*/
static int
-vn_write(struct file *fp, off_t *offset, struct uio *uio, kauth_cred_t cred,
+vn_write(file_t *fp, off_t *offset, struct uio *uio, kauth_cred_t cred,
int flags)
{
struct vnode *vp = (struct vnode *)fp->f_data;
- int count, error, ioflag;
+ int count, error, ioflag, fflag;
- FILE_LOCK(fp);
ioflag = IO_ADV_ENCODE(fp->f_advice) | IO_UNIT;
- if (vp->v_type == VREG && (fp->f_flag & O_APPEND))
+ fflag = fp->f_flag;
+ if (vp->v_type == VREG && (fflag & O_APPEND))
ioflag |= IO_APPEND;
- if (fp->f_flag & FNONBLOCK)
+ if (fflag & FNONBLOCK)
ioflag |= IO_NDELAY;
- if (fp->f_flag & FFSYNC ||
+ if (fflag & FFSYNC ||
(vp->v_mount && (vp->v_mount->mnt_flag & MNT_SYNCHRONOUS)))
ioflag |= IO_SYNC;
- else if (fp->f_flag & FDSYNC)
+ else if (fflag & FDSYNC)
ioflag |= IO_DSYNC;
- if (fp->f_flag & FALTIO)
+ if (fflag & FALTIO)
ioflag |= IO_ALTSEMANTICS;
- if (fp->f_flag & FDIRECT)
+ if (fflag & FDIRECT)
ioflag |= IO_DIRECT;
- FILE_UNLOCK(fp);
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
uio->uio_offset = *offset;
count = uio->uio_resid;
@@ -490,21 +488,21 @@ vn_write(struct file *fp, off_t *offset, struct uio *uio, kauth_cred_t cred,
* File table vnode stat routine.
*/
static int
-vn_statfile(struct file *fp, struct stat *sb, struct lwp *l)
+vn_statfile(file_t *fp, struct stat *sb)
{
struct vnode *vp = (struct vnode *)fp->f_data;
- return vn_stat(vp, sb, l);
+ return vn_stat(vp, sb);
}
int
-vn_stat(struct vnode *vp, struct stat *sb, struct lwp *l)
+vn_stat(struct vnode *vp, struct stat *sb)
{
struct vattr va;
int error;
mode_t mode;
- error = VOP_GETATTR(vp, &va, l->l_cred);
+ error = VOP_GETATTR(vp, &va, kauth_cred_get());
if (error)
return (error);
/*
@@ -559,12 +557,12 @@ vn_stat(struct vnode *vp, struct stat *sb, struct lwp *l)
* File table vnode fcntl routine.
*/
static int
-vn_fcntl(struct file *fp, u_int com, void *data, struct lwp *l)
+vn_fcntl(file_t *fp, u_int com, void *data)
{
- struct vnode *vp = ((struct vnode *)fp->f_data);
+ struct vnode *vp = fp->f_data;
int error;
- error = VOP_FCNTL(vp, com, data, fp->f_flag, l->l_cred);
+ error = VOP_FCNTL(vp, com, data, fp->f_flag, kauth_cred_get());
return (error);
}
@@ -572,10 +570,9 @@ vn_fcntl(struct file *fp, u_int com, void *data, struct lwp *l)
* File table vnode ioctl routine.
*/
static int
-vn_ioctl(struct file *fp, u_long com, void *data, struct lwp *l)
+vn_ioctl(file_t *fp, u_long com, void *data)
{
- struct vnode *vp = ((struct vnode *)fp->f_data), *ovp;
- struct proc *p = l->l_proc;
+ struct vnode *vp = fp->f_data, *ovp;
struct vattr vattr;
int error;
@@ -584,7 +581,8 @@ vn_ioctl(struct file *fp, u_long com, void *data, struct lwp *l)
case VREG:
case VDIR:
if (com == FIONREAD) {
- error = VOP_GETATTR(vp, &vattr, l->l_cred);
+ error = VOP_GETATTR(vp, &vattr,
+ kauth_cred_get());
if (error)
return (error);
*(int *)data = vattr.va_size - fp->f_offset;
@@ -623,12 +621,13 @@ vn_ioctl(struct file *fp, u_long com, void *data, struct lwp *l)
case VFIFO:
case VCHR:
case VBLK:
- error = VOP_IOCTL(vp, com, data, fp->f_flag, l->l_cred);
+ error = VOP_IOCTL(vp, com, data, fp->f_flag,
+ kauth_cred_get());
if (error == 0 && com == TIOCSCTTY) {
VREF(vp);
mutex_enter(&proclist_lock);
- ovp = p->p_session->s_ttyvp;
- p->p_session->s_ttyvp = vp;
+ ovp = curproc->p_session->s_ttyvp;
+ curproc->p_session->s_ttyvp = vp;
mutex_exit(&proclist_lock);
if (ovp != NULL)
vrele(ovp);
@@ -644,20 +643,20 @@ vn_ioctl(struct file *fp, u_long com, void *data, struct lwp *l)
* File table vnode poll routine.
*/
static int
-vn_poll(struct file *fp, int events, struct lwp *l)
+vn_poll(file_t *fp, int events)
{
- return (VOP_POLL(((struct vnode *)fp->f_data), events));
+ return (VOP_POLL(fp->f_data, events));
}
/*
* File table vnode kqfilter routine.
*/
int
-vn_kqfilter(struct file *fp, struct knote *kn)
+vn_kqfilter(file_t *fp, struct knote *kn)
{
- return (VOP_KQFILTER((struct vnode *)fp->f_data, kn));
+ return (VOP_KQFILTER(fp->f_data, kn));
}
/*
@@ -704,11 +703,10 @@ vn_lock(struct vnode *vp, int flags)
* File table vnode close routine.
*/
static int
-vn_closefile(struct file *fp, struct lwp *l)
+vn_closefile(file_t *fp)
{
- return (vn_close(((struct vnode *)fp->f_data), fp->f_flag,
- fp->f_cred, l));
+ return vn_close(fp->f_data, fp->f_flag, fp->f_cred);
}
/*
diff --git a/sys/kern/vfs_xattr.c b/sys/kern/vfs_xattr.c
index 24a78a7ea25..ff2903932c1 100644
--- a/sys/kern/vfs_xattr.c
+++ b/sys/kern/vfs_xattr.c
@@ -1,7 +1,7 @@
-/* $NetBSD: vfs_xattr.c,v 1.16 2008/01/25 14:32:15 ad Exp $ */
+/* $NetBSD: vfs_xattr.c,v 1.17 2008/03/21 21:55:00 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
@@ -75,7 +75,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_xattr.c,v 1.16 2008/01/25 14:32:15 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_xattr.c,v 1.17 2008/03/21 21:55:00 ad Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -398,7 +398,7 @@ sys_extattr_set_fd(struct lwp *l, const struct sys_extattr_set_fd_args *uap, reg
if (error)
return (error);
- error = getvnode(l->l_proc->p_fd, SCARG(uap, fd), &fp);
+ error = getvnode(SCARG(uap, fd), &fp);
if (error)
return (error);
vp = (struct vnode *) fp->f_data;
@@ -406,7 +406,7 @@ sys_extattr_set_fd(struct lwp *l, const struct sys_extattr_set_fd_args *uap, reg
error = extattr_set_vp(vp, SCARG(uap, attrnamespace), attrname,
SCARG(uap, data), SCARG(uap, nbytes), l, retval);
- FILE_UNUSE(fp, l);
+ fd_putfile(SCARG(uap, fd));
return (error);
}
@@ -492,7 +492,7 @@ sys_extattr_get_fd(struct lwp *l, const struct sys_extattr_get_fd_args *uap, reg
if (error)
return (error);
- error = getvnode(l->l_proc->p_fd, SCARG(uap, fd), &fp);
+ error = getvnode(SCARG(uap, fd), &fp);
if (error)
return (error);
vp = (struct vnode *) fp->f_data;
@@ -500,7 +500,7 @@ sys_extattr_get_fd(struct lwp *l, const struct sys_extattr_get_fd_args *uap, reg
error = extattr_get_vp(vp, SCARG(uap, attrnamespace), attrname,
SCARG(uap, data), SCARG(uap, nbytes), l, retval);
- FILE_UNUSE(fp, l);
+ fd_putfile(SCARG(uap, fd));
return (error);
}
@@ -584,14 +584,14 @@ sys_extattr_delete_fd(struct lwp *l, const struct sys_extattr_delete_fd_args *ua
if (error)
return (error);
- error = getvnode(l->l_proc->p_fd, SCARG(uap, fd), &fp);
+ error = getvnode(SCARG(uap, fd), &fp);
if (error)
return (error);
vp = (struct vnode *) fp->f_data;
error = extattr_delete_vp(vp, SCARG(uap, attrnamespace), attrname, l);
- FILE_UNUSE(fp, l);
+ fd_putfile(SCARG(uap, fd));
return (error);
}
@@ -666,7 +666,7 @@ sys_extattr_list_fd(struct lwp *l, const struct sys_extattr_list_fd_args *uap, r
struct vnode *vp;
int error;
- error = getvnode(l->l_proc->p_fd, SCARG(uap, fd), &fp);
+ error = getvnode(SCARG(uap, fd), &fp);
if (error)
return (error);
vp = (struct vnode *) fp->f_data;
@@ -674,7 +674,7 @@ sys_extattr_list_fd(struct lwp *l, const struct sys_extattr_list_fd_args *uap, r
error = extattr_list_vp(vp, SCARG(uap, attrnamespace),
SCARG(uap, data), SCARG(uap, nbytes), l, retval);
- FILE_UNUSE(fp, l);
+ fd_putfile(SCARG(uap, fd));
return (error);
}
@@ -816,7 +816,7 @@ sys_fsetxattr(struct lwp *l, const struct sys_fsetxattr_args *uap, register_t *r
if (error)
return (error);
- error = getvnode(l->l_proc->p_fd, SCARG(uap, fd), &fp);
+ error = getvnode(SCARG(uap, fd), &fp);
if (error)
return (error);
vp = (struct vnode *) fp->f_data;
@@ -826,7 +826,7 @@ sys_fsetxattr(struct lwp *l, const struct sys_fsetxattr_args *uap, register_t *r
error = extattr_set_vp(vp, EXTATTR_NAMESPACE_USER,
attrname, SCARG(uap, value), SCARG(uap, size), l, retval);
- FILE_UNUSE(fp, l);
+ fd_putfile(SCARG(uap, fd));
return (error);
}
@@ -909,7 +909,7 @@ sys_fgetxattr(struct lwp *l, const struct sys_fgetxattr_args *uap, register_t *r
if (error)
return (error);
- error = getvnode(l->l_proc->p_fd, SCARG(uap, fd), &fp);
+ error = getvnode(SCARG(uap, fd), &fp);
if (error)
return (error);
vp = (struct vnode *) fp->f_data;
@@ -917,7 +917,7 @@ sys_fgetxattr(struct lwp *l, const struct sys_fgetxattr_args *uap, register_t *r
error = extattr_get_vp(vp, EXTATTR_NAMESPACE_USER,
attrname, SCARG(uap, value), SCARG(uap, size), l, retval);
- FILE_UNUSE(fp, l);
+ fd_putfile(SCARG(uap, fd));
return (error);
}
@@ -979,7 +979,7 @@ sys_flistxattr(struct lwp *l, const struct sys_flistxattr_args *uap, register_t
struct vnode *vp;
int error;
- error = getvnode(l->l_proc->p_fd, SCARG(uap, fd), &fp);
+ error = getvnode(SCARG(uap, fd), &fp);
if (error)
return (error);
vp = (struct vnode *) fp->f_data;
@@ -987,7 +987,7 @@ sys_flistxattr(struct lwp *l, const struct sys_flistxattr_args *uap, register_t
error = extattr_list_vp(vp, EXTATTR_NAMESPACE_USER,
SCARG(uap, list), SCARG(uap, size), l, retval);
- FILE_UNUSE(fp, l);
+ fd_putfile(SCARG(uap, fd));
return (error);
}
@@ -1064,7 +1064,7 @@ sys_fremovexattr(struct lwp *l, const struct sys_fremovexattr_args *uap, registe
if (error)
return (error);
- error = getvnode(l->l_proc->p_fd, SCARG(uap, fd), &fp);
+ error = getvnode(SCARG(uap, fd), &fp);
if (error)
return (error);
vp = (struct vnode *) fp->f_data;
@@ -1072,6 +1072,6 @@ sys_fremovexattr(struct lwp *l, const struct sys_fremovexattr_args *uap, registe
error = extattr_delete_vp(vp, EXTATTR_NAMESPACE_USER,
attrname, l);
- FILE_UNUSE(fp, l);
+ fd_putfile(SCARG(uap, fd));
return (error);
}
diff --git a/sys/miscfs/fdesc/fdesc_vnops.c b/sys/miscfs/fdesc/fdesc_vnops.c
index d97fa45206a..e7fe40e79f5 100644
--- a/sys/miscfs/fdesc/fdesc_vnops.c
+++ b/sys/miscfs/fdesc/fdesc_vnops.c
@@ -1,4 +1,4 @@
-/* $NetBSD: fdesc_vnops.c,v 1.101 2007/12/08 19:29:50 pooka Exp $ */
+/* $NetBSD: fdesc_vnops.c,v 1.102 2008/03/21 21:55:00 ad Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -41,7 +41,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fdesc_vnops.c,v 1.101 2007/12/08 19:29:50 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fdesc_vnops.c,v 1.102 2008/03/21 21:55:00 ad Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -62,6 +62,7 @@ __KERNEL_RCSID(0, "$NetBSD: fdesc_vnops.c,v 1.101 2007/12/08 19:29:50 pooka Exp
#include <sys/dirent.h>
#include <sys/tty.h>
#include <sys/kauth.h>
+#include <sys/atomic.h>
#include <miscfs/fdesc/fdesc.h>
#include <miscfs/genfs/genfs.h>
@@ -125,7 +126,7 @@ int fdesc_pathconf(void *);
#define fdesc_revoke genfs_revoke
#define fdesc_putpages genfs_null_putpages
-static int fdesc_attr(int, struct vattr *, kauth_cred_t, struct lwp *);
+static int fdesc_attr(int, struct vattr *, kauth_cred_t);
int (**fdesc_vnodeop_p)(void *);
const struct vnodeopv_entry_desc fdesc_vnodeop_entries[] = {
@@ -280,7 +281,8 @@ fdesc_lookup(v)
struct lwp *l = curlwp;
const char *pname = cnp->cn_nameptr;
struct proc *p = l->l_proc;
- int numfiles = p->p_fd->fd_nfiles;
+ filedesc_t *fdp = p->p_fd;
+ int numfiles = fdp->fd_nfiles;
unsigned fd = 0;
int error;
struct vnode *fvp;
@@ -382,11 +384,14 @@ fdesc_lookup(v)
goto bad;
}
- if (fd >= numfiles || p->p_fd->fd_ofiles[fd] == NULL ||
- FILE_IS_USABLE(p->p_fd->fd_ofiles[fd]) == 0) {
+ mutex_enter(&fdp->fd_lock);
+ if (fd >= numfiles ||fdp->fd_ofiles[fd] == NULL ||
+ fdp->fd_ofiles[fd]->ff_file == NULL) {
+ mutex_exit(&fdp->fd_lock);
error = EBADF;
goto bad;
}
+ mutex_exit(&fdp->fd_lock);
error = fdesc_allocvp(Fdesc, FD_DESC+fd, dvp->v_mount, &fvp);
if (error)
@@ -440,26 +445,21 @@ fdesc_open(v)
}
static int
-fdesc_attr(fd, vap, cred, l)
+fdesc_attr(fd, vap, cred)
int fd;
struct vattr *vap;
kauth_cred_t cred;
- struct lwp *l;
{
- struct proc *p = l->l_proc;
- struct filedesc *fdp = p->p_fd;
- struct file *fp;
+ file_t *fp;
struct stat stb;
int error;
- if ((fp = fd_getfile(fdp, fd)) == NULL)
+ if ((fp = fd_getfile(fd)) == NULL)
return (EBADF);
switch (fp->f_type) {
case DTYPE_VNODE:
- FILE_USE(fp);
error = VOP_GETATTR((struct vnode *) fp->f_data, vap, cred);
- FILE_UNUSE(fp, l);
if (error == 0 && vap->va_type == VDIR) {
/*
* directories can cause loops in the namespace,
@@ -470,10 +470,8 @@ fdesc_attr(fd, vap, cred, l)
break;
default:
- FILE_USE(fp);
memset(&stb, 0, sizeof(stb));
- error = (*fp->f_ops->fo_stat)(fp, &stb, l);
- FILE_UNUSE(fp, l);
+ error = (*fp->f_ops->fo_stat)(fp, &stb);
if (error)
break;
@@ -508,6 +506,7 @@ fdesc_attr(fd, vap, cred, l)
break;
}
+ fd_putfile(fd);
return (error);
}
@@ -578,7 +577,7 @@ fdesc_getattr(v)
case Fdesc:
fd = VTOFDESC(vp)->fd_fd;
- error = fdesc_attr(fd, vap, ap->a_cred, curlwp);
+ error = fdesc_attr(fd, vap, ap->a_cred);
break;
default:
@@ -601,8 +600,7 @@ fdesc_setattr(v)
struct vattr *a_vap;
kauth_cred_t a_cred;
} */ *ap = v;
- struct filedesc *fdp = curlwp->l_proc->p_fd;
- struct file *fp;
+ file_t *fp;
unsigned fd;
/*
@@ -620,7 +618,7 @@ fdesc_setattr(v)
}
fd = VTOFDESC(ap->a_vp)->fd_fd;
- if ((fp = fd_getfile(fdp, fd)) == NULL)
+ if ((fp = fd_getfile(fd)) == NULL)
return (EBADF);
/*
@@ -628,7 +626,7 @@ fdesc_setattr(v)
* On vnode's this will cause truncation and socket/pipes make
* no sense.
*/
- mutex_exit(&fp->f_lock);
+ fd_putfile(fd);
return (0);
}
@@ -664,7 +662,7 @@ fdesc_readdir(v)
} */ *ap = v;
struct uio *uio = ap->a_uio;
struct dirent d;
- struct filedesc *fdp;
+ filedesc_t *fdp;
off_t i;
int j;
int error;
@@ -728,11 +726,10 @@ fdesc_readdir(v)
if ((ft->ft_fileno - FD_STDIN) >=
fdp->fd_nfiles)
continue;
+ membar_consumer();
if (fdp->fd_ofiles[ft->ft_fileno - FD_STDIN]
- == NULL
- || FILE_IS_USABLE(
- fdp->fd_ofiles[ft->ft_fileno - FD_STDIN])
- == 0)
+ == NULL || fdp->fd_ofiles[ft->ft_fileno -
+ FD_STDIN]->ff_file == NULL)
continue;
break;
}
@@ -749,6 +746,7 @@ fdesc_readdir(v)
}
} else {
int nfdp = fdp ? fdp->fd_nfiles : 0;
+ membar_consumer();
if (ap->a_ncookies) {
ncookies = min(ncookies, nfdp + 2);
cookies = malloc(ncookies * sizeof(off_t),
@@ -771,7 +769,7 @@ fdesc_readdir(v)
KASSERT(fdp != NULL);
j = (int)i - 2;
if (fdp == NULL || fdp->fd_ofiles[j] == NULL ||
- FILE_IS_USABLE(fdp->fd_ofiles[j]) == 0)
+ fdp->fd_ofiles[j]->ff_file == NULL)
continue;
d.d_fileno = j + FD_STDIN;
d.d_namlen = sprintf(d.d_name, "%d", j);
@@ -935,10 +933,8 @@ fdesc_kqfilter(v)
struct vnode *a_vp;
struct knote *a_kn;
} */ *ap = v;
- int error;
- struct proc *p;
- struct lwp *l;
- struct file *fp;
+ int error, fd;
+ file_t *fp;
switch (VTOFDESC(ap->a_vp)->fd_type) {
case Fctty:
@@ -947,14 +943,11 @@ fdesc_kqfilter(v)
case Fdesc:
/* just invoke kqfilter for the underlying descriptor */
- l = curlwp; /* XXX hopefully ok to use curproc here */
- p = l->l_proc;
- if ((fp = fd_getfile(p->p_fd, VTOFDESC(ap->a_vp)->fd_fd)) == NULL)
+ fd = VTOFDESC(ap->a_vp)->fd_fd;
+ if ((fp = fd_getfile(fd)) == NULL)
return (1);
-
- FILE_USE(fp);
error = (*fp->f_ops->fo_kqfilter)(fp, ap->a_kn);
- FILE_UNUSE(fp, l);
+ fd_putfile(fd);
break;
default:
diff --git a/sys/miscfs/fifofs/fifo_vnops.c b/sys/miscfs/fifofs/fifo_vnops.c
index 80cdaed041d..c3097ba36d8 100644
--- a/sys/miscfs/fifofs/fifo_vnops.c
+++ b/sys/miscfs/fifofs/fifo_vnops.c
@@ -1,4 +1,4 @@
-/* $NetBSD: fifo_vnops.c,v 1.62 2008/02/11 23:53:32 yamt Exp $ */
+/* $NetBSD: fifo_vnops.c,v 1.63 2008/03/21 21:55:00 ad Exp $ */
/*
* Copyright (c) 1990, 1993, 1995
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fifo_vnops.c,v 1.62 2008/02/11 23:53:32 yamt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fifo_vnops.c,v 1.63 2008/03/21 21:55:00 ad Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -341,13 +341,13 @@ fifo_ioctl(void *v)
return (0);
if (ap->a_fflag & FREAD) {
filetmp.f_data = ap->a_vp->v_fifoinfo->fi_readsock;
- error = soo_ioctl(&filetmp, ap->a_command, ap->a_data, curlwp);
+ error = soo_ioctl(&filetmp, ap->a_command, ap->a_data);
if (error)
return (error);
}
if (ap->a_fflag & FWRITE) {
filetmp.f_data = ap->a_vp->v_fifoinfo->fi_writesock;
- error = soo_ioctl(&filetmp, ap->a_command, ap->a_data, curlwp);
+ error = soo_ioctl(&filetmp, ap->a_command, ap->a_data);
if (error)
return (error);
}
@@ -370,12 +370,12 @@ fifo_poll(void *v)
if (ap->a_events & (POLLIN | POLLPRI | POLLRDNORM | POLLRDBAND)) {
filetmp.f_data = ap->a_vp->v_fifoinfo->fi_readsock;
if (filetmp.f_data)
- revents |= soo_poll(&filetmp, ap->a_events, curlwp);
+ revents |= soo_poll(&filetmp, ap->a_events);
}
if (ap->a_events & (POLLOUT | POLLWRNORM | POLLWRBAND)) {
filetmp.f_data = ap->a_vp->v_fifoinfo->fi_writesock;
if (filetmp.f_data)
- revents |= soo_poll(&filetmp, ap->a_events, curlwp);
+ revents |= soo_poll(&filetmp, ap->a_events);
}
return (revents);
diff --git a/sys/miscfs/genfs/genfs_vnops.c b/sys/miscfs/genfs/genfs_vnops.c
index b7b18012872..d9bb1ad532e 100644
--- a/sys/miscfs/genfs/genfs_vnops.c
+++ b/sys/miscfs/genfs/genfs_vnops.c
@@ -1,4 +1,4 @@
-/* $NetBSD: genfs_vnops.c,v 1.164 2008/02/05 14:19:53 ad Exp $ */
+/* $NetBSD: genfs_vnops.c,v 1.165 2008/03/21 21:55:00 ad Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -64,7 +64,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: genfs_vnops.c,v 1.164 2008/02/05 14:19:53 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: genfs_vnops.c,v 1.165 2008/03/21 21:55:00 ad Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -408,13 +408,13 @@ filt_genfsread(struct knote *kn, long hint)
return (1);
case 0:
mutex_enter(&vp->v_interlock);
- 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);
mutex_exit(&vp->v_interlock);
return rv;
default:
KASSERT(mutex_owned(&vp->v_interlock));
- kn->kn_data = vp->v_size - kn->kn_fp->f_offset;
+ kn->kn_data = vp->v_size - ((file_t *)kn->kn_obj)->f_offset;
return (kn->kn_data != 0);
}
}
@@ -445,7 +445,7 @@ filt_genfsvnode(struct knote *kn, long hint)
break;
}
- return (kn->kn_fflags != 0);
+ return (fflags != 0);
}
static const struct filterops genfsread_filtops =
diff --git a/sys/miscfs/portal/portal_vfsops.c b/sys/miscfs/portal/portal_vfsops.c
index baa8e90f49b..d9cb5954cff 100644
--- a/sys/miscfs/portal/portal_vfsops.c
+++ b/sys/miscfs/portal/portal_vfsops.c
@@ -1,4 +1,4 @@
-/* $NetBSD: portal_vfsops.c,v 1.70 2008/01/28 14:31:19 dholland Exp $ */
+/* $NetBSD: portal_vfsops.c,v 1.71 2008/03/21 21:55:00 ad Exp $ */
/*
* Copyright (c) 1992, 1993, 1995
@@ -40,7 +40,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: portal_vfsops.c,v 1.70 2008/01/28 14:31:19 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: portal_vfsops.c,v 1.71 2008/03/21 21:55:00 ad Exp $");
#if defined(_KERNEL_OPT)
#include "opt_compat_netbsd.h"
@@ -121,17 +121,17 @@ portal_mount(
return (EOPNOTSUPP);
/* getsock() will use the descriptor for us */
- if ((error = getsock(p->p_fd, args->pa_socket, &fp)) != 0)
+ if ((error = getsock(args->pa_socket, &fp)) != 0)
return (error);
so = (struct socket *) fp->f_data;
if (so->so_proto->pr_domain->dom_family != AF_LOCAL) {
- FILE_UNUSE(fp, NULL);
+ fd_putfile(args->pa_socket);
return (ESOCKTNOSUPPORT);
}
error = getnewvnode(VT_PORTAL, mp, portal_vnodeop_p, &rvp); /* XXX */
if (error) {
- FILE_UNUSE(fp, NULL);
+ fd_putfile(args->pa_socket);
return (error);
}
MALLOC(rvp->v_data, void *, sizeof(struct portalnode),
@@ -149,6 +149,7 @@ portal_mount(
mutex_enter(&fp->f_lock);
fp->f_count++;
mutex_exit(&fp->f_lock);
+ fd_putfile(args->pa_socket);
mp->mnt_stat.f_namemax = MAXNAMLEN;
mp->mnt_flag |= MNT_LOCAL;
@@ -189,14 +190,12 @@ portal_unmount(struct mount *mp, int mntflags)
* daemon to wake up, and then the accept will get ECONNABORTED
* which it interprets as a request to go and bury itself.
*/
- mutex_enter(&VFSTOPORTAL(mp)->pm_server->f_lock);
- FILE_USE(VFSTOPORTAL(mp)->pm_server);
soshutdown((struct socket *) VFSTOPORTAL(mp)->pm_server->f_data, 2);
/*
* Discard reference to underlying file. Must call closef because
* this may be the last reference.
*/
- closef(VFSTOPORTAL(mp)->pm_server, (struct lwp *) 0);
+ closef(VFSTOPORTAL(mp)->pm_server);
/*
* Finally, throw away the portalmount structure
*/
diff --git a/sys/miscfs/portal/portal_vnops.c b/sys/miscfs/portal/portal_vnops.c
index 0da8aacdf5d..23a15991ff9 100644
--- a/sys/miscfs/portal/portal_vnops.c
+++ b/sys/miscfs/portal/portal_vnops.c
@@ -1,4 +1,4 @@
-/* $NetBSD: portal_vnops.c,v 1.77 2008/01/19 21:54:47 pooka Exp $ */
+/* $NetBSD: portal_vnops.c,v 1.78 2008/03/21 21:55:00 ad Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -40,7 +40,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: portal_vnops.c,v 1.77 2008/01/19 21:54:47 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: portal_vnops.c,v 1.78 2008/03/21 21:55:00 ad Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -484,7 +484,7 @@ portal_open(v)
* Check that the mode the file is being opened for is a subset
* of the mode of the existing descriptor.
*/
- fp = l->l_proc->p_fd->fd_ofiles[fd];
+ fp = l->l_proc->p_fd->fd_ofiles[fd]->ff_file;
if (((ap->a_mode & (FREAD|FWRITE)) | fp->f_flag) != fp->f_flag) {
portal_closefd(l, fd); /* XXXNJWLWP */
error = EACCES;
diff --git a/sys/miscfs/procfs/procfs_fd.c b/sys/miscfs/procfs/procfs_fd.c
index 4d52e7a7275..750cda95ae1 100644
--- a/sys/miscfs/procfs/procfs_fd.c
+++ b/sys/miscfs/procfs/procfs_fd.c
@@ -1,7 +1,7 @@
-/* $NetBSD: procfs_fd.c,v 1.12 2007/11/07 00:23:37 ad Exp $ */
+/* $NetBSD: procfs_fd.c,v 1.13 2008/03/21 21:55:00 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: procfs_fd.c,v 1.12 2007/11/07 00:23:37 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: procfs_fd.c,v 1.13 2008/03/21 21:55:00 ad Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -47,25 +47,18 @@ __KERNEL_RCSID(0, "$NetBSD: procfs_fd.c,v 1.12 2007/11/07 00:23:37 ad Exp $");
#include <sys/vnode.h>
#include <sys/file.h>
#include <sys/filedesc.h>
+
#include <miscfs/procfs/procfs.h>
int
-procfs_dofd(
- struct lwp *curl,
- struct proc *p,
- struct pfsnode *pfs,
- struct uio *uio
-)
+procfs_dofd(lwp_t *curl, proc_t *p, struct pfsnode *pfs, struct uio *uio)
{
int error;
- struct file *fp;
+ file_t *fp;
off_t offs;
- fp = fd_getfile(p->p_fd, pfs->pfs_fd);
- if (fp == NULL)
- return (EBADF);
-
- FILE_USE(fp);
+ if ((fp = fd_getfile2(p, pfs->pfs_fd)) == NULL)
+ return EBADF;
offs = fp->f_offset;
@@ -74,13 +67,13 @@ procfs_dofd(
error = (*fp->f_ops->fo_read)(fp, &offs, uio, curl->l_cred, 0);
break;
case UIO_WRITE:
- error = (*fp->f_ops->fo_write)(fp, &offs, uio, curl->l_cred,0);
+ error = (*fp->f_ops->fo_write)(fp, &offs, uio, curl->l_cred, 0);
break;
default:
panic("bad uio op");
}
- FILE_UNUSE(fp, curl);
+ closef(fp);
return (error);
}
diff --git a/sys/miscfs/procfs/procfs_subr.c b/sys/miscfs/procfs/procfs_subr.c
index f7f527ac3e8..16bc03ce1b7 100644
--- a/sys/miscfs/procfs/procfs_subr.c
+++ b/sys/miscfs/procfs/procfs_subr.c
@@ -1,7 +1,7 @@
-/* $NetBSD: procfs_subr.c,v 1.85 2008/01/30 09:50:23 ad Exp $ */
+/* $NetBSD: procfs_subr.c,v 1.86 2008/03/21 21:55:00 ad Exp $ */
/*-
- * Copyright (c) 2006, 2007 The NetBSD Foundation, Inc.
+ * Copyright (c) 2006, 2007, 2008 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@@ -109,7 +109,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: procfs_subr.c,v 1.85 2008/01/30 09:50:23 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: procfs_subr.c,v 1.86 2008/03/21 21:55:00 ad Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -227,20 +227,18 @@ procfs_allocvp(mp, vpp, pid, pfs_type, fd, p)
pfs->pfs_mode = S_IRUSR|S_IXUSR;
vp->v_type = VDIR;
} else { /* /proc/N/fd/M = [ps-]rw------- */
- struct file *fp;
- struct vnode *vxp;
+ file_t *fp;
+ vnode_t *vxp;
- fp = fd_getfile(p->p_fd, pfs->pfs_fd);
- if (fp == NULL) {
+ if ((fp = fd_getfile2(p, pfs->pfs_fd)) == NULL) {
error = EBADF;
goto bad;
}
- FILE_USE(fp);
pfs->pfs_mode = S_IRUSR|S_IWUSR;
switch (fp->f_type) {
case DTYPE_VNODE:
- vxp = (struct vnode *)fp->f_data;
+ vxp = fp->f_data;
/*
* We make symlinks for directories
@@ -265,10 +263,10 @@ procfs_allocvp(mp, vpp, pid, pfs_type, fd, p)
break;
default:
error = EOPNOTSUPP;
- FILE_UNUSE(fp, curlwp);
+ closef(fp);
goto bad;
}
- FILE_UNUSE(fp, curlwp);
+ closef(fp);
}
break;
diff --git a/sys/miscfs/procfs/procfs_vnops.c b/sys/miscfs/procfs/procfs_vnops.c
index 1530a92fedc..610ae600469 100644
--- a/sys/miscfs/procfs/procfs_vnops.c
+++ b/sys/miscfs/procfs/procfs_vnops.c
@@ -1,7 +1,7 @@
-/* $NetBSD: procfs_vnops.c,v 1.165 2008/01/23 15:04:40 elad Exp $ */
+/* $NetBSD: procfs_vnops.c,v 1.166 2008/03/21 21:55:00 ad Exp $ */
/*-
- * Copyright (c) 2006, 2007 The NetBSD Foundation, Inc.
+ * Copyright (c) 2006, 2007, 2008 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@@ -112,7 +112,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: procfs_vnops.c,v 1.165 2008/01/23 15:04:40 elad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: procfs_vnops.c,v 1.166 2008/03/21 21:55:00 ad Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -793,14 +793,13 @@ procfs_getattr(v)
case PFSfd:
if (pfs->pfs_fd != -1) {
- struct file *fp;
+ file_t *fp;
- fp = fd_getfile(procp->p_fd, pfs->pfs_fd);
+ fp = fd_getfile2(procp, pfs->pfs_fd);
if (fp == NULL) {
error = EBADF;
break;
}
- FILE_USE(fp);
vap->va_nlink = 1;
vap->va_uid = kauth_cred_geteuid(fp->f_cred);
vap->va_gid = kauth_cred_getegid(fp->f_cred);
@@ -813,7 +812,7 @@ procfs_getattr(v)
vap->va_bytes = vap->va_size = 0;
break;
}
- FILE_UNUSE(fp, curlwp);
+ closef(fp);
break;
}
/*FALLTHROUGH*/
@@ -993,7 +992,6 @@ procfs_lookup(v)
pid_t pid, vnpid;
struct pfsnode *pfs;
struct proc *p = NULL;
- struct lwp *l = NULL;
int i, error;
pfstype type;
@@ -1110,7 +1108,7 @@ procfs_lookup(v)
case PFSfd: {
int fd;
- struct file *fp;
+ file_t *fp;
if ((error = procfs_proc_lock(pfs->pfs_pid, &p, ENOENT)) != 0)
return error;
@@ -1130,19 +1128,17 @@ procfs_lookup(v)
}
fd = atoi(pname, cnp->cn_namelen);
- fp = fd_getfile(p->p_fd, fd);
+ fp = fd_getfile2(p, fd);
if (fp == NULL) {
procfs_proc_unlock(p);
return ENOENT;
}
-
- FILE_USE(fp);
- fvp = (struct vnode *)fp->f_data;
+ fvp = fp->f_data;
/* Don't show directories */
if (fp->f_type == DTYPE_VNODE && fvp->v_type != VDIR) {
VREF(fvp);
- FILE_UNUSE(fp, l);
+ closef(fp);
procfs_proc_unlock(p);
vn_lock(fvp, LK_EXCLUSIVE | LK_RETRY |
(p == curproc ? LK_CANRECURSE : 0));
@@ -1150,7 +1146,7 @@ procfs_lookup(v)
return 0;
}
- FILE_UNUSE(fp, l);
+ closef(fp);
error = procfs_allocvp(dvp->v_mount, vpp, pfs->pfs_pid,
PFSfd, fd, p);
procfs_proc_unlock(p);
@@ -1336,8 +1332,7 @@ procfs_readdir(v)
}
case PFSfd: {
struct proc *p;
- struct filedesc *fdp;
- struct file *fp;
+ file_t *fp;
int lim, nc = 0;
if ((error = procfs_proc_lock(pfs->pfs_pid, &p, ESRCH)) != 0)
@@ -1352,8 +1347,7 @@ procfs_readdir(v)
return ESRCH;
}
- fdp = p->p_fd;
- nfd = fdp->fd_nfiles;
+ nfd = p->p_fd->fd_nfiles;
lim = min((int)p->p_rlimit[RLIMIT_NOFILE].rlim_cur, maxfiles);
if (i >= lim) {
@@ -1387,9 +1381,9 @@ procfs_readdir(v)
}
for (; uio->uio_resid >= UIO_MX && i < nfd; i++) {
/* check the descriptor exists */
- if ((fp = fd_getfile(fdp, i - 2)) == NULL)
+ if ((fp = fd_getfile2(p, i - 2)) == NULL)
continue;
- mutex_exit(&fp->f_lock);
+ closef(fp);
d.d_fileno = PROCFS_FILENO(pfs->pfs_pid, PFSfd, i - 2);
d.d_namlen = snprintf(d.d_name, sizeof(d.d_name),
@@ -1558,30 +1552,27 @@ procfs_readlink(v)
procfs_proc_unlock(pown);
len = strlen(bp);
} else {
- struct file *fp;
+ file_t *fp;
struct vnode *vxp, *vp;
if ((error = procfs_proc_lock(pfs->pfs_pid, &pown, ESRCH)) != 0)
return error;
- fp = fd_getfile(pown->p_fd, pfs->pfs_fd);
+ fp = fd_getfile2(pown, pfs->pfs_fd);
if (fp == NULL) {
procfs_proc_unlock(pown);
return EBADF;
}
- FILE_USE(fp);
switch (fp->f_type) {
case DTYPE_VNODE:
vxp = (struct vnode *)fp->f_data;
if (vxp->v_type != VDIR) {
- FILE_UNUSE(fp, curlwp);
error = EINVAL;
break;
}
if ((path = malloc(MAXPATHLEN, M_TEMP, M_WAITOK))
== NULL) {
- FILE_UNUSE(fp, curlwp);
error = ENOMEM;
break;
}
@@ -1620,7 +1611,7 @@ procfs_readlink(v)
error = EINVAL;
break;
}
- FILE_UNUSE(fp, curlwp);
+ closef(fp);
procfs_proc_unlock(pown);
}
diff --git a/sys/net/bpf.c b/sys/net/bpf.c
index a9c72404478..bd57b4eff29 100644
--- a/sys/net/bpf.c
+++ b/sys/net/bpf.c
@@ -1,4 +1,4 @@
-/* $NetBSD: bpf.c,v 1.134 2008/03/01 14:16:52 rmind Exp $ */
+/* $NetBSD: bpf.c,v 1.135 2008/03/21 21:55:00 ad Exp $ */
/*
* Copyright (c) 1990, 1991, 1993
@@ -39,7 +39,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bpf.c,v 1.134 2008/03/01 14:16:52 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bpf.c,v 1.135 2008/03/21 21:55:00 ad Exp $");
#if defined(_KERNEL_OPT)
#include "opt_bpf.h"
@@ -150,9 +150,9 @@ static int bpf_read(struct file *, off_t *, struct uio *, kauth_cred_t,
int);
static int bpf_write(struct file *, off_t *, struct uio *, kauth_cred_t,
int);
-static int bpf_ioctl(struct file *, u_long, void *, struct lwp *);
-static int bpf_poll(struct file *, int, struct lwp *);
-static int bpf_close(struct file *, struct lwp *);
+static int bpf_ioctl(struct file *, u_long, void *);
+static int bpf_poll(struct file *, int);
+static int bpf_close(struct file *);
static int bpf_kqfilter(struct file *, struct knote *);
static const struct fileops bpf_fileops = {
@@ -394,7 +394,7 @@ bpfopen(dev_t dev, int flag, int mode, struct lwp *l)
int error, fd;
/* falloc() will use the descriptor for us. */
- if ((error = falloc(l, &fp, &fd)) != 0)
+ if ((error = fd_allocfile(&fp, &fd)) != 0)
return error;
d = malloc(sizeof(*d), M_DEVBUF, M_WAITOK);
@@ -409,7 +409,7 @@ bpfopen(dev_t dev, int flag, int mode, struct lwp *l)
LIST_INSERT_HEAD(&bpf_list, d, bd_list);
mutex_exit(&bpf_mtx);
- return fdclone(l, fp, fd, flag, &bpf_fileops, d);
+ return fd_clone(fp, fd, flag, &bpf_fileops, d);
}
/*
@@ -418,7 +418,7 @@ bpfopen(dev_t dev, int flag, int mode, struct lwp *l)
*/
/* ARGSUSED */
static int
-bpf_close(struct file *fp, struct lwp *l)
+bpf_close(struct file *fp)
{
struct bpf_d *d = fp->f_data;
int s;
@@ -426,7 +426,7 @@ bpf_close(struct file *fp, struct lwp *l)
/*
* Refresh the PID associated with this bpf file.
*/
- d->bd_pid = l->l_proc->p_pid;
+ d->bd_pid = curproc->p_pid;
s = splnet();
if (d->bd_state == BPF_WAITING)
@@ -668,7 +668,7 @@ reset_d(struct bpf_d *d)
*/
/* ARGSUSED */
static int
-bpf_ioctl(struct file *fp, u_long cmd, void *addr, struct lwp *l)
+bpf_ioctl(struct file *fp, u_long cmd, void *addr)
{
struct bpf_d *d = fp->f_data;
int s, error = 0;
@@ -676,7 +676,7 @@ bpf_ioctl(struct file *fp, u_long cmd, void *addr, struct lwp *l)
/*
* Refresh the PID associated with this bpf file.
*/
- d->bd_pid = l->l_proc->p_pid;
+ d->bd_pid = curproc->p_pid;
s = splnet();
if (d->bd_state == BPF_WAITING)
@@ -920,12 +920,12 @@ bpf_ioctl(struct file *fp, u_long cmd, void *addr, struct lwp *l)
case TIOCSPGRP: /* Process or group to send signals to */
case FIOSETOWN:
- error = fsetown(l->l_proc, &d->bd_pgid, cmd, addr);
+ error = fsetown(&d->bd_pgid, cmd, addr);
break;
case TIOCGPGRP:
case FIOGETOWN:
- error = fgetown(l->l_proc, d->bd_pgid, cmd, addr);
+ error = fgetown(d->bd_pgid, cmd, addr);
break;
}
return (error);
@@ -1069,7 +1069,7 @@ bpf_ifname(struct ifnet *ifp, struct ifreq *ifr)
* Otherwise, return false but make a note that a selnotify() must be done.
*/
static int
-bpf_poll(struct file *fp, int events, struct lwp *l)
+bpf_poll(struct file *fp, int events)
{
struct bpf_d *d = fp->f_data;
int s = splnet();
@@ -1078,7 +1078,7 @@ bpf_poll(struct file *fp, int events, struct lwp *l)
/*
* Refresh the PID associated with this bpf file.
*/
- d->bd_pid = l->l_proc->p_pid;
+ d->bd_pid = curproc->p_pid;
revents = events & (POLLOUT | POLLWRNORM);
if (events & (POLLIN | POLLRDNORM)) {
@@ -1094,7 +1094,7 @@ bpf_poll(struct file *fp, int events, struct lwp *l)
else
revents |= events & POLLIN;
} else {
- selrecord(l, &d->bd_sel);
+ selrecord(curlwp, &d->bd_sel);
/* Start the read timeout if necessary */
if (d->bd_rtout > 0 && d->bd_state == BPF_IDLE) {
callout_reset(&d->bd_callout, d->bd_rtout,
diff --git a/sys/net/if_gre.c b/sys/net/if_gre.c
index 5a095ab2f51..d8755b83475 100644
--- a/sys/net/if_gre.c
+++ b/sys/net/if_gre.c
@@ -1,7 +1,7 @@
-/* $NetBSD: if_gre.c,v 1.124 2008/02/20 17:05:53 matt Exp $ */
+/* $NetBSD: if_gre.c,v 1.125 2008/03/21 21:55:00 ad Exp $ */
/*
- * Copyright (c) 1998 The NetBSD Foundation, Inc.
+ * Copyright (c) 1998, 2008 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@@ -47,7 +47,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_gre.c,v 1.124 2008/02/20 17:05:53 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_gre.c,v 1.125 2008/03/21 21:55:00 ad Exp $");
#include "opt_gre.h"
#include "opt_inet.h"
@@ -147,7 +147,7 @@ static bool gre_is_nullconf(const struct gre_soparm *);
static int gre_output(struct ifnet *, struct mbuf *,
const struct sockaddr *, struct rtentry *);
static int gre_ioctl(struct ifnet *, u_long, void *);
-static void gre_closef(struct file **, struct lwp *);
+static void gre_closef(file_t **);
static int gre_getsockname(struct socket *, struct mbuf *, struct lwp *);
static int gre_getpeername(struct socket *, struct mbuf *, struct lwp *);
static int gre_getnames(struct socket *, struct lwp *,
@@ -475,7 +475,9 @@ gre_socreate(struct gre_softc *sc, struct lwp *l,
GRE_DPRINTF(sc, "%s: fsocreate failed\n", __func__);
return rc;
}
-
+ if ((rc = fd_getsock(fd, &so)) == 0) {
+ return rc;
+ }
if ((m = getsombuf(so, MT_SONAME)) == NULL) {
rc = ENOBUFS;
goto out;
@@ -528,9 +530,11 @@ out:
m_freem(m);
if (rc != 0)
- fdrelease(l, fd);
- else
+ fd_close(fd);
+ else {
+ fd_putfile(fd);
*fdout = fd;
+ }
return rc;
}
@@ -809,7 +813,7 @@ gre_reconf(struct gre_softc *sc, struct socket *so, lwp_t *l,
const struct gre_soparm *newsoparm)
{
int rc;
- struct file *fp;
+ file_t *fp;
struct ifnet *ifp = &sc->sc_if;
GRE_DPRINTF(sc, "%s: enter\n", __func__);
@@ -820,7 +824,8 @@ shutdown:
gre_upcall_remove(so);
softint_disestablish(sc->sc_si);
sc->sc_si = NULL;
- fdrelease(l, sc->sc_soparm.sp_fd);
+ fd_getfile(sc->sc_soparm.sp_fd);
+ fd_close(sc->sc_soparm.sp_fd);
gre_clearconf(&sc->sc_soparm, false);
sc->sc_soparm.sp_fd = -1;
so = NULL;
@@ -833,14 +838,14 @@ shutdown:
if (sc->sc_soparm.sp_fd != -1) {
GRE_DPRINTF(sc, "%s: l.%d\n", __func__, __LINE__);
- rc = getsock(l->l_proc->p_fd, sc->sc_soparm.sp_fd, &fp);
+ rc = getsock(sc->sc_soparm.sp_fd, &fp);
if (rc != 0)
goto shutdown;
GRE_DPRINTF(sc, "%s: l.%d\n", __func__, __LINE__);
- FILE_UNUSE(fp, NULL);
so = (struct socket *)fp->f_data;
sc->sc_si = softint_establish(SOFTINT_NET, greintr, sc);
gre_upcall_add(so, sc);
+ fd_putfile(sc->sc_soparm.sp_fd);
if ((ifp->if_flags & IFF_UP) == 0) {
GRE_DPRINTF(sc, "%s: down\n", __func__);
goto shutdown;
@@ -1067,13 +1072,11 @@ out:
}
static void
-gre_closef(struct file **fpp, struct lwp *l)
+gre_closef(file_t **fpp)
{
- struct file *fp = *fpp;
+ file_t *fp = *fpp;
- mutex_enter(&fp->f_lock);
- FILE_USE(fp);
- closef(fp, l);
+ closef(fp);
*fpp = NULL;
}
@@ -1082,19 +1085,22 @@ gre_ssock(struct ifnet *ifp, struct gre_soparm *sp, int fd)
{
int error, kfd;
const struct protosw *pr;
- struct file *fp;
- struct filedesc *fdp;
+ file_t *fp;
struct gre_softc *sc = ifp->if_softc;
struct lwp *l = curlwp;
- struct proc *kp, *p = curproc;
+ struct proc *kp;
struct socket *so;
struct sockaddr_storage dst, src;
/* getsock() will FILE_USE() and unlock the descriptor for us */
- if ((error = getsock(p->p_fd, fd, &fp)) != 0) {
+ if ((fp = fd_getfile(fd)) == NULL) {
GRE_DPRINTF(sc, "%s: l.%d\n", __func__, __LINE__);
return EINVAL;
}
+ if (fp->f_type != DTYPE_SOCKET) {
+ fd_putfile(fd);
+ return ENOTSOCK;
+ }
/* Increase reference count. Now that our reference to
* the file descriptor is counted, this thread can release
@@ -1104,20 +1110,19 @@ gre_ssock(struct ifnet *ifp, struct gre_soparm *sp, int fd)
* can have use of the descriptor at once. The kernel
* thread will pick up the use if it needs it.
*/
+ mutex_enter(&fp->f_lock);
fp->f_count++;
+ mutex_exit(&fp->f_lock);
+ fd_putfile(fd);
GRE_DPRINTF(sc, "%s: l.%d f_count %d\n", __func__, __LINE__,
fp->f_count);
- FILE_UNUSE(fp, NULL);
kp = sc->sc_lwp->l_proc;
- while ((error = fdalloc(kp, 0, &kfd)) != 0 && error == ENOSPC)
- fdexpand(kp);
+ while ((error = fd_alloc(kp, 0, &kfd)) != 0 && error == ENOSPC)
+ fd_tryexpand(kp);
if (error != 0)
goto closef;
- fdp = kp->p_fd;
- rw_enter(&fdp->fd_lock, RW_WRITER);
- fdp->fd_ofiles[kfd] = fp;
- rw_exit(&fdp->fd_lock);
+ fd_affix(kp, fp, kfd);
GRE_DPRINTF(sc, "%s: l.%d\n", __func__, __LINE__);
@@ -1156,11 +1161,11 @@ gre_ssock(struct ifnet *ifp, struct gre_soparm *sp, int fd)
return 0;
release:
GRE_DPRINTF(sc, "%s: l.%d\n", __func__, __LINE__);
- fdrelease(sc->sc_lwp, kfd);
+ fd_abort(kp, fp, kfd);
return error;
closef:
GRE_DPRINTF(sc, "%s: l.%d\n", __func__, __LINE__);
- gre_closef(&fp, l);
+ gre_closef(&fp);
return error;
}
@@ -1245,6 +1250,7 @@ gre_ioctl(struct ifnet *ifp, const u_long cmd, void *data)
struct gre_soparm sp0;
ifr = data;
+ fd = 0;
GRE_DPRINTF(sc, "%s: l.%d, cmd %lu\n", __func__, __LINE__, cmd);
@@ -1430,7 +1436,6 @@ gre_ioctl(struct ifnet *ifp, const u_long cmd, void *data)
GRE_DPRINTF(sc, "%s: l.%d\n", __func__, __LINE__);
error = gre_socreate(sc, l, sp, &fd);
-
if (error != 0)
break;
@@ -1441,7 +1446,9 @@ gre_ioctl(struct ifnet *ifp, const u_long cmd, void *data)
if (cmd != GRESSOCK) {
GRE_DPRINTF(sc, "%s: l.%d\n", __func__, __LINE__);
- fdrelease(l, fd);
+ /* XXX v. dodgy */
+ if (fd_getfile(fd) != NULL)
+ fd_close(fd);
}
if (error == 0) {
diff --git a/sys/net/if_tap.c b/sys/net/if_tap.c
index 7796bc8069c..9695e0b8b68 100644
--- a/sys/net/if_tap.c
+++ b/sys/net/if_tap.c
@@ -1,7 +1,7 @@
-/* $NetBSD: if_tap.c,v 1.40 2008/03/04 13:25:05 cube Exp $ */
+/* $NetBSD: if_tap.c,v 1.41 2008/03/21 21:55:00 ad Exp $ */
/*
- * Copyright (c) 2003, 2004 The NetBSD Foundation.
+ * Copyright (c) 2003, 2004, 2008 The NetBSD Foundation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -36,7 +36,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_tap.c,v 1.40 2008/03/04 13:25:05 cube Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_tap.c,v 1.41 2008/03/21 21:55:00 ad Exp $");
#if defined(_KERNEL_OPT)
#include "bpfilter.h"
@@ -132,15 +132,14 @@ static int tap_dev_poll(int, int, struct lwp *);
static int tap_dev_kqfilter(int, struct knote *);
/* Fileops access routines */
-static int tap_fops_close(struct file *, struct lwp *);
-static int tap_fops_read(struct file *, off_t *, struct uio *,
+static int tap_fops_close(file_t *);
+static int tap_fops_read(file_t *, off_t *, struct uio *,
kauth_cred_t, int);
-static int tap_fops_write(struct file *, off_t *, struct uio *,
+static int tap_fops_write(file_t *, off_t *, struct uio *,
kauth_cred_t, int);
-static int tap_fops_ioctl(struct file *, u_long, void *,
- struct lwp *);
-static int tap_fops_poll(struct file *, int, struct lwp *);
-static int tap_fops_kqfilter(struct file *, struct knote *);
+static int tap_fops_ioctl(file_t *, u_long, void *);
+static int tap_fops_poll(file_t *, int);
+static int tap_fops_kqfilter(file_t *, struct knote *);
static const struct fileops tap_fileops = {
tap_fops_read,
@@ -694,21 +693,20 @@ static int
tap_dev_cloner(struct lwp *l)
{
struct tap_softc *sc;
- struct file *fp;
+ file_t *fp;
int error, fd;
- if ((error = falloc(l, &fp, &fd)) != 0)
+ if ((error = fd_allocfile(&fp, &fd)) != 0)
return (error);
if ((sc = tap_clone_creator(-1)) == NULL) {
- FILE_UNUSE(fp, l);
- ffree(fp);
+ fd_abort(curproc, fp, fd);
return (ENXIO);
}
sc->sc_flags |= TAP_INUSE;
- return fdclone(l, fp, fd, FREAD|FWRITE, &tap_fileops,
+ return fd_clone(fp, fd, FREAD|FWRITE, &tap_fileops,
(void *)(intptr_t)device_unit(sc->sc_dev));
}
@@ -742,7 +740,7 @@ tap_cdev_close(dev_t dev, int flags, int fmt,
* would dead lock. TAP_GOING ensures that this situation doesn't happen.
*/
static int
-tap_fops_close(struct file *fp, struct lwp *l)
+tap_fops_close(file_t *fp)
{
int unit = (intptr_t)fp->f_data;
struct tap_softc *sc;
@@ -806,7 +804,7 @@ tap_cdev_read(dev_t dev, struct uio *uio, int flags)
}
static int
-tap_fops_read(struct file *fp, off_t *offp, struct uio *uio,
+tap_fops_read(file_t *fp, off_t *offp, struct uio *uio,
kauth_cred_t cred, int flags)
{
return tap_dev_read((intptr_t)fp->f_data, uio, flags);
@@ -904,7 +902,7 @@ tap_cdev_write(dev_t dev, struct uio *uio, int flags)
}
static int
-tap_fops_write(struct file *fp, off_t *offp, struct uio *uio,
+tap_fops_write(file_t *fp, off_t *offp, struct uio *uio,
kauth_cred_t cred, int flags)
{
return tap_dev_write((intptr_t)fp->f_data, uio, flags);
@@ -974,9 +972,9 @@ tap_cdev_ioctl(dev_t dev, u_long cmd, void *data, int flags,
}
static int
-tap_fops_ioctl(struct file *fp, u_long cmd, void *data, struct lwp *l)
+tap_fops_ioctl(file_t *fp, u_long cmd, void *data)
{
- return tap_dev_ioctl((intptr_t)fp->f_data, cmd, (void *)data, l);
+ return tap_dev_ioctl((intptr_t)fp->f_data, cmd, data, curlwp);
}
static int
@@ -1007,11 +1005,11 @@ tap_dev_ioctl(int unit, u_long cmd, void *data, struct lwp *l)
} break;
case TIOCSPGRP:
case FIOSETOWN:
- error = fsetown(l->l_proc, &sc->sc_pgid, cmd, data);
+ error = fsetown(&sc->sc_pgid, cmd, data);
break;
case TIOCGPGRP:
case FIOGETOWN:
- error = fgetown(l->l_proc, sc->sc_pgid, cmd, data);
+ error = fgetown(sc->sc_pgid, cmd, data);
break;
case FIOASYNC:
if (*(int *)data)
@@ -1050,9 +1048,9 @@ tap_cdev_poll(dev_t dev, int events, struct lwp *l)
}
static int
-tap_fops_poll(struct file *fp, int events, struct lwp *l)
+tap_fops_poll(file_t *fp, int events)
{
- return tap_dev_poll((intptr_t)fp->f_data, events, l);
+ return tap_dev_poll((intptr_t)fp->f_data, events, curlwp);
}
static int
@@ -1099,7 +1097,7 @@ tap_cdev_kqfilter(dev_t dev, struct knote *kn)
}
static int
-tap_fops_kqfilter(struct file *fp, struct knote *kn)
+tap_fops_kqfilter(file_t *fp, struct knote *kn)
{
return tap_dev_kqfilter((intptr_t)fp->f_data, kn);
}
diff --git a/sys/net/if_tun.c b/sys/net/if_tun.c
index e5a9e8c3af8..d88ca057a8c 100644
--- a/sys/net/if_tun.c
+++ b/sys/net/if_tun.c
@@ -1,4 +1,4 @@
-/* $NetBSD: if_tun.c,v 1.104 2008/03/01 14:16:52 rmind Exp $ */
+/* $NetBSD: if_tun.c,v 1.105 2008/03/21 21:55:00 ad Exp $ */
/*
* Copyright (c) 1988, Julian Onions <jpo@cs.nott.ac.uk>
@@ -15,7 +15,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_tun.c,v 1.104 2008/03/01 14:16:52 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_tun.c,v 1.105 2008/03/21 21:55:00 ad Exp $");
#include "opt_inet.h"
@@ -688,12 +688,12 @@ tunioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l)
case TIOCSPGRP:
case FIOSETOWN:
- error = fsetown(l->l_proc, &tp->tun_pgid, cmd, data);
+ error = fsetown(&tp->tun_pgid, cmd, data);
break;
case TIOCGPGRP:
case FIOGETOWN:
- error = fgetown(l->l_proc, tp->tun_pgid, cmd, data);
+ error = fgetown(tp->tun_pgid, cmd, data);
break;
default:
diff --git a/sys/netsmb/smb_dev.c b/sys/netsmb/smb_dev.c
index 159cc96c4e8..4dfa03e7b7f 100644
--- a/sys/netsmb/smb_dev.c
+++ b/sys/netsmb/smb_dev.c
@@ -1,4 +1,4 @@
-/* $NetBSD: smb_dev.c,v 1.28 2008/03/01 14:16:52 rmind Exp $ */
+/* $NetBSD: smb_dev.c,v 1.29 2008/03/21 21:55:01 ad Exp $ */
/*
* Copyright (c) 2000-2001 Boris Popov
@@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: smb_dev.c,v 1.28 2008/03/01 14:16:52 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: smb_dev.c,v 1.29 2008/03/21 21:55:01 ad Exp $");
#include <sys/param.h>
#include <sys/kernel.h>
@@ -470,31 +470,28 @@ int
smb_dev2share(int fd, int mode, struct smb_cred *scred,
struct smb_share **sspp)
{
- struct lwp *l = scred->scr_l;
- struct file *fp;
+ file_t *fp;
struct vnode *vp;
struct smb_dev *sdp;
struct smb_share *ssp;
dev_t dev;
int error;
- if ((fp = fd_getfile(l->l_proc->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;
if (fp->f_type != DTYPE_VNODE
|| (fp->f_flag & (FREAD|FWRITE)) == 0
|| vp->v_type != VCHR
|| vp->v_rdev == NODEV) {
- FILE_UNUSE(fp, l);
+ fd_putfile(fd);
return (EBADF);
}
dev = vp->v_rdev;
- FILE_UNUSE(fp, l);
+ fd_putfile(fd);
sdp = SMB_GETDEV(dev);
if (!sdp)
diff --git a/sys/nfs/nfs_kq.c b/sys/nfs/nfs_kq.c
index e1ba9e5b5b5..32226b95fdf 100644
--- a/sys/nfs/nfs_kq.c
+++ b/sys/nfs/nfs_kq.c
@@ -1,4 +1,4 @@
-/* $NetBSD: nfs_kq.c,v 1.20 2008/02/12 08:55:27 yamt Exp $ */
+/* $NetBSD: nfs_kq.c,v 1.21 2008/03/21 21:55:01 ad Exp $ */
/*-
* Copyright (c) 2002, 2008 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nfs_kq.c,v 1.20 2008/02/12 08:55:27 yamt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nfs_kq.c,v 1.21 2008/03/21 21:55:01 ad Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -221,13 +221,13 @@ filt_nfsread(struct knote *kn, long hint)
return (1);
case 0:
mutex_enter(&vp->v_interlock);
- kn->kn_data = vp->v_size - kn->kn_fp->f_offset != 0;
+ kn->kn_data = vp->v_size - ((file_t *)kn->kn_obj)->f_offset;
rv = (kn->kn_data != 0);
mutex_exit(&vp->v_interlock);
return rv;
default:
KASSERT(mutex_owned(&vp->v_interlock));
- kn->kn_data = vp->v_size - kn->kn_fp->f_offset != 0;
+ kn->kn_data = vp->v_size - ((file_t *)kn->kn_obj)->f_offset;
return (kn->kn_data != 0);
}
}
diff --git a/sys/nfs/nfs_syscalls.c b/sys/nfs/nfs_syscalls.c
index 0d1bfba6550..7115b7bcc5b 100644
--- a/sys/nfs/nfs_syscalls.c
+++ b/sys/nfs/nfs_syscalls.c
@@ -1,4 +1,4 @@
-/* $NetBSD: nfs_syscalls.c,v 1.131 2008/02/28 17:07:49 elad Exp $ */
+/* $NetBSD: nfs_syscalls.c,v 1.132 2008/03/21 21:55:01 ad Exp $ */
/*
* Copyright (c) 1989, 1993
@@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nfs_syscalls.c,v 1.131 2008/02/28 17:07:49 elad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nfs_syscalls.c,v 1.132 2008/03/21 21:55:01 ad Exp $");
#include "fs_nfs.h"
#include "opt_nfs.h"
@@ -154,7 +154,7 @@ sys_nfssvc(struct lwp *l, const struct sys_nfssvc_args *uap, register_t *retval)
} */
int error;
#ifdef NFSSERVER
- struct file *fp;
+ file_t *fp;
struct mbuf *nam;
struct nfsd_args nfsdarg;
struct nfsd_srvargs nfsd_srvargs, *nsd = &nfsd_srvargs;
@@ -198,7 +198,7 @@ sys_nfssvc(struct lwp *l, const struct sys_nfssvc_args *uap, register_t *retval)
if (error)
return (error);
/* getsock() will use the descriptor for us */
- error = getsock(l->l_proc->p_fd, nfsdarg.sock, &fp);
+ error = getsock(nfsdarg.sock, &fp);
if (error)
return (error);
/*
@@ -210,12 +210,12 @@ sys_nfssvc(struct lwp *l, const struct sys_nfssvc_args *uap, register_t *retval)
error = sockargs(&nam, nfsdarg.name, nfsdarg.namelen,
MT_SONAME);
if (error) {
- FILE_UNUSE(fp, NULL);
+ fd_putfile(nfsdarg.sock);
return (error);
}
}
error = nfssvc_addsock(fp, nam);
- FILE_UNUSE(fp, NULL);
+ fd_putfile(nfsdarg.sock);
#endif /* !NFSSERVER */
} else if (SCARG(uap, flag) & NFSSVC_SETEXPORTSLIST) {
#ifndef NFSSERVER
@@ -385,7 +385,7 @@ nfsrv_sockfree(struct nfssvc_sock *slp)
*/
int
nfssvc_addsock(fp, mynam)
- struct file *fp;
+ file_t *fp;
struct mbuf *mynam;
{
struct mbuf *m;
@@ -904,7 +904,7 @@ nfsrv_slpderef(slp)
ref = --slp->ns_sref;
mutex_exit(&nfsd_lock);
if (ref == 0 && (slp->ns_flags & SLP_VALID) == 0) {
- struct file *fp;
+ file_t *fp;
mutex_enter(&nfsd_lock);
KASSERT((slp->ns_gflags & SLP_G_DOREC) == 0);
@@ -916,9 +916,8 @@ nfsrv_slpderef(slp)
slp->ns_fp = NULL;
KASSERT(fp != NULL);
KASSERT(fp->f_data == slp->ns_so);
- mutex_enter(&fp->f_lock);
- FILE_USE(fp);
- closef(fp, (struct lwp *)0);
+ KASSERT(fp->f_count > 0);
+ closef(fp);
slp->ns_so = NULL;
}
diff --git a/sys/opencrypto/cryptodev.c b/sys/opencrypto/cryptodev.c
index 1694c823bda..8516c460ece 100644
--- a/sys/opencrypto/cryptodev.c
+++ b/sys/opencrypto/cryptodev.c
@@ -1,4 +1,4 @@
-/* $NetBSD: cryptodev.c,v 1.34 2008/02/04 14:46:27 tls Exp $ */
+/* $NetBSD: cryptodev.c,v 1.35 2008/03/21 21:55:01 ad Exp $ */
/* $FreeBSD: src/sys/opencrypto/cryptodev.c,v 1.4.2.4 2003/06/03 00:09:02 sam Exp $ */
/* $OpenBSD: cryptodev.c,v 1.53 2002/07/10 22:21:30 mickey Exp $ */
@@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cryptodev.c,v 1.34 2008/02/04 14:46:27 tls Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cryptodev.c,v 1.35 2008/03/21 21:55:01 ad Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -95,10 +95,10 @@ static int cryptowrite(dev_t dev, struct uio *uio, int ioflag);
static int cryptoselect(dev_t dev, int rw, struct lwp *l);
/* Declaration of cloned-device (per-ctxt) entrypoints */
-static int cryptof_read(struct file *, off_t *, struct uio *, kauth_cred_t, int);
-static int cryptof_write(struct file *, off_t *, struct uio *, kauth_cred_t, int);
-static int cryptof_ioctl(struct file *, u_long, void*, struct lwp *l);
-static int cryptof_close(struct file *, struct lwp *);
+static int cryptof_read(file_t *, off_t *, struct uio *, kauth_cred_t, int);
+static int cryptof_write(file_t *, off_t *, struct uio *, kauth_cred_t, int);
+static int cryptof_ioctl(file_t *, u_long, void *);
+static int cryptof_close(file_t *);
static const struct fileops cryptofops = {
cryptof_read,
@@ -133,7 +133,7 @@ static int cryptodevkey_cb(void *);
/* ARGSUSED */
int
-cryptof_read(struct file *fp, off_t *poff,
+cryptof_read(file_t *fp, off_t *poff,
struct uio *uio, kauth_cred_t cred, int flags)
{
return (EIO);
@@ -141,7 +141,7 @@ cryptof_read(struct file *fp, off_t *poff,
/* ARGSUSED */
int
-cryptof_write(struct file *fp, off_t *poff,
+cryptof_write(file_t *fp, off_t *poff,
struct uio *uio, kauth_cred_t cred, int flags)
{
return (EIO);
@@ -149,10 +149,10 @@ cryptof_write(struct file *fp, off_t *poff,
/* ARGSUSED */
int
-cryptof_ioctl(struct file *fp, u_long cmd, void* data, struct lwp *l)
+cryptof_ioctl(file_t *fp, u_long cmd, void *data)
{
struct cryptoini cria, crie;
- struct fcrypt *fcr = (struct fcrypt *)fp->f_data;
+ struct fcrypt *fcr = fp->f_data;
struct csession *cse;
struct session_op *sop;
struct crypt_op *cop;
@@ -163,13 +163,13 @@ cryptof_ioctl(struct file *fp, u_long cmd, void* data, struct lwp *l)
int error = 0;
/* backwards compatibility */
- struct file *criofp;
+ file_t *criofp;
struct fcrypt *criofcr;
int criofd;
switch (cmd) {
case CRIOGET: /* XXX deprecated, remove after 5.0 */
- if ((error = falloc(l, &criofp, &criofd)) != 0)
+ if ((error = fd_allocfile(&criofp, &criofd)) != 0)
return error;
criofcr = pool_get(&fcrpl, PR_WAITOK);
mutex_spin_enter(&crypto_mtx);
@@ -180,7 +180,7 @@ cryptof_ioctl(struct file *fp, u_long cmd, void* data, struct lwp *l)
*/
criofcr->sesn = 1;
mutex_spin_exit(&crypto_mtx);
- (void)fdclone(l, criofp, criofd, (FREAD|FWRITE),
+ (void)fd_clone(criofp, criofd, (FREAD|FWRITE),
&cryptofops, criofcr);
*(u_int32_t *)data = criofd;
return error;
@@ -353,7 +353,7 @@ bail:
DPRINTF(("csefind failed\n"));
return (EINVAL);
}
- error = cryptodev_op(cse, cop, l);
+ error = cryptodev_op(cse, cop, curlwp);
DPRINTF(("cryptodev_op error = %d\n", error));
break;
case CIOCKEY:
@@ -710,9 +710,9 @@ fail:
/* ARGSUSED */
static int
-cryptof_close(struct file *fp, struct lwp *l)
+cryptof_close(file_t *fp)
{
- struct fcrypt *fcr = (struct fcrypt *)fp->f_data;
+ struct fcrypt *fcr = fp->f_data;
struct csession *cse;
mutex_spin_enter(&crypto_mtx);
@@ -820,14 +820,14 @@ static int
cryptoopen(dev_t dev, int flag, int mode,
struct lwp *l)
{
- struct file *fp;
+ file_t *fp;
struct fcrypt *fcr;
int fd, error;
if (crypto_usercrypto == 0)
return (ENXIO);
- if ((error = falloc(l, &fp, &fd)) != 0)
+ if ((error = fd_allocfile(&fp, &fd)) != 0)
return error;
fcr = pool_get(&fcrpl, PR_WAITOK);
@@ -839,7 +839,7 @@ cryptoopen(dev_t dev, int flag, int mode,
*/
fcr->sesn = 1;
mutex_spin_exit(&crypto_mtx);
- return fdclone(l, fp, fd, flag, &cryptofops, fcr);
+ return fd_clone(fp, fd, flag, &cryptofops, fcr);
}
static int
diff --git a/sys/rump/fs/lib/libsyspuffs/puffs_rumpglue.c b/sys/rump/fs/lib/libsyspuffs/puffs_rumpglue.c
index 3a1ab25eca0..772136ad38a 100644
--- a/sys/rump/fs/lib/libsyspuffs/puffs_rumpglue.c
+++ b/sys/rump/fs/lib/libsyspuffs/puffs_rumpglue.c
@@ -1,4 +1,4 @@
-/* $NetBSD: puffs_rumpglue.c,v 1.2 2008/01/27 19:07:21 pooka Exp $ */
+/* $NetBSD: puffs_rumpglue.c,v 1.3 2008/03/21 21:55:01 ad Exp $ */
/*
* Copyright (c) 2008 Antti Kantee. All Rights Reserved.
@@ -29,7 +29,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: puffs_rumpglue.c,v 1.2 2008/01/27 19:07:21 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: puffs_rumpglue.c,v 1.3 2008/03/21 21:55:01 ad Exp $");
#include <sys/param.h>
#include <sys/conf.h>
@@ -83,8 +83,7 @@ readthread(void *arg)
ssize_t n;
off = 0;
- fp = fd_getfile(pap->fdp, pap->fpfd);
- FILE_USE(fp);
+ fp = fd_getfile(pap->fpfd);
error = dofileread(pap->fpfd, fp, buf, BUFSIZE,
&off, 0, &rv);
if (error) {
@@ -128,8 +127,7 @@ writethread(void *arg)
panic("rumpuser_read %zd %d", n, error);
off = 0;
- fp = fd_getfile(pap->fdp, pap->fpfd);
- FILE_USE(fp);
+ fp = fd_getfile(pap->fpfd);
error = dofilewrite(pap->fpfd, fp, buf, n,
&off, 0, &rv);
if (error == ENXIO)
diff --git a/sys/rump/librump/rumpkern/Makefile b/sys/rump/librump/rumpkern/Makefile
index 14c054526a3..5828bcf1f4b 100644
--- a/sys/rump/librump/rumpkern/Makefile
+++ b/sys/rump/librump/rumpkern/Makefile
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.31 2008/03/11 22:57:26 pooka Exp $
+# $NetBSD: Makefile,v 1.32 2008/03/21 21:55:01 ad Exp $
#
.include <bsd.own.mk>
@@ -21,7 +21,7 @@ SRCS+= fstrans_stub.c misc_stub.c pmap_stub.c vfsops_stub.c
# sys/kern
SRCS+= clock_subr.c kern_descrip.c kern_lock.c kern_stub.c param.c \
subr_bufq.c subr_hash.c subr_prf2.c subr_specificdata.c \
- subr_time.c subr_workqueue.c sys_generic.c vfs_bio.c \
+ subr_time.c subr_workqueue.c sys_descrip.c sys_generic.c vfs_bio.c \
vfs_cache.c vfs_getcwd.c vfs_hooks.c vfs_init.c vfs_lookup.c \
vfs_subr.c vfs_subr2.c vfs_vnops.c vfs_syscalls.c vnode_if.c
diff --git a/sys/rump/librump/rumpkern/emul.c b/sys/rump/librump/rumpkern/emul.c
index 0dca5f70cf9..985fabec4ca 100644
--- a/sys/rump/librump/rumpkern/emul.c
+++ b/sys/rump/librump/rumpkern/emul.c
@@ -1,4 +1,4 @@
-/* $NetBSD: emul.c,v 1.32 2008/03/19 00:40:34 bjs Exp $ */
+/* $NetBSD: emul.c,v 1.33 2008/03/21 21:55:01 ad Exp $ */
/*
* Copyright (c) 2007 Antti Kantee. All Rights Reserved.
@@ -458,7 +458,7 @@ sigispending(struct lwp *l, int signo)
}
void
-knote_fdclose(struct lwp *l, int fd)
+knote_fdclose(int fd)
{
/* since we don't add knotes, we don't have to remove them */
diff --git a/sys/rump/librump/rumpkern/rump.c b/sys/rump/librump/rumpkern/rump.c
index 58238ef187a..07cdc5680af 100644
--- a/sys/rump/librump/rumpkern/rump.c
+++ b/sys/rump/librump/rumpkern/rump.c
@@ -1,4 +1,4 @@
-/* $NetBSD: rump.c,v 1.39 2008/03/18 15:16:22 pooka Exp $ */
+/* $NetBSD: rump.c,v 1.40 2008/03/21 21:55:01 ad Exp $ */
/*
* Copyright (c) 2007 Antti Kantee. All Rights Reserved.
@@ -45,13 +45,13 @@
#include "rump_private.h"
#include "rumpuser.h"
-struct proc rump_proc;
+struct proc proc0;
struct cwdinfo rump_cwdi;
struct pstats rump_stats;
struct plimit rump_limits;
kauth_cred_t rump_cred = RUMPCRED_SUSER;
struct cpu_info rump_cpu;
-struct filedesc0 rump_filedesc0;
+struct filedesc rump_filedesc0;
struct proclist allproc;
kmutex_t rump_giantlock;
@@ -102,12 +102,12 @@ rump_init()
rw_init(&rump_cwdi.cwdi_lock);
l = &lwp0;
- p = &rump_proc;
+ p = &proc0;
p->p_stats = &rump_stats;
p->p_cwdi = &rump_cwdi;
p->p_limit = &rump_limits;
p->p_pid = 0;
- p->p_fd = &rump_filedesc0.fd_fd;
+ p->p_fd = &rump_filedesc0;
p->p_vmspace = &rump_vmspace;
l->l_cred = rump_cred;
l->l_proc = p;
@@ -124,9 +124,9 @@ rump_init()
syncdelay = 0;
dovfsusermount = 1;
- filedesc_init();
vfsinit();
bufinit();
+ fd_sys_init();
selsysinit();
rumpvfs_init();
@@ -148,9 +148,8 @@ rump_init()
sigemptyset(&sigcantmask);
+ fd_init(&rump_filedesc0);
rump_cwdi.cwdi_cdir = rootvnode;
-
- fdinit1(&rump_filedesc0);
}
struct mount *
@@ -629,7 +628,7 @@ rump_setup_curlwp(pid_t pid, lwpid_t lid, int set)
l = kmem_zalloc(sizeof(struct lwp), KM_SLEEP);
p = kmem_zalloc(sizeof(struct proc), KM_SLEEP);
- p->p_cwdi = cwdinit(&rump_proc);
+ p->p_cwdi = cwdinit();
p->p_stats = &rump_stats;
p->p_limit = &rump_limits;
@@ -639,7 +638,8 @@ rump_setup_curlwp(pid_t pid, lwpid_t lid, int set)
l->l_proc = p;
l->l_lid = lid;
- p->p_fd = fdinit(NULL);
+ p->p_fd = fd_init(&rump_filedesc0);
+ l->l_fd = p->p_fd;
if (set)
rumpuser_set_curlwp(l);
@@ -653,7 +653,7 @@ rump_clear_curlwp()
struct lwp *l;
l = rumpuser_get_curlwp();
- fdfree(l);
+ fd_free();
cwdfree(l->l_proc->p_cwdi);
kmem_free(l->l_proc, sizeof(*l->l_proc));
kmem_free(l, sizeof(*l));
diff --git a/sys/sys/cpu_data.h b/sys/sys/cpu_data.h
index e6d889a2727..9f66c705cfe 100644
--- a/sys/sys/cpu_data.h
+++ b/sys/sys/cpu_data.h
@@ -1,7 +1,7 @@
-/* $NetBSD: cpu_data.h,v 1.17 2008/03/11 02:24:43 ad Exp $ */
+/* $NetBSD: cpu_data.h,v 1.18 2008/03/21 21:55:01 ad Exp $ */
/*-
- * Copyright (c) 2004, 2006, 2007 The NetBSD Foundation, Inc.
+ * Copyright (c) 2004, 2006, 2007, 2008 The NetBSD Foundation, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/sys/sys/lwp.h b/sys/sys/lwp.h
index fffb12569ec..2536d5b5d36 100644
--- a/sys/sys/lwp.h
+++ b/sys/sys/lwp.h
@@ -1,4 +1,4 @@
-/* $NetBSD: lwp.h,v 1.80 2008/03/17 16:54:51 ad Exp $ */
+/* $NetBSD: lwp.h,v 1.81 2008/03/21 21:55:01 ad Exp $ */
/*-
* Copyright (c) 2001, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -153,6 +153,7 @@ struct lwp {
void *l_private; /* !: svr4-style lwp-private data */
struct lwp *l_switchto; /* !: mi_switch: switch to this LWP */
struct kauth_cred *l_cred; /* !: cached credentials */
+ struct filedesc *l_fd; /* !: cached copy of proc::p_fd */
void *l_emuldata; /* !: kernel lwp-private data */
u_int l_cv_signalled; /* c: restarted by cv_signal() */
u_short l_shlocks; /* !: lockdebug: shared locks held */
diff --git a/sys/sys/socketvar.h b/sys/sys/socketvar.h
index f747e99c94f..f1660b0189b 100644
--- a/sys/sys/socketvar.h
+++ b/sys/sys/socketvar.h
@@ -1,4 +1,4 @@
-/* $NetBSD: socketvar.h,v 1.103 2008/03/20 19:23:15 ad Exp $ */
+/* $NetBSD: socketvar.h,v 1.104 2008/03/21 21:55:01 ad Exp $ */
/*-
* Copyright (c) 1982, 1986, 1990, 1993
@@ -276,14 +276,14 @@ struct mbuf *getsombuf(struct socket *, int);
/*
* File operations on sockets.
*/
-int soo_read(struct file *, off_t *, struct uio *, kauth_cred_t, int);
-int soo_write(struct file *, off_t *, struct uio *, kauth_cred_t, int);
-int soo_fcntl(struct file *, u_int cmd, void *, struct lwp *);
-int soo_ioctl(struct file *, u_long cmd, void *, struct lwp *);
-int soo_poll(struct file *, int, struct lwp *);
-int soo_kqfilter(struct file *, struct knote *);
-int soo_close(struct file *, struct lwp *);
-int soo_stat(struct file *, struct stat *, struct lwp *);
+int soo_read(file_t *, off_t *, struct uio *, kauth_cred_t, int);
+int soo_write(file_t *, off_t *, struct uio *, kauth_cred_t, int);
+int soo_fcntl(file_t *, u_int cmd, void *);
+int soo_ioctl(file_t *, u_long cmd, void *);
+int soo_poll(file_t *, int);
+int soo_kqfilter(file_t *, struct knote *);
+int soo_close(file_t *);
+int soo_stat(file_t *, struct stat *);
void sbappend(struct sockbuf *, struct mbuf *);
void sbappendstream(struct sockbuf *, struct mbuf *);
int sbappendaddr(struct sockbuf *, const struct sockaddr *, struct mbuf *,
diff --git a/sys/sys/vfs_syscalls.h b/sys/sys/vfs_syscalls.h
index c0bfe37fa7a..142ce3cc14f 100644
--- a/sys/sys/vfs_syscalls.h
+++ b/sys/sys/vfs_syscalls.h
@@ -1,4 +1,4 @@
-/* $NetBSD: vfs_syscalls.h,v 1.6 2008/03/11 20:40:58 pooka Exp $ */
+/* $NetBSD: vfs_syscalls.h,v 1.7 2008/03/21 21:55:01 ad Exp $ */
#ifndef _SYS_VFS_SYSCALLS_H_
#define _SYS_VFS_SYSCALLS_H_
@@ -13,7 +13,7 @@ extern int dovfsusermount;
*/
/* Status functions to kernel 'struct stat' buffers */
-int do_sys_stat(struct lwp *, const char *, unsigned int, struct stat *);
+int do_sys_stat(const char *, unsigned int, struct stat *);
int do_fhstat(struct lwp *, const void *, size_t, struct stat *);
int do_fhstatvfs(struct lwp *, const void *, size_t, struct statvfs *, int);
diff --git a/sys/sys/vnode.h b/sys/sys/vnode.h
index c798ebbef0d..da13a4f40d9 100644
--- a/sys/sys/vnode.h
+++ b/sys/sys/vnode.h
@@ -1,4 +1,4 @@
-/* $NetBSD: vnode.h,v 1.190 2008/02/05 14:19:52 ad Exp $ */
+/* $NetBSD: vnode.h,v 1.191 2008/03/21 21:55:01 ad Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -626,7 +626,7 @@ void vn_init1(void);
/* see vnsubr(9) */
int vn_bwrite(void *);
-int vn_close(struct vnode *, int, kauth_cred_t, struct lwp *);
+int vn_close(struct vnode *, int, kauth_cred_t);
int vn_isunder(struct vnode *, struct vnode *, struct lwp *);
int vn_lock(struct vnode *, int);
void vn_markexec(struct vnode *);
@@ -638,7 +638,7 @@ int vn_readdir(struct file *, char *, int, u_int, int *, struct lwp *,
off_t **, int *);
void vn_restorerecurse(struct vnode *, u_int);
u_int vn_setrecurse(struct vnode *);
-int vn_stat(struct vnode *, struct stat *, struct lwp *);
+int vn_stat(struct vnode *, struct stat *);
int vn_kqfilter(struct file *, struct knote *);
int vn_writechk(struct vnode *);
int vn_openchk(struct vnode *, kauth_cred_t, int);
@@ -661,7 +661,7 @@ int vlockmgr(struct vnlock *, int);
int vlockstatus(struct vnlock *);
/* from vfs_syscalls.c - abused by compat code */
-int getvnode(struct filedesc *, int, struct file **);
+int getvnode(int, struct file **);
/* see vfssubr(9) */
void vfs_getnewfsid(struct mount *);
diff --git a/sys/ufs/ufs/ufs_extattr.c b/sys/ufs/ufs/ufs_extattr.c
index 7e404c80ecd..43d0c3cf0bd 100644
--- a/sys/ufs/ufs/ufs_extattr.c
+++ b/sys/ufs/ufs/ufs_extattr.c
@@ -1,4 +1,4 @@
-/* $NetBSD: ufs_extattr.c,v 1.20 2008/01/30 14:54:01 ad Exp $ */
+/* $NetBSD: ufs_extattr.c,v 1.21 2008/03/21 21:55:01 ad Exp $ */
/*-
* Copyright (c) 1999-2002 Robert N. M. Watson
@@ -48,7 +48,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ufs_extattr.c,v 1.20 2008/01/30 14:54:01 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ufs_extattr.c,v 1.21 2008/03/21 21:55:01 ad Exp $");
#include "opt_ffs.h"
@@ -330,7 +330,7 @@ ufs_extattr_enable_with_open(struct ufsmount *ump, struct vnode *vp,
error = ufs_extattr_enable(ump, attrnamespace, attrname, vp, l);
if (error != 0)
- vn_close(vp, FREAD|FWRITE, l->l_cred, l);
+ vn_close(vp, FREAD|FWRITE, l->l_cred);
return (error);
}
@@ -692,7 +692,7 @@ ufs_extattr_disable(struct ufsmount *ump, int attrnamespace,
LIST_REMOVE(uele, uele_entries);
error = vn_close(uele->uele_backing_vnode, FREAD|FWRITE,
- l->l_cred, l);
+ l->l_cred);
free(uele, M_UFS_EXTATTR);
diff --git a/sys/ufs/ufs/ufs_quota.c b/sys/ufs/ufs/ufs_quota.c
index 145d4d4142a..484b1e2392a 100644
--- a/sys/ufs/ufs/ufs_quota.c
+++ b/sys/ufs/ufs/ufs_quota.c
@@ -1,4 +1,4 @@
-/* $NetBSD: ufs_quota.c,v 1.58 2008/01/25 14:16:41 ad Exp $ */
+/* $NetBSD: ufs_quota.c,v 1.59 2008/03/21 21:55:01 ad Exp $ */
/*
* Copyright (c) 1982, 1986, 1990, 1993, 1995
@@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ufs_quota.c,v 1.58 2008/01/25 14:16:41 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ufs_quota.c,v 1.59 2008/03/21 21:55:01 ad Exp $");
#include <sys/param.h>
#include <sys/kernel.h>
@@ -424,7 +424,7 @@ quotaon(struct lwp *l, struct mount *mp, int type, void *fname)
vp = nd.ni_vp;
VOP_UNLOCK(vp, 0);
if (vp->v_type != VREG) {
- (void) vn_close(vp, FREAD|FWRITE, l->l_cred, l);
+ (void) vn_close(vp, FREAD|FWRITE, l->l_cred);
return (EACCES);
}
if (*vpp != vp)
@@ -560,7 +560,7 @@ again:
dqflush(qvp);
#endif
qvp->v_vflag &= ~VV_SYSTEM;
- error = vn_close(qvp, FREAD|FWRITE, l->l_cred, l);
+ error = vn_close(qvp, FREAD|FWRITE, l->l_cred);
mutex_enter(&dqlock);
ump->um_quotas[type] = NULLVP;
cred = ump->um_cred[type];
diff --git a/sys/uvm/uvm_mmap.c b/sys/uvm/uvm_mmap.c
index 04e95063fa2..fe06ac3f24c 100644
--- a/sys/uvm/uvm_mmap.c
+++ b/sys/uvm/uvm_mmap.c
@@ -1,4 +1,4 @@
-/* $NetBSD: uvm_mmap.c,v 1.121 2008/01/02 11:49:18 ad Exp $ */
+/* $NetBSD: uvm_mmap.c,v 1.122 2008/03/21 21:55:01 ad Exp $ */
/*
* Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -51,7 +51,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uvm_mmap.c,v 1.121 2008/01/02 11:49:18 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_mmap.c,v 1.122 2008/03/21 21:55:01 ad Exp $");
#include "opt_compat_netbsd.h"
#include "opt_pax.h"
@@ -307,7 +307,6 @@ sys_mmap(struct lwp *l, const struct sys_mmap_args *uap, register_t *retval)
vm_prot_t prot, maxprot;
int flags, fd;
vaddr_t defaddr;
- struct filedesc *fdp = p->p_fd;
struct file *fp = NULL;
struct vnode *vp;
void *handle;
@@ -386,26 +385,24 @@ sys_mmap(struct lwp *l, const struct sys_mmap_args *uap, register_t *retval)
*/
if ((flags & MAP_ANON) == 0) {
-
- if ((fp = fd_getfile(fdp, fd)) == NULL)
+ if ((fp = fd_getfile(fd)) == NULL)
return (EBADF);
if (fp->f_type != DTYPE_VNODE) {
- mutex_exit(&fp->f_lock);
+ fd_putfile(fd);
return (ENODEV); /* only mmap vnodes! */
}
- vp = (struct vnode *)fp->f_data; /* convert to vnode */
-
+ vp = fp->f_data; /* convert to vnode */
if (vp->v_type != VREG && vp->v_type != VCHR &&
vp->v_type != VBLK) {
- mutex_exit(&fp->f_lock);
+ fd_putfile(fd);
return (ENODEV); /* only REG/CHR/BLK support mmap */
}
if (vp->v_type != VCHR && pos < 0) {
- mutex_exit(&fp->f_lock);
+ fd_putfile(fd);
return (EINVAL);
}
if (vp->v_type != VCHR && (pos + size) < pos) {
- mutex_exit(&fp->f_lock);
+ fd_putfile(fd);
return (EOVERFLOW); /* no offset wrapping */
}
@@ -413,7 +410,7 @@ sys_mmap(struct lwp *l, const struct sys_mmap_args *uap, register_t *retval)
if (vp->v_type == VCHR
&& (vp->v_rdev == zerodev || COMPAT_ZERODEV(vp->v_rdev))) {
flags |= MAP_ANON;
- mutex_exit(&fp->f_lock);
+ fd_putfile(fd);
fp = NULL;
goto is_anon;
}
@@ -456,10 +453,9 @@ sys_mmap(struct lwp *l, const struct sys_mmap_args *uap, register_t *retval)
if (fp->f_flag & FREAD)
maxprot |= VM_PROT_READ;
else if (prot & PROT_READ) {
- mutex_exit(&fp->f_lock);
+ fd_putfile(fd);
return (EACCES);
}
- FILE_USE(fp);
/* check write access, shared case first */
if (flags & MAP_SHARED) {
@@ -472,19 +468,19 @@ sys_mmap(struct lwp *l, const struct sys_mmap_args *uap, register_t *retval)
if (fp->f_flag & FWRITE) {
if ((error =
VOP_GETATTR(vp, &va, l->l_cred))) {
- FILE_UNUSE(fp, l);
+ fd_putfile(fd);
return (error);
}
if ((va.va_flags &
(SF_SNAPSHOT|IMMUTABLE|APPEND)) == 0)
maxprot |= VM_PROT_WRITE;
else if (prot & PROT_WRITE) {
- FILE_UNUSE(fp, l);
+ fd_putfile(fd);
return (EPERM);
}
}
else if (prot & PROT_WRITE) {
- FILE_UNUSE(fp, l);
+ fd_putfile(fd);
return (EACCES);
}
} else {
@@ -519,7 +515,7 @@ sys_mmap(struct lwp *l, const struct sys_mmap_args *uap, register_t *retval)
(p->p_rlimit[RLIMIT_DATA].rlim_cur -
ctob(p->p_vmspace->vm_dsize))) {
if (fp != NULL)
- FILE_UNUSE(fp, l);
+ fd_putfile(fd);
return (ENOMEM);
}
}
@@ -541,7 +537,7 @@ sys_mmap(struct lwp *l, const struct sys_mmap_args *uap, register_t *retval)
*/
if (prot & VM_PROT_EXECUTE) {
if (fp != NULL)
- FILE_UNUSE(fp, l);
+ fd_putfile(fd);
return (EPERM);
}
@@ -574,7 +570,7 @@ sys_mmap(struct lwp *l, const struct sys_mmap_args *uap, register_t *retval)
*retval = (register_t)(addr + pageoff);
if (fp != NULL)
- FILE_UNUSE(fp, l);
+ fd_putfile(fd);
return (error);
}