diff options
author | Peter Valchev <pvalchev@cvs.openbsd.org> | 2002-02-14 22:57:19 +0000 |
---|---|---|
committer | Peter Valchev <pvalchev@cvs.openbsd.org> | 2002-02-14 22:57:19 +0000 |
commit | f2dcd99cca731fe6ef0a61ca6a9d64872439febf (patch) | |
tree | 7a11f5c653196e126ec053086c3f0cf0cd39123c /sys/compat/ultrix | |
parent | 0e740613f2fbdd26969bca268c0429b96c37ebb8 (diff) |
More FREF/FRELE fixes
Diffstat (limited to 'sys/compat/ultrix')
-rw-r--r-- | sys/compat/ultrix/ultrix_ioctl.c | 128 |
1 files changed, 74 insertions, 54 deletions
diff --git a/sys/compat/ultrix/ultrix_ioctl.c b/sys/compat/ultrix/ultrix_ioctl.c index 4c80fc8f5f7..71bf9544e8c 100644 --- a/sys/compat/ultrix/ultrix_ioctl.c +++ b/sys/compat/ultrix/ultrix_ioctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ultrix_ioctl.c,v 1.8 2001/10/26 12:03:27 art Exp $ */ +/* $OpenBSD: ultrix_ioctl.c,v 1.9 2002/02/14 22:57:18 pvalchev Exp $ */ /* $NetBSD: ultrix_ioctl.c,v 1.3.4.1 1996/06/13 18:22:37 jonathan Exp $ */ /* from : NetBSD: sunos_ioctl.c,v 1.21 1995/10/07 06:27:31 mycroft Exp */ @@ -444,16 +444,19 @@ ultrix_sys_ioctl(p, v, retval) register_t *retval; { struct ultrix_sys_ioctl_args *uap = v; - register struct filedesc *fdp = p->p_fd; - register struct file *fp; + struct filedesc *fdp = p->p_fd; + struct file *fp; register int (*ctl)(); int error; if ((fp = fd_getfile(fdp, SCARG(uap, fd))) == NULL) return EBADF; + FREF(fp); - if ((fp->f_flag & (FREAD|FWRITE)) == 0) - return EBADF; + if ((fp->f_flag & (FREAD|FWRITE)) == 0) { + error = EBADF; + goto out; + } ctl = fp->f_ops->fo_ioctl; @@ -467,33 +470,39 @@ ultrix_sys_ioctl(p, v, retval) if ((error = copyin(SCARG(uap, data), (caddr_t)&disc, sizeof disc)) != 0) - return error; + goto out; /* map SunOS NTTYDISC into our termios discipline */ if (disc == 2) disc = 0; /* all other disciplines are not supported by NetBSD */ - if (disc) - return ENXIO; + if (disc) { + error = ENXIO; + goto out; + } - return (*ctl)(fp, TIOCSETD, (caddr_t)&disc, p); + error = (*ctl)(fp, TIOCSETD, (caddr_t)&disc, p); + goto out; } case _IOW('t', 101, int): /* sun SUNOS_TIOCSSOFTCAR */ { int x; /* unused */ - return copyin((caddr_t)&x, SCARG(uap, data), sizeof x); + error = copyin((caddr_t)&x, SCARG(uap, data), sizeof x); + goto out; } case _IOR('t', 100, int): /* sun SUNOS_TIOCSSOFTCAR */ { int x = 0; - return copyout((caddr_t)&x, SCARG(uap, data), sizeof x); + error = copyout((caddr_t)&x, SCARG(uap, data), sizeof x); + goto out; } case _IO('t', 36): /* sun TIOCCONS, no parameters */ { int on = 1; - return (*ctl)(fp, TIOCCONS, (caddr_t)&on, p); + error = (*ctl)(fp, TIOCCONS, (caddr_t)&on, p); + goto out; } case _IOW('t', 37, struct sunos_ttysize): { @@ -501,15 +510,16 @@ ultrix_sys_ioctl(p, v, retval) struct sunos_ttysize ss; if ((error = (*ctl)(fp, TIOCGWINSZ, (caddr_t)&ws, p)) != 0) - return (error); + goto out; if ((error = copyin (SCARG(uap, data), &ss, sizeof (ss))) != 0) - return error; + goto out; ws.ws_row = ss.ts_row; ws.ws_col = ss.ts_col; - return ((*ctl)(fp, TIOCSWINSZ, (caddr_t)&ws, p)); + error = ((*ctl)(fp, TIOCSWINSZ, (caddr_t)&ws, p)); + goto out; } case _IOW('t', 38, struct sunos_ttysize): { @@ -517,12 +527,13 @@ ultrix_sys_ioctl(p, v, retval) struct sunos_ttysize ss; if ((error = (*ctl)(fp, TIOCGWINSZ, (caddr_t)&ws, p)) != 0) - return (error); + goto out; ss.ts_row = ws.ws_row; ss.ts_col = ws.ws_col; - return copyout ((caddr_t)&ss, SCARG(uap, data), sizeof (ss)); + error = copyout ((caddr_t)&ss, SCARG(uap, data), sizeof (ss)); + goto out; } case _IOW('t', 130, int): SCARG(uap, com) = TIOCSPGRP; @@ -542,16 +553,19 @@ ultrix_sys_ioctl(p, v, retval) struct ultrix_termio st; if ((error = (*ctl)(fp, TIOCGETA, (caddr_t)&bts, p)) != 0) - return error; + goto out; btios2stios (&bts, &sts); if (SCARG(uap, com) == ULTRIX_TCGETA) { stios2stio (&sts, &st); - return copyout((caddr_t)&st, SCARG(uap, data), + error = copyout((caddr_t)&st, SCARG(uap, data), sizeof (st)); - } 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*/ } /* Emulate termio tcset() */ @@ -562,15 +576,14 @@ ultrix_sys_ioctl(p, v, retval) struct termios bts; struct ultrix_termios sts; struct ultrix_termio st; - int result; if ((error = copyin(SCARG(uap, data), (caddr_t)&st, sizeof (st))) != 0) - return error; + goto out; /* get full BSD termios so we don't lose information */ if ((error = (*ctl)(fp, TIOCGETA, (caddr_t)&bts, p)) != 0) - return error; + goto out; /* * convert to sun termios, copy in information from @@ -583,17 +596,11 @@ ultrix_sys_ioctl(p, v, retval) /* * map ioctl code: ultrix tcsets are numbered in reverse order */ -#ifdef notyet - return (*ctl)(fp, ULTRIX_TCSETA - SCARG(uap, com) + TIOCSETA, - (caddr_t)&bts, p); -#else - result= (*ctl)(fp, ULTRIX_TCSETA - SCARG(uap, com) + TIOCSETA, + error = (*ctl)(fp, ULTRIX_TCSETA - SCARG(uap, com) + TIOCSETA, (caddr_t)&bts, p); printf("ultrix TCSETA %lx returns %d\n", - ULTRIX_TCSETA - SCARG(uap, com), result); - return result; -#endif - + ULTRIX_TCSETA - SCARG(uap, com), error); + goto out; } /* Emulate termios tcset() */ case ULTRIX_TCSETS: @@ -605,10 +612,11 @@ ultrix_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, ULTRIX_TCSETS - SCARG(uap, com) + TIOCSETA, + error = (*ctl)(fp, ULTRIX_TCSETS - SCARG(uap, com) + TIOCSETA, (caddr_t)&bts, p); + goto out; } /* * Pseudo-tty ioctl translations. @@ -618,16 +626,18 @@ ultrix_sys_ioctl(p, v, retval) error = copyin (SCARG(uap, data), (caddr_t)&on, sizeof (on)); if (error != 0) - return error; - return (*ctl)(fp, TIOCUCNTL, (caddr_t)&on, p); + goto out; + error = (*ctl)(fp, TIOCUCNTL, (caddr_t)&on, p); + goto out; } case _IOW('t', 33, int): { /* TIOCSIGNAL */ int error, sig; error = copyin (SCARG(uap, data), (caddr_t)&sig, sizeof (sig)); if (error != 0) - return error; - return (*ctl)(fp, TIOCSIG, (caddr_t)&sig, p); + goto out; + error = (*ctl)(fp, TIOCSIG, (caddr_t)&sig, p); + goto out; } /* @@ -637,35 +647,39 @@ ultrix_sys_ioctl(p, v, retval) type_t localbuf; \ if ((error = copyin (SCARG(uap, data), \ (caddr_t)&localbuf, sizeof (type_t))) != 0) \ - return error; \ - return (*ctl)(fp, a, (caddr_t)&localbuf, p); \ + goto out; \ + error = (*ctl)(fp, a, (caddr_t)&localbuf, p); \ + goto out; \ } #define INOUT_TYPE(a, type_t) { \ type_t localbuf; \ if ((error = copyin (SCARG(uap, data), (caddr_t)&localbuf, \ sizeof (type_t))) != 0) \ - return error; \ + goto out; \ if ((error = (*ctl)(fp, a, (caddr_t)&localbuf, p)) != 0) \ - return error; \ - return copyout ((caddr_t)&localbuf, SCARG(uap, data), sizeof (type_t)); \ + goto out; \ + error = copyout ((caddr_t)&localbuf, SCARG(uap, data), sizeof (type_t)); \ + goto out; \ } #define IFREQ_IN(a) { \ struct ifreq ifreq; \ if ((error = copyin (SCARG(uap, data), (caddr_t)&ifreq, sizeof (ifreq))) != 0) \ - return error; \ - return (*ctl)(fp, a, (caddr_t)&ifreq, p); \ + goto out; \ + error = (*ctl)(fp, a, (caddr_t)&ifreq, p); \ + goto out; \ } #define IFREQ_INOUT(a) { \ struct ifreq ifreq; \ if ((error = copyin (SCARG(uap, data), (caddr_t)&ifreq, sizeof (ifreq))) != 0) \ - return error; \ + goto out;; \ if ((error = (*ctl)(fp, a, (caddr_t)&ifreq, p)) != 0) \ - return error; \ - return copyout ((caddr_t)&ifreq, SCARG(uap, data), sizeof (ifreq)); \ + goto out; \ + error = copyout ((caddr_t)&ifreq, SCARG(uap, data), sizeof (ifreq)); \ + goto out; \ } case _IOW('i', 12, struct ifreq): @@ -737,7 +751,8 @@ ultrix_sys_ioctl(p, v, retval) case _IOW('i', 48, int): /* SIOCSPROMISC */ case _IOW('i', 49, struct ifreq): /* SIOCADDMULTI */ case _IOW('i', 50, struct ifreq): /* SIOCDELMULTI */ - return EOPNOTSUPP; + error = EOPNOTSUPP; + goto out; case _IOWR('i', 20, struct ifconf): /* SIOCGIFCONF */ { @@ -750,14 +765,19 @@ ultrix_sys_ioctl(p, v, retval) */ if ((error = copyin (SCARG(uap, data), (caddr_t)&ifconf, sizeof (ifconf))) != 0) - return error; + goto out; if ((error = (*ctl)(fp, OSIOCGIFCONF, * (caddr_t)&ifconf, p)) !=0 ) - return error; - return copyout ((caddr_t)&ifconf, SCARG(uap, data), + goto out; + error = copyout ((caddr_t)&ifconf, SCARG(uap, data), sizeof (ifconf)); + goto out; } } - return (sys_ioctl(p, uap, retval)); + error = (sys_ioctl(p, uap, retval)); + +out: + FRELE(fp); + return (error); } |