Subject: port-amiga/2519: Amiga port doesn't attach ttys to kernel tty list
To: None <gnats-bugs@NetBSD.ORG>
From: Jason R. Thorpe <thorpej@Feeble-Gourmet.COM>
List: netbsd-bugs
Date: 06/04/1996 22:35:26
>Number:         2519
>Category:       port-amiga
>Synopsis:       Amiga port doesn't attach ttys to kernel tty list
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    gnats-admin (GNATS administrator)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Jun  5 02:05:10 1996
>Last-Modified:
>Originator:     Jason R. Thorpe
>Organization:
The Feeble Gourmet
>Release:        NetBSD 1.2_ALPHA sup'd June 3
>Environment:
	
System: NetBSD coredump 1.2_ALPHA NetBSD 1.2_ALPHA (COREDUMP) #0: Mon Jun 3 20:21:47 PDT 1996 root@coredump:/local/src/sys/arch/amiga/compile/COREDUMP amiga


>Description:
	tty structres aren't attached to the tty list, so tty stats can't
	be read from userland.

>How-To-Repeat:
	Run pstat -t ... lose.

>Fix:
	Attached below are the obvious patches ... I've missed any
	statically allocated tty structs, if there are any.

	It'd be nice if this hit the release branch.

*** /tmp/ite.c	Tue Jun  4 22:26:07 1996
--- ite.c	Tue Jun  4 22:27:23 1996
***************
*** 444,452 ****
  	
  	ip = getitesp(dev);
  
! 	if (ip->tp == NULL)
  		tp = ip->tp = ttymalloc();
! 	else
  		tp = ip->tp;
  	if ((tp->t_state & (TS_ISOPEN | TS_XCLUDE)) == (TS_ISOPEN | TS_XCLUDE)
  	    && p->p_ucred->cr_uid != 0)
--- 444,453 ----
  	
  	ip = getitesp(dev);
  
! 	if (ip->tp == NULL) {
  		tp = ip->tp = ttymalloc();
! 		tty_attach(tp);
! 	} else
  		tp = ip->tp;
  	if ((tp->t_state & (TS_ISOPEN | TS_XCLUDE)) == (TS_ISOPEN | TS_XCLUDE)
  	    && p->p_ucred->cr_uid != 0)
*** /tmp/mfc.c	Tue Jun  4 22:26:14 1996
--- mfc.c	Tue Jun  4 22:27:43 1996
***************
*** 483,490 ****
  
  	if (sc->sc_tty)
  		tp = sc->sc_tty;
! 	else
  		tp = sc->sc_tty = ttymalloc();
  
  	tp->t_oproc = (void (*) (struct tty *)) mfcsstart;
  	tp->t_param = mfcsparam;
--- 483,492 ----
  
  	if (sc->sc_tty)
  		tp = sc->sc_tty;
! 	else {
  		tp = sc->sc_tty = ttymalloc();
+ 		tty_attach(tp);
+ 	}
  
  	tp->t_oproc = (void (*) (struct tty *)) mfcsstart;
  	tp->t_param = mfcsparam;
*** /tmp/msc.c	Tue Jun  4 22:26:21 1996
--- msc.c	Tue Jun  4 22:28:08 1996
***************
*** 323,328 ****
--- 323,329 ----
    if (!msc_tty[ttyn]) {
  
        tp = ttymalloc();
+       tty_attach(tp);
        msc_tty[ttyn] = tp;
        msc_tty[ttyn+1] = (struct tty *)NULL;
  
*** /tmp/ser.c	Tue Jun  4 22:25:24 1996
--- ser.c	Tue Jun  4 22:24:15 1996
***************
*** 250,258 ****
  
  	if (ser_tty[unit]) 
  		tp = ser_tty[unit];
! 	else
  		tp = ((struct ser_softc *)ser_cd.cd_devs[unit])->ser_tty =
  		    ser_tty[unit] =  ttymalloc();
  
  	tp->t_oproc = (void (*) (struct tty *)) serstart;
  	tp->t_param = serparam;
--- 250,260 ----
  
  	if (ser_tty[unit]) 
  		tp = ser_tty[unit];
! 	else {
  		tp = ((struct ser_softc *)ser_cd.cd_devs[unit])->ser_tty =
  		    ser_tty[unit] =  ttymalloc();
+ 		tty_attach(tp);
+ 	}
  
  	tp->t_oproc = (void (*) (struct tty *)) serstart;
  	tp->t_param = serparam;
>Audit-Trail:
>Unformatted: