diff options
author | dzwdz | 2021-09-16 06:42:07 +0000 |
---|---|---|
committer | dzwdz | 2021-09-16 06:42:07 +0000 |
commit | 267a85f9ef709ccbefe5ae0ccbb306bd21921418 (patch) | |
tree | f5ed73b0fdb5500bc81ed790c69d8b2764f0ad32 /src/kernel | |
parent | 206ca77636cca94d14d7486a7a0e2679bf107a28 (diff) |
implement output from vfs calls
Diffstat (limited to 'src/kernel')
-rw-r--r-- | src/kernel/syscalls.c | 11 | ||||
-rw-r--r-- | src/kernel/vfs/request.c | 1 | ||||
-rw-r--r-- | src/kernel/vfs/request.h | 8 |
3 files changed, 12 insertions, 8 deletions
diff --git a/src/kernel/syscalls.c b/src/kernel/syscalls.c index d39aed9..a5c6f43 100644 --- a/src/kernel/syscalls.c +++ b/src/kernel/syscalls.c @@ -236,7 +236,16 @@ int _syscall_fs_respond(char __user *buf, int ret) { struct vfs_request *req = process_current->handled_req; if (!req) return -1; - // TODO copy buffer + if (req->output.len > 0 && ret > 0) { + // if this vfsop outputs data and ret is positive, it's the length of the buffer + // TODO document + if (ret > req->output.len) + ret = req->output.len; // i'm not handling this in a special way - the fs server can prevent this on its own + if (!virt_cpy(req->caller->pages, req->output.buf, + process_current->pages, buf, ret)) { + // how should this error even be handled? TODO + } + } process_current->handled_req = NULL; vfs_request_finish(req, ret); diff --git a/src/kernel/vfs/request.c b/src/kernel/vfs/request.c index 9a51688..6159bbf 100644 --- a/src/kernel/vfs/request.c +++ b/src/kernel/vfs/request.c @@ -96,7 +96,6 @@ int vfs_request_finish(struct vfs_request *req, int ret) { } if (req->input.kern) kfree(req->input.buf_kern); - if (req->output.kern) kfree(req->output.buf_kern); req->caller->state = PS_RUNNING; regs_savereturn(&req->caller->regs, ret); diff --git a/src/kernel/vfs/request.h b/src/kernel/vfs/request.h index aabef4f..0ad50e9 100644 --- a/src/kernel/vfs/request.h +++ b/src/kernel/vfs/request.h @@ -18,7 +18,7 @@ struct vfs_backend { // describes an in-process vfs call struct vfs_request { enum vfs_operation type; - struct { // TODO maybe this should be a separate type + struct { bool kern; // if false: use .buf ; if true: use .buf_kern union { char __user *buf; @@ -27,11 +27,7 @@ struct vfs_request { int len; } input; struct { - bool kern; // if false: use .buf ; if true: use .buf_kern - union { - char __user *buf; - char *buf_kern; - }; + char __user *buf; int len; } output; |