diff options
author | dzwdz | 2022-08-11 22:29:48 +0200 |
---|---|---|
committer | dzwdz | 2022-08-11 22:29:48 +0200 |
commit | 162395700b100943eb019ce2b363f4d6ed03ab1a (patch) | |
tree | 69f3e3905a6e2a162de91e7f2e1f8336dc045d4b /src/kernel/pipe.c | |
parent | 35e5e715070db6c4862f70fb05008fcb88420db9 (diff) |
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.
Diffstat (limited to 'src/kernel/pipe.c')
-rw-r--r-- | src/kernel/pipe.c | 18 |
1 files changed, 13 insertions, 5 deletions
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 <kernel/pipe.h> #include <kernel/util.h> -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; |