[net.bugs.4bsd] FIONREAD bug

z (07/16/82)

The FIONREAD ioctl works properly when used on slave pty's, but not on
controller pty's; it erroneously always returns zero.  The reason is
that the character count for the controller pty is located in a
different place from where FIONREAD expects it.  The following code
corrects this.  There are a number of places this code can be put; we
put it right after the first statement in ptyioctl (the statement which
sets up tp).

	if (cdevsw[major(dev)].d_open == ptcopen && cmd == FIONREAD) {
	    	off_t nread;
	    	nread = tp->t_outq.c_cc;
	    	if (copyout((caddr_t)&nread, addr, sizeof (off_t)))
		       u.u_error = EFAULT;
	    	return;
	}