mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-10-27 12:48:22 +00:00
kernel: implement FIONREAD for ttys
This commit is contained in:
@@ -385,6 +385,13 @@ int tty_ioctl(tty_t *tty, unsigned long req, void *arg, int *result, cred_t *cre
|
||||
size_t len = min(strlen(tty->name) + 1, TTY_NAME_MAX);
|
||||
return USERCOPY_POSSIBLY_TO_USER(arg, tty->name, len);
|
||||
}
|
||||
case FIONREAD: {
|
||||
MUTEX_ACQUIRE(&tty->readmutex);
|
||||
int count = RINGBUFFER_DATACOUNT(&tty->readbuffer);
|
||||
MUTEX_RELEASE(&tty->readmutex);
|
||||
int status = USERCOPY_POSSIBLY_TO_USER(arg, &count, sizeof(count));
|
||||
return status;
|
||||
}
|
||||
default:
|
||||
return ENOTTY;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user