summaryrefslogtreecommitdiff
path: root/src/user/app
diff options
context:
space:
mode:
Diffstat (limited to 'src/user/app')
-rw-r--r--src/user/app/drawmouse/drawmouse.c4
-rw-r--r--src/user/app/dvd/dvd.c2
-rw-r--r--src/user/app/ext2fs/main.c54
-rw-r--r--src/user/app/httpd/httpd.c6
-rw-r--r--src/user/app/init/driver/driver.h2
-rw-r--r--src/user/app/init/driver/initctl.c6
-rw-r--r--src/user/app/init/driver/ps2.c6
-rw-r--r--src/user/app/init/driver/termcook.c20
-rw-r--r--src/user/app/init/init.c20
-rw-r--r--src/user/app/iochk/iochk.c8
-rw-r--r--src/user/app/iostress/iostress.c4
-rw-r--r--src/user/app/logfs/logfs.c4
-rw-r--r--src/user/app/login/login.c8
-rw-r--r--src/user/app/netdog/nd.c12
-rw-r--r--src/user/app/netstack/arp.c6
-rw-r--r--src/user/app/netstack/ether.c4
-rw-r--r--src/user/app/netstack/fs.c50
-rw-r--r--src/user/app/netstack/netstack.c4
-rw-r--r--src/user/app/netstack/proto.h6
-rw-r--r--src/user/app/shell/builtins.c8
-rw-r--r--src/user/app/shell/shell.c16
-rw-r--r--src/user/app/tests/kernel/fdlimit.c28
-rw-r--r--src/user/app/tests/kernel/fs.c44
-rw-r--r--src/user/app/tests/kernel/misc.c38
-rw-r--r--src/user/app/tests/kernel/miscsyscall.c160
-rw-r--r--src/user/app/tests/kernel/path.c6
-rw-r--r--src/user/app/tests/kernel/threads.c12
-rw-r--r--src/user/app/tests/libc/esemaphore.c34
-rw-r--r--src/user/app/tests/stress.c4
-rw-r--r--src/user/app/tests/tests.c14
-rw-r--r--src/user/app/tests/tests.h2
-rw-r--r--src/user/app/tmpfs/tmpfs.c22
32 files changed, 307 insertions, 307 deletions
diff --git a/src/user/app/drawmouse/drawmouse.c b/src/user/app/drawmouse/drawmouse.c
index 6e2a881..24aa55e 100644
--- a/src/user/app/drawmouse/drawmouse.c
+++ b/src/user/app/drawmouse/drawmouse.c
@@ -50,7 +50,7 @@ struct packet {
int main(void) {
char buf[64];
- handle_t fd = camellia_open("/kdev/ps2/mouse", OPEN_READ);
+ hid_t fd = camellia_open("/kdev/ps2/mouse", OPEN_READ);
if (fd < 0) {
eprintf("couldn't open mouse");
return 1;
@@ -64,7 +64,7 @@ int main(void) {
for (;;) {
- int len = _syscall_read(fd, buf, sizeof buf, 0);
+ int len = _sys_read(fd, buf, sizeof buf, 0);
if (len == 0) break;
ring_put(&r, buf, len);
while (ring_used(&r) >= 3) {
diff --git a/src/user/app/dvd/dvd.c b/src/user/app/dvd/dvd.c
index f880782..70adc8b 100644
--- a/src/user/app/dvd/dvd.c
+++ b/src/user/app/dvd/dvd.c
@@ -36,7 +36,7 @@ int main(void) {
y += dy;
draw_rect(x, y, w, h, col++);
dirty_flush(&dirty, &fb);
- _syscall_sleep(1000 / 60);
+ _sys_sleep(1000 / 60);
}
return 1;
diff --git a/src/user/app/ext2fs/main.c b/src/user/app/ext2fs/main.c
index 65e7460..678d189 100644
--- a/src/user/app/ext2fs/main.c
+++ b/src/user/app/ext2fs/main.c
@@ -21,10 +21,10 @@ struct handle {
static int my_read(void *fp, void *buf, size_t len, size_t off);
static int my_write(void *fp, const void *buf, size_t len, size_t off);
-static void do_open(struct ext2 *fs, handle_t reqh, struct ufs_request *req, char *buf);
-static void do_read(struct ext2 *fs, handle_t reqh, struct ufs_request *req, char *buf, size_t buflen);
-static void do_write(struct ext2 *fs, handle_t reqh, struct ufs_request *req, char *buf);
-static void do_getsize(struct ext2 *fs, handle_t reqh, struct ufs_request *req);
+static void do_open(struct ext2 *fs, hid_t reqh, struct ufs_request *req, char *buf);
+static void do_read(struct ext2 *fs, hid_t reqh, struct ufs_request *req, char *buf, size_t buflen);
+static void do_write(struct ext2 *fs, hid_t reqh, struct ufs_request *req, char *buf);
+static void do_getsize(struct ext2 *fs, hid_t reqh, struct ufs_request *req);
static int
my_read(void *fp, void *buf, size_t len, size_t off)
@@ -51,61 +51,61 @@ my_write(void *fp, const void *buf, size_t len, size_t off)
}
static void
-do_open(struct ext2 *fs, handle_t reqh, struct ufs_request *req, char *buf)
+do_open(struct ext2 *fs, hid_t reqh, struct ufs_request *req, char *buf)
{
bool is_dir = req->len == 0 || buf[req->len-1] == '/';
uint32_t n = ext2c_walk(fs, buf, req->len);
if (n == 0) {
if (is_dir) {
- _syscall_fs_respond(reqh, NULL, -ENOSYS, 0);
+ _sys_fs_respond(reqh, NULL, -ENOSYS, 0);
return;
}
/* buf[0] == '/', strrchr != NULL */
char *name = strrchr(buf, '/') + 1;
uint32_t dir_n = ext2c_walk(fs, buf, name - buf);
if (dir_n == 0) {
- _syscall_fs_respond(reqh, NULL, -ENOENT, 0);
+ _sys_fs_respond(reqh, NULL, -ENOENT, 0);
return;
}
n = ext2_alloc_inode(fs, 0100700);
if (n == 0) {
- _syscall_fs_respond(reqh, NULL, -1, 0);
+ _sys_fs_respond(reqh, NULL, -1, 0);
return;
}
if (ext2_link(fs, dir_n, name, n, 1) < 0) {
- _syscall_fs_respond(reqh, NULL, -1, 0);
+ _sys_fs_respond(reqh, NULL, -1, 0);
return;
}
} else {
struct ext2d_inode *inode = ext2_req_inode(fs, n);
if (!inode) {
- _syscall_fs_respond(reqh, NULL, -ENOENT, 0);
+ _sys_fs_respond(reqh, NULL, -ENOENT, 0);
return;
}
int type = (inode->perms >> 12) & 0xF;
ext2_dropreq(fs, inode, false);
if ((type == 0x8 && is_dir) || (type == 0x4 && !is_dir)) {
- _syscall_fs_respond(reqh, NULL, -ENOENT, 0);
+ _sys_fs_respond(reqh, NULL, -ENOENT, 0);
return;
} else if (type != 0x8 && type != 0x4) {
- _syscall_fs_respond(reqh, NULL, -ENOSYS, 0);
+ _sys_fs_respond(reqh, NULL, -ENOSYS, 0);
return;
}
}
struct handle *h = malloc(sizeof *h);
if (!h) {
- _syscall_fs_respond(reqh, NULL, -1, 0);
+ _sys_fs_respond(reqh, NULL, -1, 0);
return;
}
h->n = n;
h->dir = is_dir;
- _syscall_fs_respond(reqh, h, 0, 0);
+ _sys_fs_respond(reqh, h, 0, 0);
}
static void
-do_read(struct ext2 *fs, handle_t reqh, struct ufs_request *req, char *buf, size_t buflen)
+do_read(struct ext2 *fs, hid_t reqh, struct ufs_request *req, char *buf, size_t buflen)
{
struct handle *h = req->id;
if (!h->dir) {
@@ -116,7 +116,7 @@ do_read(struct ext2 *fs, handle_t reqh, struct ufs_request *req, char *buf, size
void *b = ext2_req_file(fs, h->n, &req->capacity, req->offset);
if (!b) goto err;
- _syscall_fs_respond(reqh, b, req->capacity, 0);
+ _sys_fs_respond(reqh, b, req->capacity, 0);
ext2_dropreq(fs, b, false);
} else {
struct dirbuild db;
@@ -142,15 +142,15 @@ do_read(struct ext2 *fs, handle_t reqh, struct ufs_request *req, char *buf, size
dir_appendl(&db, iter.ent->name, iter.ent->namelen_lower);
}
}
- _syscall_fs_respond(reqh, buf, dir_finish(&db), 0);
+ _sys_fs_respond(reqh, buf, dir_finish(&db), 0);
}
return;
err:
- _syscall_fs_respond(reqh, NULL, -1, 0);
+ _sys_fs_respond(reqh, NULL, -1, 0);
}
static void
-do_write(struct ext2 *fs, handle_t reqh, struct ufs_request *req, char *buf)
+do_write(struct ext2 *fs, hid_t reqh, struct ufs_request *req, char *buf)
{
struct handle *h = req->id;
if (h->dir) goto err;
@@ -169,24 +169,24 @@ do_write(struct ext2 *fs, handle_t reqh, struct ufs_request *req, char *buf)
inode = NULL;
int ret = ext2_write(fs, h->n, buf, req->len, req->offset);
- _syscall_fs_respond(reqh, NULL, ret, 0);
+ _sys_fs_respond(reqh, NULL, ret, 0);
return;
err:
- _syscall_fs_respond(reqh, NULL, -1, 0);
+ _sys_fs_respond(reqh, NULL, -1, 0);
}
static void
-do_getsize(struct ext2 *fs, handle_t reqh, struct ufs_request *req) {
+do_getsize(struct ext2 *fs, hid_t reqh, struct ufs_request *req) {
struct handle *h = req->id;
if (h->dir) goto err;
struct ext2d_inode *inode = ext2_req_inode(fs, h->n);
if (!inode) goto err;
- _syscall_fs_respond(reqh, NULL, inode->size_lower, 0);
+ _sys_fs_respond(reqh, NULL, inode->size_lower, 0);
ext2_dropreq(fs, inode, false);
return;
err:
- _syscall_fs_respond(reqh, NULL, -1, 0);
+ _sys_fs_respond(reqh, NULL, -1, 0);
}
int
@@ -208,7 +208,7 @@ main(int argc, char **argv)
char *buf = malloc(buflen);
struct ufs_request req;
for (;;) {
- handle_t reqh = ufs_wait(buf, buflen, &req);
+ hid_t reqh = ufs_wait(buf, buflen, &req);
struct handle *h = req.id;
if (reqh < 0) break;
switch (req.op) {
@@ -226,10 +226,10 @@ main(int argc, char **argv)
break;
case VFSOP_CLOSE:
free(h);
- _syscall_fs_respond(reqh, NULL, -1, 0);
+ _sys_fs_respond(reqh, NULL, -1, 0);
break;
default:
- _syscall_fs_respond(reqh, NULL, -1, 0);
+ _sys_fs_respond(reqh, NULL, -1, 0);
break;
}
}
diff --git a/src/user/app/httpd/httpd.c b/src/user/app/httpd/httpd.c
index 02f9e6b..668e534 100644
--- a/src/user/app/httpd/httpd.c
+++ b/src/user/app/httpd/httpd.c
@@ -20,7 +20,7 @@ static void handle(FILE *c) {
char *end = strchr(path, ' ');
if (end) *end = '\0';
- handle_t h = _syscall_open(path, strlen(path), OPEN_READ);
+ hid_t h = _sys_open(path, strlen(path), OPEN_READ);
if (h < 0) {
fprintf(c, "HTTP/1.1 404 Not Found\r\n\r\n");
return;
@@ -65,9 +65,9 @@ static void handle(FILE *c) {
int main(int argc, char **argv) {
const char *path = (argc > 1) ? argv[1] : "/net/listen/0.0.0.0/tcp/80";
- handle_t conn;
+ hid_t conn;
for (;;) {
- conn = _syscall_open(path, strlen(path), OPEN_RW);
+ conn = _sys_open(path, strlen(path), OPEN_RW);
if (conn < 0)
errx(1, "open('%s') failed, errno %d", path, -conn);
FILE *f = fdopen(conn, "a+");
diff --git a/src/user/app/init/driver/driver.h b/src/user/app/init/driver/driver.h
index fc9f51b..98c18f1 100644
--- a/src/user/app/init/driver/driver.h
+++ b/src/user/app/init/driver/driver.h
@@ -1,7 +1,7 @@
#pragma once
#include <camellia/types.h>
-void initctl_drv(handle_t killswitch);
+void initctl_drv(hid_t killswitch);
void ps2_drv(void);
void tmpfs_drv(void);
diff --git a/src/user/app/init/driver/initctl.c b/src/user/app/init/driver/initctl.c
index 67c8ade..fed71b7 100644
--- a/src/user/app/init/driver/initctl.c
+++ b/src/user/app/init/driver/initctl.c
@@ -6,7 +6,7 @@
#include <string.h>
#include <camellia/compat.h>
-void initctl_drv(handle_t killswitch) {
+void initctl_drv(hid_t killswitch) {
struct ufs_request res;
char buf[64];
const size_t buflen = sizeof buf;
@@ -28,10 +28,10 @@ void initctl_drv(handle_t killswitch) {
}
}
if (!strcmp(buf, "halt")) {
- _syscall_write(killswitch, "halt", 4, 0, 0);
+ _sys_write(killswitch, "halt", 4, 0, 0);
}
if (!strcmp(buf, "intr")) {
- _syscall_write(killswitch, "intr", 4, 0, 0);
+ _sys_write(killswitch, "intr", 4, 0, 0);
}
c0_fs_respond(NULL, res.len, 0);
break;
diff --git a/src/user/app/init/driver/ps2.c b/src/user/app/init/driver/ps2.c
index 1accbfc..a5cdb07 100644
--- a/src/user/app/init/driver/ps2.c
+++ b/src/user/app/init/driver/ps2.c
@@ -32,7 +32,7 @@ static const char keymap_upper[] = {
static volatile uint8_t backlog_buf[16];
static volatile ring_t backlog = {(void*)backlog_buf, sizeof backlog_buf, 0, 0};
-static handle_t fd;
+static hid_t fd;
static bool keys[0x80] = {0};
@@ -63,7 +63,7 @@ static void main_loop(void) {
case VFSOP_READ:
while (ring_used((void*)&backlog) == 0) {
/* read raw input until we have something to output */
- int len = _syscall_read(fd, buf, sizeof buf, 0);
+ int len = _sys_read(fd, buf, sizeof buf, 0);
if (len == 0) break;
for (int i = 0; i < len; i++)
parse_scancode(buf[i]);
@@ -80,7 +80,7 @@ static void main_loop(void) {
}
void ps2_drv(void) {
- fd = _syscall_open("/kdev/ps2/kb", 12, 0);
+ fd = _sys_open("/kdev/ps2/kb", 12, 0);
if (fd < 0) exit(1);
main_loop();
diff --git a/src/user/app/init/driver/termcook.c b/src/user/app/init/driver/termcook.c
index 8845839..a76f3a8 100644
--- a/src/user/app/init/driver/termcook.c
+++ b/src/user/app/init/driver/termcook.c
@@ -10,21 +10,21 @@ enum tstate {
CSI,
};
-static void w_output(handle_t output, const char *buf, size_t len) {
+static void w_output(hid_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, 0);
+ int ret = _sys_write(output, buf + pos, len - pos, pos, 0);
if (ret < 0) break;
pos += ret;
}
}
-static void line_editor(handle_t input, handle_t output) {
+static void line_editor(hid_t input, hid_t output) {
char readbuf[16], linebuf[256];
size_t linepos = 0;
enum tstate state = Normal;
for (;;) {
- int readlen = _syscall_read(input, readbuf, sizeof readbuf, -1);
+ int readlen = _sys_read(input, readbuf, sizeof readbuf, -1);
if (readlen < 0) return;
for (int i = 0; i < readlen; i++) {
char c = readbuf[i];
@@ -39,13 +39,13 @@ static void line_editor(handle_t input, handle_t output) {
}
break;
case 3: /* C-c */
- _syscall_exit(1);
+ _sys_exit(1);
case 4: /* EOT, C-d */
if (linepos > 0) {
w_output(output, linebuf, linepos);
linepos = 0;
} else {
- _syscall_write(output, NULL, 0, 0, 0); /* EOF */
+ _sys_write(output, NULL, 0, 0, 0); /* EOF */
}
break;
case '\n':
@@ -82,14 +82,14 @@ static void line_editor(handle_t input, handle_t output) {
}
void termcook(void) {
- handle_t stdin_pipe[2] = {-1, -1};
- if (_syscall_pipe(stdin_pipe, 0) < 0)
+ hid_t stdin_pipe[2] = {-1, -1};
+ if (_sys_pipe(stdin_pipe, 0) < 0)
return;
if (!fork()) {
/* the caller continues in a child process,
* so it can be killed when the line editor quits */
- _syscall_dup(stdin_pipe[0], 0, 0);
+ _sys_dup(stdin_pipe[0], 0, 0);
close(stdin_pipe[0]);
close(stdin_pipe[1]);
return;
@@ -99,5 +99,5 @@ void termcook(void) {
line_editor(0, stdin_pipe[1]);
exit(0);
}
- exit(_syscall_await());
+ exit(_sys_await());
}
diff --git a/src/user/app/init/init.c b/src/user/app/init/init.c
index d872b24..8346a31 100644
--- a/src/user/app/init/init.c
+++ b/src/user/app/init/init.c
@@ -26,18 +26,18 @@ void redirect(const char *exe, const char *out, const char *in) {
termcook();
execv(exe, (void*)argv);
fprintf(stderr, "init: couldn't start %s\n", exe);
- _syscall_sleep(5000);
+ _sys_sleep(5000);
exit(1);
}
- _syscall_await();
- _syscall_intr();
+ _sys_await();
+ _sys_intr();
}
}
}
int main(void) {
const char *teststr = "I am teststr.\n";
- handle_t killswitch_pipe[2];
+ hid_t killswitch_pipe[2];
freopen("/kdev/com1", "a+", stdout);
freopen("/kdev/com1", "a+", stderr);
@@ -86,7 +86,7 @@ int main(void) {
execv(argv[0], (void*)argv);
}
- if (_syscall_pipe(killswitch_pipe, 0) < 0) {
+ if (_sys_pipe(killswitch_pipe, 0) < 0) {
printf("couldn't create the killswitch pipe, quitting...\n");
return 1;
}
@@ -106,20 +106,20 @@ int main(void) {
char buf[128];
for (;;) {
- if (_syscall_read(killswitch_pipe[0], buf, 128, 0) != 4) {
+ if (_sys_read(killswitch_pipe[0], buf, 128, 0) != 4) {
break;
}
if (memcmp(buf, "intr", 4) == 0) {
- _syscall_intr();
+ _sys_intr();
} else if (memcmp(buf, "halt", 4) == 0) {
break;
}
}
printf("[init] intr\n");
- _syscall_intr();
- _syscall_sleep(1000);
+ _sys_intr();
+ _sys_sleep(1000);
printf("[init] filicide\n");
- _syscall_filicide();
+ _sys_filicide();
printf("[init] goodbye\n");
return 0;
}
diff --git a/src/user/app/iochk/iochk.c b/src/user/app/iochk/iochk.c
index e4b0346..9703919 100644
--- a/src/user/app/iochk/iochk.c
+++ b/src/user/app/iochk/iochk.c
@@ -13,7 +13,7 @@ static bool verbose = false;
#define eprintf(fmt, ...) fprintf(stderr, "iochk: "fmt"\n" __VA_OPT__(,) __VA_ARGS__)
-void check(handle_t h) {
+void check(hid_t h) {
const size_t buflen = 4096;
const size_t offsets[] = {
0, 1, 2, 3, 4, 5, 6, 7,
@@ -28,7 +28,7 @@ void check(handle_t h) {
}
long offlast = 0;
- long retlast = _syscall_read(h, buflast, buflen, offlast);
+ long retlast = _sys_read(h, buflast, buflen, offlast);
if (retlast < 0) {
eprintf("error %d when reading at offset %d", retlast, offlast);
goto end;
@@ -41,7 +41,7 @@ void check(handle_t h) {
assert(diff >= 0);
if (retlast < diff) break;
- long retcur = _syscall_read(h, bufcur, buflen, offcur);
+ long retcur = _sys_read(h, bufcur, buflen, offcur);
if (retcur < 0) {
eprintf("error %d when reading at offset %d", retlast, offcur);
break;
@@ -85,7 +85,7 @@ int main(int argc, char **argv) {
for (; optind < argc; optind++) {
const char *path = argv[optind];
verbosef("checking %s...\n", path);
- handle_t h = camellia_open(path, OPEN_READ);
+ hid_t h = camellia_open(path, OPEN_READ);
if (h < 0) {
eprintf("couldn't open %s", path);
continue;
diff --git a/src/user/app/iostress/iostress.c b/src/user/app/iostress/iostress.c
index 2f15471..3a3a23c 100644
--- a/src/user/app/iostress/iostress.c
+++ b/src/user/app/iostress/iostress.c
@@ -26,9 +26,9 @@ int main(int argc, char **argv) {
for (long i = 0; i < num_runs; i++) {
uint64_t time = __rdtsc();
for (long j = 0; j < num_calls; j++)
- _syscall_write(1, inbuf, num_bytes, -1, 0);
+ _sys_write(1, inbuf, num_bytes, -1, 0);
results[i] = __rdtsc() - time;
- _syscall_write(1, "\n", 1, -1, 0);
+ _sys_write(1, "\n", 1, -1, 0);
}
uint64_t total = 0;
diff --git a/src/user/app/logfs/logfs.c b/src/user/app/logfs/logfs.c
index 14a8f2a..a50d530 100644
--- a/src/user/app/logfs/logfs.c
+++ b/src/user/app/logfs/logfs.c
@@ -11,7 +11,7 @@ _Noreturn void fs(void) {
if (!buf) err(1, "malloc");
for (;;) {
struct ufs_request req;
- handle_t reqh = ufs_wait(buf, buflen, &req);
+ hid_t reqh = ufs_wait(buf, buflen, &req);
if (reqh < 0) errx(1, "ufs_wait error");
switch (req.op) {
@@ -23,7 +23,7 @@ _Noreturn void fs(void) {
/* Unsupported vfs operation.
* Currently if you never create your own file descriptors you won't receive
* anything but VFSOP_OPEN, but it's idiomatic to handle this anyways. */
- _syscall_fs_respond(reqh, NULL, -1, 0);
+ _sys_fs_respond(reqh, NULL, -1, 0);
break;
}
}
diff --git a/src/user/app/login/login.c b/src/user/app/login/login.c
index a348254..0f9e8b7 100644
--- a/src/user/app/login/login.c
+++ b/src/user/app/login/login.c
@@ -36,23 +36,23 @@ static void drv(const char *user) {
char *buf = malloc(PATH_MAX);
for (;;) {
struct ufs_request req;
- handle_t reqh = ufs_wait(buf, PATH_MAX, &req);
+ hid_t reqh = ufs_wait(buf, PATH_MAX, &req);
if (reqh < 0) break;
switch (req.op) {
case VFSOP_OPEN:
if (segcmp(buf, 1, "Users") && segcmp(buf, 2, user)) { // /Users/$user/**
forward_open(reqh, buf, req.len, req.flags);
} else if (segcmp(buf, 1, "Users") && segcmp(buf, 3, "private")) { // /Users/*/private/**
- _syscall_fs_respond(reqh, NULL, -EACCES, 0);
+ _sys_fs_respond(reqh, NULL, -EACCES, 0);
} else if (!OPEN_WRITEABLE(req.flags)) {
forward_open(reqh, buf, req.len, req.flags);
} else {
- _syscall_fs_respond(reqh, NULL, -EACCES, 0);
+ _sys_fs_respond(reqh, NULL, -EACCES, 0);
}
break;
default:
- _syscall_fs_respond(reqh, NULL, -1, 0);
+ _sys_fs_respond(reqh, NULL, -1, 0);
break;
}
}
diff --git a/src/user/app/netdog/nd.c b/src/user/app/netdog/nd.c
index 93e1d3a..fdc8361 100644
--- a/src/user/app/netdog/nd.c
+++ b/src/user/app/netdog/nd.c
@@ -6,15 +6,15 @@
#define eprintf(fmt, ...) fprintf(stderr, "netdog: "fmt"\n" __VA_OPT__(,) __VA_ARGS__)
-handle_t conn;
+hid_t conn;
void send_stdin(void *arg) { (void)arg;
static char buf[4096];
for (;;) {
// TODO define STDIN_FILENO
- long ret = _syscall_read(0, buf, sizeof buf, -1);
+ long ret = _sys_read(0, buf, sizeof buf, -1);
if (ret <= 0) return; /* instead of sending an empty packet, quit. */
- ret = _syscall_write(conn, buf, ret, -1, 0);
+ ret = _sys_write(conn, buf, ret, -1, 0);
if (ret < 0) return;
}
}
@@ -22,9 +22,9 @@ void send_stdin(void *arg) { (void)arg;
void recv_stdout(void *arg) { (void)arg;
static char buf[4096];
for (;;) {
- long ret = _syscall_read(conn, buf, sizeof buf, -1);
+ long ret = _sys_read(conn, buf, sizeof buf, -1);
if (ret < 0) return;
- ret = _syscall_write(1, buf, ret, -1, 0);
+ ret = _sys_write(1, buf, ret, -1, 0);
if (ret < 0) return;
}
}
@@ -43,6 +43,6 @@ int main(int argc, char **argv) {
thread_create(0, send_stdin, NULL);
thread_create(0, recv_stdout, NULL);
- _syscall_await();
+ _sys_await();
return 0;
}
diff --git a/src/user/app/netstack/arp.c b/src/user/app/netstack/arp.c
index 6c230b3..3a1c8da 100644
--- a/src/user/app/netstack/arp.c
+++ b/src/user/app/netstack/arp.c
@@ -107,7 +107,7 @@ int arpcache_get(uint32_t ip, mac_t *mac) {
return -1;
}
-void arp_fsread(handle_t h, long offset) {
+void arp_fsread(hid_t h, long offset) {
const char *fmt = "%08x\t%02x:%02x:%02x:%02x:%02x:%02x\n";
long linelen = snprintf(NULL, 0, fmt, 0, 1, 2, 3, 4, 5, 6) + 1;
char buf[28];
@@ -129,10 +129,10 @@ void arp_fsread(handle_t h, long offset) {
cur->mac[3],
cur->mac[4],
cur->mac[5]);
- _syscall_fs_respond(h, buf + offset, linelen - offset, 0);
+ _sys_fs_respond(h, buf + offset, linelen - offset, 0);
return;
err:
- _syscall_fs_respond(h, NULL, -1, 0);
+ _sys_fs_respond(h, NULL, -1, 0);
}
long arp_fswrite(const char *buf, long len, long offset) {
diff --git a/src/user/app/netstack/ether.c b/src/user/app/netstack/ether.c
index 20d16ab..52abac2 100644
--- a/src/user/app/netstack/ether.c
+++ b/src/user/app/netstack/ether.c
@@ -19,7 +19,7 @@ void ether_parse(const uint8_t *buf, size_t len) {
for (struct ethq **iter = &ether_queue; iter && *iter; ) {
struct ethq *qe = *iter;
- _syscall_fs_respond(qe->h, buf, len, 0);
+ _sys_fs_respond(qe->h, buf, len, 0);
/* remove entry */
/* yes, doing it this way here doesn't make sense. i'm preparing for filtering */
*iter = qe->next;
@@ -54,6 +54,6 @@ uint8_t *ether_start(size_t len, struct ethernet ether) {
void ether_finish(uint8_t *pkt) {
uint8_t *buf = pkt - Payload - fhoff;
size_t len = *(size_t*)buf;
- _syscall_write(state.raw_h, buf + fhoff, len, 0, 0);
+ _sys_write(state.raw_h, buf + fhoff, len, 0, 0);
free(buf);
}
diff --git a/src/user/app/netstack/fs.c b/src/user/app/netstack/fs.c
index ad6c23c..6d51c35 100644
--- a/src/user/app/netstack/fs.c
+++ b/src/user/app/netstack/fs.c
@@ -43,14 +43,14 @@ struct handle {
size_t readcap;
} tcp;
bool dead;
- handle_t reqh;
+ hid_t reqh;
};
static void tcp_listen_callback(struct tcp_conn *c, void *arg) {
struct handle *h = arg;
h->tcp.c = c;
- _syscall_fs_respond(h->reqh, h, 0, 0);
+ _sys_fs_respond(h->reqh, h, 0, 0);
h->reqh = -1;
}
@@ -63,7 +63,7 @@ static void tcp_recv_callback(void *arg) {
h->tcp.readcap = sizeof buf;
size_t len = tcpc_tryread(h->tcp.c, buf, h->tcp.readcap);
if (len > 0) {
- _syscall_fs_respond(h->reqh, buf, len, 0);
+ _sys_fs_respond(h->reqh, buf, len, 0);
h->reqh = -1;
}
}
@@ -73,7 +73,7 @@ static void tcp_close_callback(void *arg) {
struct handle *h = arg;
h->dead = true;
if (h->reqh >= 0) {
- _syscall_fs_respond(h->reqh, NULL, -ECONNRESET, 0);
+ _sys_fs_respond(h->reqh, NULL, -ECONNRESET, 0);
h->reqh = -1;
return;
}
@@ -82,14 +82,14 @@ static void tcp_close_callback(void *arg) {
static void udp_listen_callback(struct udp_conn *c, void *arg) {
struct handle *h = arg;
h->udp.c = c;
- _syscall_fs_respond(h->reqh, h, 0, 0);
+ _sys_fs_respond(h->reqh, h, 0, 0);
h->reqh = -1;
}
static void udp_recv_callback(const void *buf, size_t len, void *arg) {
struct handle *h = arg;
if (h->reqh >= 0) {
- _syscall_fs_respond(h->reqh, buf, len, 0);
+ _sys_fs_respond(h->reqh, buf, len, 0);
h->reqh = -1;
return;
}
@@ -106,14 +106,14 @@ static void udp_recv_callback(const void *buf, size_t len, void *arg) {
}
}
-static void recv_enqueue(struct handle *h, handle_t reqh, size_t readcap) {
+static void recv_enqueue(struct handle *h, hid_t reqh, size_t readcap) {
if (h->reqh > 0) {
// TODO queue
- _syscall_fs_respond(reqh, NULL, -1, 0);
+ _sys_fs_respond(reqh, NULL, -1, 0);
return;
}
if (h->type == H_UDP && h->udp.rx) {
- _syscall_fs_respond(reqh, h->udp.rx->buf, h->udp.rx->len, 0);
+ _sys_fs_respond(reqh, h->udp.rx->buf, h->udp.rx->len, 0);
h->udp.rx = h->udp.rx->next;
free(h->udp.rx);
return;
@@ -125,8 +125,8 @@ static void recv_enqueue(struct handle *h, handle_t reqh, size_t readcap) {
}
}
-static void fs_open(handle_t reqh, char *path, int flags) {
-#define respond(buf, val) do{ _syscall_fs_respond(reqh, buf, val, 0); return; }while(0)
+static void fs_open(hid_t reqh, char *path, int flags) {
+#define respond(buf, val) do{ _sys_fs_respond(reqh, buf, val, 0); return; }while(0)
struct handle *h;
if (*path != '/') respond(NULL, -1);
path++;
@@ -241,7 +241,7 @@ void fs_thread(void *arg) { (void)arg;
char *buf = malloc(buflen);
for (;;) {
struct ufs_request res;
- handle_t reqh = _syscall_fs_wait(buf, buflen, &res);
+ hid_t reqh = _sys_fs_wait(buf, buflen, &res);
if (reqh < 0) break;
struct handle *h = res.id;
long ret;
@@ -251,12 +251,12 @@ void fs_thread(void *arg) { (void)arg;
buf[res.len] = '\0';
fs_open(reqh, buf, res.flags);
} else {
- _syscall_fs_respond(reqh, NULL, -1, 0);
+ _sys_fs_respond(reqh, NULL, -1, 0);
}
break;
case VFSOP_READ:
if (h->dead) {
- _syscall_fs_respond(reqh, NULL, -ECONNRESET, 0);
+ _sys_fs_respond(reqh, NULL, -ECONNRESET, 0);
break;
}
switch (h->type) {
@@ -275,44 +275,44 @@ void fs_thread(void *arg) { (void)arg;
arp_fsread(reqh, res.offset);
break;
default:
- _syscall_fs_respond(reqh, NULL, -1, 0);
+ _sys_fs_respond(reqh, NULL, -1, 0);
}
break;
case VFSOP_WRITE:
if (h->dead) {
- _syscall_fs_respond(reqh, NULL, -ECONNRESET, 0);
+ _sys_fs_respond(reqh, NULL, -ECONNRESET, 0);
break;
}
switch (h->type) {
case H_ETHER:
- ret = _syscall_write(state.raw_h, buf, res.len, 0, 0);
- _syscall_fs_respond(reqh, NULL, ret, 0);
+ ret = _sys_write(state.raw_h, buf, res.len, 0, 0);
+ _sys_fs_respond(reqh, NULL, ret, 0);
break;
case H_TCP:
tcpc_send(h->tcp.c, buf, res.len);
- _syscall_fs_respond(reqh, NULL, res.len, 0);
+ _sys_fs_respond(reqh, NULL, res.len, 0);
break;
case H_UDP:
udpc_send(h->udp.c, buf, res.len);
- _syscall_fs_respond(reqh, NULL, res.len, 0);
+ _sys_fs_respond(reqh, NULL, res.len, 0);
break;
case H_ARP:
- _syscall_fs_respond(reqh, NULL, arp_fswrite(buf, res.len, res.offset), 0);
+ _sys_fs_respond(reqh, NULL, arp_fswrite(buf, res.len, res.offset), 0);
break;
default:
- _syscall_fs_respond(reqh, NULL, -1, 0);
+ _sys_fs_respond(reqh, NULL, -1, 0);
}
break;
case VFSOP_CLOSE:
// TODO remove entries in queue
- // TODO why does close even have _syscall_fs_respond?
+ // TODO why does close even have _sys_fs_respond?
if (h->type == H_TCP) tcpc_close(h->tcp.c);
if (h->type == H_UDP) udpc_close(h->udp.c);
free(h);
- _syscall_fs_respond(reqh, NULL, -1, 0);
+ _sys_fs_respond(reqh, NULL, -1, 0);
break;
default:
- _syscall_fs_respond(reqh, NULL, -1, 0);
+ _sys_fs_respond(reqh, NULL, -1, 0);
break;
}
}
diff --git a/src/user/app/netstack/netstack.c b/src/user/app/netstack/netstack.c
index 405be09..c2e9223 100644
--- a/src/user/app/netstack/netstack.c
+++ b/src/user/app/netstack/netstack.c
@@ -17,7 +17,7 @@ void network_thread(void *arg) { (void)arg;
const size_t buflen = 4096;
char *buf = malloc(buflen);
for (;;) {
- long ret = _syscall_read(state.raw_h, buf, buflen, -1);
+ long ret = _sys_read(state.raw_h, buf, buflen, -1);
if (ret < 0) break;
ether_parse((void*)buf, ret);
}
@@ -49,6 +49,6 @@ int main(int argc, char **argv) {
arp_request(state.gateway);
thread_create(0, network_thread, NULL);
thread_create(0, fs_thread, NULL);
- _syscall_await();
+ _sys_await();
return 0;
}
diff --git a/src/user/app/netstack/proto.h b/src/user/app/netstack/proto.h
index 4d881ca..8ea11ac 100644
--- a/src/user/app/netstack/proto.h
+++ b/src/user/app/netstack/proto.h
@@ -10,7 +10,7 @@ extern struct net_state {
mac_t mac;
uint32_t ip, gateway;
- handle_t raw_h;
+ hid_t raw_h;
} state;
enum { /* ethertype */
@@ -51,7 +51,7 @@ struct icmp {
* will break if i implement a scheduler*/
struct ethq {
struct ethq *next;
- handle_t h;
+ hid_t h;
};
extern struct ethq *ether_queue;
@@ -59,7 +59,7 @@ void arp_parse(const uint8_t *buf, size_t len);
void arp_request(uint32_t ip);
/* 0 on success, -1 on failure */
int arpcache_get(uint32_t ip, mac_t *mac);
-void arp_fsread(handle_t h, long offset);
+void arp_fsread(hid_t h, long offset);
long arp_fswrite(const char *buf, long len, long offset);
void icmp_parse(const uint8_t *buf, size_t len, struct ipv4 ip);
diff --git a/src/user/app/shell/builtins.c b/src/user/app/shell/builtins.c
index 870a6af..e0f848e 100644
--- a/src/user/app/shell/builtins.c
+++ b/src/user/app/shell/builtins.c
@@ -58,13 +58,13 @@ static void cmd_echo(int argc, char **argv) {
void cmd_getsize(int argc, char **argv) {
if (argc < 2) errx(1, "no arguments");
for (int i = 1; i < argc; i++) {
- handle_t h = camellia_open(argv[i], OPEN_READ);
+ hid_t h = camellia_open(argv[i], OPEN_READ);
if (h < 0) {
warn("error opening %s", argv[i]);
continue;
}
- printf("%s: %d\n", argv[i], (int)_syscall_getsize(h));
- _syscall_close(h);
+ printf("%s: %d\n", argv[i], (int)_sys_getsize(h));
+ _sys_close(h);
}
}
@@ -205,7 +205,7 @@ static void cmd_rm(int argc, char **argv) {
static void cmd_sleep(int argc, char **argv) {
if (argc < 2) errx(1, "no arguments");
- _syscall_sleep(strtol(argv[1], NULL, 0) * 1000);
+ _sys_sleep(strtol(argv[1], NULL, 0) * 1000);
}
static void cmd_touch(int argc, char **argv) {
diff --git a/src/user/app/shell/shell.c b/src/user/app/shell/shell.c
index 564daa8..5808de1 100644
--- a/src/user/app/shell/shell.c
+++ b/src/user/app/shell/shell.c
@@ -50,14 +50,14 @@ void run_args(int argc, char **argv, struct redir *redir) {
if (argc < 2) {
fprintf(stderr, "shadow: missing path\n");
} else {
- _syscall_mount(HANDLE_NULLFS, argv[1], strlen(argv[1]));
+ _sys_mount(HANDLE_NULLFS, argv[1], strlen(argv[1]));
}
} else if (!strcmp(argv[0], "procmnt")) {
if (argc < 2) {
fprintf(stderr, "procmnt: missing mountpoint\n");
return;
}
- _syscall_mount(HANDLE_PROCFS, argv[1], strlen(argv[1]));
+ _sys_mount(HANDLE_PROCFS, argv[1], strlen(argv[1]));
if (!fork2_n_mount("/")) {
fs_dir_inject(argv[1]);
exit(1);
@@ -79,7 +79,7 @@ void run_args(int argc, char **argv, struct redir *redir) {
}
if (fork()) {
- _syscall_await();
+ _sys_await();
return;
}
@@ -91,18 +91,18 @@ void run_args(int argc, char **argv, struct redir *redir) {
/* a workaround for file offsets not being preserved across exec()s.
* TODO document that weird behaviour of exec() */
- handle_t p[2];
- if (_syscall_pipe(p, 0) < 0) {
+ hid_t p[2];
+ if (_sys_pipe(p, 0) < 0) {
errx(1, "couldn't create redirection pipe");
}
- if (!_syscall_fork(FORK_NOREAP, NULL)) {
+ if (!_sys_fork(FORK_NOREAP, NULL)) {
/* the child forwards data from the pipe to the file */
const size_t buflen = 512;
char *buf = malloc(buflen);
if (!buf) err(1, "when redirecting");
close(p[1]);
for (;;) {
- long len = _syscall_read(p[0], buf, buflen, 0);
+ long len = _sys_read(p[0], buf, buflen, 0);
if (len < 0) exit(0);
fwrite(buf, 1, len, f);
if (ferror(f)) exit(0);
@@ -111,7 +111,7 @@ void run_args(int argc, char **argv, struct redir *redir) {
fclose(f);
close(p[0]);
- if (_syscall_dup(p[1], 1, 0) < 0) {
+ if (_sys_dup(p[1], 1, 0) < 0) {
errx(1, "dup() failed when redirecting");
}
}
diff --git a/src/user/app/tests/kernel/fdlimit.c b/src/user/app/tests/kernel/fdlimit.c
index d22af13..f332357 100644
--- a/src/user/app/tests/kernel/fdlimit.c
+++ b/src/user/app/tests/kernel/fdlimit.c
@@ -4,10 +4,10 @@
#include <unistd.h>
static void test_fdlimit_pipe(void) {
- handle_t ends[2];
- handle_t h[2] = {-1, -1};
+ hid_t ends[2];
+ hid_t h[2] = {-1, -1};
for (;;) {
- handle_t cur = _syscall_open("/", 1, OPEN_READ);
+ hid_t cur = _sys_open("/", 1, OPEN_READ);
if (cur == -EMFILE) break;
test(cur >= 0);
h[0] = h[1];
@@ -15,31 +15,31 @@ static void test_fdlimit_pipe(void) {
}
test(h[0] >= 0); /* we need at least two handles */
- test(_syscall_pipe(ends, 0) == -EMFILE);
- test(_syscall_open("/", 1, OPEN_READ) == -EMFILE);
+ test(_sys_pipe(ends, 0) == -EMFILE);
+ test(_sys_open("/", 1, OPEN_READ) == -EMFILE);
close(h[1]);
- test(_syscall_pipe(ends, 0) == -EMFILE);
- test(_syscall_open("/", 1, OPEN_READ) == h[1]);
- test(_syscall_open("/", 1, OPEN_READ) == -EMFILE);
+ test(_sys_pipe(ends, 0) == -EMFILE);
+ test(_sys_open("/", 1, OPEN_READ) == h[1]);
+ test(_sys_open("/", 1, OPEN_READ) == -EMFILE);
close(h[0]);
close(h[1]);
- test(_syscall_pipe(ends, 0) == 0);
+ test(_sys_pipe(ends, 0) == 0);
}
static void test_fdlimit_fork(void) {
for (;;) {
- handle_t cur = _syscall_open("/", 1, OPEN_READ);
+ hid_t cur = _sys_open("/", 1, OPEN_READ);
if (cur == -EMFILE) break;
test(cur >= 0);
}
- if (!_syscall_fork(0, NULL)) _syscall_exit(123);
+ if (!_sys_fork(0, NULL)) _sys_exit(123);
- test(_syscall_fork(FORK_NEWFS, NULL) == -EMFILE);
- test(_syscall_await() == 123);
- test(_syscall_await() == ~0);
+ test(_sys_fork(FORK_NEWFS, NULL) == -EMFILE);
+ test(_sys_await() == 123);
+ test(_sys_await() == ~0);
}
void r_k_fdlimit(void) {
diff --git a/src/user/app/tests/kernel/fs.c b/src/user/app/tests/kernel/fs.c
index 6669c41..b5684d7 100644
--- a/src/user/app/tests/kernel/fs.c
+++ b/src/user/app/tests/kernel/fs.c
@@ -5,34 +5,34 @@
#include <string.h>
static void test_unfinished_req(void) {
- handle_t h = -1;
- int ret = _syscall_fork(FORK_NEWFS, &h);
+ hid_t h = -1;
+ int ret = _sys_fork(FORK_NEWFS, &h);
test(0 <= ret);
if (ret == 0) {
// TODO make a similar test with all 0s passed to fs_wait
struct ufs_request res;
- _syscall_fs_wait(NULL, 0, &res);
+ _sys_fs_wait(NULL, 0, &res);
// TODO second fs_wait
exit(0);
} else {
test(0 <= h);
- test(_syscall_mount(h, "/", 1) == 0);
- int ret = _syscall_open("/", 1, 0);
+ test(_sys_mount(h, "/", 1) == 0);
+ int ret = _sys_open("/", 1, 0);
test(ret < 0);
// the handler quits while handling that call - but this syscall should return anyways
}
}
static void test_orphaned_fs(void) {
- handle_t h = -1;
- int ret = _syscall_fork(FORK_NEWFS, &h);
+ hid_t h = -1;
+ int ret = _sys_fork(FORK_NEWFS, &h);
test(0 <= ret);
if (ret == 0) {
exit(0);
} else {
test(0 <= h);
- test(_syscall_mount(h, "/", 1) == 0);
- int ret = _syscall_open("/", 1, 0);
+ test(_sys_mount(h, "/", 1) == 0);
+ int ret = _sys_open("/", 1, 0);
test(ret < 0);
}
}
@@ -41,32 +41,32 @@ static void test_fs_cleanup(void) {
const char *msg = "success";
int msglen = 8;
char buf[16];
- handle_t ends[2];
- test(_syscall_pipe(ends, 0) >= 0);
- if (!_syscall_fork(0, NULL)) {
- handle_t h = -1;
- if (_syscall_fork(FORK_NEWFS, &h) == 0) {
+ hid_t ends[2];
+ test(_sys_pipe(ends, 0) >= 0);
+ if (!_sys_fork(0, NULL)) {
+ hid_t h = -1;
+ if (_sys_fork(FORK_NEWFS, &h) == 0) {
for (;;) {
struct ufs_request req;
- handle_t reqh = _syscall_fs_wait(buf, sizeof buf, &req);
+ hid_t reqh = _sys_fs_wait(buf, sizeof buf, &req);
if (reqh < 0) break;
- _syscall_fs_respond(reqh, NULL, 0, 0); /* success */
+ _sys_fs_respond(reqh, NULL, 0, 0); /* success */
}
/* this is the test: does it break out of the loop
* when it should cleanup */
- _syscall_write(ends[1], msg, msglen, -1, 0);
+ _sys_write(ends[1], msg, msglen, -1, 0);
exit(0);
} else {
- test(_syscall_mount(h, "/", 1) == 0);
- h = _syscall_open("/", 1, 0);
+ test(_sys_mount(h, "/", 1) == 0);
+ h = _sys_open("/", 1, 0);
test(h >= 0);
- _syscall_close(h);
+ _sys_close(h);
// TODO another test without the delay
- _syscall_sleep(0);
+ _sys_sleep(0);
exit(0);
}
} else {
- test(_syscall_read(ends[0], buf, sizeof buf, 0) == msglen);
+ test(_sys_read(ends[0], buf, sizeof buf, 0) == msglen);
test(memcmp(buf, msg, msglen) == 0);
}
}
diff --git a/src/user/app/tests/kernel/misc.c b/src/user/app/tests/kernel/misc.c
index f6a8feb..b60ebc0 100644
--- a/src/user/app/tests/kernel/misc.c
+++ b/src/user/app/tests/kernel/misc.c
@@ -16,7 +16,7 @@ static void test_fault_kill(void) {
}
int await_cnt = 0;
- while (_syscall_await() != ~0) await_cnt++;
+ while (_sys_await() != ~0) await_cnt++;
test(await_cnt == 2);
}
@@ -24,32 +24,32 @@ static void test_efault(void) {
const char *str = "o, 16 characters";
char str2[16];
char *invalid = (void*)0x1000;
- handle_t h;
+ hid_t h;
memcpy(str2, str, 16);
- test((h = _syscall_open(TMPFILEPATH, strlen(TMPFILEPATH), OPEN_CREATE | OPEN_WRITE)) >= 0);
- test(_syscall_write(h, str, 16, 0, 0) == 16);
- test(_syscall_write(h, str2, 16, 0, 0) == 16);
+ test((h = _sys_open(TMPFILEPATH, strlen(TMPFILEPATH), OPEN_CREATE | OPEN_WRITE)) >= 0);
+ test(_sys_write(h, str, 16, 0, 0) == 16);
+ test(_sys_write(h, str2, 16, 0, 0) == 16);
- test(_syscall_write(h, invalid, 16, 0, 0) == -EFAULT);
+ test(_sys_write(h, invalid, 16, 0, 0) == -EFAULT);
/* x64 non-canonical pointers */
- test(_syscall_write(h, (void*)((uintptr_t)str ^ 0x8000000000000000), 16, 0, 0) == -EFAULT);
- test(_syscall_write(h, (void*)((uintptr_t)str ^ 0x1000000000000000), 16, 0, 0) == -EFAULT);
- test(_syscall_write(h, (void*)((uintptr_t)str ^ 0x0100000000000000), 16, 0, 0) == -EFAULT);
- test(_syscall_write(h, (void*)((uintptr_t)str ^ 0x0010000000000000), 16, 0, 0) == -EFAULT);
- test(_syscall_write(h, (void*)((uintptr_t)str ^ 0x0001000000000000), 16, 0, 0) == -EFAULT);
- test(_syscall_write(h, (void*)((uintptr_t)str ^ 0x0000800000000000), 16, 0, 0) == -EFAULT);
+ test(_sys_write(h, (void*)((uintptr_t)str ^ 0x8000000000000000), 16, 0, 0) == -EFAULT);
+ test(_sys_write(h, (void*)((uintptr_t)str ^ 0x1000000000000000), 16, 0, 0) == -EFAULT);
+ test(_sys_write(h, (void*)((uintptr_t)str ^ 0x0100000000000000), 16, 0, 0) == -EFAULT);
+ test(_sys_write(h, (void*)((uintptr_t)str ^ 0x0010000000000000), 16, 0, 0) == -EFAULT);
+ test(_sys_write(h, (void*)((uintptr_t)str ^ 0x0001000000000000), 16, 0, 0) == -EFAULT);
+ test(_sys_write(h, (void*)((uintptr_t)str ^ 0x0000800000000000), 16, 0, 0) == -EFAULT);
- test(_syscall_write(h, (void*)((uintptr_t)str2 ^ 0x8000000000000000), 16, 0, 0) == -EFAULT);
- test(_syscall_write(h, (void*)((uintptr_t)str2 ^ 0x1000000000000000), 16, 0, 0) == -EFAULT);
- test(_syscall_write(h, (void*)((uintptr_t)str2 ^ 0x0100000000000000), 16, 0, 0) == -EFAULT);
- test(_syscall_write(h, (void*)((uintptr_t)str2 ^ 0x0010000000000000), 16, 0, 0) == -EFAULT);
- test(_syscall_write(h, (void*)((uintptr_t)str2 ^ 0x0001000000000000), 16, 0, 0) == -EFAULT);
- test(_syscall_write(h, (void*)((uintptr_t)str2 ^ 0x0000800000000000), 16, 0, 0) == -EFAULT);
+ test(_sys_write(h, (void*)((uintptr_t)str2 ^ 0x8000000000000000), 16, 0, 0) == -EFAULT);
+ test(_sys_write(h, (void*)((uintptr_t)str2 ^ 0x1000000000000000), 16, 0, 0) == -EFAULT);
+ test(_sys_write(h, (void*)((uintptr_t)str2 ^ 0x0100000000000000), 16, 0, 0) == -EFAULT);
+ test(_sys_write(h, (void*)((uintptr_t)str2 ^ 0x0010000000000000), 16, 0, 0) == -EFAULT);
+ test(_sys_write(h, (void*)((uintptr_t)str2 ^ 0x0001000000000000), 16, 0, 0) == -EFAULT);
+ test(_sys_write(h, (void*)((uintptr_t)str2 ^ 0x0000800000000000), 16, 0, 0) == -EFAULT);
- test(_syscall_write(h, str, 16, 0, 0) == 16);
+ test(_sys_write(h, str, 16, 0, 0) == 16);
close(h);
}
diff --git a/src/user/app/tests/kernel/miscsyscall.c b/src/user/app/tests/kernel/miscsyscall.c
index 58a9afb..c90560e 100644
--- a/src/user/app/tests/kernel/miscsyscall.c
+++ b/src/user/app/tests/kernel/miscsyscall.c
@@ -17,7 +17,7 @@ static void test_await(void) {
if (!fork())
exit(i);
- while ((ret = _syscall_await()) != ~0) {
+ while ((ret = _sys_await()) != ~0) {
test(0 <= ret && ret < 16);
counts[ret]++;
}
@@ -30,114 +30,114 @@ static void test_await2(void) {
/* hangs on failure */
if (!fork()) {
if (!fork()) {
- for (;;) _syscall_sleep(1000000000);
+ for (;;) _sys_sleep(1000000000);
} else {
exit(123);
}
}
- test(_syscall_await() == 123);
- test(_syscall_await() == ~0); /* don't wait for tombstone */
- _syscall_filicide();
+ test(_sys_await() == 123);
+ test(_sys_await() == ~0); /* don't wait for tombstone */
+ _sys_filicide();
}
static void test_pipe(void) {
const char *pipe_msgs[2] = {"hello", "world"};
- handle_t ends[2];
+ hid_t ends[2];
char buf[16];
/* test regular reads / writes */
- test(_syscall_pipe(ends, 0) >= 0);
+ test(_sys_pipe(ends, 0) >= 0);
if (!fork()) {
/* those repeated asserts ensure that you can't read/write to the wrong ends */
- test(_syscall_read(ends[1], buf, 16, 0) < 0);
- test(_syscall_write(ends[0], buf, 16, 0, 0) < 0);
+ test(_sys_read(ends[1], buf, 16, 0) < 0);
+ test(_sys_write(ends[0], buf, 16, 0, 0) < 0);
- test(5 == _syscall_write(ends[1], pipe_msgs[0], 5, -1, 0));
+ test(5 == _sys_write(ends[1], pipe_msgs[0], 5, -1, 0));
- test(_syscall_read(ends[1], buf, 16, 0) < 0);
- test(_syscall_write(ends[0], buf, 16, 0, 0) < 0);
+ test(_sys_read(ends[1], buf, 16, 0) < 0);
+ test(_sys_write(ends[0], buf, 16, 0, 0) < 0);
- test(5 == _syscall_write(ends[1], pipe_msgs[1], 5, -1, 0));
+ test(5 == _sys_write(ends[1], pipe_msgs[1], 5, -1, 0));
exit(0);
} else {
- test(_syscall_read(ends[1], buf, 16, 0) < 0);
- test(_syscall_write(ends[0], buf, 16, 0, 0) < 0);
+ test(_sys_read(ends[1], buf, 16, 0) < 0);
+ test(_sys_write(ends[0], buf, 16, 0, 0) < 0);
- test(5 == _syscall_read(ends[0], buf, 16, 0));
+ test(5 == _sys_read(ends[0], buf, 16, 0));
test(!memcmp(buf, pipe_msgs[0], 5));
- test(_syscall_read(ends[1], buf, 16, 0) < 0);
- test(_syscall_write(ends[0], buf, 16, 0, 0) < 0);
+ test(_sys_read(ends[1], buf, 16, 0) < 0);
+ test(_sys_write(ends[0], buf, 16, 0, 0) < 0);
- test(5 == _syscall_read(ends[0], buf, 16, 0));
+ test(5 == _sys_read(ends[0], buf, 16, 0));
test(!memcmp(buf, pipe_msgs[1], 5));
- _syscall_await();
+ _sys_await();
}
close(ends[0]);
close(ends[1]);
/* writing to pipes with one end closed */
- test(_syscall_pipe(ends, 0) >= 0);
+ test(_sys_pipe(ends, 0) >= 0);
for (int i = 0; i < 16; i++) {
if (!fork()) {
close(ends[1]);
- test(_syscall_read(ends[0], buf, 16, 0) < 0);
+ test(_sys_read(ends[0], buf, 16, 0) < 0);
exit(0);
}
}
close(ends[1]);
for (int i = 0; i < 16; i++)
- _syscall_await();
+ _sys_await();
close(ends[0]);
- test(_syscall_pipe(ends, 0) >= 0);
+ test(_sys_pipe(ends, 0) >= 0);
for (int i = 0; i < 16; i++) {
if (!fork()) {
close(ends[0]);
- test(_syscall_write(ends[1], buf, 16, 0, 0) < 0);
+ test(_sys_write(ends[1], buf, 16, 0, 0) < 0);
exit(0);
}
}
close(ends[0]);
for (int i = 0; i < 16; i++)
- _syscall_await();
+ _sys_await();
close(ends[1]);
/* queueing */
- test(_syscall_pipe(ends, 0) >= 0);
+ test(_sys_pipe(ends, 0) >= 0);
for (int i = 0; i < 16; i++) {
if (!fork()) {
- test(_syscall_write(ends[1], pipe_msgs[0], 5, -1, 0) == 5);
+ test(_sys_write(ends[1], pipe_msgs[0], 5, -1, 0) == 5);
exit(0);
}
}
close(ends[1]);
for (int i = 0; i < 16; i++) {
- test(_syscall_read(ends[0], buf, sizeof buf, 0) == 5);
- _syscall_await();
+ test(_sys_read(ends[0], buf, sizeof buf, 0) == 5);
+ _sys_await();
}
- test(_syscall_read(ends[0], buf, sizeof buf, 0) < 0);
+ test(_sys_read(ends[0], buf, sizeof buf, 0) < 0);
close(ends[0]);
- test(_syscall_pipe(ends, 0) >= 0);
+ test(_sys_pipe(ends, 0) >= 0);
for (int i = 0; i < 16; i++) {
if (!fork()) {
memset(buf, 0, sizeof buf);
- test(_syscall_read(ends[0], buf, 5, -1) == 5);
+ test(_sys_read(ends[0], buf, 5, -1) == 5);
test(!memcmp(buf, pipe_msgs[1], 5));
exit(0);
}
}
close(ends[0]);
for (int i = 0; i < 16; i++) {
- test(_syscall_write(ends[1], pipe_msgs[1], 5, -1, 0) == 5);
- _syscall_await();
+ test(_sys_write(ends[1], pipe_msgs[1], 5, -1, 0) == 5);
+ _sys_await();
}
- test(_syscall_write(ends[1], pipe_msgs[1], 5, -1, 0) < 0);
+ test(_sys_write(ends[1], pipe_msgs[1], 5, -1, 0) < 0);
close(ends[1]);
@@ -147,65 +147,65 @@ static void test_pipe(void) {
static void test_memflag(void) {
void *page = (void*)0x77777000;
- _syscall_memflag(page, 4096, MEMFLAG_PRESENT); // allocate page
+ _sys_memflag(page, 4096, MEMFLAG_PRESENT); // allocate page
memset(page, 77, 4096); // write to it
- _syscall_memflag(page, 4096, 0); // free it
+ _sys_memflag(page, 4096, 0); // free it
if (!fork()) {
memset(page, 11, 4096); // should segfault
exit(0);
} else {
- test(_syscall_await() != 0); // test if the process crashed
+ test(_sys_await() != 0); // test if the process crashed
}
char *pages[4];
for (size_t i = 0; i < 4; i++) {
- pages[i] = _syscall_memflag(NULL, 4096, MEMFLAG_FINDFREE);
- test(pages[i] == _syscall_memflag(NULL, 4096, MEMFLAG_FINDFREE | MEMFLAG_PRESENT));
+ pages[i] = _sys_memflag(NULL, 4096, MEMFLAG_FINDFREE);
+ test(pages[i] == _sys_memflag(NULL, 4096, MEMFLAG_FINDFREE | MEMFLAG_PRESENT));
if (i > 0) test(pages[i] != pages[i-1]);
*pages[i] = 0x77;
}
for (size_t i = 0; i < 4; i++)
- _syscall_memflag(pages, 4096, MEMFLAG_PRESENT);
+ _sys_memflag(pages, 4096, MEMFLAG_PRESENT);
}
static void test_dup(void) {
- handle_t pipe[2];
- handle_t h1, h2;
- test(_syscall_pipe(pipe, 0) >= 0);
+ hid_t pipe[2];
+ hid_t h1, h2;
+ test(_sys_pipe(pipe, 0) >= 0);
if (!fork()) {
close(pipe[0]);
- h1 = _syscall_dup(pipe[1], -1, 0);
+ h1 = _sys_dup(pipe[1], -1, 0);
test(h1 >= 0);
test(h1 != pipe[1]);
- h2 = _syscall_dup(h1, -1, 0);
+ h2 = _sys_dup(h1, -1, 0);
test(h2 >= 0);
test(h2 != pipe[1] && h2 != h1);
- _syscall_write(pipe[1], "og", 2, 0, 0);
- _syscall_write(h1, "h1", 2, 0, 0);
- _syscall_write(h2, "h2", 2, 0, 0);
+ _sys_write(pipe[1], "og", 2, 0, 0);
+ _sys_write(h1, "h1", 2, 0, 0);
+ _sys_write(h2, "h2", 2, 0, 0);
close(pipe[1]);
- _syscall_write(h1, "h1", 2, 0, 0);
- _syscall_write(h2, "h2", 2, 0, 0);
+ _sys_write(h1, "h1", 2, 0, 0);
+ _sys_write(h2, "h2", 2, 0, 0);
- test(_syscall_dup(h1, pipe[1], 0) == pipe[1]);
- test(_syscall_dup(h2, pipe[1], 0) == pipe[1]);
- test(_syscall_dup(h1, pipe[1], 0) == pipe[1]);
- test(_syscall_dup(h2, pipe[1], 0) == pipe[1]);
+ test(_sys_dup(h1, pipe[1], 0) == pipe[1]);
+ test(_sys_dup(h2, pipe[1], 0) == pipe[1]);
+ test(_sys_dup(h1, pipe[1], 0) == pipe[1]);
+ test(_sys_dup(h2, pipe[1], 0) == pipe[1]);
close(h1);
close(h2);
- test(_syscall_dup(pipe[1], h2, 0) == h2);
- _syscall_write(h2, "h2", 2, 0, 0);
+ test(_sys_dup(pipe[1], h2, 0) == h2);
+ _sys_write(h2, "h2", 2, 0, 0);
close(h2);
- test(_syscall_dup(pipe[1], h1, 0) == h1);
- _syscall_write(h1, "h1", 2, 0, 0);
+ test(_sys_dup(pipe[1], h1, 0) == h1);
+ _sys_write(h1, "h1", 2, 0, 0);
close(h1);
exit(0);
@@ -213,10 +213,10 @@ static void test_dup(void) {
char buf[16];
size_t count = 0;
close(pipe[1]);
- while (_syscall_read(pipe[0], buf, sizeof buf, 0) >= 0)
+ while (_sys_read(pipe[0], buf, sizeof buf, 0) >= 0)
count++;
test(count == 7);
- _syscall_await();
+ _sys_await();
}
@@ -226,47 +226,47 @@ static void test_dup(void) {
static void test_execbuf(void) {
if (!fork()) {
uint64_t buf[] = {
- EXECBUF_SYSCALL, _SYSCALL_EXIT, 123, 0, 0, 0, 0,
+ EXECBUF_SYSCALL, _SYS_EXIT, 123, 0, 0, 0, 0,
};
- _syscall_execbuf(buf, sizeof buf);
+ _sys_execbuf(buf, sizeof buf);
test_fail();
} else {
- test(_syscall_await() == 123);
+ test(_sys_await() == 123);
}
}
static void test_sleep(void) {
- handle_t reader;
+ hid_t reader;
FILE *writer;
if (!forkpipe(&writer, &reader)) {
if (!fork()) {
if (!fork()) {
- _syscall_sleep(100);
+ _sys_sleep(100);
fprintf(writer, "1");
- _syscall_sleep(200);
+ _sys_sleep(200);
fprintf(writer, "3");
- _syscall_sleep(200);
+ _sys_sleep(200);
fprintf(writer, "5");
- _syscall_exit(0);
+ _sys_exit(0);
}
if (!fork()) {
fprintf(writer, "0");
- _syscall_sleep(200);
+ _sys_sleep(200);
fprintf(writer, "2");
- _syscall_sleep(200);
+ _sys_sleep(200);
fprintf(writer, "4");
/* get killed while asleep
* a peaceful death, i suppose. */
- for (;;) _syscall_sleep(1000000000);
+ for (;;) _sys_sleep(1000000000);
}
- _syscall_await();
- _syscall_filicide();
- _syscall_exit(0);
+ _sys_await();
+ _sys_filicide();
+ _sys_exit(0);
}
/* this part checks if, after killing an asleep process,
* other processes can still wake up */
- _syscall_sleep(600);
+ _sys_sleep(600);
fprintf(writer, "6");
exit(0);
} else {
@@ -275,7 +275,7 @@ static void test_sleep(void) {
size_t pos = 0;
for (;;) {
char buf[128];
- long ret = _syscall_read(reader, buf, sizeof buf, 0);
+ long ret = _sys_read(reader, buf, sizeof buf, 0);
if (ret < 0) break;
test(pos + ret <= target);
test(memcmp(buf, expected + pos, ret) == 0);
@@ -286,8 +286,8 @@ static void test_sleep(void) {
}
static void test_badopen(void) {
- test(_syscall_open(TMPFILEPATH, strlen(TMPFILEPATH), OPEN_CREATE | OPEN_WRITE) >= 0);
- test(_syscall_open(TMPFILEPATH, strlen(TMPFILEPATH), OPEN_CREATE) == -EINVAL);
+ test(_sys_open(TMPFILEPATH, strlen(TMPFILEPATH), OPEN_CREATE | OPEN_WRITE) >= 0);
+ test(_sys_open(TMPFILEPATH, strlen(TMPFILEPATH), OPEN_CREATE) == -EINVAL);
}
void r_k_miscsyscall(void) {
diff --git a/src/user/app/tests/kernel/path.c b/src/user/app/tests/kernel/path.c
index 2bce344..5392681 100644
--- a/src/user/app/tests/kernel/path.c
+++ b/src/user/app/tests/kernel/path.c
@@ -94,11 +94,11 @@ static void test_mount_resolve(void) {
for (size_t i = 0; i < sizeof(testcases) / sizeof(testcases[0]); i++) {
const char *input = testcases[i][0];
const char *expected = testcases[i][1];
- handle_t h = _syscall_open(input, strlen(input), 0);
+ hid_t h = _sys_open(input, strlen(input), 0);
test(h >= 0);
- int len = _syscall_read(h, buf, sizeof buf, 0);
+ int len = _sys_read(h, buf, sizeof buf, 0);
test(len == (int)strlen(expected) && !memcmp(expected, buf, len));
- _syscall_close(h);
+ _sys_close(h);
}
}
diff --git a/src/user/app/tests/kernel/threads.c b/src/user/app/tests/kernel/threads.c
index cb7111d..abca41c 100644
--- a/src/user/app/tests/kernel/threads.c
+++ b/src/user/app/tests/kernel/threads.c
@@ -18,13 +18,13 @@ static void test_basic_thread(void) {
test(global_n == 10);
}
-handle_t global_h;
+hid_t global_h;
static void shared_handle(void *sem) {
- handle_t ends[2];
- test(_syscall_pipe(ends, 0) >= 0);
+ hid_t ends[2];
+ test(_sys_pipe(ends, 0) >= 0);
global_h = ends[0];
esem_signal(sem);
- _syscall_write(ends[1], "Hello!", 7, -1, 0);
+ _sys_write(ends[1], "Hello!", 7, -1, 0);
}
static void test_shared_handle(void) {
struct evil_sem *sem = esem_new(0);
@@ -34,7 +34,7 @@ static void test_shared_handle(void) {
esem_wait(sem);
test(global_h >= 0);
- test(_syscall_read(global_h, buf, sizeof buf, 0) == 7);
+ test(_sys_read(global_h, buf, sizeof buf, 0) == 7);
test(!strcmp("Hello!", buf));
}
@@ -44,7 +44,7 @@ static void many_thread(void *arg) {
static void test_many_threads(void) {
uint64_t n = 0;
for (int i = 0; i < 10; i++) thread_create(0, many_thread, &n);
- for (int i = 0; i < 10; i++) _syscall_await();
+ for (int i = 0; i < 10; i++) _sys_await();
test(n == 100);
}
diff --git a/src/user/app/tests/libc/esemaphore.c b/src/user/app/tests/libc/esemaphore.c
index f1856ff..2f1d4bc 100644
--- a/src/user/app/tests/libc/esemaphore.c
+++ b/src/user/app/tests/libc/esemaphore.c
@@ -6,37 +6,37 @@
#include <unistd.h>
#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, 0);
+static void odd(hid_t out, struct evil_sem *sem1, struct evil_sem *sem2) {
+ _sys_write(out, "1", 1, -1, 0);
esem_signal(sem1);
esem_wait(sem2);
- _syscall_write(out, "3", 1, -1, 0);
+ _sys_write(out, "3", 1, -1, 0);
esem_signal(sem1);
esem_wait(sem2);
- _syscall_write(out, "5", 1, -1, 0);
+ _sys_write(out, "5", 1, -1, 0);
esem_signal(sem1);
}
-static void even(handle_t out, struct evil_sem *sem1, struct evil_sem *sem2) {
+static void even(hid_t out, struct evil_sem *sem1, struct evil_sem *sem2) {
esem_wait(sem1);
- _syscall_write(out, "2", 1, -1, 0);
+ _sys_write(out, "2", 1, -1, 0);
esem_signal(sem2);
esem_wait(sem1);
- _syscall_write(out, "4", 1, -1, 0);
+ _sys_write(out, "4", 1, -1, 0);
esem_signal(sem2);
esem_wait(sem1);
- _syscall_write(out, "6", 1, -1, 0);
+ _sys_write(out, "6", 1, -1, 0);
esem_signal(sem2);
}
static void test_semaphore(void) {
struct evil_sem *sem1, *sem2;
- handle_t pipe[2];
- test(_syscall_pipe(pipe, 0) >= 0);
+ hid_t pipe[2];
+ test(_sys_pipe(pipe, 0) >= 0);
if (!fork()) {
sem1 = esem_new(0);
@@ -47,12 +47,12 @@ static void test_semaphore(void) {
exit(69);
} else {
even(pipe[1], sem1, sem2);
- test(_syscall_await() == 69);
+ test(_sys_await() == 69);
}
esem_free(sem1);
esem_free(sem2);
- _syscall_write(pipe[1], "|", 1, -1, 0);
+ _sys_write(pipe[1], "|", 1, -1, 0);
sem1 = esem_new(0);
sem2 = esem_new(0);
@@ -62,13 +62,13 @@ static void test_semaphore(void) {
exit(69);
} else {
odd(pipe[1], sem1, sem2);
- test(_syscall_await() == 69);
- _syscall_await();
+ test(_sys_await() == 69);
+ _sys_await();
}
esem_free(sem1);
esem_free(sem2);
- _syscall_filicide();
+ _sys_filicide();
exit(0);
} else {
close(pipe[1]);
@@ -76,7 +76,7 @@ static void test_semaphore(void) {
char buf[16];
size_t pos = 0;
for (;;) {
- int ret = _syscall_read(pipe[0], buf + pos, sizeof(buf) - pos, 0);
+ int ret = _sys_read(pipe[0], buf + pos, sizeof(buf) - pos, 0);
if (ret < 0) break;
pos += ret;
}
@@ -86,7 +86,7 @@ static void test_semaphore(void) {
test_fail();
}
- _syscall_await();
+ _sys_await();
}
}
diff --git a/src/user/app/tests/stress.c b/src/user/app/tests/stress.c
index 1df462a..1ef018c 100644
--- a/src/user/app/tests/stress.c
+++ b/src/user/app/tests/stress.c
@@ -11,7 +11,7 @@ static void run_forked(void (*fn)()) {
} else {
/* successful tests must return 0
* TODO add a better fail msg */
- if (_syscall_await() != 0) test_fail();
+ if (_sys_await() != 0) test_fail();
}
}
@@ -19,7 +19,7 @@ static void run_forked(void (*fn)()) {
static void stress_fork(void) {
for (size_t i = 0; i < 2048; i++) {
if (!fork()) exit(0);
- _syscall_await();
+ _sys_await();
}
}
diff --git a/src/user/app/tests/tests.c b/src/user/app/tests/tests.c
index f2f9aa5..7139fc7 100644
--- a/src/user/app/tests/tests.c
+++ b/src/user/app/tests/tests.c
@@ -10,19 +10,19 @@ FILE *fail_trig;
void run_test(void (*fn)()) {
if (!fork()) {
fn();
- _syscall_filicide();
+ _sys_filicide();
exit(0);
} else {
/* successful tests must return 0 */
- if (_syscall_await() != 0) {
+ if (_sys_await() != 0) {
test_failf("%p, base %p", (void*)fn - (void*)_image_base, _image_base);
}
}
}
-int forkpipe(FILE **f, handle_t *h) {
- handle_t ends[2];
- if (_syscall_pipe(ends, 0) < 0) {
+int forkpipe(FILE **f, hid_t *h) {
+ hid_t ends[2];
+ if (_sys_pipe(ends, 0) < 0) {
fprintf(stderr, "couldn't create pipe\n");
exit(1);
}
@@ -40,7 +40,7 @@ int forkpipe(FILE **f, handle_t *h) {
}
int main(void) {
- handle_t reader;
+ hid_t reader;
if (!forkpipe(&fail_trig, &reader)) {
r_k_miscsyscall();
r_k_fs();
@@ -57,7 +57,7 @@ int main(void) {
} else {
for (;;) {
char buf[128];
- long ret = _syscall_read(reader, buf, sizeof buf, 0);
+ long ret = _sys_read(reader, buf, sizeof buf, 0);
if (ret < 0) break;
printf("\033[31mFAIL\033[0m ");
fwrite(buf, ret, 1, stdout);
diff --git a/src/user/app/tests/tests.h b/src/user/app/tests/tests.h
index e93653e..5037e1a 100644
--- a/src/user/app/tests/tests.h
+++ b/src/user/app/tests/tests.h
@@ -21,7 +21,7 @@ void r_s_ringbuf(void);
extern FILE *fail_trig;
-int forkpipe(FILE **f, handle_t *h);
+int forkpipe(FILE **f, hid_t *h);
#define argify(str) str, sizeof(str) - 1
#define test_fail() do { \
diff --git a/src/user/app/tmpfs/tmpfs.c b/src/user/app/tmpfs/tmpfs.c
index c55da59..6d58790 100644
--- a/src/user/app/tmpfs/tmpfs.c
+++ b/src/user/app/tmpfs/tmpfs.c
@@ -123,14 +123,14 @@ int main(void) {
for (;;) {
struct ufs_request req;
- handle_t reqh = ufs_wait(buf, buflen, &req);
+ hid_t reqh = ufs_wait(buf, buflen, &req);
struct node *ptr = req.id;
if (reqh < 0) break;
switch (req.op) {
case VFSOP_OPEN:
ptr = tmpfs_open(buf, &req);
- _syscall_fs_respond(reqh, ptr, ptr ? 0 : -ENOENT, 0);
+ _sys_fs_respond(reqh, ptr, ptr ? 0 : -ENOENT, 0);
break;
case VFSOP_READ:
@@ -140,16 +140,16 @@ int main(void) {
for (struct node *iter = ptr->child; iter; iter = iter->sibling) {
dir_appendl(&db, iter->name, iter->namelen);
}
- _syscall_fs_respond(reqh, buf, dir_finish(&db), 0);
+ _sys_fs_respond(reqh, buf, dir_finish(&db), 0);
} else {
fs_normslice(&req.offset, &req.len, ptr->size, false);
- _syscall_fs_respond(reqh, ptr->buf + req.offset, req.len, 0);
+ _sys_fs_respond(reqh, ptr->buf + req.offset, req.len, 0);
}
break;
case VFSOP_WRITE:
if (ptr->directory) {
- _syscall_fs_respond(reqh, NULL, -ENOSYS, 0);
+ _sys_fs_respond(reqh, NULL, -ENOSYS, 0);
break;
}
@@ -163,7 +163,7 @@ int main(void) {
if ((req.flags & WRITE_TRUNCATE) || ptr->size < req.offset + req.len) {
ptr->size = req.offset + req.len;
}
- _syscall_fs_respond(reqh, NULL, req.len, 0);
+ _sys_fs_respond(reqh, NULL, req.len, 0);
break;
case VFSOP_GETSIZE:
@@ -174,23 +174,23 @@ int main(void) {
for (struct node *iter = ptr->child; iter; iter = iter->sibling) {
dir_append(&db, iter->name);
}
- _syscall_fs_respond(reqh, NULL, dir_finish(&db), 0);
+ _sys_fs_respond(reqh, NULL, dir_finish(&db), 0);
} else {
- _syscall_fs_respond(reqh, NULL, ptr->size, 0);
+ _sys_fs_respond(reqh, NULL, ptr->size, 0);
}
break;
case VFSOP_REMOVE:
- _syscall_fs_respond(reqh, NULL, node_remove(ptr), 0);
+ _sys_fs_respond(reqh, NULL, node_remove(ptr), 0);
break;
case VFSOP_CLOSE:
node_close(ptr);
- _syscall_fs_respond(reqh, NULL, -1, 0);
+ _sys_fs_respond(reqh, NULL, -1, 0);
break;
default:
- _syscall_fs_respond(reqh, NULL, -1, 0);
+ _sys_fs_respond(reqh, NULL, -1, 0);
break;
}
}