tty: add ttyname ioctl

This commit is contained in:
Matheus
2024-05-28 18:12:05 -03:00
parent 1dd262fcca
commit 35eca115f5
2 changed files with 29 additions and 2 deletions
+7
View File
@@ -295,6 +295,8 @@ static int poll(int minor, polldata_t *data, int events) {
#define TIOCSCTTY 0x540E
#define TIOCGPGRP 0x540F
#define TIOCSPGRP 0x5410
#define TTY_IOCTL_NAME 0x771101141113l
#define TTY_NAME_MAX 32
int tty_ioctl(tty_t *tty, unsigned long req, void *arg, int *result) {
switch (req) {
@@ -350,6 +352,11 @@ int tty_ioctl(tty_t *tty, unsigned long req, void *arg, int *result) {
PROC_RELEASE(proc);
return error;
}
case TTY_IOCTL_NAME: {
size_t len = min(strlen(tty->name) + 1, TTY_NAME_MAX);
memcpy(arg, tty->name, len);
break;
}
default:
return ENOTTY;
}