summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArtur Grabowski <art@cvs.openbsd.org>2002-02-08 19:58:04 +0000
committerArtur Grabowski <art@cvs.openbsd.org>2002-02-08 19:58:04 +0000
commit74cc050cba69fd95ad311bc915741efce4b47d3c (patch)
tree9dde8b04740cba2c7ca53c8a9ca2f3a415e6ac92
parenta607d18f17b443a4486125b5d45d69f8b16fc454 (diff)
Require a FREFd file in dofilewrite{,v}.
-rw-r--r--sys/kern/sys_generic.c12
-rw-r--r--sys/kern/vfs_syscalls.c26
2 files changed, 20 insertions, 18 deletions
diff --git a/sys/kern/sys_generic.c b/sys/kern/sys_generic.c
index e1242ccae00..08c3776d51e 100644
--- a/sys/kern/sys_generic.c
+++ b/sys/kern/sys_generic.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sys_generic.c,v 1.35 2002/02/08 19:47:50 art Exp $ */
+/* $OpenBSD: sys_generic.c,v 1.36 2002/02/08 19:58:03 art Exp $ */
/* $NetBSD: sys_generic.c,v 1.24 1996/03/29 00:25:32 cgd Exp $ */
/*
@@ -302,7 +302,9 @@ sys_write(p, v, retval)
if ((fp->f_flag & FWRITE) == 0)
return (EBADF);
- /* dofilewrite() will unuse the descriptor for us */
+ FREF(fp);
+
+ /* dofilewrite() will FRELE the descriptor for us */
return (dofilewrite(p, fd, fp, SCARG(uap, buf), SCARG(uap, nbyte),
&fp->f_offset, retval));
}
@@ -366,6 +368,7 @@ dofilewrite(p, fd, fp, buf, nbyte, offset, retval)
#endif
*retval = cnt;
out:
+ FRELE(fp);
return (error);
}
@@ -392,7 +395,9 @@ sys_writev(p, v, retval)
if ((fp->f_flag & FWRITE) == 0)
return (EBADF);
- /* dofilewritev() will unuse the descriptor for us */
+ FREF(fp);
+
+ /* dofilewritev() will FRELE the descriptor for us */
return (dofilewritev(p, fd, fp, SCARG(uap, iovp), SCARG(uap, iovcnt),
&fp->f_offset, retval));
}
@@ -485,6 +490,7 @@ dofilewritev(p, fd, fp, iovp, iovcnt, offset, retval)
if (needfree)
free(needfree, M_IOV);
out:
+ FRELE(fp);
return (error);
}
diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c
index 0ee7ac2dbb7..feba23580aa 100644
--- a/sys/kern/vfs_syscalls.c
+++ b/sys/kern/vfs_syscalls.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vfs_syscalls.c,v 1.91 2002/02/08 19:47:50 art Exp $ */
+/* $OpenBSD: vfs_syscalls.c,v 1.92 2002/02/08 19:58:03 art Exp $ */
/* $NetBSD: vfs_syscalls.c,v 1.71 1996/04/23 10:29:02 mycroft Exp $ */
/*
@@ -2721,7 +2721,7 @@ sys_pwrite(p, v, retval)
struct file *fp;
struct vnode *vp;
off_t offset;
- int error, fd = SCARG(uap, fd);
+ int fd = SCARG(uap, fd);
if ((fp = fd_getfile(fdp, fd)) == NULL)
return (EBADF);
@@ -2730,18 +2730,16 @@ sys_pwrite(p, v, retval)
vp = (struct vnode *)fp->f_data;
if (fp->f_type != DTYPE_VNODE || vp->v_type == VFIFO) {
- error = ESPIPE;
- goto out;
+ return (ESPIPE);
}
+ FREF(fp);
+
offset = SCARG(uap, offset);
- /* dofilewrite() will unuse the descriptor for us */
+ /* dofilewrite() will FRELE the descriptor for us */
return (dofilewrite(p, fd, fp, SCARG(uap, buf), SCARG(uap, nbyte),
&offset, retval));
-
- out:
- return (error);
}
@@ -2765,7 +2763,7 @@ sys_pwritev(p, v, retval)
struct file *fp;
struct vnode *vp;
off_t offset;
- int error, fd = SCARG(uap, fd);
+ int fd = SCARG(uap, fd);
if ((fp = fd_getfile(fdp, fd)) == NULL)
return (EBADF);
@@ -2774,16 +2772,14 @@ sys_pwritev(p, v, retval)
vp = (struct vnode *)fp->f_data;
if (fp->f_type != DTYPE_VNODE || vp->v_type == VFIFO) {
- error = ESPIPE;
- goto out;
+ return (ESPIPE);
}
+ FREF(fp);
+
offset = SCARG(uap, offset);
- /* dofilewritev() will unuse the descriptor for us */
+ /* dofilewritev() will FRELE the descriptor for us */
return (dofilewritev(p, fd, fp, SCARG(uap, iovp), SCARG(uap, iovcnt),
&offset, retval));
-
- out:
- return (error);
}