summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/compat/common/vfs_syscalls_25.c11
-rw-r--r--sys/compat/common/vfs_syscalls_43.c15
-rw-r--r--sys/compat/freebsd/freebsd_file.c7
-rw-r--r--sys/compat/ibcs2/ibcs2_misc.c25
-rw-r--r--sys/compat/ibcs2/ibcs2_stat.c7
-rw-r--r--sys/compat/linux/linux_misc.c4
-rw-r--r--sys/compat/netbsd/netbsd_file.c7
-rw-r--r--sys/compat/netbsd/netbsd_getdents.c4
-rw-r--r--sys/compat/osf1/osf1_mount.c8
-rw-r--r--sys/compat/sunos/sunos_misc.c24
-rw-r--r--sys/compat/svr4/svr4_misc.c24
-rw-r--r--sys/compat/ultrix/ultrix_pathname.c7
-rw-r--r--sys/kern/vfs_syscalls.c55
-rw-r--r--sys/miscfs/fdesc/fdesc_vnops.c17
14 files changed, 146 insertions, 69 deletions
diff --git a/sys/compat/common/vfs_syscalls_25.c b/sys/compat/common/vfs_syscalls_25.c
index 03d01687d45..b073e1eaada 100644
--- a/sys/compat/common/vfs_syscalls_25.c
+++ b/sys/compat/common/vfs_syscalls_25.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vfs_syscalls_25.c,v 1.1 2001/05/16 17:14:38 millert Exp $ */
+/* $OpenBSD: vfs_syscalls_25.c,v 1.2 2002/02/12 18:41:20 art Exp $ */
/*
* Copyright (c) 1989, 1993
@@ -135,21 +135,24 @@ compat_25_sys_fstatfs(p, v, retval)
void *v;
register_t *retval;
{
- register struct compat_25_sys_fstatfs_args /* {
+ struct compat_25_sys_fstatfs_args /* {
syscallarg(int) fd;
syscallarg(struct ostatfs *) buf;
} */ *uap = v;
struct file *fp;
struct mount *mp;
- register struct statfs *sp;
+ struct statfs *sp;
struct ostatfs osb;
int error;
if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0)
return (error);
+ FREF(fp);
mp = ((struct vnode *)fp->f_data)->v_mount;
sp = &mp->mnt_stat;
- if ((error = VFS_STATFS(mp, sp, p)) != 0)
+ error = VFS_STATFS(mp, sp, p);
+ FRELE(fp);
+ if (error)
return (error);
statfs_to_ostatfs(p, mp, sp, &osb);
diff --git a/sys/compat/common/vfs_syscalls_43.c b/sys/compat/common/vfs_syscalls_43.c
index 976043be90c..e9ccc4c1e83 100644
--- a/sys/compat/common/vfs_syscalls_43.c
+++ b/sys/compat/common/vfs_syscalls_43.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vfs_syscalls_43.c,v 1.16 2001/11/06 19:53:17 miod Exp $ */
+/* $OpenBSD: vfs_syscalls_43.c,v 1.17 2002/02/12 18:41:20 art Exp $ */
/* $NetBSD: vfs_syscalls_43.c,v 1.4 1996/03/14 19:31:52 christos Exp $ */
/*
@@ -355,10 +355,13 @@ compat_43_sys_getdirentries(p, v, retval)
return (error);
if ((fp->f_flag & FREAD) == 0)
return (EBADF);
+ FREF(fp);
vp = (struct vnode *)fp->f_data;
unionread:
- if (vp->v_type != VDIR)
- return (EINVAL);
+ if (vp->v_type != VDIR) {
+ error = EINVAL;
+ goto bad;
+ }
aiov.iov_base = SCARG(uap, buf);
aiov.iov_len = SCARG(uap, count);
auio.uio_iov = &aiov;
@@ -428,13 +431,13 @@ unionread:
}
VOP_UNLOCK(vp, 0, p);
if (error)
- return (error);
+ goto bad;
if ((SCARG(uap, count) == auio.uio_resid) &&
union_check_p &&
(union_check_p(p, &vp, fp, auio, &error) != 0))
goto unionread;
if (error)
- return (error);
+ goto bad;
if ((SCARG(uap, count) == auio.uio_resid) &&
(vp->v_flag & VROOT) &&
@@ -450,5 +453,7 @@ unionread:
error = copyout((caddr_t)&loff, (caddr_t)SCARG(uap, basep),
sizeof(long));
*retval = SCARG(uap, count) - auio.uio_resid;
+bad:
+ FRELE(fp);
return (error);
}
diff --git a/sys/compat/freebsd/freebsd_file.c b/sys/compat/freebsd/freebsd_file.c
index 4ef1e246661..483dc4d94ba 100644
--- a/sys/compat/freebsd/freebsd_file.c
+++ b/sys/compat/freebsd/freebsd_file.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: freebsd_file.c,v 1.11 2001/10/26 12:03:27 art Exp $ */
+/* $OpenBSD: freebsd_file.c,v 1.12 2002/02/12 18:41:20 art Exp $ */
/* $NetBSD: freebsd_file.c,v 1.3 1996/05/03 17:03:09 christos Exp $ */
/*
@@ -623,7 +623,10 @@ freebsd_sys_fstatfs(p, v, retval)
return (error);
mp = ((struct vnode *)fp->f_data)->v_mount;
sp = &mp->mnt_stat;
- if ((error = VFS_STATFS(mp, sp, p)) != 0)
+ FREF(fp);
+ error = VFS_STATFS(mp, sp, p);
+ FRELE(fp);
+ if (error)
return (error);
sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
diff --git a/sys/compat/ibcs2/ibcs2_misc.c b/sys/compat/ibcs2/ibcs2_misc.c
index 8688ded925e..e22a525f44c 100644
--- a/sys/compat/ibcs2/ibcs2_misc.c
+++ b/sys/compat/ibcs2/ibcs2_misc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ibcs2_misc.c,v 1.19 2001/11/06 19:53:17 miod Exp $ */
+/* $OpenBSD: ibcs2_misc.c,v 1.20 2002/02/12 18:41:20 art Exp $ */
/* $NetBSD: ibcs2_misc.c,v 1.23 1997/01/15 01:37:49 perry Exp $ */
/*
@@ -434,15 +434,16 @@ ibcs2_sys_getdents(p, v, retval)
if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0)
return (error);
+ FREF(fp);
args.resid = SCARG(uap, nbytes);
args.outp = (caddr_t)SCARG(uap, buf);
-
- if ((error = readdir_with_callback(fp, &fp->f_offset, args.resid,
- ibcs2_readdir_callback, &args)) != 0)
+ error = readdir_with_callback(fp, &fp->f_offset, args.resid,
+ ibcs2_readdir_callback, &args)
+ FRELE(fp);
+ if (error)
return (error);
*retval = SCARG(uap, nbytes) - args.resid;
-
return (0);
}
@@ -474,15 +475,17 @@ ibcs2_sys_read(p, v, retval)
if (vp->v_type != VDIR)
return sys_read(p, uap, retval);
+ FREF(fp);
args.resid = SCARG(uap, nbytes);
args.outp = (caddr_t)SCARG(uap, buf);
-
- if ((error = readdir_with_callback(fp, &fp->f_offset, args.resid,
- ibcs2_classicread_callback, &args)) != 0)
+
+ error = readdir_with_callback(fp, &fp->f_offset, args.resid,
+ ibcs2_classicread_callback, &args);
+ FRELE(fp);
+ if (error)
return (error);
-
- *retval = SCARG(uap, nbytes) - args.resid;
-
+
+ *retval = SCARG(uap, nbytes) - args.resid;
return (0);
}
diff --git a/sys/compat/ibcs2/ibcs2_stat.c b/sys/compat/ibcs2/ibcs2_stat.c
index 97bba65505b..53c6b6b7c1a 100644
--- a/sys/compat/ibcs2/ibcs2_stat.c
+++ b/sys/compat/ibcs2/ibcs2_stat.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ibcs2_stat.c,v 1.6 2001/11/06 19:53:17 miod Exp $ */
+/* $OpenBSD: ibcs2_stat.c,v 1.7 2002/02/12 18:41:20 art Exp $ */
/* $NetBSD: ibcs2_stat.c,v 1.5 1996/05/03 17:05:32 christos Exp $ */
/*
@@ -149,7 +149,10 @@ ibcs2_sys_fstatfs(p, v, retval)
return (error);
mp = ((struct vnode *)fp->f_data)->v_mount;
sp = &mp->mnt_stat;
- if ((error = VFS_STATFS(mp, sp, p)) != 0)
+ FREF(fp);
+ error = VFS_STATFS(mp, sp, p);
+ FRELE(fp);
+ if (error)
return (error);
sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
return cvt_statfs(sp, (caddr_t)SCARG(uap, buf), SCARG(uap, len));
diff --git a/sys/compat/linux/linux_misc.c b/sys/compat/linux/linux_misc.c
index 091b1d7b089..15072100460 100644
--- a/sys/compat/linux/linux_misc.c
+++ b/sys/compat/linux/linux_misc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: linux_misc.c,v 1.39 2001/11/06 19:53:17 miod Exp $ */
+/* $OpenBSD: linux_misc.c,v 1.40 2002/02/12 18:41:20 art Exp $ */
/* $NetBSD: linux_misc.c,v 1.27 1996/05/20 01:59:21 fvdl Exp $ */
/*
@@ -1022,6 +1022,7 @@ linux_sys_getdents(p, v, retval)
args.resid = nbytes;
args.outp = (caddr_t)SCARG(uap, dirent);
+ FREF(fp);
if ((error = readdir_with_callback(fp, &fp->f_offset, nbytes,
linux_readdir_callback, &args)) != 0)
goto exit;
@@ -1029,6 +1030,7 @@ linux_sys_getdents(p, v, retval)
*retval = nbytes - args.resid;
exit:
+ FRELE(fp);
return (error);
}
diff --git a/sys/compat/netbsd/netbsd_file.c b/sys/compat/netbsd/netbsd_file.c
index 5fe0988a34c..61d19bd5c6a 100644
--- a/sys/compat/netbsd/netbsd_file.c
+++ b/sys/compat/netbsd/netbsd_file.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: netbsd_file.c,v 1.1 1999/09/17 22:14:09 kstailey Exp $ */
+/* $OpenBSD: netbsd_file.c,v 1.2 2002/02/12 18:41:20 art Exp $ */
/* $NetBSD: freebsd_file.c,v 1.3 1996/05/03 17:03:09 christos Exp $ */
/*
@@ -597,7 +597,10 @@ netbsd_sys_fstatfs(p, v, retval)
return (error);
mp = ((struct vnode *)fp->f_data)->v_mount;
sp = &mp->mnt_stat;
- if ((error = VFS_STATFS(mp, sp, p)) != 0)
+ FREF(fp);
+ error = VFS_STATFS(mp, sp, p);
+ FRELE(fp);
+ if (error)
return (error);
sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
diff --git a/sys/compat/netbsd/netbsd_getdents.c b/sys/compat/netbsd/netbsd_getdents.c
index aad9e1a2d45..7e92951d5e4 100644
--- a/sys/compat/netbsd/netbsd_getdents.c
+++ b/sys/compat/netbsd/netbsd_getdents.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: netbsd_getdents.c,v 1.4 2001/09/05 23:38:28 art Exp $ */
+/* $OpenBSD: netbsd_getdents.c,v 1.5 2002/02/12 18:41:20 art Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1993
@@ -167,9 +167,11 @@ netbsd_sys_getdents(p, v, retval)
return (error);
if ((fp->f_flag & FREAD) == 0)
return (EBADF);
+ FREF(fp);
error = netbsd_vn_readdir(fp, SCARG(uap, buf), UIO_USERSPACE,
SCARG(uap, count), &done, p, 0, 0);
*retval = done;
+ FRELE(fp);
return (error);
}
diff --git a/sys/compat/osf1/osf1_mount.c b/sys/compat/osf1/osf1_mount.c
index 2872db884eb..506d18bca6b 100644
--- a/sys/compat/osf1/osf1_mount.c
+++ b/sys/compat/osf1/osf1_mount.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: osf1_mount.c,v 1.5 2000/08/04 15:47:55 ericj Exp $ */
+/* $OpenBSD: osf1_mount.c,v 1.6 2002/02/12 18:41:20 art Exp $ */
/* $NetBSD: osf1_mount.c,v 1.14 1999/05/05 01:51:34 cgd Exp $ */
/*
@@ -117,12 +117,14 @@ osf1_sys_fstatfs(p, v, retval)
struct osf1_statfs osfs;
int error;
- /* getvnode() will use the descriptor for us */
if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)))
return (error);
mp = ((struct vnode *)fp->f_data)->v_mount;
sp = &mp->mnt_stat;
- if ((error = VFS_STATFS(mp, sp, p)))
+ FREF(fp);
+ error = VFS_STATFS(mp, sp, p);
+ FRELE(fp);
+ if (error)
goto out;
sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
osf1_cvt_statfs_from_native(sp, &osfs);
diff --git a/sys/compat/sunos/sunos_misc.c b/sys/compat/sunos/sunos_misc.c
index d3a4371c7f4..939288415d7 100644
--- a/sys/compat/sunos/sunos_misc.c
+++ b/sys/compat/sunos/sunos_misc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sunos_misc.c,v 1.32 2002/02/12 13:05:31 art Exp $ */
+/* $OpenBSD: sunos_misc.c,v 1.33 2002/02/12 18:41:21 art Exp $ */
/* $NetBSD: sunos_misc.c,v 1.65 1996/04/22 01:44:31 christos Exp $ */
/*
@@ -441,9 +441,12 @@ sunos_sys_getdents(p, v, retval)
args.resid = SCARG(uap, nbytes);
args.outp = (caddr_t)SCARG(uap, buf);
-
- if ((error = readdir_with_callback(fp, &fp->f_offset, args.resid,
- sunos_readdir_callback, &args)) != 0)
+
+ FREF(fp);
+ error = readdir_with_callback(fp, &fp->f_offset, args.resid,
+ sunos_readdir_callback, &args);
+ FRELE(fp);
+ if (error)
return (error);
*retval = SCARG(uap, nbytes) - args.resid;
@@ -594,18 +597,22 @@ sunos_sys_fchroot(p, v, retval)
if ((error = getvnode(fdp, SCARG(uap, fd), &fp)) != 0)
return (error);
vp = (struct vnode *)fp->f_data;
+ FREF(fp);
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p);
if (vp->v_type != VDIR)
error = ENOTDIR;
else
error = VOP_ACCESS(vp, VEXEC, p->p_ucred, p);
VOP_UNLOCK(vp, 0, p);
- if (error)
+ if (error) {
+ FRELE(fp);
return (error);
+ }
VREF(vp);
if (fdp->fd_rdir != NULL)
vrele(fdp->fd_rdir);
fdp->fd_rdir = vp;
+ FRELE(fp);
return (0);
}
@@ -849,14 +856,17 @@ sunos_sys_fstatfs(p, v, retval)
struct sunos_sys_fstatfs_args *uap = v;
struct file *fp;
struct mount *mp;
- register struct statfs *sp;
+ struct statfs *sp;
int error;
if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0)
return (error);
mp = ((struct vnode *)fp->f_data)->v_mount;
sp = &mp->mnt_stat;
- if ((error = VFS_STATFS(mp, sp, p)) != 0)
+ FREF(fp);
+ error = VFS_STATFS(mp, sp, p);
+ FRELE(fp);
+ if (error)
return (error);
sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
return sunstatfs(sp, (caddr_t)SCARG(uap, buf));
diff --git a/sys/compat/svr4/svr4_misc.c b/sys/compat/svr4/svr4_misc.c
index 99d911bdcf1..4eebd06f5af 100644
--- a/sys/compat/svr4/svr4_misc.c
+++ b/sys/compat/svr4/svr4_misc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: svr4_misc.c,v 1.38 2001/11/28 13:47:39 art Exp $ */
+/* $OpenBSD: svr4_misc.c,v 1.39 2002/02/12 18:41:21 art Exp $ */
/* $NetBSD: svr4_misc.c,v 1.42 1996/12/06 03:22:34 christos Exp $ */
/*
@@ -304,9 +304,12 @@ svr4_sys_getdents(p, v, retval)
args.resid = SCARG(uap, nbytes);
args.outp = (caddr_t)SCARG(uap, buf);
-
- if ((error = readdir_with_callback(fp, &fp->f_offset, SCARG(uap, nbytes),
- svr4_readdir_callback, &args)) != 0)
+
+ FREF(fp);
+ error = readdir_with_callback(fp, &fp->f_offset, SCARG(uap, nbytes),
+ svr4_readdir_callback, &args);
+ FRELE(fp);
+ if (error)
return (error);
*retval = SCARG(uap, nbytes) - args.resid;
@@ -330,9 +333,12 @@ svr4_sys_getdents64(p, v, retval)
args.resid = SCARG(uap, nbytes);
args.outp = (caddr_t)SCARG(uap, dp);
-
- if ((error = readdir_with_callback(fp, &fp->f_offset, SCARG(uap, nbytes),
+
+ FREF(fp);
+ error = readdir_with_callback(fp, &fp->f_offset, SCARG(uap, nbytes),
svr4_readdir64_callback, &args)) != 0)
+ FRELE(fp);
+ if (error)
return (error);
*retval = SCARG(uap, nbytes) - args.resid;
@@ -424,6 +430,7 @@ svr4_sys_fchroot(p, v, retval)
return error;
if ((error = getvnode(fdp, SCARG(uap, fd), &fp)) != 0)
return error;
+ FREF(fp);
vp = (struct vnode *) fp->f_data;
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p);
if (vp->v_type != VDIR)
@@ -431,12 +438,15 @@ svr4_sys_fchroot(p, v, retval)
else
error = VOP_ACCESS(vp, VEXEC, p->p_ucred, p);
VOP_UNLOCK(vp, 0, p);
- if (error)
+ if (error) {
+ FRELE(fp);
return error;
+ }
VREF(vp);
if (fdp->fd_rdir != NULL)
vrele(fdp->fd_rdir);
fdp->fd_rdir = vp;
+ FRELE(fp);
return 0;
}
diff --git a/sys/compat/ultrix/ultrix_pathname.c b/sys/compat/ultrix/ultrix_pathname.c
index b4e55576064..1073053c24c 100644
--- a/sys/compat/ultrix/ultrix_pathname.c
+++ b/sys/compat/ultrix/ultrix_pathname.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ultrix_pathname.c,v 1.5 2002/02/02 16:05:58 art Exp $ */
+/* $OpenBSD: ultrix_pathname.c,v 1.6 2002/02/12 18:41:21 art Exp $ */
/* $NetBSD: ultrix_pathname.c,v 1.2 1996/04/07 17:23:07 jonathan Exp $ */
/*
@@ -282,9 +282,12 @@ ultrix_sys_fstatfs(p, v, retval)
if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0)
return (error);
+ FREF(fp);
mp = ((struct vnode *)fp->f_data)->v_mount;
sp = &mp->mnt_stat;
- if ((error = VFS_STATFS(mp, sp, p)) != 0)
+ error = VFS_STATFS(mp, sp, p);
+ FRELE(fp);
+ if (error)
return (error);
sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
return ultrixstatfs(sp, (caddr_t)SCARG(uap, buf));
diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c
index feba23580aa..b4aeb2e150c 100644
--- a/sys/kern/vfs_syscalls.c
+++ b/sys/kern/vfs_syscalls.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vfs_syscalls.c,v 1.92 2002/02/08 19:58:03 art Exp $ */
+/* $OpenBSD: vfs_syscalls.c,v 1.93 2002/02/12 18:41:21 art Exp $ */
/* $NetBSD: vfs_syscalls.c,v 1.71 1996/04/23 10:29:02 mycroft Exp $ */
/*
@@ -604,13 +604,13 @@ sys_fstatfs(p, v, retval)
void *v;
register_t *retval;
{
- register struct sys_fstatfs_args /* {
+ struct sys_fstatfs_args /* {
syscallarg(int) fd;
syscallarg(struct statfs *) buf;
} */ *uap = v;
struct file *fp;
struct mount *mp;
- register struct statfs *sp;
+ struct statfs *sp;
int error;
struct statfs sb;
@@ -618,7 +618,10 @@ sys_fstatfs(p, v, retval)
return (error);
mp = ((struct vnode *)fp->f_data)->v_mount;
sp = &mp->mnt_stat;
- if ((error = VFS_STATFS(mp, sp, p)) != 0)
+ FREF(fp);
+ error = VFS_STATFS(mp, sp, p);
+ FRELE(fp);
+ if (error)
return (error);
sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
#if notyet
@@ -723,7 +726,7 @@ sys_fchdir(p, v, retval)
struct sys_fchdir_args /* {
syscallarg(int) fd;
} */ *uap = v;
- register struct filedesc *fdp = p->p_fd;
+ struct filedesc *fdp = p->p_fd;
struct vnode *vp, *tdp;
struct mount *mp;
struct file *fp;
@@ -731,6 +734,7 @@ sys_fchdir(p, v, retval)
if ((error = getvnode(fdp, SCARG(uap, fd), &fp)) != 0)
return (error);
+ /* No need to FREF/FRELE since we VREF the vnode here. */
vp = (struct vnode *)fp->f_data;
VREF(vp);
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p);
@@ -1800,7 +1804,7 @@ sys_fchflags(p, v, retval)
void *v;
register_t *retval;
{
- register struct sys_fchflags_args /* {
+ struct sys_fchflags_args /* {
syscallarg(int) fd;
syscallarg(unsigned int) flags;
} */ *uap = v;
@@ -1811,6 +1815,7 @@ sys_fchflags(p, v, retval)
if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0)
return (error);
+ FREF(fp);
vp = (struct vnode *)fp->f_data;
VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE);
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p);
@@ -1834,6 +1839,7 @@ sys_fchflags(p, v, retval)
}
out:
VOP_UNLOCK(vp, 0, p);
+ FRELE(fp);
return (error);
}
@@ -1886,7 +1892,7 @@ sys_fchmod(p, v, retval)
void *v;
register_t *retval;
{
- register struct sys_fchmod_args /* {
+ struct sys_fchmod_args /* {
syscallarg(int) fd;
syscallarg(int) mode;
} */ *uap = v;
@@ -1900,6 +1906,7 @@ sys_fchmod(p, v, retval)
if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0)
return (error);
+ FREF(fp);
vp = (struct vnode *)fp->f_data;
VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE);
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p);
@@ -1911,6 +1918,7 @@ sys_fchmod(p, v, retval)
error = VOP_SETATTR(vp, &vattr, p->p_ucred, p);
}
VOP_UNLOCK(vp, 0, p);
+ FRELE(fp);
return (error);
}
@@ -2028,12 +2036,12 @@ sys_fchown(p, v, retval)
void *v;
register_t *retval;
{
- register struct sys_fchown_args /* {
+ struct sys_fchown_args /* {
syscallarg(int) fd;
syscallarg(int) uid;
syscallarg(int) gid;
} */ *uap = v;
- register struct vnode *vp;
+ struct vnode *vp;
struct vattr vattr;
int error;
struct file *fp;
@@ -2041,6 +2049,7 @@ sys_fchown(p, v, retval)
if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0)
return (error);
+ FREF(fp);
vp = (struct vnode *)fp->f_data;
VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE);
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p);
@@ -2065,6 +2074,7 @@ sys_fchown(p, v, retval)
}
out:
VOP_UNLOCK(vp, 0, p);
+ FRELE(fp);
return (error);
}
@@ -2138,7 +2148,7 @@ sys_futimes(p, v, retval)
syscallarg(int) fd;
syscallarg(struct timeval *) tptr;
} */ *uap = v;
- register struct vnode *vp;
+ struct vnode *vp;
struct timeval tv[2];
struct vattr vattr;
int error;
@@ -2162,6 +2172,7 @@ sys_futimes(p, v, retval)
}
if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0)
return (error);
+ FREF(fp);
vp = (struct vnode *)fp->f_data;
VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE);
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p);
@@ -2175,6 +2186,7 @@ sys_futimes(p, v, retval)
error = VOP_SETATTR(vp, &vattr, p->p_ucred, p);
}
VOP_UNLOCK(vp, 0, p);
+ FRELE(fp);
return (error);
}
@@ -2226,7 +2238,7 @@ sys_ftruncate(p, v, retval)
void *v;
register_t *retval;
{
- register struct sys_ftruncate_args /* {
+ struct sys_ftruncate_args /* {
syscallarg(int) fd;
syscallarg(int) pad;
syscallarg(off_t) length;
@@ -2240,6 +2252,7 @@ sys_ftruncate(p, v, retval)
return (error);
if ((fp->f_flag & FWRITE) == 0)
return (EINVAL);
+ FREF(fp);
vp = (struct vnode *)fp->f_data;
VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE);
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p);
@@ -2251,6 +2264,7 @@ sys_ftruncate(p, v, retval)
error = VOP_SETATTR(vp, &vattr, fp->f_cred, p);
}
VOP_UNLOCK(vp, 0, p);
+ FRELE(fp);
return (error);
}
@@ -2267,12 +2281,13 @@ sys_fsync(p, v, retval)
struct sys_fsync_args /* {
syscallarg(int) fd;
} */ *uap = v;
- register struct vnode *vp;
+ struct vnode *vp;
struct file *fp;
int error;
if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0)
return (error);
+ FREF(fp);
vp = (struct vnode *)fp->f_data;
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p);
error = VOP_FSYNC(vp, fp->f_cred, MNT_WAIT, p);
@@ -2282,6 +2297,7 @@ sys_fsync(p, v, retval)
#endif
VOP_UNLOCK(vp, 0, p);
+ FRELE(fp);
return (error);
}
@@ -2485,7 +2501,7 @@ sys_getdirentries(p, v, retval)
void *v;
register_t *retval;
{
- register struct sys_getdirentries_args /* {
+ struct sys_getdirentries_args /* {
syscallarg(int) fd;
syscallarg(char *) buf;
syscallarg(u_int) count;
@@ -2502,10 +2518,13 @@ sys_getdirentries(p, v, retval)
return (error);
if ((fp->f_flag & FREAD) == 0)
return (EBADF);
+ FREF(fp);
vp = (struct vnode *)fp->f_data;
unionread:
- if (vp->v_type != VDIR)
- return (EINVAL);
+ if (vp->v_type != VDIR) {
+ error = EINVAL;
+ goto bad;
+ }
aiov.iov_base = SCARG(uap, buf);
aiov.iov_len = SCARG(uap, count);
auio.uio_iov = &aiov;
@@ -2520,13 +2539,13 @@ unionread:
fp->f_offset = auio.uio_offset;
VOP_UNLOCK(vp, 0, p);
if (error)
- return (error);
+ goto bad;
if ((SCARG(uap, count) == auio.uio_resid) &&
union_check_p &&
(union_check_p(p, &vp, fp, auio, &error) != 0))
goto unionread;
if (error)
- return (error);
+ goto bad;
if ((SCARG(uap, count) == auio.uio_resid) &&
(vp->v_flag & VROOT) &&
@@ -2542,6 +2561,8 @@ unionread:
error = copyout((caddr_t)&loff, (caddr_t)SCARG(uap, basep),
sizeof(long));
*retval = SCARG(uap, count) - auio.uio_resid;
+bad:
+ FRELE(fp);
return (error);
}
diff --git a/sys/miscfs/fdesc/fdesc_vnops.c b/sys/miscfs/fdesc/fdesc_vnops.c
index 632fc28bd74..b120fe7da96 100644
--- a/sys/miscfs/fdesc/fdesc_vnops.c
+++ b/sys/miscfs/fdesc/fdesc_vnops.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: fdesc_vnops.c,v 1.28 2002/02/02 16:05:58 art Exp $ */
+/* $OpenBSD: fdesc_vnops.c,v 1.29 2002/02/12 18:41:21 art Exp $ */
/* $NetBSD: fdesc_vnops.c,v 1.32 1996/04/11 11:24:29 mrg Exp $ */
/*
@@ -568,17 +568,24 @@ fdesc_setattr(v)
}
return (error);
}
+ FREF(fp);
vp = (struct vnode *)fp->f_data;
- if (vp->v_mount->mnt_flag & MNT_RDONLY)
- return (EROFS);
+ if (vp->v_mount->mnt_flag & MNT_RDONLY) {
+ error = EROFS;
+ goto out;
+ }
/*
* Directories can cause deadlocks.
*/
- if (vp->v_type == VDIR)
- return (EOPNOTSUPP);
+ if (vp->v_type == VDIR) {
+ error = EOPNOTSUPP;
+ goto out;
+ }
vn_lock(vp, LK_EXCLUSIVE|LK_RETRY, p);
error = VOP_SETATTR(vp, vap, ap->a_cred, p);
VOP_UNLOCK(vp, 0, p);
+out:
+ FRELE(fp);
return (error);
}