From 206ca77636cca94d14d7486a7a0e2679bf107a28 Mon Sep 17 00:00:00 2001 From: dzwdz Date: Thu, 16 Sep 2021 06:33:26 +0000 Subject: fs_read stub, basic implementation in userland --- src/init/main.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/init/main.c') diff --git a/src/init/main.c b/src/init/main.c index 15afaf5..bed9ddb 100644 --- a/src/init/main.c +++ b/src/init/main.c @@ -43,6 +43,14 @@ void fs_test(void) { file = _syscall_open(argify("/mnt/tty")); log("open returned. "); _syscall_write(file, argify("hello")); + + // try reading + char buf[8]; + int len; + for (int i = 0; i < 8; i++) + buf[i] = '.'; + len = _syscall_read(file, buf, len); + _syscall_write(tty_fd, buf, len + 1); // read 1 byte past, should be a dot } void fs_server(handle_t back) { @@ -57,6 +65,11 @@ void fs_server(handle_t back) { _syscall_fs_respond(NULL, 32); // doesn't check the path yet break; + case VFSOP_READ: + // all reads output "world" + _syscall_fs_respond("world", 5); + break; + case VFSOP_WRITE: // uppercase the buffer for (int i = 0; i < len; i++) buf[i] &= ~id; // id == 32 -- cgit v1.2.3