mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-10-27 12:48:22 +00:00
pty: handle tty ioctl
This commit is contained in:
@@ -34,5 +34,6 @@ void tty_init();
|
||||
tty_t *tty_create(char *name, ttydevicewritefn_t writefn, ttyinactivefn_t inactivefn, void *internal);
|
||||
void tty_process(tty_t *tty, char c);
|
||||
void tty_unregister(tty_t *tty);
|
||||
int tty_ioctl(tty_t *tty, unsigned long req, void *arg, int *result);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -22,6 +22,7 @@ typedef unsigned int tcflag_t;
|
||||
#define TCGETS 0x5401
|
||||
#define TCSETS 0x5402
|
||||
#define TIOCGWINSZ 0x5413
|
||||
#define TIOCSWINSZ 0x5414
|
||||
|
||||
typedef struct {
|
||||
unsigned short ws_row;
|
||||
|
||||
+2
-3
@@ -198,14 +198,13 @@ static int ioctl(int minor, unsigned long request, void *_arg, int *result) {
|
||||
return ENODEV;
|
||||
|
||||
switch (request) {
|
||||
case TIOCGPTN:
|
||||
{
|
||||
case TIOCGPTN: {
|
||||
int *arg = _arg;
|
||||
*arg = pty->minor;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return ENOTTY;
|
||||
return tty_ioctl(pty->tty, request, _arg, result);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
+22
-9
@@ -25,7 +25,7 @@ void tty_process(tty_t *tty, char c) {
|
||||
char echoc = (tty->termios.c_lflag & ECHO) ? c : '\0';
|
||||
|
||||
// echo control characters
|
||||
if ((tty->termios.c_lflag & ECHOCTL) && c < 32 && c != '\n' && c != '\r' && c != '\b' && c != '\t') {
|
||||
if ((tty->termios.c_lflag & ECHOCTL) && c < 32 && c != '\n' && c != '\r' && c != '\b' && c != '\t' && c != '\e') {
|
||||
char tmp[2] = {'^', c + 0x40};
|
||||
tty->writetodevice(tty->deviceinternal, tmp, 2);
|
||||
}
|
||||
@@ -231,22 +231,27 @@ static int poll(int minor, polldata_t *data, int events) {
|
||||
return internalpoll(tty, data, events);
|
||||
}
|
||||
|
||||
static int ioctl(int minor, unsigned long req, void *arg, int *result) {
|
||||
tty_t *tty = ttyget(minor);
|
||||
if (tty == NULL)
|
||||
return ENODEV;
|
||||
|
||||
int tty_ioctl(tty_t *tty, unsigned long req, void *arg, int *result) {
|
||||
switch (req) {
|
||||
case TIOCGWINSZ:
|
||||
case TIOCGWINSZ: {
|
||||
winsize_t *w = arg;
|
||||
*w = tty->winsize;
|
||||
break;
|
||||
case TCGETS:
|
||||
}
|
||||
case TIOCSWINSZ: {
|
||||
winsize_t *w = arg;
|
||||
tty->winsize = *w;
|
||||
// TODO send signal to foreground process group
|
||||
break;
|
||||
}
|
||||
case TCGETS: {
|
||||
*(termios_t *)arg = tty->termios;
|
||||
break;
|
||||
case TCSETS:
|
||||
}
|
||||
case TCSETS: {
|
||||
tty->termios = *(termios_t *)arg;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return ENOTTY;
|
||||
}
|
||||
@@ -254,6 +259,14 @@ static int ioctl(int minor, unsigned long req, void *arg, int *result) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ioctl(int minor, unsigned long req, void *arg, int *result) {
|
||||
tty_t *tty = ttyget(minor);
|
||||
if (tty == NULL)
|
||||
return ENODEV;
|
||||
|
||||
return tty_ioctl(tty, req, arg, result);
|
||||
}
|
||||
|
||||
static int isatty(int minor) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user