From: David van Moolenbroek Date: Mon, 25 Aug 2014 19:34:39 +0000 (+0000) Subject: tty/pty: unbreak stty(1) X-Git-Tag: v3.3.0~47 X-Git-Url: http://zhaoyanbai.com/repos/?a=commitdiff_plain;h=refs%2Fchanges%2F84%2F2784%2F1;p=minix.git tty/pty: unbreak stty(1) Change-Id: I3f857dcbb89e18c7db3a72f4bd6809beb7904bc0 --- diff --git a/minix/drivers/tty/pty/pty.c b/minix/drivers/tty/pty/pty.c index 772aa5b09..6fc49bc30 100644 --- a/minix/drivers/tty/pty/pty.c +++ b/minix/drivers/tty/pty/pty.c @@ -45,7 +45,8 @@ typedef struct pty { /* Output buffer. */ int ocount; /* # characters in the buffer */ char *ohead, *otail; /* head and tail of the circular buffer */ - char obuf[2048]; /* buffer for bytes going to the pty reader */ + char obuf[TTY_OUT_BYTES]; + /* buffer for bytes going to the pty reader */ /* select() data. */ unsigned int select_ops; /* Which operations do we want to know about? */ diff --git a/minix/drivers/tty/pty/tty.c b/minix/drivers/tty/pty/tty.c index 48bb90068..1f71a17d5 100644 --- a/minix/drivers/tty/pty/tty.c +++ b/minix/drivers/tty/pty/tty.c @@ -84,6 +84,8 @@ static struct termios termios_defaults = { }; static struct winsize winsize_defaults; /* = all zeroes */ +static const char lined[TTLINEDNAMELEN] = "termios"; /* line discipline */ + /* Global variables for the TTY task (declared extern in tty.h). */ tty_t tty_table[NR_PTYS]; u32_t system_hz; @@ -391,17 +393,25 @@ static int do_ioctl(devminor_t minor, unsigned long request, endpoint_t endpt, sigchar(tp, SIGWINCH, 0); break; case TIOCGETD: /* get line discipline */ - { - int disc = TTYDISC; - r = sys_safecopyto(endpt, grant, 0, - (vir_bytes) &disc, (vir_bytes) sizeof(disc)); + i = TTYDISC; + r = sys_safecopyto(endpt, grant, 0, (vir_bytes) &i, sizeof(i)); break; - } case TIOCSETD: /* set line discipline */ printf("TTY: TIOCSETD: can't set any other line discipline.\n"); r = ENOTTY; break; - + case TIOCGLINED: /* get line discipline as string */ + r = sys_safecopyto(endpt, grant, 0, (vir_bytes) lined, sizeof(lined)); + break; + case TIOCGQSIZE: /* get input/output queue sizes */ + /* Not sure what to report here. We are using input and output queues + * of different sizes, and the IOCTL allows for one single value for + * both. So far this seems to be just for stty(1) so let's just report + * the larger of the two. TODO: revisit queue sizes altogether. + */ + i = MAX(TTY_IN_BYTES, TTY_OUT_BYTES); + r = sys_safecopyto(endpt, grant, 0, (vir_bytes) &i, sizeof(i)); + break; case TIOCSCTTY: /* Process sets this tty as its controlling tty */ tp->tty_pgrp = user_endpt; diff --git a/minix/drivers/tty/pty/tty.h b/minix/drivers/tty/pty/tty.h index 7fae103ee..8d353cfec 100644 --- a/minix/drivers/tty/pty/tty.h +++ b/minix/drivers/tty/pty/tty.h @@ -8,6 +8,7 @@ #define PTYPX_MINOR 192 #define TTY_IN_BYTES 256 /* tty input queue size */ +#define TTY_OUT_BYTES 2048 /* tty output queue size */ #define TAB_SIZE 8 /* distance between tab stops */ #define TAB_MASK 7 /* mask to compute a tab stop position */ diff --git a/minix/drivers/tty/tty/tty.c b/minix/drivers/tty/tty/tty.c index 51519cc46..841035acd 100644 --- a/minix/drivers/tty/tty/tty.c +++ b/minix/drivers/tty/tty/tty.c @@ -133,6 +133,8 @@ u32_t system_hz; u32_t consoleline = CONS_MINOR; u32_t kernel_msg_color = 0; +static const char lined[TTLINEDNAMELEN] = "termios"; /* line discipline */ + /* SEF functions and variables. */ static void sef_local_startup(void); static int sef_cb_init_fresh(int type, sef_init_info_t *info); @@ -677,16 +679,20 @@ static int do_ioctl(devminor_t minor, unsigned long request, endpoint_t endpt, beep_x(bell.kb_pitch, ticks); break; case TIOCGETD: /* get line discipline */ - { - int disc = TTYDISC; - r = sys_safecopyto(endpt, grant, 0, - (vir_bytes) &disc, (vir_bytes) sizeof(disc)); + i = TTYDISC; + r = sys_safecopyto(endpt, grant, 0, (vir_bytes) &i, sizeof(i)); break; - } case TIOCSETD: /* set line discipline */ printf("TTY: TIOCSETD: can't set any other line discipline.\n"); r = ENOTTY; break; + case TIOCGLINED: /* get line discipline as string */ + r = sys_safecopyto(endpt, grant, 0, (vir_bytes) lined, sizeof(lined)); + break; + case TIOCGQSIZE: /* get input/output queue sizes */ + i = TTY_IN_BYTES; /* best we can do.. */ + r = sys_safecopyto(endpt, grant, 0, (vir_bytes) &i, sizeof(i)); + break; case KIOCSMAP: /* Load a new keymap (only /dev/console). */ if (isconsole(tp)) r = kbd_loadmap(endpt, grant);