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.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 |
652 if (devsw(dev)->d_open == ptcopen) { |
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 |
692 * the slave is open. |
693 */ 694 if ((tp->t_state & TS_ISOPEN) == 0) |
695 return (EAGAIN); |
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 */ |
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 } |
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 --- |