diff options
author | dzwdz | 2022-07-29 18:45:47 +0200 |
---|---|---|
committer | dzwdz | 2022-07-29 18:45:47 +0200 |
commit | a658e1068eb2f849736931d2b99bcb6290c7ec0a (patch) | |
tree | fd2f6d31cf74799aa7318524bea7c707767e6b0e /src | |
parent | c6424fbc55298399f133ca1ede11e1f0b4a5c824 (diff) |
syscall: up the max argument count to 5; make write accept flags
Diffstat (limited to 'src')
-rw-r--r-- | src/kernel/arch/amd64/sysenter.c | 2 | ||||
-rw-r--r-- | src/kernel/execbuf.c | 6 | ||||
-rw-r--r-- | src/kernel/syscalls.c | 10 | ||||
-rw-r--r-- | src/shared/include/camellia/execbuf.h | 2 | ||||
-rw-r--r-- | src/shared/include/camellia/syscalls.h | 4 | ||||
-rw-r--r-- | src/user/app/init/driver/ansiterm.c | 2 | ||||
-rw-r--r-- | src/user/app/init/driver/termcook.c | 4 | ||||
-rw-r--r-- | src/user/app/tests/pipe.c | 20 | ||||
-rw-r--r-- | src/user/app/tests/semaphore.c | 14 | ||||
-rw-r--r-- | src/user/app/tests/tests.c | 58 | ||||
-rw-r--r-- | src/user/lib/elfload.c | 4 | ||||
-rw-r--r-- | src/user/lib/esemaphore.c | 4 | ||||
-rw-r--r-- | src/user/lib/file.c | 2 | ||||
-rw-r--r-- | src/user/lib/fs/misc.c | 2 | ||||
-rw-r--r-- | src/user/lib/syscall.c | 32 | ||||
-rw-r--r-- | src/user/lib/syscall.c.awk | 4 |
16 files changed, 87 insertions, 83 deletions
diff --git a/src/kernel/arch/amd64/sysenter.c b/src/kernel/arch/amd64/sysenter.c index b5cec73..459247f 100644 --- a/src/kernel/arch/amd64/sysenter.c +++ b/src/kernel/arch/amd64/sysenter.c @@ -13,6 +13,6 @@ _Noreturn void sysexit(struct registers regs) { _Noreturn void sysenter_stage2(void) { struct registers *regs = &process_current->regs; *regs = _sysexit_regs; - _syscall(regs->rdi, regs->rsi, regs->rdx, regs->r10, regs->r8); + _syscall(regs->rdi, regs->rsi, regs->rdx, regs->r10, regs->r8, regs->r9); process_switch_any(); } diff --git a/src/kernel/execbuf.c b/src/kernel/execbuf.c index 682566e..8ab0268 100644 --- a/src/kernel/execbuf.c +++ b/src/kernel/execbuf.c @@ -19,7 +19,7 @@ static void try_fetch(struct process *proc, uint64_t *buf, size_t amt) { } _Noreturn void execbuf_run(struct process *proc) { - uint64_t buf[5]; + uint64_t buf[6]; assert(proc == process_current); // idiotic, but needed because of _syscall. assert(proc->state == PS_RUNNING); @@ -28,8 +28,8 @@ _Noreturn void execbuf_run(struct process *proc) { try_fetch(proc, buf, 1); switch (buf[0]) { case EXECBUF_SYSCALL: - try_fetch(proc, buf, 5); - _syscall(buf[0], buf[1], buf[2], buf[3], buf[4]); + try_fetch(proc, buf, 6); + _syscall(buf[0], buf[1], buf[2], buf[3], buf[4], buf[5]); process_switch_any(); case EXECBUF_JMP: diff --git a/src/kernel/syscalls.c b/src/kernel/syscalls.c index 9c4e2fa..0dec4c5 100644 --- a/src/kernel/syscalls.c +++ b/src/kernel/syscalls.c @@ -1,3 +1,4 @@ +#include <camellia/errno.h> #include <camellia/flags.h> #include <camellia/syscalls.h> #include <kernel/arch/generic.h> @@ -229,9 +230,11 @@ long _syscall_read(handle_t handle_num, void __user *buf, size_t len, long offse return -1; // dummy } -long _syscall_write(handle_t handle_num, const void __user *buf, size_t len, long offset) { +long _syscall_write(handle_t handle_num, const void __user *buf, size_t len, long offset, int flags) { struct handle *h = process_handle_get(process_current, handle_num); if (!h) SYSCALL_RETURN(-1); + if (flags != 0) + SYSCALL_RETURN(-ENOSYS); switch (h->type) { case HANDLE_FILE: vfsreq_create((struct vfs_request) { @@ -244,6 +247,7 @@ long _syscall_write(handle_t handle_num, const void __user *buf, size_t len, lon .offset = offset, .caller = process_current, .backend = h->backend, + .flags = flags }); break; case HANDLE_PIPE: @@ -387,7 +391,7 @@ void _syscall_debug_klog(const void __user *buf, size_t len) { // kprintf("[klog] %x\t%s\n", process_current->id, kbuf); } -long _syscall(long num, long a, long b, long c, long d) { +long _syscall(long num, long a, long b, long c, long d, long e) { /* note: this isn't the only place where syscalls get called from! * see execbuf */ switch (num) { @@ -413,7 +417,7 @@ long _syscall(long num, long a, long b, long c, long d) { _syscall_read(a, (userptr_t)b, c, d); break; case _SYSCALL_WRITE: - _syscall_write(a, (userptr_t)b, c, d); + _syscall_write(a, (userptr_t)b, c, d, e); break; case _SYSCALL_CLOSE: _syscall_close(a); diff --git a/src/shared/include/camellia/execbuf.h b/src/shared/include/camellia/execbuf.h index c9d444d..9741f66 100644 --- a/src/shared/include/camellia/execbuf.h +++ b/src/shared/include/camellia/execbuf.h @@ -1,7 +1,7 @@ #pragma once /* the instruction format is bound to change, atm it's extremely inefficient */ -/* takes 5 arguments */ +/* takes 6 arguments */ #define EXECBUF_SYSCALL 0xF0000001 /* takes 1 argument, changes %rip */ #define EXECBUF_JMP 0xF0000002 diff --git a/src/shared/include/camellia/syscalls.h b/src/shared/include/camellia/syscalls.h index 7864123..67bd713 100644 --- a/src/shared/include/camellia/syscalls.h +++ b/src/shared/include/camellia/syscalls.h @@ -33,7 +33,7 @@ enum { _SYSCALL_DEBUG_KLOG, }; -long _syscall(long, long, long, long, long); +long _syscall(long, long, long, long, long, long); /** Kills the current process. */ @@ -59,7 +59,7 @@ long _syscall_mount(handle_t h, const char __user *path, long len); handle_t _syscall_dup(handle_t from, handle_t to, int flags); long _syscall_read(handle_t h, void __user *buf, size_t len, long offset); -long _syscall_write(handle_t h, const void __user *buf, size_t len, long offset); +long _syscall_write(handle_t h, const void __user *buf, size_t len, long offset, int flags); long _syscall_close(handle_t h); struct fs_wait_response { diff --git a/src/user/app/init/driver/ansiterm.c b/src/user/app/init/driver/ansiterm.c index b5d3772..5daab41 100644 --- a/src/user/app/init/driver/ansiterm.c +++ b/src/user/app/init/driver/ansiterm.c @@ -20,7 +20,7 @@ static void flush(void) { /* we have to do multiple write() calls if we're behind a shitty passthrough fs * i don't like this either */ while (off < sizeof(vga)) - off += _syscall_write(vga_fd, (void*)vga + off, sizeof(vga) - off, off); + off += _syscall_write(vga_fd, (void*)vga + off, sizeof(vga) - off, off, 0); dirty = false; pendingFlush = false; } diff --git a/src/user/app/init/driver/termcook.c b/src/user/app/init/driver/termcook.c index 3dc6f32..83b46be 100644 --- a/src/user/app/init/driver/termcook.c +++ b/src/user/app/init/driver/termcook.c @@ -6,7 +6,7 @@ static void w_output(handle_t output, const char *buf, size_t len) { size_t pos = 0; while (pos < len) { - int ret = _syscall_write(output, buf + pos, len - pos, pos); + int ret = _syscall_write(output, buf + pos, len - pos, pos, 0); if (ret < 0) break; pos += ret; } @@ -33,7 +33,7 @@ static void line_editor(handle_t input, handle_t output) { w_output(output, linebuf, linepos); linepos = 0; } else { - _syscall_write(output, NULL, 0, 0); // eof + _syscall_write(output, NULL, 0, 0, 0); // eof } break; case '\n': diff --git a/src/user/app/tests/pipe.c b/src/user/app/tests/pipe.c index d6e954a..2d67fa7 100644 --- a/src/user/app/tests/pipe.c +++ b/src/user/app/tests/pipe.c @@ -17,28 +17,28 @@ void test_pipe(void) { if (!fork()) { /* those repeated asserts ensure that you can't read/write to the wrong ends */ assert(_syscall_read(ends[1], buf, 16, 0) < 0); - assert(_syscall_write(ends[0], buf, 16, 0) < 0); + assert(_syscall_write(ends[0], buf, 16, 0, 0) < 0); - ret = _syscall_write(ends[1], pipe_msgs[0], 5, -1); + ret = _syscall_write(ends[1], pipe_msgs[0], 5, -1, 0); assert(ret == 5); assert(_syscall_read(ends[1], buf, 16, 0) < 0); - assert(_syscall_write(ends[0], buf, 16, 0) < 0); + assert(_syscall_write(ends[0], buf, 16, 0, 0) < 0); - ret = _syscall_write(ends[1], pipe_msgs[1], 5, -1); + ret = _syscall_write(ends[1], pipe_msgs[1], 5, -1, 0); assert(ret == 5); exit(0); } else { assert(_syscall_read(ends[1], buf, 16, 0) < 0); - assert(_syscall_write(ends[0], buf, 16, 0) < 0); + assert(_syscall_write(ends[0], buf, 16, 0, 0) < 0); ret = _syscall_read(ends[0], buf, 16, 0); assert(ret == 5); assert(!memcmp(buf, pipe_msgs[0], 5)); assert(_syscall_read(ends[1], buf, 16, 0) < 0); - assert(_syscall_write(ends[0], buf, 16, 0) < 0); + assert(_syscall_write(ends[0], buf, 16, 0, 0) < 0); _syscall_read(ends[0], buf, 16, 0); assert(ret == 5); @@ -68,7 +68,7 @@ void test_pipe(void) { for (int i = 0; i < 16; i++) { if (!fork()) { close(ends[0]); - assert(_syscall_write(ends[1], buf, 16, 0) < 0); + assert(_syscall_write(ends[1], buf, 16, 0, 0) < 0); exit(0); } } @@ -82,7 +82,7 @@ void test_pipe(void) { assert(_syscall_pipe(ends, 0) >= 0); for (int i = 0; i < 16; i++) { if (!fork()) { - assert(_syscall_write(ends[1], pipe_msgs[0], 5, -1) == 5); + assert(_syscall_write(ends[1], pipe_msgs[0], 5, -1, 0) == 5); exit(0); } } @@ -105,10 +105,10 @@ void test_pipe(void) { } close(ends[0]); for (int i = 0; i < 16; i++) { - assert(_syscall_write(ends[1], pipe_msgs[1], 5, -1) == 5); + assert(_syscall_write(ends[1], pipe_msgs[1], 5, -1, 0) == 5); _syscall_await(); } - assert(_syscall_write(ends[1], pipe_msgs[1], 5, -1) < 0); + assert(_syscall_write(ends[1], pipe_msgs[1], 5, -1, 0) < 0); close(ends[1]); diff --git a/src/user/app/tests/semaphore.c b/src/user/app/tests/semaphore.c index e05f2f9..956734e 100644 --- a/src/user/app/tests/semaphore.c +++ b/src/user/app/tests/semaphore.c @@ -8,29 +8,29 @@ #include <user/lib/esemaphore.h> static void odd(handle_t out, struct evil_sem *sem1, struct evil_sem *sem2) { - _syscall_write(out, "1", 1, -1); + _syscall_write(out, "1", 1, -1, 0); esem_signal(sem1); esem_wait(sem2); - _syscall_write(out, "3", 1, -1); + _syscall_write(out, "3", 1, -1, 0); esem_signal(sem1); esem_wait(sem2); - _syscall_write(out, "5", 1, -1); + _syscall_write(out, "5", 1, -1, 0); esem_signal(sem1); } static void even(handle_t out, struct evil_sem *sem1, struct evil_sem *sem2) { esem_wait(sem1); - _syscall_write(out, "2", 1, -1); + _syscall_write(out, "2", 1, -1, 0); esem_signal(sem2); esem_wait(sem1); - _syscall_write(out, "4", 1, -1); + _syscall_write(out, "4", 1, -1, 0); esem_signal(sem2); esem_wait(sem1); - _syscall_write(out, "6", 1, -1); + _syscall_write(out, "6", 1, -1, 0); esem_signal(sem2); } @@ -53,7 +53,7 @@ void test_semaphore(void) { esem_free(sem1); esem_free(sem2); - _syscall_write(pipe[1], "|", 1, -1); + _syscall_write(pipe[1], "|", 1, -1, 0); sem1 = esem_new(0); sem2 = esem_new(0); diff --git a/src/user/app/tests/tests.c b/src/user/app/tests/tests.c index 458f748..1d1156e 100644 --- a/src/user/app/tests/tests.c +++ b/src/user/app/tests/tests.c @@ -133,13 +133,13 @@ static void test_dup(void) { assert(h2 >= 0); assert(h2 != pipe[1] && h2 != h1); - _syscall_write(pipe[1], "og", 2, 0); - _syscall_write(h1, "h1", 2, 0); - _syscall_write(h2, "h2", 2, 0); + _syscall_write(pipe[1], "og", 2, 0, 0); + _syscall_write(h1, "h1", 2, 0, 0); + _syscall_write(h2, "h2", 2, 0, 0); close(pipe[1]); - _syscall_write(h1, "h1", 2, 0); - _syscall_write(h2, "h2", 2, 0); + _syscall_write(h1, "h1", 2, 0, 0); + _syscall_write(h2, "h2", 2, 0, 0); assert(_syscall_dup(h1, pipe[1], 0) == pipe[1]); assert(_syscall_dup(h2, pipe[1], 0) == pipe[1]); @@ -149,11 +149,11 @@ static void test_dup(void) { close(h2); assert(_syscall_dup(pipe[1], h2, 0) == h2); - _syscall_write(h2, "h2", 2, 0); + _syscall_write(h2, "h2", 2, 0, 0); close(h2); assert(_syscall_dup(pipe[1], h1, 0) == h1); - _syscall_write(h1, "h1", 2, 0); + _syscall_write(h1, "h1", 2, 0, 0); close(h1); exit(0); @@ -200,27 +200,27 @@ static void test_efault(void) { memcpy(str2, str, 16); assert((h = _syscall_open(tmpfilepath, strlen(tmpfilepath), OPEN_CREATE))); - assert(_syscall_write(h, str, 16, 0) == 16); - assert(_syscall_write(h, str2, 16, 0) == 16); + assert(_syscall_write(h, str, 16, 0, 0) == 16); + assert(_syscall_write(h, str2, 16, 0, 0) == 16); - assert(_syscall_write(h, invalid, 16, 0) == -EFAULT); + assert(_syscall_write(h, invalid, 16, 0, 0) == -EFAULT); /* x64 canonical pointers */ - assert(_syscall_write(h, (void*)((uintptr_t)str ^ 0x8000000000000000), 16, 0) == -EFAULT); - assert(_syscall_write(h, (void*)((uintptr_t)str ^ 0x1000000000000000), 16, 0) == -EFAULT); - assert(_syscall_write(h, (void*)((uintptr_t)str ^ 0x0100000000000000), 16, 0) == -EFAULT); - assert(_syscall_write(h, (void*)((uintptr_t)str ^ 0x0010000000000000), 16, 0) == -EFAULT); - assert(_syscall_write(h, (void*)((uintptr_t)str ^ 0x0001000000000000), 16, 0) == -EFAULT); - assert(_syscall_write(h, (void*)((uintptr_t)str ^ 0x0000800000000000), 16, 0) == -EFAULT); - - assert(_syscall_write(h, (void*)((uintptr_t)str2 ^ 0x8000000000000000), 16, 0) == -EFAULT); - assert(_syscall_write(h, (void*)((uintptr_t)str2 ^ 0x1000000000000000), 16, 0) == -EFAULT); - assert(_syscall_write(h, (void*)((uintptr_t)str2 ^ 0x0100000000000000), 16, 0) == -EFAULT); - assert(_syscall_write(h, (void*)((uintptr_t)str2 ^ 0x0010000000000000), 16, 0) == -EFAULT); - assert(_syscall_write(h, (void*)((uintptr_t)str2 ^ 0x0001000000000000), 16, 0) == -EFAULT); - assert(_syscall_write(h, (void*)((uintptr_t)str2 ^ 0x0000800000000000), 16, 0) == -EFAULT); - - assert(_syscall_write(h, str, 16, 0) == 16); + assert(_syscall_write(h, (void*)((uintptr_t)str ^ 0x8000000000000000), 16, 0, 0) == -EFAULT); + assert(_syscall_write(h, (void*)((uintptr_t)str ^ 0x1000000000000000), 16, 0, 0) == -EFAULT); + assert(_syscall_write(h, (void*)((uintptr_t)str ^ 0x0100000000000000), 16, 0, 0) == -EFAULT); + assert(_syscall_write(h, (void*)((uintptr_t)str ^ 0x0010000000000000), 16, 0, 0) == -EFAULT); + assert(_syscall_write(h, (void*)((uintptr_t)str ^ 0x0001000000000000), 16, 0, 0) == -EFAULT); + assert(_syscall_write(h, (void*)((uintptr_t)str ^ 0x0000800000000000), 16, 0, 0) == -EFAULT); + + assert(_syscall_write(h, (void*)((uintptr_t)str2 ^ 0x8000000000000000), 16, 0, 0) == -EFAULT); + assert(_syscall_write(h, (void*)((uintptr_t)str2 ^ 0x1000000000000000), 16, 0, 0) == -EFAULT); + assert(_syscall_write(h, (void*)((uintptr_t)str2 ^ 0x0100000000000000), 16, 0, 0) == -EFAULT); + assert(_syscall_write(h, (void*)((uintptr_t)str2 ^ 0x0010000000000000), 16, 0, 0) == -EFAULT); + assert(_syscall_write(h, (void*)((uintptr_t)str2 ^ 0x0001000000000000), 16, 0, 0) == -EFAULT); + assert(_syscall_write(h, (void*)((uintptr_t)str2 ^ 0x0000800000000000), 16, 0, 0) == -EFAULT); + + assert(_syscall_write(h, str, 16, 0, 0) == 16); close(h); } @@ -229,16 +229,16 @@ static void test_execbuf(void) { const char str1[] = "test_execbuf: string 1\n"; const char str2[] = "test_execbuf: and 2\n"; uint64_t buf[] = { - EXECBUF_SYSCALL, _SYSCALL_WRITE, 1, (uintptr_t)str1, sizeof(str1) - 1, -1, - EXECBUF_SYSCALL, _SYSCALL_WRITE, 1, (uintptr_t)str2, sizeof(str2) - 1, -1, - EXECBUF_SYSCALL, _SYSCALL_EXIT, 0, 0, 0, 0, + EXECBUF_SYSCALL, _SYSCALL_WRITE, 1, (uintptr_t)str1, sizeof(str1) - 1, -1, 0, + EXECBUF_SYSCALL, _SYSCALL_WRITE, 1, (uintptr_t)str2, sizeof(str2) - 1, -1, 0, + EXECBUF_SYSCALL, _SYSCALL_EXIT, 0, 0, 0, 0, 0, }; _syscall_execbuf(buf, sizeof buf); test_fail(); } static void test_misc(void) { - assert(_syscall(~0, 0, 0, 0, 0) < 0); /* try making an invalid syscall */ + assert(_syscall(~0, 0, 0, 0, 0, 0) < 0); /* try making an invalid syscall */ } diff --git a/src/user/lib/elfload.c b/src/user/lib/elfload.c index 71714ab..e3853ba 100644 --- a/src/user/lib/elfload.c +++ b/src/user/lib/elfload.c @@ -87,8 +87,8 @@ void _freejmp(void *entry, void *low, size_t len, char **argv, char **envp) { uintptr_t high = (uintptr_t)low + len; uint64_t buf[] = { - EXECBUF_SYSCALL, _SYSCALL_MEMFLAG, 0, (uintptr_t)low, 0, 0, - EXECBUF_SYSCALL, _SYSCALL_MEMFLAG, high, ~0 - 0xF000 - high, 0, 0, + EXECBUF_SYSCALL, _SYSCALL_MEMFLAG, 0, (uintptr_t)low, 0, 0, 0, + EXECBUF_SYSCALL, _SYSCALL_MEMFLAG, high, ~0 - 0xF000 - high, 0, 0, 0, EXECBUF_JMP, (uintptr_t)entry, }; execbuf_chstack(stack_w, buf, sizeof buf); diff --git a/src/user/lib/esemaphore.c b/src/user/lib/esemaphore.c index 70cedae..f58b510 100644 --- a/src/user/lib/esemaphore.c +++ b/src/user/lib/esemaphore.c @@ -5,7 +5,7 @@ #include <user/lib/esemaphore.h> void esem_signal(struct evil_sem *sem) { - _syscall_write(sem->signal, NULL, 0, 0); + _syscall_write(sem->signal, NULL, 0, 0, 0); } void esem_wait(struct evil_sem *sem) { @@ -25,7 +25,7 @@ struct evil_sem *esem_new(int value) { close(ends_signal[1]); while (_syscall_read(ends_signal[0], NULL, 0, 0) >= 0) { if (!_syscall_fork(FORK_NOREAP, NULL)) { - _syscall_write(ends_wait[1], NULL, 0, 0); + _syscall_write(ends_wait[1], NULL, 0, 0, 0); exit(0); } } diff --git a/src/user/lib/file.c b/src/user/lib/file.c index a26c8bb..b7e70e6 100644 --- a/src/user/lib/file.c +++ b/src/user/lib/file.c @@ -127,7 +127,7 @@ size_t fwrite(const void *restrict ptr, size_t size, size_t nitems, FILE *restri return 0; while (pos < total) { - long res = _syscall_write(f->fd, buf + pos, total - pos, f->pos); + long res = _syscall_write(f->fd, buf + pos, total - pos, f->pos, 0); if (res < 0) { f->error = true; errno = -res; diff --git a/src/user/lib/fs/misc.c b/src/user/lib/fs/misc.c index 32464b3..55ba9a6 100644 --- a/src/user/lib/fs/misc.c +++ b/src/user/lib/fs/misc.c @@ -151,7 +151,7 @@ void fs_dir_inject(const char *path) { case VFSOP_WRITE: if (data->delegate >= 0) - ret = _syscall_write(data->delegate, buf, res.len, res.offset); + ret = _syscall_write(data->delegate, buf, res.len, res.offset, res.flags); else ret = -1; _syscall_fs_respond(NULL, ret, 0); diff --git a/src/user/lib/syscall.c b/src/user/lib/syscall.c index 7e0de88..842b7b9 100644 --- a/src/user/lib/syscall.c +++ b/src/user/lib/syscall.c @@ -6,63 +6,63 @@ _Noreturn void _syscall_exit(long ret) { - _syscall(_SYSCALL_EXIT, ret, 0, 0, 0); + _syscall(_SYSCALL_EXIT, ret, 0, 0, 0, 0); __builtin_unreachable(); } long _syscall_await(void) { - return _syscall(_SYSCALL_AWAIT, 0, 0, 0, 0); + return _syscall(_SYSCALL_AWAIT, 0, 0, 0, 0, 0); } long _syscall_fork(int flags, handle_t __user *fs_front) { - return _syscall(_SYSCALL_FORK, (long)flags, (long)fs_front, 0, 0); + return _syscall(_SYSCALL_FORK, (long)flags, (long)fs_front, 0, 0, 0); } handle_t _syscall_open(const char __user *path, long len, int flags) { - return (handle_t)_syscall(_SYSCALL_OPEN, (long)path, len, (long)flags, 0); + return (handle_t)_syscall(_SYSCALL_OPEN, (long)path, len, (long)flags, 0, 0); } long _syscall_mount(handle_t h, const char __user *path, long len) { - return _syscall(_SYSCALL_MOUNT, (long)h, (long)path, len, 0); + return _syscall(_SYSCALL_MOUNT, (long)h, (long)path, len, 0, 0); } handle_t _syscall_dup(handle_t from, handle_t to, int flags) { - return (handle_t)_syscall(_SYSCALL_DUP, (long)from, (long)to, (long)flags, 0); + return (handle_t)_syscall(_SYSCALL_DUP, (long)from, (long)to, (long)flags, 0, 0); } long _syscall_read(handle_t h, void __user *buf, size_t len, long offset) { - return _syscall(_SYSCALL_READ, (long)h, (long)buf, (long)len, offset); + return _syscall(_SYSCALL_READ, (long)h, (long)buf, (long)len, offset, 0); } -long _syscall_write(handle_t h, const void __user *buf, size_t len, long offset) { - return _syscall(_SYSCALL_WRITE, (long)h, (long)buf, (long)len, offset); +long _syscall_write(handle_t h, const void __user *buf, size_t len, long offset, int flags) { + return _syscall(_SYSCALL_WRITE, (long)h, (long)buf, (long)len, offset, (long)flags); } long _syscall_close(handle_t h) { - return _syscall(_SYSCALL_CLOSE, (long)h, 0, 0, 0); + return _syscall(_SYSCALL_CLOSE, (long)h, 0, 0, 0, 0); } long _syscall_fs_wait(char __user *buf, long max_len, struct fs_wait_response __user *res) { - return _syscall(_SYSCALL_FS_WAIT, (long)buf, max_len, (long)res, 0); + return _syscall(_SYSCALL_FS_WAIT, (long)buf, max_len, (long)res, 0, 0); } long _syscall_fs_respond(void __user *buf, long ret, int flags) { - return _syscall(_SYSCALL_FS_RESPOND, (long)buf, ret, (long)flags, 0); + return _syscall(_SYSCALL_FS_RESPOND, (long)buf, ret, (long)flags, 0, 0); } void __user *_syscall_memflag(void __user *addr, size_t len, int flags) { - return (void __user *)_syscall(_SYSCALL_MEMFLAG, (long)addr, (long)len, (long)flags, 0); + return (void __user *)_syscall(_SYSCALL_MEMFLAG, (long)addr, (long)len, (long)flags, 0, 0); } long _syscall_pipe(handle_t __user user_ends[2], int flags) { - return _syscall(_SYSCALL_PIPE, (long)user_ends, (long)flags, 0, 0); + return _syscall(_SYSCALL_PIPE, (long)user_ends, (long)flags, 0, 0, 0); } long _syscall_execbuf(void __user *buf, size_t len) { - return _syscall(_SYSCALL_EXECBUF, (long)buf, (long)len, 0, 0); + return _syscall(_SYSCALL_EXECBUF, (long)buf, (long)len, 0, 0, 0); } void _syscall_debug_klog(const void __user *buf, size_t len) { - return (void)_syscall(_SYSCALL_DEBUG_KLOG, (long)buf, (long)len, 0, 0); + return (void)_syscall(_SYSCALL_DEBUG_KLOG, (long)buf, (long)len, 0, 0, 0); } diff --git a/src/user/lib/syscall.c.awk b/src/user/lib/syscall.c.awk index 58f9a4c..192df6a 100644 --- a/src/user/lib/syscall.c.awk +++ b/src/user/lib/syscall.c.awk @@ -23,7 +23,7 @@ BEGIN { if (params == "void") params = "" split(params, p, /,/); - for (i = 0; i <= 4; i += 1) { + for (i = 0; i < 6; i += 1) { if (p[i]) { # p[i] is a parameter, convert it into an expression to pass to _syscall() sub(/^ */, "", p[i]); # strip @@ -44,7 +44,7 @@ BEGIN { printf "return "; if (rets != "long") printf "(%s)", rets; } - printf "_syscall(%s, %s, %s, %s, %s);\n", toupper(name), p[1], p[2], p[3], p[4]; + printf "_syscall(%s, %s, %s, %s, %s, %s);\n", toupper(name), p[1], p[2], p[3], p[4], p[5]; if (index($0, "_Noreturn")) print "\t__builtin_unreachable();"; print "}\n"; |