summaryrefslogtreecommitdiffstats
path: root/sys/kern/tty_pts.c
diff options
context:
space:
mode:
authored <ed@FreeBSD.org>2008-12-13 07:23:55 +0000
committered <ed@FreeBSD.org>2008-12-13 07:23:55 +0000
commit7397703a4c3f486b6d07c4be65374baae3776f5a (patch)
treeae8eeb23ae692d601dbfdcf2332a18c9838f661d /sys/kern/tty_pts.c
parent87d51087469197c8178c6ac4f4b0ba96f7ce41dc (diff)
downloadFreeBSD-src-7397703a4c3f486b6d07c4be65374baae3776f5a.zip
FreeBSD-src-7397703a4c3f486b6d07c4be65374baae3776f5a.tar.gz
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
Diffstat (limited to 'sys/kern/tty_pts.c')
-rw-r--r--sys/kern/tty_pts.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/sys/kern/tty_pts.c b/sys/kern/tty_pts.c
index 9e81a6d..c767daa 100644
--- a/sys/kern/tty_pts.c
+++ b/sys/kern/tty_pts.c
@@ -273,6 +273,16 @@ ptsdev_ioctl(struct file *fp, u_long cmd, void *data,
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;
OpenPOWER on IntegriCloud