summaryrefslogtreecommitdiffstats
path: root/sys/kern/vfs_vnops.c
diff options
context:
space:
mode:
authorgreen <green@FreeBSD.org>1999-09-19 17:00:25 +0000
committergreen <green@FreeBSD.org>1999-09-19 17:00:25 +0000
commit140cb4ff83b0061eeba0756f708f3f7c117e76e5 (patch)
treedbfb58e46547ab96401ba9719626c5b12448fbfd /sys/kern/vfs_vnops.c
parentc171f3b18205ec5324a32cba54aff58ae5594701 (diff)
downloadFreeBSD-src-140cb4ff83b0061eeba0756f708f3f7c117e76e5.zip
FreeBSD-src-140cb4ff83b0061eeba0756f708f3f7c117e76e5.tar.gz
This is what was "fdfix2.patch," a fix for fd sharing. It's pretty
far-reaching in fd-land, so you'll want to consult the code for changes. The biggest change is that now, you don't use fp->f_ops->fo_foo(fp, bar) but instead fo_foo(fp, bar), which increments and decrements the fp refcount upon entry and exit. Two new calls, fhold() and fdrop(), are provided. Each does what it seems like it should, and if fdrop() brings the refcount to zero, the fd is freed as well. Thanks to peter ("to hell with it, it looks ok to me.") for his review. Thanks to msmith for keeping me from putting locks everywhere :) Reviewed by: peter
Diffstat (limited to 'sys/kern/vfs_vnops.c')
-rw-r--r--sys/kern/vfs_vnops.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c
index c42ebf6..242c696 100644
--- a/sys/kern/vfs_vnops.c
+++ b/sys/kern/vfs_vnops.c
@@ -57,11 +57,11 @@ static int vn_closefile __P((struct file *fp, struct proc *p));
static int vn_ioctl __P((struct file *fp, u_long com, caddr_t data,
struct proc *p));
static int vn_read __P((struct file *fp, struct uio *uio,
- struct ucred *cred, int flags));
+ struct ucred *cred, int flags, struct proc *p));
static int vn_poll __P((struct file *fp, int events, struct ucred *cred,
struct proc *p));
static int vn_write __P((struct file *fp, struct uio *uio,
- struct ucred *cred, int flags));
+ struct ucred *cred, int flags, struct proc *p));
struct fileops vnops =
{ vn_read, vn_write, vn_ioctl, vn_poll, vn_closefile };
@@ -274,16 +274,19 @@ vn_rdwr(rw, vp, base, len, offset, segflg, ioflg, cred, aresid, p)
* File table vnode read routine.
*/
static int
-vn_read(fp, uio, cred, flags)
+vn_read(fp, uio, cred, flags, p)
struct file *fp;
struct uio *uio;
struct ucred *cred;
+ struct proc *p;
int flags;
{
- struct vnode *vp = (struct vnode *)fp->f_data;
- struct proc *p = uio->uio_procp;
+ struct vnode *vp;
int error, ioflag;
+ KASSERT(uio->uio_procp == p, ("uio_procp %p is not p %p",
+ uio->uio_procp, p));
+ vp = (struct vnode *)fp->f_data;
ioflag = 0;
if (fp->f_flag & FNONBLOCK)
ioflag |= IO_NDELAY;
@@ -330,16 +333,18 @@ vn_read(fp, uio, cred, flags)
* File table vnode write routine.
*/
static int
-vn_write(fp, uio, cred, flags)
+vn_write(fp, uio, cred, flags, p)
struct file *fp;
struct uio *uio;
struct ucred *cred;
+ struct proc *p;
int flags;
{
struct vnode *vp;
- struct proc *p = uio->uio_procp;
int error, ioflag;
+ KASSERT(uio->uio_procp == p, ("uio_procp %p is not p %p",
+ uio->uio_procp, p));
vp = (struct vnode *)fp->f_data;
if (vp->v_type == VREG)
bwillwrite();
OpenPOWER on IntegriCloud