Make TIOCSTI work again.

It looks like I didn't implement this when I imported MPSAFE TTY.
Applications like mail(1) still use this. I think it's conceptually bad.

Tested by:	Pete French <petefrench ticketswitch com>
MFC after:	2 weeks
This commit is contained in:
Ed Schouten 2010-01-04 20:59:52 +00:00
parent 7173b6e554
commit 328d9d2c96
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=201532
4 changed files with 26 additions and 13 deletions

View File

@ -505,12 +505,12 @@ ttydev_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int fflag,
case TIOCSPGRP:
case TIOCSTART:
case TIOCSTAT:
case TIOCSTI:
case TIOCSTOP:
case TIOCSWINSZ:
#if 0
case TIOCSDRAINWAIT:
case TIOCSETD:
case TIOCSTI:
#endif
#ifdef COMPAT_43TTY
case TIOCLBIC:
@ -559,7 +559,7 @@ ttydev_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int fflag,
new->c_ospeed = old->c_ospeed;
}
error = tty_ioctl(tp, cmd, data, td);
error = tty_ioctl(tp, cmd, data, fflag, td);
done: tty_unlock(tp);
return (error);
@ -1350,7 +1350,8 @@ tty_flush(struct tty *tp, int flags)
}
static int
tty_generic_ioctl(struct tty *tp, u_long cmd, void *data, struct thread *td)
tty_generic_ioctl(struct tty *tp, u_long cmd, void *data, int fflag,
struct thread *td)
{
int error;
@ -1677,17 +1678,26 @@ tty_generic_ioctl(struct tty *tp, u_long cmd, void *data, struct thread *td)
case TIOCSTAT:
tty_info(tp);
return (0);
case TIOCSTI:
if ((fflag & FREAD) == 0 && priv_check(td, PRIV_TTY_STI))
return (EPERM);
if (!tty_is_ctty(tp, td->td_proc) &&
priv_check(td, PRIV_TTY_STI))
return (EACCES);
ttydisc_rint(tp, *(char *)data, 0);
ttydisc_rint_done(tp);
return (0);
}
#ifdef COMPAT_43TTY
return tty_ioctl_compat(tp, cmd, data, td);
return tty_ioctl_compat(tp, cmd, data, fflag, td);
#else /* !COMPAT_43TTY */
return (ENOIOCTL);
#endif /* COMPAT_43TTY */
}
int
tty_ioctl(struct tty *tp, u_long cmd, void *data, struct thread *td)
tty_ioctl(struct tty *tp, u_long cmd, void *data, int fflag, struct thread *td)
{
int error;
@ -1698,7 +1708,7 @@ tty_ioctl(struct tty *tp, u_long cmd, void *data, struct thread *td)
error = ttydevsw_ioctl(tp, cmd, data, td);
if (error == ENOIOCTL)
error = tty_generic_ioctl(tp, cmd, data, td);
error = tty_generic_ioctl(tp, cmd, data, fflag, td);
return (error);
}

View File

@ -180,7 +180,8 @@ ttsetcompat(struct tty *tp, u_long *com, caddr_t data, struct termios *term)
/*ARGSUSED*/
int
tty_ioctl_compat(struct tty *tp, u_long com, caddr_t data, struct thread *td)
tty_ioctl_compat(struct tty *tp, u_long com, caddr_t data, int fflag,
struct thread *td)
{
switch (com) {
case TIOCSETP:
@ -196,7 +197,7 @@ tty_ioctl_compat(struct tty *tp, u_long com, caddr_t data, struct thread *td)
term = tp->t_termios;
if ((error = ttsetcompat(tp, &com, data, &term)) != 0)
return error;
return tty_ioctl(tp, com, &term, td);
return tty_ioctl(tp, com, &term, fflag, td);
}
case TIOCGETP: {
struct sgttyb *sg = (struct sgttyb *)data;
@ -255,12 +256,13 @@ tty_ioctl_compat(struct tty *tp, u_long com, caddr_t data, struct thread *td)
int ldisczero = 0;
return (tty_ioctl(tp, TIOCSETD,
*(int *)data == 2 ? (caddr_t)&ldisczero : data, td));
*(int *)data == 2 ? (caddr_t)&ldisczero : data,
fflag, td));
}
case OTIOCCONS:
*(int *)data = 1;
return (tty_ioctl(tp, TIOCCONS, data, td));
return (tty_ioctl(tp, TIOCCONS, data, fflag, td));
default:
return (ENOIOCTL);

View File

@ -379,7 +379,7 @@ ptsdev_ioctl(struct file *fp, u_long cmd, void *data,
/* Just redirect this ioctl to the slave device. */
tty_lock(tp);
error = tty_ioctl(tp, cmd, data, td);
error = tty_ioctl(tp, cmd, data, fp->f_flag, td);
tty_unlock(tp);
if (error == ENOIOCTL)
error = ENOTTY;

View File

@ -182,9 +182,10 @@ void tty_wakeup(struct tty *tp, int flags);
int tty_checkoutq(struct tty *tp);
int tty_putchar(struct tty *tp, char c);
int tty_ioctl(struct tty *tp, u_long cmd, void *data, struct thread *td);
int tty_ioctl_compat(struct tty *tp, u_long cmd, caddr_t data,
int tty_ioctl(struct tty *tp, u_long cmd, void *data, int fflag,
struct thread *td);
int tty_ioctl_compat(struct tty *tp, u_long cmd, caddr_t data,
int fflag, struct thread *td);
void tty_init_console(struct tty *tp, speed_t speed);
void tty_flush(struct tty *tp, int flags);
void tty_hiwat_in_block(struct tty *tp);