summaryrefslogtreecommitdiff
path: root/src/user/app/init/driver/ps2.c
diff options
context:
space:
mode:
authordzwdz2023-07-08 17:32:41 +0200
committerdzwdz2023-07-08 17:32:41 +0200
commit6b085892a0e99c21ccb2d94a2edab91cc4f87ad1 (patch)
treeffc97c5e4b210cfaa27425860de362afe7081a68 /src/user/app/init/driver/ps2.c
parentf74df1c4100401e88b8b31db4e25d53cf98b15df (diff)
user/keyboard: check open() path
this prevents someone from trying to `ls /keyboard/`, and makes `echo */*` in dash almost work if you mash the keyboard
Diffstat (limited to 'src/user/app/init/driver/ps2.c')
-rw-r--r--src/user/app/init/driver/ps2.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/user/app/init/driver/ps2.c b/src/user/app/init/driver/ps2.c
index 4fee60a..2752238 100644
--- a/src/user/app/init/driver/ps2.c
+++ b/src/user/app/init/driver/ps2.c
@@ -1,9 +1,10 @@
#include "driver.h"
+#include <camellia/compat.h>
#include <camellia/syscalls.h>
+#include <errno.h>
#include <shared/ring.h>
#include <stdbool.h>
#include <stdlib.h>
-#include <camellia/compat.h>
static const char keymap_lower[] = {
@@ -55,9 +56,15 @@ static void main_loop(void) {
struct ufs_request res;
int ret;
while (!c0_fs_wait(buf, sizeof buf, &res)) {
+ // TODO don't hang on ps2 reads
+
switch (res.op) {
case VFSOP_OPEN:
- c0_fs_respond(NULL, 1, 0);
+ if (res.len == 0) {
+ c0_fs_respond(NULL, 1, 0);
+ } else {
+ c0_fs_respond(NULL, -ENOENT, 0);
+ }
break;
case VFSOP_READ: