diff options
author | dzwdz | 2022-04-07 22:33:03 +0200 |
---|---|---|
committer | dzwdz | 2022-04-07 22:33:03 +0200 |
commit | ab74da4bfff9d37b7b5f5f98bda7edfc2ebc3ea6 (patch) | |
tree | d44fc9ee4c1b1a41bc1f6646ba497aba6b272473 /src/init | |
parent | 6a71c766e60a9ac12876a0ea8a10c997df2507a3 (diff) |
kernel/vfs: fix panic when using an user fs which hadn't yet wait()ed
Diffstat (limited to 'src/init')
-rw-r--r-- | src/init/main.c | 44 | ||||
-rw-r--r-- | src/init/stdlib.c | 2 |
2 files changed, 24 insertions, 22 deletions
diff --git a/src/init/main.c b/src/init/main.c index a46cb18..661ee64 100644 --- a/src/init/main.c +++ b/src/init/main.c @@ -16,43 +16,43 @@ extern char _bss_end; extern char _initrd; void read_file(const char *path, size_t len); -void fs_prep(void); __attribute__((section(".text.startup"))) int main(void) { // allocate bss _syscall_memflag(&_bss_start, &_bss_end - &_bss_start, MEMFLAG_PRESENT); - // TODO if (!fork2_n_mount("/tty")) ansiterm_drv(); - - __tty_fd = _syscall_open(argify("/com1")); - if (__tty_fd < 0) - _syscall_exit(1); + MOUNT("/init", tar_driver(&_initrd)); MOUNT("/keyboard", ps2_drv()); + MOUNT("/vga_tty", ansiterm_drv()); - fs_prep(); - shell_loop(); + MOUNT("/bind", fs_passthru(NULL)); - _syscall_exit(0); -} + if (!_syscall_fork()) { + __tty_fd = _syscall_open(argify("/com1")); + if (__tty_fd < 0) _syscall_exit(1); -void fs_prep(void) { - handle_t front = _syscall_fs_fork2(); - if (!front) { - tar_driver(&_initrd); + shell_loop(); _syscall_exit(1); } - /* the trailing slash should be ignored by mount() - * TODO actually write tests */ - _syscall_mount(front, argify("/init/")); + if (!_syscall_fork()) { + __tty_fd = _syscall_open(argify("/vga_tty")); + if (__tty_fd < 0) _syscall_exit(1); - if (!fork2_n_mount("/")) fs_dir_inject("/init/"); + shell_loop(); + _syscall_exit(1); + } - /* from here on i'll just use the helper MOUNT macro */ + // try to find any working output + __tty_fd = _syscall_open(argify("/com1")); + if (__tty_fd < 0) __tty_fd = _syscall_open(argify("/vga_tty")); - /* passthrough fs */ - MOUNT("/2nd/", fs_passthru(NULL)); /* copies / under /2nd */ - MOUNT("/3rd/", fs_passthru("/init/")); /* copies /init under /3rd */ + for (;;) { + _syscall_await(); + printf("init: something quit\n"); + } + + _syscall_exit(0); } diff --git a/src/init/stdlib.c b/src/init/stdlib.c index e8b3f97..839b8f5 100644 --- a/src/init/stdlib.c +++ b/src/init/stdlib.c @@ -10,6 +10,8 @@ int printf(const char *fmt, ...) { int total = 0; va_list argp; va_start(argp, fmt); + if (__tty_fd < 0) return 0; + for (;;) { char c = *fmt++; switch (c) { |