mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-11-01 15:08:21 +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);
|
tty_t *tty_create(char *name, ttydevicewritefn_t writefn, ttyinactivefn_t inactivefn, void *internal);
|
||||||
void tty_process(tty_t *tty, char c);
|
void tty_process(tty_t *tty, char c);
|
||||||
void tty_unregister(tty_t *tty);
|
void tty_unregister(tty_t *tty);
|
||||||
|
int tty_ioctl(tty_t *tty, unsigned long req, void *arg, int *result);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ typedef unsigned int tcflag_t;
|
|||||||
#define TCGETS 0x5401
|
#define TCGETS 0x5401
|
||||||
#define TCSETS 0x5402
|
#define TCSETS 0x5402
|
||||||
#define TIOCGWINSZ 0x5413
|
#define TIOCGWINSZ 0x5413
|
||||||
|
#define TIOCSWINSZ 0x5414
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
unsigned short ws_row;
|
unsigned short ws_row;
|
||||||
|
|||||||
+2
-3
@@ -198,14 +198,13 @@ static int ioctl(int minor, unsigned long request, void *_arg, int *result) {
|
|||||||
return ENODEV;
|
return ENODEV;
|
||||||
|
|
||||||
switch (request) {
|
switch (request) {
|
||||||
case TIOCGPTN:
|
case TIOCGPTN: {
|
||||||
{
|
|
||||||
int *arg = _arg;
|
int *arg = _arg;
|
||||||
*arg = pty->minor;
|
*arg = pty->minor;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
return ENOTTY;
|
return tty_ioctl(pty->tty, request, _arg, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
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';
|
char echoc = (tty->termios.c_lflag & ECHO) ? c : '\0';
|
||||||
|
|
||||||
// echo control characters
|
// 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};
|
char tmp[2] = {'^', c + 0x40};
|
||||||
tty->writetodevice(tty->deviceinternal, tmp, 2);
|
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);
|
return internalpoll(tty, data, events);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ioctl(int minor, unsigned long req, void *arg, int *result) {
|
int tty_ioctl(tty_t *tty, unsigned long req, void *arg, int *result) {
|
||||||
tty_t *tty = ttyget(minor);
|
|
||||||
if (tty == NULL)
|
|
||||||
return ENODEV;
|
|
||||||
|
|
||||||
switch (req) {
|
switch (req) {
|
||||||
case TIOCGWINSZ:
|
case TIOCGWINSZ: {
|
||||||
winsize_t *w = arg;
|
winsize_t *w = arg;
|
||||||
*w = tty->winsize;
|
*w = tty->winsize;
|
||||||
break;
|
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;
|
*(termios_t *)arg = tty->termios;
|
||||||
break;
|
break;
|
||||||
case TCSETS:
|
}
|
||||||
|
case TCSETS: {
|
||||||
tty->termios = *(termios_t *)arg;
|
tty->termios = *(termios_t *)arg;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
return ENOTTY;
|
return ENOTTY;
|
||||||
}
|
}
|
||||||
@@ -254,6 +259,14 @@ static int ioctl(int minor, unsigned long req, void *arg, int *result) {
|
|||||||
return 0;
|
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) {
|
static int isatty(int minor) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user