From 468ef8f1d57527af3fe8b67bbc73813e951a0ec5 Mon Sep 17 00:00:00 2001 From: dzwdz Date: Sat, 17 Aug 2024 01:57:04 +0200 Subject: 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. --- src/kernel/syscalls.c | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) (limited to 'src/kernel/syscalls.c') diff --git a/src/kernel/syscalls.c b/src/kernel/syscalls.c index a6c807c..0b22770 100644 --- a/src/kernel/syscalls.c +++ b/src/kernel/syscalls.c @@ -96,11 +96,8 @@ hid_t _sys_open(const char __user *path, long len, int flags) { vfsreq_dispatchcopy((VfsReq) { .type = VFSOP_OPEN, - .input = { - .kern = true, - .buf_kern = path_buf, - .len = len, - }, + .kin = path_buf, + .kinlen = len, .caller = proc_cur, .backend = mount->backend, .flags = flags, @@ -198,12 +195,12 @@ static long simple_vfsop( .flags = flags, }; if (vfsop == VFSOP_READ) { - req.output.buf = buf; - req.output.len = len; + req.out = buf; + req.outlen = len; } if (vfsop == VFSOP_WRITE) { - req.input.buf = buf; - req.input.len = len; + req.uin = buf; + req.uinlen = len; } vfsreq_dispatchcopy(req); } else if (h->type == HANDLE_PIPE) { @@ -295,12 +292,8 @@ long _sys_fs_respond(hid_t hid, const void __user *buf, long ret, int flags) { if (ret > 0 && req->type == VFSOP_READ) { /* vfsreq_finish can't copy this data, as it doesn't know where the * buf argument came from */ - ret = min(ret, capped_cast32(req->output.len)); - ret = pcpy_bi( - req->caller, req->output.buf, - proc_cur, buf, - ret - ); + ret = min(ret, capped_cast32(req->outlen)); + ret = pcpy_bi(req->caller, req->out, proc_cur, buf, ret); } vfsreq_finish(req, (void __user *)buf, ret, flags, proc_cur); } -- cgit v1.2.3