diff options
author | dzwdz | 2021-11-16 20:39:26 +0100 |
---|---|---|
committer | dzwdz | 2021-11-16 20:39:26 +0100 |
commit | ac88b6add9f26e71ed41ef0fbc61c96a25375095 (patch) | |
tree | 7b0e215d24d4d7a506836e424697b6727149d0fb /src/init/fs/misc.c | |
parent | fefca619c1b98f9fe27cfff0c32f39b751ee6a60 (diff) |
init: implement a halfassed passthrough fs
Diffstat (limited to 'src/init/fs/misc.c')
-rw-r--r-- | src/init/fs/misc.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/init/fs/misc.c b/src/init/fs/misc.c new file mode 100644 index 0000000..134c311 --- /dev/null +++ b/src/init/fs/misc.c @@ -0,0 +1,33 @@ +#include <init/stdlib.h> +#include <shared/flags.h> +#include <shared/syscalls.h> + +void fs_passthru() { + struct fs_wait_response res; + int buf_size = 64; + char buf[ 64]; + int ret; + + for (;;) { + switch (_syscall_fs_wait(buf, buf_size, &res)) { + case VFSOP_OPEN: + ret = _syscall_open(buf, res.len); + _syscall_fs_respond(NULL, ret); + break; + + case VFSOP_READ: + if (res.capacity > buf_size) + res.capacity = buf_size; /* don't overflow the buffer */ + ret = _syscall_read(res.id, buf, res.capacity, res.offset); + _syscall_fs_respond(buf, ret); + break; + + // temporarily doesn't support writing + // also TODO closing + + default: + _syscall_fs_respond(NULL, -1); + break; + } + } +} |