summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoranton <anton@cvs.openbsd.org>2020-02-16 19:35:00 +0000
committeranton <anton@cvs.openbsd.org>2020-02-16 19:35:00 +0000
commit518fc1d692562b212770a1dee56e817ed52d2448 (patch)
tree3eee51ddbe8a4ea63bb5938f5074a7592a1d7f22
parent4a3a2456e2bdd8f52ca6e2276c3ccbabe989299e (diff)
Rework vn_ioctl() to only have a single point of return. This will make
it easier to grab the kernel lock once ioctl() is unlocked. Thanks to semarie@ who came up with an improved diff. ok mpi@ semarie@ visa@
-rw-r--r--sys/kern/vfs_vnops.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c
index 2e5f64e3b86..f175bbc7284 100644
--- a/sys/kern/vfs_vnops.c
+++ b/sys/kern/vfs_vnops.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vfs_vnops.c,v 1.111 2020/01/05 13:46:02 visa Exp $ */
+/* $OpenBSD: vfs_vnops.c,v 1.112 2020/02/16 19:34:59 anton Exp $ */
/* $NetBSD: vfs_vnops.c,v 1.20 1996/02/04 02:18:41 christos Exp $ */
/*
@@ -508,7 +508,7 @@ vn_ioctl(struct file *fp, u_long com, caddr_t data, struct proc *p)
{
struct vnode *vp = fp->f_data;
struct vattr vattr;
- int error;
+ int error = ENOTTY;
switch (vp->v_type) {
@@ -517,15 +517,12 @@ vn_ioctl(struct file *fp, u_long com, caddr_t data, struct proc *p)
if (com == FIONREAD) {
error = VOP_GETATTR(vp, &vattr, p->p_ucred, p);
if (error)
- return (error);
+ break;
*(int *)data = vattr.va_size - foffset(fp);
- return (0);
- }
- if (com == FIONBIO || com == FIOASYNC) /* XXX */
- return (0); /* XXX */
- /* FALLTHROUGH */
- default:
- return (ENOTTY);
+
+ } else if (com == FIONBIO || com == FIOASYNC) /* XXX */
+ error = 0; /* XXX */
+ break;
case VFIFO:
case VCHR:
@@ -539,8 +536,13 @@ vn_ioctl(struct file *fp, u_long com, caddr_t data, struct proc *p)
if (ovp)
vrele(ovp);
}
- return (error);
+ break;
+
+ default:
+ break;
}
+
+ return (error);
}
/*