svn commit: r186030 - head/sys/kern

Ed Schouten ed at FreeBSD.org
Sat Dec 13 07:23:55 UTC 2008


Author: ed
Date: Sat Dec 13 07:23:55 2008
New Revision: 186030
URL: http://svn.freebsd.org/changeset/base/186030

Log:
  Add FIONREAD to pseudo-terminal master devices.
  
  All ioctl()'s that aren't implemented by pts(4) are forwarded to the TTY
  itself. Unfortunately this is not correct for FIONREAD, because it will
  give the wrong amount of bytes that are available to read.
  
  Tested by:	keramida
  Reminded by:	keramida

Modified:
  head/sys/kern/tty_pts.c

Modified: head/sys/kern/tty_pts.c
==============================================================================
--- head/sys/kern/tty_pts.c	Sat Dec 13 07:03:16 2008	(r186029)
+++ head/sys/kern/tty_pts.c	Sat Dec 13 07:23:55 2008	(r186030)
@@ -273,6 +273,16 @@ ptsdev_ioctl(struct file *fp, u_long cmd
 	case FIONBIO:
 		/* This device supports non-blocking operation. */
 		return (0);
+	case FIONREAD:
+		tty_lock(tp);
+		if (psc->pts_flags & PTS_FINISHED) {
+			/* Force read() to be called. */
+			*(int *)data = 1;
+		} else {
+			*(int *)data = ttydisc_getc_poll(tp);
+		}
+		tty_unlock(tp);
+		return (0);
 	case FIODGNAME: {
 		struct fiodgname_arg *fgn;
 		const char *p;


More information about the svn-src-all mailing list