fix a few problems with pty. warn about how if you only have 1 pty

defined, your really getting 32.  Also warn about how you can't have
more than 256 pty's when your using DEVFS (non DEVFS can use more, just
the makedev script doesn't know how to make >256).  it also doesn't
allocate more memory than needed in this case.

Make sure that the signal passed in TIOCSIG isn't 0 as it might cause
a panic.  I personally haven't seen this happen, but after a similar
bug in syscons crashed my machine, I'm acutely aware of this one. :)
This commit is contained in:
John-Mark Gurney 1997-07-30 10:05:18 +00:00
parent f1909e979c
commit 5e2022633a

View File

@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)tty_pty.c 8.4 (Berkeley) 2/20/95
* $Id: tty_pty.c,v 1.42 1997/03/23 03:36:28 bde Exp $
* $Id: tty_pty.c,v 1.43 1997/03/24 12:03:06 bde Exp $
*/
/*
@ -93,6 +93,19 @@ static struct cdevsw ptc_cdevsw =
#if NPTY == 1
#undef NPTY
#define NPTY 32 /* crude XXX */
#warning You have only one pty defined, redefining to 32.
#endif
#ifdef DEVFS
#define MAXUNITS (8 * 32)
static void *devfs_token_pts[MAXUNITS];
static void *devfs_token_ptc[MAXUNITS];
static const char jnames[] = "pqrsPQRS";
#if NPTY > MAXUNITS
#undef NPTY
#define NPTY MAXUNITS
#warning Can't have more than 256 pty's with DEVFS defined.
#endif
#endif
#define BUFSIZ 100 /* Chunk size iomoved to/from user */
@ -710,7 +723,8 @@ ptyioctl(dev, cmd, data, flag, p)
break;
case TIOCSIG:
if (*(unsigned int *)data >= NSIG)
if (*(unsigned int *)data >= NSIG ||
*(unsigned int *)data == 0)
return(EINVAL);
if ((tp->t_lflag&NOFLSH) == 0)
ttyflush(tp, FREAD|FWRITE);
@ -780,12 +794,6 @@ ptyioctl(dev, cmd, data, flag, p)
}
static ptc_devsw_installed = 0;
#ifdef DEVFS
#define MAXUNITS (8 * 32)
static void *devfs_token_pts[MAXUNITS];
static void *devfs_token_ptc[MAXUNITS];
static const char jnames[] = "pqrsPQRS";
#endif
static void
ptc_drvinit(void *unused)
@ -802,11 +810,6 @@ ptc_drvinit(void *unused)
cdevsw_add(&dev, &ptc_cdevsw, NULL);
ptc_devsw_installed = 1;
#ifdef DEVFS
/*XXX*/
#if NPTY > MAXUNITS
#undef NPTY
#define NPTY MAXUNITS
#endif
for ( i = 0 ; i<NPTY ; i++ ) {
j = i / 32;
k = i % 32;