Subject: kern/451: bug in miscfs/fdesc
To: None <gnats-admin>
From: Alasdair Baird <alasdair@wildcat.demon.co.uk>
List: netbsd-bugs
Date: 08/31/1994 11:05:26
>Number:         451
>Category:       kern
>Synopsis:       fdesc file system implements botched /dev/tty
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    gnats-admin (Kernel Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Aug 31 11:05:11 1994
>Originator:     Alasdair Baird
>Organization:
absolutely none whatsoever
>Release:        current (29 Aug 94)
>Environment:
System: NetBSD wildcat.demon.co.uk 1.0_BETA NetBSD 1.0_BETA (WILDCAT) #54: Tue Aug 30 21:50:09 BST 1994 root@wildcat.demon.co.uk:/usr/src/sys/arch/i386/compile/WILDCAT i386


>Description:
	The fdesc file system, as well as providing /dev/fd/* and the
	/dev/std{in,out,err} special files, takes it upon itself to
	provide a /dev/tty.  Why when there is a perfectly satifactory
	one there already is beyond my ken, but fdesc also takes the
	opportunity to make it appear a fifo rather than a character
	special file.  This seems more than slighlty incredibly
	perverse, especially when applications expect /dev/tty to be
	a character special thingumy.
>How-To-Repeat:
	Union mount fdesc file system over /dev, try "ls -l /dev/tty"
	while simultaneously keeping a puzzled look off your face at
	the "p" in the first column.
>Fix:
	I haven't had time to fix it correctly, nor the desire when
	there is already a fully functioning /dev/tty---unless someone
	can suggest why the following is a bad idea, what follows
	merely excises the majority of the /dev/tty functionality from
	the fdesc filesystem.  (It also fixes/make proper use of a vfs
	macro to initialise a vattr structure, for no extra charge.)
	It seems to work; certainly my /dev/tty now appears to be a
	character special once again.


*** fdesc_vnops.c.orig	Tue Aug 30 02:07:18 1994
--- fdesc_vnops.c	Tue Aug 30 01:36:07 1994
***************
*** 198,203 ****
--- 198,204 ----
  			return (0);
  		}
  
+ #if 0
  		if (ap->a_cnp->cn_namelen == 3 && bcmp(pname, "tty", 3) == 0) {
  			struct vnode *ttyvp = cttyvp(p);
  			if (ttyvp == NULL) {
***************
*** 212,217 ****
--- 213,219 ----
  			VOP_LOCK(fvp);
  			return (0);
  		}
+ #endif
  
  		ln = 0;
  		switch (ap->a_cnp->cn_namelen) {
***************
*** 396,403 ****
  	case Fdevfd:
  	case Flink:
  	case Fctty:
! 		bzero((caddr_t) vap, sizeof(*vap));
! 		vattr_null(vap);
  		vap->va_fileid = VTOFDESC(vp)->fd_ix;
  
  		switch (VTOFDESC(vp)->fd_type) {
--- 398,404 ----
  	case Fdevfd:
  	case Flink:
  	case Fctty:
! 		VATTR_NULL(vap);
  		vap->va_fileid = VTOFDESC(vp)->fd_ix;
  
  		switch (VTOFDESC(vp)->fd_type) {
***************
*** 517,523 ****
--- 518,526 ----
  	{ FD_STDIN, UIO_MX, 5, "stdin" },
  	{ FD_STDOUT, UIO_MX, 6, "stdout" },
  	{ FD_STDERR, UIO_MX, 6, "stderr" },
+ #if 0
  	{ FD_CTTY, UIO_MX, 3, "tty" },
+ #endif
  	{ 0 }
  };
  
>Audit-Trail:
>Unformatted:


------------------------------------------------------------------------------