Subject: kern/31403: /dev/ptm tries to return /dev/ptyv0 which doesn't exist
To: None <kern-bug-people@netbsd.org, gnats-admin@netbsd.org,>
From: Simon Burge <simonb@wasabisystems.com>
List: netbsd-bugs
Date: 09/27/2005 14:47:02
>Number:         31403
>Category:       kern
>Synopsis:       /dev/ptm tries to return /dev/ptyv0 which doesn't exist
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Sep 27 14:47:02 +0000 2005
>Originator:     Simon Burge <simonb@wasabisystems.com>
>Release:        NetBSD 3.0_BETA from approx Sep 6, 2005
>Organization:
Wasabi Systems
>Environment:
System: NetBSD thoreau 3.0_BETA NetBSD 3.0_BETA (THOREAU) #1: Tue Sep 6 01:13:10 EST 2005 simonb@thoreau:/usr/obj/sys/arch/i386/compile/THOREAU i386
Architecture: i386
Machine: i386
>Description:

	When trying to start an xterm when there are already many
	xterms running, the following error happens:

	    thoreau 10758> xterm
	    xterm: Error 32, errno 2: No such file or directory
	    Reason: get_pty: not enough ptys

	ktrace shows:

	  2523 xterm    CALL  open(0xbd98998a,2,0x66c57c9)
	  2523 xterm    NAMI  "/dev/ptm"
	  2523 xterm    RET   open 4
	  2523 xterm    CALL  ioctl(4,TIOCPTMGET,0xbfbfce20)
	  2523 xterm    NAMI  "/dev/ptyv0"
	  2523 xterm    RET   ioctl -1 errno 2 No such file or directory


        It appears that /dev/ptm returns the next available pty number,
        and when this gets to 96, pty_makename() in kern/tty_bsdpty.c
        returns /dev/ttyv0 and /dev/ptyv0.  However, /dev/MAKEDEV
        doesn't create any ptyv* devices:

            if [ "$t1" = v ]; then
		warn "$i: pty unit conflicts with console ttyv0 device"
		continue
	    fi

	and thus we lose.

>How-To-Repeat:

	Start lots of xterms.

>Fix:

	Not sure.

        One idea is to remove 'v' from TTY_LETTERS in tty_bsdpty.c, and
        then adjust /dev/MAKEDEV so that ptyw0 is the minor number after
        ptyuf (ie, 96).