summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/init/fs/misc.c33
-rw-r--r--src/init/fs/misc.h3
-rw-r--r--src/init/main.c10
3 files changed, 46 insertions, 0 deletions
diff --git a/src/init/fs/misc.c b/src/init/fs/misc.c
new file mode 100644
index 0000000..134c311
--- /dev/null
+++ b/src/init/fs/misc.c
@@ -0,0 +1,33 @@
+#include <init/stdlib.h>
+#include <shared/flags.h>
+#include <shared/syscalls.h>
+
+void fs_passthru() {
+ struct fs_wait_response res;
+ int buf_size = 64;
+ char buf[ 64];
+ int ret;
+
+ for (;;) {
+ switch (_syscall_fs_wait(buf, buf_size, &res)) {
+ case VFSOP_OPEN:
+ ret = _syscall_open(buf, res.len);
+ _syscall_fs_respond(NULL, ret);
+ break;
+
+ case VFSOP_READ:
+ if (res.capacity > buf_size)
+ res.capacity = buf_size; /* don't overflow the buffer */
+ ret = _syscall_read(res.id, buf, res.capacity, res.offset);
+ _syscall_fs_respond(buf, ret);
+ break;
+
+ // temporarily doesn't support writing
+ // also TODO closing
+
+ default:
+ _syscall_fs_respond(NULL, -1);
+ break;
+ }
+ }
+}
diff --git a/src/init/fs/misc.h b/src/init/fs/misc.h
new file mode 100644
index 0000000..6afca79
--- /dev/null
+++ b/src/init/fs/misc.h
@@ -0,0 +1,3 @@
+#pragma once
+
+void fs_passthru();
diff --git a/src/init/main.c b/src/init/main.c
index 795e2ac..8ddbe6d 100644
--- a/src/init/main.c
+++ b/src/init/main.c
@@ -1,3 +1,4 @@
+#include <init/fs/misc.h>
#include <init/shell.h>
#include <init/stdlib.h>
#include <init/tar.h>
@@ -41,4 +42,13 @@ void fs_prep(void) {
/* the trailing slash should be ignored by mount()
* TODO actually write tests */
_syscall_mount(front, argify("/init/"));
+
+
+ /* passthrough fs */
+ front = _syscall_fs_fork2();
+ if (!front) {
+ fs_passthru();
+ _syscall_exit(1); /* unreachable */
+ }
+ _syscall_mount(front, argify("/2nd"));
}