diff options
-rw-r--r-- | src/init/fs/misc.c | 18 | ||||
-rw-r--r-- | src/init/fs/misc.h | 2 | ||||
-rw-r--r-- | src/init/main.c | 5 |
3 files changed, 20 insertions, 5 deletions
diff --git a/src/init/fs/misc.c b/src/init/fs/misc.c index 55d14fa..d12fce3 100644 --- a/src/init/fs/misc.c +++ b/src/init/fs/misc.c @@ -10,16 +10,28 @@ bool fork2_n_mount(const char *path) { return h; } -void fs_passthru(void) { +void fs_passthru(const char *prefix) { struct fs_wait_response res; int buf_size = 64; char buf[ 64]; - int ret; + int ret, prefix_len; + if (prefix) prefix_len = strlen(prefix); for (;;) { switch (_syscall_fs_wait(buf, buf_size, &res)) { case VFSOP_OPEN: - ret = _syscall_open(buf, res.len); + if (prefix) { + if (prefix_len + res.len <= buf_size) { + // TODO memmove + char tmp[64]; + memcpy(tmp, buf, res.len); + memcpy(buf, prefix, prefix_len); + memcpy(buf + prefix_len, tmp, res.len); + ret = _syscall_open(buf, res.len + prefix_len); + } else ret = -1; + } else { + ret = _syscall_open(buf, res.len); + } _syscall_fs_respond(NULL, ret); break; diff --git a/src/init/fs/misc.h b/src/init/fs/misc.h index 87d5bdb..33e98f5 100644 --- a/src/init/fs/misc.h +++ b/src/init/fs/misc.h @@ -3,4 +3,4 @@ bool fork2_n_mount(const char *path); -void fs_passthru(void); +void fs_passthru(const char *prefix); diff --git a/src/init/main.c b/src/init/main.c index f0c9779..d19b1e5 100644 --- a/src/init/main.c +++ b/src/init/main.c @@ -47,5 +47,8 @@ void fs_prep(void) { /* passthrough fs */ if (!fork2_n_mount("/2nd")) - fs_passthru(); + fs_passthru(NULL); + + if (!fork2_n_mount("/3nd")) + fs_passthru("/init"); } |