summaryrefslogtreecommitdiff
path: root/src/user
diff options
context:
space:
mode:
Diffstat (limited to 'src/user')
-rw-r--r--src/user/app/init/driver/ansiterm.c2
-rw-r--r--src/user/app/init/driver/termcook.c4
-rw-r--r--src/user/app/tests/pipe.c20
-rw-r--r--src/user/app/tests/semaphore.c14
-rw-r--r--src/user/app/tests/tests.c58
-rw-r--r--src/user/lib/elfload.c4
-rw-r--r--src/user/lib/esemaphore.c4
-rw-r--r--src/user/lib/file.c2
-rw-r--r--src/user/lib/fs/misc.c2
-rw-r--r--src/user/lib/syscall.c32
-rw-r--r--src/user/lib/syscall.c.awk4
11 files changed, 73 insertions, 73 deletions
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";