pty.c (24207) | pty.c (27770) |
---|---|
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.42 1997/03/23 03:36:28 bde Exp $ | 34 * $Id: tty_pty.c,v 1.43 1997/03/24 12:03:06 bde Exp $ |
35 */ 36 37/* 38 * Pseudo-teletype Driver 39 * (Actually two drivers, requiring two entries in 'cdevsw') 40 */ 41#include "pty.h" /* XXX */ 42 --- 45 unchanged lines hidden (view full) --- 88 { ptcopen, ptcclose, ptcread, ptcwrite, /*6*/ 89 ptyioctl, nullstop, nullreset, ptydevtotty,/* ptyp */ 90 ptcselect, nommap, NULL, "ptc", NULL, -1 }; 91 92 93#if NPTY == 1 94#undef NPTY 95#define NPTY 32 /* crude XXX */ | 35 */ 36 37/* 38 * Pseudo-teletype Driver 39 * (Actually two drivers, requiring two entries in 'cdevsw') 40 */ 41#include "pty.h" /* XXX */ 42 --- 45 unchanged lines hidden (view full) --- 88 { ptcopen, ptcclose, ptcread, ptcwrite, /*6*/ 89 ptyioctl, nullstop, nullreset, ptydevtotty,/* ptyp */ 90 ptcselect, nommap, NULL, "ptc", NULL, -1 }; 91 92 93#if NPTY == 1 94#undef NPTY 95#define NPTY 32 /* crude XXX */ |
96#warning You have only one pty defined, redefining to 32. |
|
96#endif 97 | 97#endif 98 |
99#ifdef DEVFS 100#define MAXUNITS (8 * 32) 101static void *devfs_token_pts[MAXUNITS]; 102static void *devfs_token_ptc[MAXUNITS]; 103static const char jnames[] = "pqrsPQRS"; 104#if NPTY > MAXUNITS 105#undef NPTY 106#define NPTY MAXUNITS 107#warning Can't have more than 256 pty's with DEVFS defined. 108#endif 109#endif 110 |
|
98#define BUFSIZ 100 /* Chunk size iomoved to/from user */ 99 100/* 101 * pts == /dev/tty[pqrsPQRS][0123456789abcdefghijklmnopqrstuv] 102 * ptc == /dev/pty[pqrsPQRS][0123456789abcdefghijklmnopqrstuv] 103 */ 104static struct tty pt_tty[NPTY]; /* XXX */ 105static struct pt_ioctl { --- 599 unchanged lines hidden (view full) --- 705 case TIOCSETD: 706 case TIOCSETA: 707 case TIOCSETAW: 708 case TIOCSETAF: 709 ndflush(&tp->t_outq, tp->t_outq.c_cc); 710 break; 711 712 case TIOCSIG: | 111#define BUFSIZ 100 /* Chunk size iomoved to/from user */ 112 113/* 114 * pts == /dev/tty[pqrsPQRS][0123456789abcdefghijklmnopqrstuv] 115 * ptc == /dev/pty[pqrsPQRS][0123456789abcdefghijklmnopqrstuv] 116 */ 117static struct tty pt_tty[NPTY]; /* XXX */ 118static struct pt_ioctl { --- 599 unchanged lines hidden (view full) --- 718 case TIOCSETD: 719 case TIOCSETA: 720 case TIOCSETAW: 721 case TIOCSETAF: 722 ndflush(&tp->t_outq, tp->t_outq.c_cc); 723 break; 724 725 case TIOCSIG: |
713 if (*(unsigned int *)data >= NSIG) | 726 if (*(unsigned int *)data >= NSIG || 727 *(unsigned int *)data == 0) |
714 return(EINVAL); 715 if ((tp->t_lflag&NOFLSH) == 0) 716 ttyflush(tp, FREAD|FWRITE); 717 pgsignal(tp->t_pgrp, *(unsigned int *)data, 1); 718 if ((*(unsigned int *)data == SIGINFO) && 719 ((tp->t_lflag&NOKERNINFO) == 0)) 720 ttyinfo(tp); 721 return(0); --- 53 unchanged lines hidden (view full) --- 775 pti->pt_flags |= PF_NOSTOP; 776 ptcwakeup(tp, FREAD); 777 } 778 } 779 return (error); 780} 781 782static ptc_devsw_installed = 0; | 728 return(EINVAL); 729 if ((tp->t_lflag&NOFLSH) == 0) 730 ttyflush(tp, FREAD|FWRITE); 731 pgsignal(tp->t_pgrp, *(unsigned int *)data, 1); 732 if ((*(unsigned int *)data == SIGINFO) && 733 ((tp->t_lflag&NOKERNINFO) == 0)) 734 ttyinfo(tp); 735 return(0); --- 53 unchanged lines hidden (view full) --- 789 pti->pt_flags |= PF_NOSTOP; 790 ptcwakeup(tp, FREAD); 791 } 792 } 793 return (error); 794} 795 796static ptc_devsw_installed = 0; |
783#ifdef DEVFS 784#define MAXUNITS (8 * 32) 785static void *devfs_token_pts[MAXUNITS]; 786static void *devfs_token_ptc[MAXUNITS]; 787static const char jnames[] = "pqrsPQRS"; 788#endif | |
789 790static void 791ptc_drvinit(void *unused) 792{ 793#ifdef DEVFS 794 int i,j,k; 795#endif 796 dev_t dev; 797 798 if( ! ptc_devsw_installed ) { 799 dev = makedev(CDEV_MAJOR_S, 0); 800 cdevsw_add(&dev, &pts_cdevsw, NULL); 801 dev = makedev(CDEV_MAJOR_C, 0); 802 cdevsw_add(&dev, &ptc_cdevsw, NULL); 803 ptc_devsw_installed = 1; 804#ifdef DEVFS | 797 798static void 799ptc_drvinit(void *unused) 800{ 801#ifdef DEVFS 802 int i,j,k; 803#endif 804 dev_t dev; 805 806 if( ! ptc_devsw_installed ) { 807 dev = makedev(CDEV_MAJOR_S, 0); 808 cdevsw_add(&dev, &pts_cdevsw, NULL); 809 dev = makedev(CDEV_MAJOR_C, 0); 810 cdevsw_add(&dev, &ptc_cdevsw, NULL); 811 ptc_devsw_installed = 1; 812#ifdef DEVFS |
805/*XXX*/ 806#if NPTY > MAXUNITS 807#undef NPTY 808#define NPTY MAXUNITS 809#endif | |
810 for ( i = 0 ; i<NPTY ; i++ ) { 811 j = i / 32; 812 k = i % 32; 813 devfs_token_pts[i] = 814 devfs_add_devswf(&pts_cdevsw,i, 815 DV_CHR,0,0,0666, 816 "tty%c%n",jnames[j],k); 817 devfs_token_ptc[i] = 818 devfs_add_devswf(&ptc_cdevsw,i, 819 DV_CHR,0,0,0666, 820 "pty%c%n",jnames[j],k); 821 } 822#endif 823 } 824} 825 826SYSINIT(ptcdev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE+CDEV_MAJOR_C,ptc_drvinit,NULL) | 813 for ( i = 0 ; i<NPTY ; i++ ) { 814 j = i / 32; 815 k = i % 32; 816 devfs_token_pts[i] = 817 devfs_add_devswf(&pts_cdevsw,i, 818 DV_CHR,0,0,0666, 819 "tty%c%n",jnames[j],k); 820 devfs_token_ptc[i] = 821 devfs_add_devswf(&ptc_cdevsw,i, 822 DV_CHR,0,0,0666, 823 "pty%c%n",jnames[j],k); 824 } 825#endif 826 } 827} 828 829SYSINIT(ptcdev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE+CDEV_MAJOR_C,ptc_drvinit,NULL) |