Deleted Added
full compact
pty.c (47203) pty.c (47301)
1/*
2 * Copyright (c) 1982, 1986, 1989, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 17 unchanged lines hidden (view full) ---

26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 * @(#)tty_pty.c 8.4 (Berkeley) 2/20/95
1/*
2 * Copyright (c) 1982, 1986, 1989, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 17 unchanged lines hidden (view full) ---

26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 * @(#)tty_pty.c 8.4 (Berkeley) 2/20/95
34 * $Id: tty_pty.c,v 1.57 1999/05/08 06:39:43 phk Exp $
34 * $Id: tty_pty.c,v 1.58 1999/05/14 20:44:20 luoqi Exp $
35 */
36
37/*
38 * Pseudo-teletype Driver
39 * (Actually two drivers, requiring two entries in 'cdevsw')
40 */
41#include "pty.h" /* XXX */
42#include "opt_compat.h"

--- 601 unchanged lines hidden (view full) ---

644 int flag;
645 struct proc *p;
646{
647 register struct tty *tp = &pt_tty[minor(dev)];
648 register struct pt_ioctl *pti = &pt_ioctl[minor(dev)];
649 register u_char *cc = tp->t_cc;
650 int stop, error;
651
35 */
36
37/*
38 * Pseudo-teletype Driver
39 * (Actually two drivers, requiring two entries in 'cdevsw')
40 */
41#include "pty.h" /* XXX */
42#include "opt_compat.h"

--- 601 unchanged lines hidden (view full) ---

644 int flag;
645 struct proc *p;
646{
647 register struct tty *tp = &pt_tty[minor(dev)];
648 register struct pt_ioctl *pti = &pt_ioctl[minor(dev)];
649 register u_char *cc = tp->t_cc;
650 int stop, error;
651
652 /*
653 * IF CONTROLLER STTY THEN MUST FLUSH TO PREVENT A HANG.
654 * ttywflush(tp) will hang if there are characters in the outq.
655 */
656 if (cmd == TIOCEXT) {
657 /*
658 * When the EXTPROC bit is being toggled, we need
659 * to send an TIOCPKT_IOCTL if the packet driver
660 * is turned on.
661 */
662 if (*(int *)data) {
663 if (pti->pt_flags & PF_PKT) {
664 pti->pt_send |= TIOCPKT_IOCTL;
665 ptcwakeup(tp, FREAD);
666 }
667 tp->t_lflag |= EXTPROC;
668 } else {
669 if ((tp->t_lflag & EXTPROC) &&
670 (pti->pt_flags & PF_PKT)) {
671 pti->pt_send |= TIOCPKT_IOCTL;
672 ptcwakeup(tp, FREAD);
673 }
674 tp->t_lflag &= ~EXTPROC;
675 }
676 return(0);
677 } else if (devsw(dev)->d_open == ptcopen) {
652 if (devsw(dev)->d_open == ptcopen) {
678 switch (cmd) {
679
680 case TIOCGPGRP:
681 /*
682 * We avoid calling ttioctl on the controller since,
683 * in that case, tp must be the controlling terminal.
684 */
685 *(int *)data = tp->t_pgrp ? tp->t_pgrp->pg_id : 0;

--- 23 unchanged lines hidden (view full) ---

709 else
710 pti->pt_flags &= ~PF_REMOTE;
711 ttyflush(tp, FREAD|FWRITE);
712 return (0);
713 }
714
715 /*
716 * The rest of the ioctls shouldn't be called until
653 switch (cmd) {
654
655 case TIOCGPGRP:
656 /*
657 * We avoid calling ttioctl on the controller since,
658 * in that case, tp must be the controlling terminal.
659 */
660 *(int *)data = tp->t_pgrp ? tp->t_pgrp->pg_id : 0;

--- 23 unchanged lines hidden (view full) ---

684 else
685 pti->pt_flags &= ~PF_REMOTE;
686 ttyflush(tp, FREAD|FWRITE);
687 return (0);
688 }
689
690 /*
691 * The rest of the ioctls shouldn't be called until
717 * the slave is open. (Should we return an error?)
692 * the slave is open.
718 */
719 if ((tp->t_state & TS_ISOPEN) == 0)
693 */
694 if ((tp->t_state & TS_ISOPEN) == 0)
720 return (0);
695 return (EAGAIN);
721
722 switch (cmd) {
723#ifdef COMPAT_43
724 case TIOCSETP:
725 case TIOCSETN:
726#endif
727 case TIOCSETD:
728 case TIOCSETA:
729 case TIOCSETAW:
730 case TIOCSETAF:
696
697 switch (cmd) {
698#ifdef COMPAT_43
699 case TIOCSETP:
700 case TIOCSETN:
701#endif
702 case TIOCSETD:
703 case TIOCSETA:
704 case TIOCSETAW:
705 case TIOCSETAF:
706 /*
707 * IF CONTROLLER STTY THEN MUST FLUSH TO PREVENT A HANG.
708 * ttywflush(tp) will hang if there are characters in
709 * the outq.
710 */
731 ndflush(&tp->t_outq, tp->t_outq.c_cc);
732 break;
733
734 case TIOCSIG:
735 if (*(unsigned int *)data >= NSIG ||
736 *(unsigned int *)data == 0)
737 return(EINVAL);
738 if ((tp->t_lflag&NOFLSH) == 0)
739 ttyflush(tp, FREAD|FWRITE);
740 pgsignal(tp->t_pgrp, *(unsigned int *)data, 1);
741 if ((*(unsigned int *)data == SIGINFO) &&
742 ((tp->t_lflag&NOKERNINFO) == 0))
743 ttyinfo(tp);
744 return(0);
745 }
746 }
711 ndflush(&tp->t_outq, tp->t_outq.c_cc);
712 break;
713
714 case TIOCSIG:
715 if (*(unsigned int *)data >= NSIG ||
716 *(unsigned int *)data == 0)
717 return(EINVAL);
718 if ((tp->t_lflag&NOFLSH) == 0)
719 ttyflush(tp, FREAD|FWRITE);
720 pgsignal(tp->t_pgrp, *(unsigned int *)data, 1);
721 if ((*(unsigned int *)data == SIGINFO) &&
722 ((tp->t_lflag&NOKERNINFO) == 0))
723 ttyinfo(tp);
724 return(0);
725 }
726 }
727 if (cmd == TIOCEXT) {
728 /*
729 * When the EXTPROC bit is being toggled, we need
730 * to send an TIOCPKT_IOCTL if the packet driver
731 * is turned on.
732 */
733 if (*(int *)data) {
734 if (pti->pt_flags & PF_PKT) {
735 pti->pt_send |= TIOCPKT_IOCTL;
736 ptcwakeup(tp, FREAD);
737 }
738 tp->t_lflag |= EXTPROC;
739 } else {
740 if ((tp->t_lflag & EXTPROC) &&
741 (pti->pt_flags & PF_PKT)) {
742 pti->pt_send |= TIOCPKT_IOCTL;
743 ptcwakeup(tp, FREAD);
744 }
745 tp->t_lflag &= ~EXTPROC;
746 }
747 return(0);
748 }
747 error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, data, flag, p);
748 if (error == ENOIOCTL)
749 error = ttioctl(tp, cmd, data, flag);
750 if (error == ENOIOCTL) {
751 if (pti->pt_flags & PF_UCNTL &&
752 (cmd & ~0xff) == UIOCCMD(0)) {
753 if (cmd & 0xff) {
754 pti->pt_ucntl = (u_char)cmd;

--- 87 unchanged lines hidden ---
749 error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, data, flag, p);
750 if (error == ENOIOCTL)
751 error = ttioctl(tp, cmd, data, flag);
752 if (error == ENOIOCTL) {
753 if (pti->pt_flags & PF_UCNTL &&
754 (cmd & ~0xff) == UIOCCMD(0)) {
755 if (cmd & 0xff) {
756 pti->pt_ucntl = (u_char)cmd;

--- 87 unchanged lines hidden ---