svn commit: r202553 - in stable/8/sys: kern sys
Ed Schouten
ed at FreeBSD.org
Mon Jan 18 09:04:54 UTC 2010
Author: ed
Date: Mon Jan 18 09:04:53 2010
New Revision: 202553
URL: http://svn.freebsd.org/changeset/base/202553
Log:
MFC r201532:
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>
Modified:
stable/8/sys/kern/tty.c
stable/8/sys/kern/tty_compat.c
stable/8/sys/kern/tty_pts.c
stable/8/sys/sys/tty.h
Directory Properties:
stable/8/sys/ (props changed)
stable/8/sys/amd64/include/xen/ (props changed)
stable/8/sys/cddl/contrib/opensolaris/ (props changed)
stable/8/sys/contrib/dev/acpica/ (props changed)
stable/8/sys/contrib/pf/ (props changed)
stable/8/sys/dev/xen/xenpci/ (props changed)
Modified: stable/8/sys/kern/tty.c
==============================================================================
--- stable/8/sys/kern/tty.c Mon Jan 18 06:48:24 2010 (r202552)
+++ stable/8/sys/kern/tty.c Mon Jan 18 09:04:53 2010 (r202553)
@@ -504,12 +504,12 @@ ttydev_ioctl(struct cdev *dev, u_long cm
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:
@@ -558,7 +558,7 @@ ttydev_ioctl(struct cdev *dev, u_long cm
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);
@@ -1330,7 +1330,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;
@@ -1657,17 +1658,26 @@ tty_generic_ioctl(struct tty *tp, u_long
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;
@@ -1678,7 +1688,7 @@ tty_ioctl(struct tty *tp, u_long cmd, vo
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);
}
Modified: stable/8/sys/kern/tty_compat.c
==============================================================================
--- stable/8/sys/kern/tty_compat.c Mon Jan 18 06:48:24 2010 (r202552)
+++ stable/8/sys/kern/tty_compat.c Mon Jan 18 09:04:53 2010 (r202553)
@@ -180,7 +180,8 @@ ttsetcompat(struct tty *tp, u_long *com,
/*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
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
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);
Modified: stable/8/sys/kern/tty_pts.c
==============================================================================
--- stable/8/sys/kern/tty_pts.c Mon Jan 18 06:48:24 2010 (r202552)
+++ stable/8/sys/kern/tty_pts.c Mon Jan 18 09:04:53 2010 (r202553)
@@ -396,7 +396,7 @@ ptsdev_ioctl(struct file *fp, u_long cmd
/* 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;
Modified: stable/8/sys/sys/tty.h
==============================================================================
--- stable/8/sys/sys/tty.h Mon Jan 18 06:48:24 2010 (r202552)
+++ stable/8/sys/sys/tty.h Mon Jan 18 09:04:53 2010 (r202553)
@@ -182,9 +182,10 @@ void tty_wakeup(struct tty *tp, int flag
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);
More information about the svn-src-all
mailing list