From f9f1795a754c57d6d148e202dbc7864576cf2d47 Mon Sep 17 00:00:00 2001 From: dzwdz Date: Tue, 16 Nov 2021 20:45:13 +0100 Subject: init: implement fork2_n_mount --- src/init/fs/misc.c | 8 ++++++++ src/init/fs/misc.h | 3 +++ src/init/main.c | 7 ++----- 3 files changed, 13 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/init/fs/misc.c b/src/init/fs/misc.c index a8d9517..55d14fa 100644 --- a/src/init/fs/misc.c +++ b/src/init/fs/misc.c @@ -1,7 +1,15 @@ +#include #include #include +#include #include +bool fork2_n_mount(const char *path) { + handle_t h = _syscall_fs_fork2(); + if (h) _syscall_mount(h, path, strlen(path)); + return h; +} + void fs_passthru(void) { struct fs_wait_response res; int buf_size = 64; diff --git a/src/init/fs/misc.h b/src/init/fs/misc.h index c7ce7c7..87d5bdb 100644 --- a/src/init/fs/misc.h +++ b/src/init/fs/misc.h @@ -1,3 +1,6 @@ #pragma once +#include + +bool fork2_n_mount(const char *path); void fs_passthru(void); diff --git a/src/init/main.c b/src/init/main.c index 8ddbe6d..f0c9779 100644 --- a/src/init/main.c +++ b/src/init/main.c @@ -43,12 +43,9 @@ void fs_prep(void) { * TODO actually write tests */ _syscall_mount(front, argify("/init/")); + /* from here on i'll just use the helper func fork2_n_mount */ /* passthrough fs */ - front = _syscall_fs_fork2(); - if (!front) { + if (!fork2_n_mount("/2nd")) fs_passthru(); - _syscall_exit(1); /* unreachable */ - } - _syscall_mount(front, argify("/2nd")); } -- cgit v1.2.3