summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/init/fs/misc.c5
-rw-r--r--src/init/tar.c5
-rw-r--r--src/kernel/vfs/request.c3
-rw-r--r--src/shared/syscalls.h3
4 files changed, 11 insertions, 5 deletions
diff --git a/src/init/fs/misc.c b/src/init/fs/misc.c
index d12fce3..cb94ef5 100644
--- a/src/init/fs/misc.c
+++ b/src/init/fs/misc.c
@@ -17,8 +17,8 @@ void fs_passthru(const char *prefix) {
int ret, prefix_len;
if (prefix) prefix_len = strlen(prefix);
- for (;;) {
- switch (_syscall_fs_wait(buf, buf_size, &res)) {
+ while (!_syscall_fs_wait(buf, buf_size, &res)) {
+ switch (res.op) {
case VFSOP_OPEN:
if (prefix) {
if (prefix_len + res.len <= buf_size) {
@@ -50,4 +50,5 @@ void fs_passthru(const char *prefix) {
break;
}
}
+ _syscall_exit(0);
}
diff --git a/src/init/tar.c b/src/init/tar.c
index b041a98..e0843e7 100644
--- a/src/init/tar.c
+++ b/src/init/tar.c
@@ -18,8 +18,8 @@ static const char *root_fakemeta = ""; /* see comment in tar_open */
void tar_driver(void *base) {
static char buf[BUF_SIZE];
struct fs_wait_response res;
- for (;;) {
- switch (_syscall_fs_wait(buf, BUF_SIZE, &res)) {
+ while (!_syscall_fs_wait(buf, BUF_SIZE, &res)) {
+ switch (res.op) {
case VFSOP_OPEN:
_syscall_fs_respond(NULL, tar_open(buf, res.len, base, ~0));
break;
@@ -33,6 +33,7 @@ void tar_driver(void *base) {
break;
}
}
+ _syscall_exit(0);
}
static int tar_open(const char *path, int len, void *base, size_t base_len) {
diff --git a/src/kernel/vfs/request.c b/src/kernel/vfs/request.c
index f431eac..45a7ae7 100644
--- a/src/kernel/vfs/request.c
+++ b/src/kernel/vfs/request.c
@@ -63,12 +63,13 @@ _Noreturn void vfs_request_pass2handler(struct vfs_request *req) {
res.capacity = req->output.len;
res.id = req->id;
res.offset = req->offset;
+ res.op = req->type;
if (!virt_cpy_to(handler->pages,
handler->awaited_req.res, &res, sizeof res))
goto fail; // can't copy response struct
- regs_savereturn(&handler->regs, req->type);
+ regs_savereturn(&handler->regs, 0);
process_switch(handler);
fail:
panic_unimplemented(); // TODO
diff --git a/src/shared/syscalls.h b/src/shared/syscalls.h
index 8ec1a41..b78246c 100644
--- a/src/shared/syscalls.h
+++ b/src/shared/syscalls.h
@@ -50,11 +50,14 @@ int _syscall_close(handle_t);
handle_t _syscall_fs_fork2(void);
struct fs_wait_response {
+ enum vfs_operation op;
int len; // how much was put in *buf
int capacity; // how much output can be accepted by the caller
int id; // file id (returned by the open handler, passed to other calls)
int offset;
};
+/** Blocks until an fs request is made.
+ * @return 0 if everything was successful */
int _syscall_fs_wait(char __user *buf, int max_len, struct fs_wait_response __user *res);
int _syscall_fs_respond(char __user *buf, int ret);