From 162395700b100943eb019ce2b363f4d6ed03ab1a Mon Sep 17 00:00:00 2001 From: dzwdz Date: Thu, 11 Aug 2022 22:29:48 +0200 Subject: kernel/syscalls: merge a few syscalls into vfsop_simple Those had a lot of repeating code, but I'm not sure if this is the right change. Well, apart from making pipe_joinqueue more consistent. --- src/kernel/pipe.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'src/kernel/pipe.c') diff --git a/src/kernel/pipe.c b/src/kernel/pipe.c index 2dc98fe..bf775b8 100644 --- a/src/kernel/pipe.c +++ b/src/kernel/pipe.c @@ -3,12 +3,20 @@ #include #include -bool pipe_joinqueue(struct handle *h, bool wants_write, +static void pipe_trytransfer(struct handle *h); + +void pipe_joinqueue(struct handle *h, bool wants_write, struct process *proc, void __user *pbuf, size_t pbuflen) { assert(h && h->type == HANDLE_PIPE); - if (wants_write == h->pipe.write_end) return false; - if (!h->pipe.sister) return false; + if (wants_write == h->pipe.write_end) { + regs_savereturn(&proc->regs, -1); + return; + } + if (!h->pipe.sister) { + regs_savereturn(&proc->regs, -1); + return; + } struct process **slot = &h->pipe.queued; while (*slot) { @@ -22,10 +30,10 @@ bool pipe_joinqueue(struct handle *h, bool wants_write, proc->waits4pipe.buf = pbuf; proc->waits4pipe.len = pbuflen; proc->waits4pipe.next = NULL; - return true; + pipe_trytransfer(h); } -void pipe_trytransfer(struct handle *h) { +static void pipe_trytransfer(struct handle *h) { struct process *rdr, *wtr; struct virt_cpy_error cpyerr; int len; -- cgit v1.2.3