diff options
Diffstat (limited to 'src/init/main.c')
-rw-r--r-- | src/init/main.c | 42 |
1 files changed, 28 insertions, 14 deletions
diff --git a/src/init/main.c b/src/init/main.c index de8a599..f31da02 100644 --- a/src/init/main.c +++ b/src/init/main.c @@ -12,6 +12,7 @@ extern char _bss_end; int tty_fd; void fs_test(void); +void fs_server(handle_t back); __attribute__((section(".text.startup"))) int main(void) { @@ -21,30 +22,43 @@ int main(void) { tty_fd = _syscall_open("/tty", sizeof("/tty") - 1); if (tty_fd < 0) _syscall_exit(argify("couldn't open tty")); - log(" opened /tty "); fs_test(); _syscall_exit(argify("my job here is done.")); } void fs_test(void) { - static char buf[64]; - int len = 64; handle_t front, back, file; front = _syscall_fs_create(&back); if (_syscall_fork()) { // child: is the fs server - log("fs_wait started. "); - _syscall_fs_wait(back, buf, &len); - log("fs_wait returned. "); - _syscall_write(tty_fd, buf, len); - _syscall_fs_respond(0, NULL, 0); - } else { - // parent: accesses the fs - _syscall_mount(front, argify("/mnt")); - log("requesting file. "); - file = _syscall_open(argify("/mnt/test")); - log("open returned. "); + fs_server(back); + return; } + + // parent: accesses the fs + _syscall_mount(front, argify("/mnt")); + log("requesting file. "); + file = _syscall_open(argify("/mnt/tty")); + log("open returned. "); +} + +void fs_server(handle_t back) { + static char buf[64]; + int len; + for (;;) { + len = 64; + switch (_syscall_fs_wait(back, buf, &len)) { + case VFSOP_OPEN: + _syscall_write(tty_fd, buf, len); + log(" was opened. "); + _syscall_fs_respond(0, NULL, 0); // doesn't check the path yet + break; + default: + log("fuck"); + break; + } + } + } |