tty/pty: unbreak stty(1)
Change-Id: I3f857dcbb89e18c7db3a72f4bd6809beb7904bc0
This commit is contained in:
parent
e5c9686c0f
commit
391516dd77
4 changed files with 30 additions and 12 deletions
|
@ -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? */
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 */
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue