diff options
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; + } + } +} |