summaryrefslogtreecommitdiff
path: root/src/kernel/vfs/request.c
diff options
context:
space:
mode:
authordzwdz2024-08-17 01:57:04 +0200
committerdzwdz2024-08-17 01:57:04 +0200
commit468ef8f1d57527af3fe8b67bbc73813e951a0ec5 (patch)
tree0e10641f6bc7548bdb0dbd77cd5c4737977a197b /src/kernel/vfs/request.c
parent806eecd7a2fe12daccf2c7c7171ce52e3fd93799 (diff)
kernel: split the kernel/user inputs in VfsReq
I think I've done this refactor in the opposite direction a few years ago. This is mostly meant to prepare me for setxattr, which requires two inputs - coincidentally, one is already going to be a kernel input, and the other will be an user input, so it works out. I also just didn't like the previous way it worked, this feels cleaner.
Diffstat (limited to 'src/kernel/vfs/request.c')
-rw-r--r--src/kernel/vfs/request.c36
1 files changed, 17 insertions, 19 deletions
diff --git a/src/kernel/vfs/request.c b/src/kernel/vfs/request.c
index 69a007e..9b60080 100644
--- a/src/kernel/vfs/request.c
+++ b/src/kernel/vfs/request.c
@@ -100,11 +100,11 @@ vfsreq_finish(VfsReq *req, char __user *stored, long ret, int flags, Proc *handl
}
if (req->type == VFSOP_READ && ret >= 0) {
- assert((size_t)ret <= req->output.len);
+ assert((size_t)ret <= req->outlen);
}
- if (req->input.kern) {
- kfree(req->input.buf_kern);
+ if (req->kin) {
+ kfree(req->kin);
}
if (req->backend) {
@@ -148,23 +148,21 @@ vfsback_useraccept(VfsReq *req)
// it's a way to tell apart kernel and user backends apart
// TODO check validity of memory regions somewhere else
- if (req->input.buf) {
- __user void *buf = handler->awaited_req.buf;
- len = min(req->input.len, handler->awaited_req.max_len);
- if (req->input.kern) {
- pcpy_to(handler, buf, req->input.buf_kern, len);
- } else {
- len = pcpy_bi(
- handler, buf,
- req->caller, req->input.buf, len
- );
- }
+ assert(!(req->kin && req->uin));
+ if (req->kin) {
+ void __user *buf = handler->awaited_req.buf;
+ len = min(req->kinlen, handler->awaited_req.max_len);
+ pcpy_to(handler, buf, req->kin, len);
+ } else if (req->uin) {
+ void __user *buf = handler->awaited_req.buf;
+ len = min(req->uinlen, handler->awaited_req.max_len);
+ len = pcpy_bi(handler, buf, req->caller, req->uin, len);
} else {
- len = req->output.len;
+ len = req->outlen;
}
res.len = len;
- res.capacity = req->output.len;
+ res.capacity = req->outlen;
res.id = req->id;
res.id2 = req->id2;
res.offset = req->offset;
@@ -263,16 +261,16 @@ reqqueue_ringreadall(ReqQueue *q, ring_t *r)
/* read as much as the biggest request wants */
for (req = q->head; req; req = req->reqqueue_next) {
- mlen = max(mlen, req->output.len);
+ mlen = max(mlen, req->outlen);
}
mlen = min(mlen, sizeof tmp);
mlen = ring_get(r, tmp, mlen);
while ((req = reqqueue_pop(q))) {
- size_t ret = min(mlen, req->output.len);
+ size_t ret = min(mlen, req->outlen);
assert(req->type == VFSOP_READ);
if (req->caller) {
- pcpy_to(req->caller, req->output.buf, tmp, ret);
+ pcpy_to(req->caller, req->out, tmp, ret);
}
vfsreq_finish_short(req, ret);
}