summaryrefslogtreecommitdiff
path: root/sys/compat/ibcs2/ibcs2_ioctl.c
diff options
context:
space:
mode:
authorPeter Valchev <pvalchev@cvs.openbsd.org>2002-02-14 22:57:19 +0000
committerPeter Valchev <pvalchev@cvs.openbsd.org>2002-02-14 22:57:19 +0000
commitf2dcd99cca731fe6ef0a61ca6a9d64872439febf (patch)
tree7a11f5c653196e126ec053086c3f0cf0cd39123c /sys/compat/ibcs2/ibcs2_ioctl.c
parent0e740613f2fbdd26969bca268c0429b96c37ebb8 (diff)
More FREF/FRELE fixes
Diffstat (limited to 'sys/compat/ibcs2/ibcs2_ioctl.c')
-rw-r--r--sys/compat/ibcs2/ibcs2_ioctl.c94
1 files changed, 61 insertions, 33 deletions
diff --git a/sys/compat/ibcs2/ibcs2_ioctl.c b/sys/compat/ibcs2/ibcs2_ioctl.c
index f4c7291e1be..a40ee811975 100644
--- a/sys/compat/ibcs2/ibcs2_ioctl.c
+++ b/sys/compat/ibcs2/ibcs2_ioctl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ibcs2_ioctl.c,v 1.9 2001/10/26 12:03:27 art Exp $ */
+/* $OpenBSD: ibcs2_ioctl.c,v 1.10 2002/02/14 22:57:18 pvalchev Exp $ */
/* $NetBSD: ibcs2_ioctl.c,v 1.12 1996/08/10 09:08:26 mycroft Exp $ */
/*
@@ -347,10 +347,12 @@ ibcs2_sys_ioctl(p, v, retval)
if ((fp = fd_getfile(fdp, SCARG(uap, fd))) == NULL)
return (EBADF);
+ FREF(fp);
if ((fp->f_flag & (FREAD|FWRITE)) == 0) {
DPRINTF(("ibcs2_ioctl(%d): bad fp flag ", p->p_pid));
- return EBADF;
+ error = EBADF;
+ goto out;
}
ctl = fp->f_ops->fo_ioctl;
@@ -365,7 +367,7 @@ ibcs2_sys_ioctl(p, v, retval)
struct ibcs2_termio st;
if ((error = (*ctl)(fp, TIOCGETA, (caddr_t)&bts, p)) != 0)
- return error;
+ goto out;
btios2stios (&bts, &sts);
if (SCARG(uap, cmd) == IBCS2_TCGETA) {
@@ -375,10 +377,12 @@ ibcs2_sys_ioctl(p, v, retval)
if (error)
DPRINTF(("ibcs2_ioctl(%d): copyout failed ",
p->p_pid));
- return error;
- } else
- return copyout((caddr_t)&sts, SCARG(uap, data),
+ goto out;
+ } else {
+ error = copyout((caddr_t)&sts, SCARG(uap, data),
sizeof (sts));
+ goto out;
+ }
/*NOTREACHED*/
}
@@ -394,14 +398,14 @@ ibcs2_sys_ioctl(p, v, retval)
sizeof(st))) != 0) {
DPRINTF(("ibcs2_ioctl(%d): TCSET copyin failed ",
p->p_pid));
- return error;
+ goto out;
}
/* get full BSD termios so we don't lose information */
if ((error = (*ctl)(fp, TIOCGETA, (caddr_t)&bts, p)) != 0) {
DPRINTF(("ibcs2_ioctl(%d): TCSET ctl failed fd %d ",
p->p_pid, SCARG(uap, fd)));
- return error;
+ goto out;
}
/*
@@ -412,8 +416,9 @@ ibcs2_sys_ioctl(p, v, retval)
stio2stios(&st, &sts);
stios2btios(&sts, &bts);
- return (*ctl)(fp, SCARG(uap, cmd) - IBCS2_TCSETA + TIOCSETA,
+ error = (*ctl)(fp, SCARG(uap, cmd) - IBCS2_TCSETA + TIOCSETA,
(caddr_t)&bts, p);
+ goto out;
}
case IBCS2_XCSETA:
@@ -425,11 +430,12 @@ ibcs2_sys_ioctl(p, v, retval)
if ((error = copyin(SCARG(uap, data), (caddr_t)&sts,
sizeof (sts))) != 0) {
- return error;
+ goto out;
}
stios2btios (&sts, &bts);
- return (*ctl)(fp, SCARG(uap, cmd) - IBCS2_XCSETA + TIOCSETA,
+ error = (*ctl)(fp, SCARG(uap, cmd) - IBCS2_XCSETA + TIOCSETA,
(caddr_t)&bts, p);
+ goto out;
}
case IBCS2_OXCSETA:
@@ -441,16 +447,18 @@ ibcs2_sys_ioctl(p, v, retval)
if ((error = copyin(SCARG(uap, data), (caddr_t)&sts,
sizeof (sts))) != 0) {
- return error;
+ goto out;
}
stios2btios (&sts, &bts);
- return (*ctl)(fp, SCARG(uap, cmd) - IBCS2_OXCSETA + TIOCSETA,
+ error = (*ctl)(fp, SCARG(uap, cmd) - IBCS2_OXCSETA + TIOCSETA,
(caddr_t)&bts, p);
+ goto out;
}
case IBCS2_TCSBRK:
DPRINTF(("ibcs2_ioctl(%d): TCSBRK ", p->p_pid));
- return ENOSYS;
+ error = ENOSYS;
+ goto out;
case IBCS2_TCXONC:
{
@@ -458,13 +466,17 @@ ibcs2_sys_ioctl(p, v, retval)
case 0:
case 1:
DPRINTF(("ibcs2_ioctl(%d): TCXONC ", p->p_pid));
- return ENOSYS;
+ error = ENOSYS;
+ goto out;
case 2:
- return (*ctl)(fp, TIOCSTOP, (caddr_t)0, p);
+ error = (*ctl)(fp, TIOCSTOP, (caddr_t)0, p);
+ goto out;
case 3:
- return (*ctl)(fp, TIOCSTART, (caddr_t)1, p);
+ error = (*ctl)(fp, TIOCSTART, (caddr_t)1, p);
+ goto out;
default:
- return EINVAL;
+ error = EINVAL;
+ goto out;
}
}
@@ -483,22 +495,27 @@ ibcs2_sys_ioctl(p, v, retval)
arg = FREAD | FWRITE;
break;
default:
- return EINVAL;
+ error = EINVAL;
+ goto out;
}
- return (*ctl)(fp, TIOCFLUSH, (caddr_t)&arg, p);
+ error = (*ctl)(fp, TIOCFLUSH, (caddr_t)&arg, p);
+ goto out;
}
case IBCS2_TIOCGWINSZ:
SCARG(uap, cmd) = TIOCGWINSZ;
- return sys_ioctl(p, uap, retval);
+ error = sys_ioctl(p, uap, retval);
+ goto out;
case IBCS2_TIOCSWINSZ:
SCARG(uap, cmd) = TIOCSWINSZ;
- return sys_ioctl(p, uap, retval);
+ error = sys_ioctl(p, uap, retval);
+ goto out;
case IBCS2_TIOCGPGRP:
- return copyout((caddr_t)&p->p_pgrp->pg_id, SCARG(uap, data),
+ error = copyout((caddr_t)&p->p_pgrp->pg_id, SCARG(uap, data),
sizeof(p->p_pgrp->pg_id));
+ goto out;
case IBCS2_TIOCSPGRP: /* XXX - is uap->data a pointer to pgid? */
{
@@ -507,18 +524,22 @@ ibcs2_sys_ioctl(p, v, retval)
SCARG(&sa, pid) = 0;
SCARG(&sa, pgid) = (int)SCARG(uap, data);
if ((error = sys_setpgid(p, &sa, retval)) != 0)
- return error;
- return 0;
+ goto out;
+ error = 0;
+ goto out;
}
case IBCS2_TCGETSC: /* SCO console - get scancode flags */
- return ENOSYS;
+ error = ENOSYS;
+ goto out;
case IBCS2_TCSETSC: /* SCO console - set scancode flags */
- return ENOSYS;
+ error = ENOSYS;
+ goto out;
case IBCS2_SIOCSOCKSYS:
- return ibcs2_socksys(p, uap, retval);
+ error = ibcs2_socksys(p, uap, retval);
+ goto out;
case IBCS2_FIONBIO:
{
@@ -526,20 +547,27 @@ ibcs2_sys_ioctl(p, v, retval)
if ((error = copyin(SCARG(uap, data), &arg,
sizeof(arg))) != 0)
- return error;
+ goto out;
- return (*ctl)(fp, FIONBIO, (caddr_t)&arg, p);
+ error = (*ctl)(fp, FIONBIO, (caddr_t)&arg, p);
+ goto out;
}
case IBCS2_FIONREAD:
case IBCS2_I_NREAD: /* STREAMS */
SCARG(uap, cmd) = FIONREAD;
- return sys_ioctl(p, uap, retval);
+ error = sys_ioctl(p, uap, retval);
+ goto out;
default:
DPRINTF(("ibcs2_ioctl(%d): unknown cmd 0x%lx ",
p->p_pid, SCARG(uap, cmd)));
- return ENOSYS;
+ error = ENOSYS;
+ goto out;
}
- return ENOSYS;
+ error = ENOSYS;
+
+out:
+ FRELE(fp);
+ return (error);
}