From 3cf91c530ddcd5d33cff1daa5a0a5d42f6147364 Mon Sep 17 00:00:00 2001 From: "Andrey A. Chernov" Date: Thu, 13 Apr 1995 11:11:11 +0000 Subject: [PATCH] Move setcompat code to another place, initial/locked devices not supposed to work with old style ioctls --- sys/dev/sio/sio.c | 26 ++++++++++++-------------- sys/i386/isa/sio.c | 26 ++++++++++++-------------- sys/isa/sio.c | 26 ++++++++++++-------------- 3 files changed, 36 insertions(+), 42 deletions(-) diff --git a/sys/dev/sio/sio.c b/sys/dev/sio/sio.c index a3c8f2e107b8..f652839b09e7 100644 --- a/sys/dev/sio/sio.c +++ b/sys/dev/sio/sio.c @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * from: @(#)com.c 7.5 (Berkeley) 5/16/91 - * $Id: sio.c,v 1.91 1995/04/12 22:00:41 phk Exp $ + * $Id: sio.c,v 1.92 1995/04/13 09:22:40 ache Exp $ */ #include "sio.h" @@ -1286,7 +1286,6 @@ sioioctl(dev, cmd, data, flag, p) int s; int tiocm_xxx; struct tty *tp; - struct termios *ct; #if defined(COMPAT_43) || defined(COMPAT_SUNOS) struct termios term; int oldcmd; @@ -1295,9 +1294,9 @@ sioioctl(dev, cmd, data, flag, p) mynor = minor(dev); com = com_addr(MINOR_TO_UNIT(mynor)); iobase = com->iobase; - tp = com->tp; - ct = NULL; if (mynor & CONTROL_MASK) { + struct termios *ct; + switch (mynor & CONTROL_MASK) { case CONTROL_INIT_STATE: ct = mynor & CALLOUT_MASK ? &com->it_out : &com->it_in; @@ -1308,16 +1307,6 @@ sioioctl(dev, cmd, data, flag, p) default: return (ENODEV); /* /dev/nodev */ } - } -#if defined(COMPAT_43) || defined(COMPAT_SUNOS) - term = ct != NULL ? *ct : tp->t_termios; - oldcmd = cmd; - if ((error = ttsetcompat(tp, &cmd, data, &term)) != 0) - return error; - if (cmd != oldcmd) - data = (caddr_t)&term; -#endif - if (mynor & CONTROL_MASK) { switch (cmd) { case TIOCSETA: error = suser(p->p_ucred, &p->p_acflag); @@ -1366,6 +1355,15 @@ sioioctl(dev, cmd, data, flag, p) return (ENOTTY); } } + tp = com->tp; +#if defined(COMPAT_43) || defined(COMPAT_SUNOS) + term = tp->t_termios; + oldcmd = cmd; + if ((error = ttsetcompat(tp, &cmd, data, &term)) != 0) + return error; + if (cmd != oldcmd) + data = (caddr_t)&term; +#endif if (cmd == TIOCSETA || cmd == TIOCSETAW || cmd == TIOCSETAF) { int cc; struct termios *dt = (struct termios *)data; diff --git a/sys/i386/isa/sio.c b/sys/i386/isa/sio.c index a3c8f2e107b8..f652839b09e7 100644 --- a/sys/i386/isa/sio.c +++ b/sys/i386/isa/sio.c @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * from: @(#)com.c 7.5 (Berkeley) 5/16/91 - * $Id: sio.c,v 1.91 1995/04/12 22:00:41 phk Exp $ + * $Id: sio.c,v 1.92 1995/04/13 09:22:40 ache Exp $ */ #include "sio.h" @@ -1286,7 +1286,6 @@ sioioctl(dev, cmd, data, flag, p) int s; int tiocm_xxx; struct tty *tp; - struct termios *ct; #if defined(COMPAT_43) || defined(COMPAT_SUNOS) struct termios term; int oldcmd; @@ -1295,9 +1294,9 @@ sioioctl(dev, cmd, data, flag, p) mynor = minor(dev); com = com_addr(MINOR_TO_UNIT(mynor)); iobase = com->iobase; - tp = com->tp; - ct = NULL; if (mynor & CONTROL_MASK) { + struct termios *ct; + switch (mynor & CONTROL_MASK) { case CONTROL_INIT_STATE: ct = mynor & CALLOUT_MASK ? &com->it_out : &com->it_in; @@ -1308,16 +1307,6 @@ sioioctl(dev, cmd, data, flag, p) default: return (ENODEV); /* /dev/nodev */ } - } -#if defined(COMPAT_43) || defined(COMPAT_SUNOS) - term = ct != NULL ? *ct : tp->t_termios; - oldcmd = cmd; - if ((error = ttsetcompat(tp, &cmd, data, &term)) != 0) - return error; - if (cmd != oldcmd) - data = (caddr_t)&term; -#endif - if (mynor & CONTROL_MASK) { switch (cmd) { case TIOCSETA: error = suser(p->p_ucred, &p->p_acflag); @@ -1366,6 +1355,15 @@ sioioctl(dev, cmd, data, flag, p) return (ENOTTY); } } + tp = com->tp; +#if defined(COMPAT_43) || defined(COMPAT_SUNOS) + term = tp->t_termios; + oldcmd = cmd; + if ((error = ttsetcompat(tp, &cmd, data, &term)) != 0) + return error; + if (cmd != oldcmd) + data = (caddr_t)&term; +#endif if (cmd == TIOCSETA || cmd == TIOCSETAW || cmd == TIOCSETAF) { int cc; struct termios *dt = (struct termios *)data; diff --git a/sys/isa/sio.c b/sys/isa/sio.c index a3c8f2e107b8..f652839b09e7 100644 --- a/sys/isa/sio.c +++ b/sys/isa/sio.c @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * from: @(#)com.c 7.5 (Berkeley) 5/16/91 - * $Id: sio.c,v 1.91 1995/04/12 22:00:41 phk Exp $ + * $Id: sio.c,v 1.92 1995/04/13 09:22:40 ache Exp $ */ #include "sio.h" @@ -1286,7 +1286,6 @@ sioioctl(dev, cmd, data, flag, p) int s; int tiocm_xxx; struct tty *tp; - struct termios *ct; #if defined(COMPAT_43) || defined(COMPAT_SUNOS) struct termios term; int oldcmd; @@ -1295,9 +1294,9 @@ sioioctl(dev, cmd, data, flag, p) mynor = minor(dev); com = com_addr(MINOR_TO_UNIT(mynor)); iobase = com->iobase; - tp = com->tp; - ct = NULL; if (mynor & CONTROL_MASK) { + struct termios *ct; + switch (mynor & CONTROL_MASK) { case CONTROL_INIT_STATE: ct = mynor & CALLOUT_MASK ? &com->it_out : &com->it_in; @@ -1308,16 +1307,6 @@ sioioctl(dev, cmd, data, flag, p) default: return (ENODEV); /* /dev/nodev */ } - } -#if defined(COMPAT_43) || defined(COMPAT_SUNOS) - term = ct != NULL ? *ct : tp->t_termios; - oldcmd = cmd; - if ((error = ttsetcompat(tp, &cmd, data, &term)) != 0) - return error; - if (cmd != oldcmd) - data = (caddr_t)&term; -#endif - if (mynor & CONTROL_MASK) { switch (cmd) { case TIOCSETA: error = suser(p->p_ucred, &p->p_acflag); @@ -1366,6 +1355,15 @@ sioioctl(dev, cmd, data, flag, p) return (ENOTTY); } } + tp = com->tp; +#if defined(COMPAT_43) || defined(COMPAT_SUNOS) + term = tp->t_termios; + oldcmd = cmd; + if ((error = ttsetcompat(tp, &cmd, data, &term)) != 0) + return error; + if (cmd != oldcmd) + data = (caddr_t)&term; +#endif if (cmd == TIOCSETA || cmd == TIOCSETAW || cmd == TIOCSETAF) { int cc; struct termios *dt = (struct termios *)data;