From owner-svn-src-all@FreeBSD.ORG Mon Jan 18 09:04:54 2010 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4F3B4106566B; Mon, 18 Jan 2010 09:04:54 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 3DB3E8FC1C; Mon, 18 Jan 2010 09:04:54 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o0I94sIY011668; Mon, 18 Jan 2010 09:04:54 GMT (envelope-from ed@svn.freebsd.org) Received: (from ed@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o0I94seL011664; Mon, 18 Jan 2010 09:04:54 GMT (envelope-from ed@svn.freebsd.org) Message-Id: <201001180904.o0I94seL011664@svn.freebsd.org> From: Ed Schouten Date: Mon, 18 Jan 2010 09:04:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r202553 - in stable/8/sys: kern sys X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Jan 2010 09:04:54 -0000 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 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);