diff options
author | dzwdz | 2021-09-20 18:54:40 +0200 |
---|---|---|
committer | dzwdz | 2021-09-20 18:54:40 +0200 |
commit | 29bcaabe450e1bbd906111c5c83407d80abd584d (patch) | |
tree | e898b1f3994c67c157c834ee8bcd2e7bb7176b63 /src/init | |
parent | 7ba8059015fd08a952d48ab71bf91202ea4f06eb (diff) |
use a single struct for all fs_wait return values
Diffstat (limited to 'src/init')
-rw-r--r-- | src/init/syscalls.c | 5 | ||||
-rw-r--r-- | src/init/tar.c | 19 |
2 files changed, 13 insertions, 11 deletions
diff --git a/src/init/syscalls.c b/src/init/syscalls.c index 549ff61..7d0fef9 100644 --- a/src/init/syscalls.c +++ b/src/init/syscalls.c @@ -38,8 +38,9 @@ handle_t _syscall_fs_create(handle_t __user *back) { return _syscall(_SYSCALL_FS_CREATE, (int)back, 0, 0, 0); } -int _syscall_fs_wait(handle_t back, char __user *buf, int __user *len, int __user *id) { - return _syscall(_SYSCALL_FS_WAIT, back, (int)buf, (int)len, (int)id); +int _syscall_fs_wait(handle_t back, char __user *buf, int max_len, + struct fs_wait_response __user *res) { + return _syscall(_SYSCALL_FS_WAIT, back, (int)buf, max_len, (int)res); } int _syscall_fs_respond(char __user *buf, int ret) { diff --git a/src/init/tar.c b/src/init/tar.c index 43efe3b..74e4c83 100644 --- a/src/init/tar.c +++ b/src/init/tar.c @@ -3,6 +3,8 @@ #include <shared/syscalls.h> #include <stdint.h> +#define BUF_SIZE 64 + extern int tty_fd; // TODO struct tar @@ -12,20 +14,19 @@ static void *tar_find(const char *path, size_t path_len, void *base, size_t base static int oct_parse(char *str, size_t len); void tar_driver(handle_t back, void *base) { - static char buf[64]; - int len; - void *id; // IDs usually are integers, but here i'm using them as pointers - // to the metadata sectors + static char buf[BUF_SIZE]; + struct fs_wait_response res; for (;;) { - len = 64; - switch (_syscall_fs_wait(back, buf, &len, (int*)&id)) { + switch (_syscall_fs_wait(back, buf, BUF_SIZE, &res)) { case VFSOP_OPEN: - _syscall_fs_respond(NULL, tar_open(buf, len, base, ~0)); + _syscall_fs_respond(NULL, tar_open(buf, res.len, base, ~0)); break; - case VFSOP_READ: - _syscall_fs_respond(id + 512, tar_size(id)); + case VFSOP_READ: { + void *meta = (void*)res.id; + _syscall_fs_respond(meta + 512, tar_size(meta)); break; + } default: _syscall_fs_respond(NULL, -1); // unsupported |