summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordzwdz2021-11-26 20:03:49 +0100
committerdzwdz2021-11-26 20:03:49 +0100
commit970b5b7c6a7778579a4398cdb8d0bfb6bcd33da1 (patch)
tree8b7a6f954bfca35387c6c4e5f55680b905162553
parent12dd15c6253e0e8f67d458d84000000bc10c422e (diff)
init/fs: add the MOUNT macro
-rw-r--r--src/init/fs/misc.h6
-rw-r--r--src/init/main.c15
2 files changed, 11 insertions, 10 deletions
diff --git a/src/init/fs/misc.h b/src/init/fs/misc.h
index 8e31844..e360a25 100644
--- a/src/init/fs/misc.h
+++ b/src/init/fs/misc.h
@@ -6,3 +6,9 @@ bool fork2_n_mount(const char *path);
void fs_passthru(const char *prefix);
void fs_dir_inject(const char *path);
+
+/** Mounts something and injects its path into the fs */
+// TODO path needs to have a trailing slash
+#define MOUNT(path, impl) \
+ if (!fork2_n_mount(path)) {impl;} \
+ if (!fork2_n_mount("/")) fs_dir_inject(path);
diff --git a/src/init/main.c b/src/init/main.c
index b723c7b..2fe17eb 100644
--- a/src/init/main.c
+++ b/src/init/main.c
@@ -43,16 +43,11 @@ 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 */
+ if (!fork2_n_mount("/")) fs_dir_inject("/init/");
- /* passthrough fs */
- if (!fork2_n_mount("/2nd"))
- fs_passthru(NULL);
-
- if (!fork2_n_mount("/3nd"))
- fs_passthru("/init");
-
- if (!fork2_n_mount("/"))
- fs_dir_inject("/test/dir/");
+ /* from here on i'll just use the helper MOUNT macro */
+ /* passthrough fs */
+ MOUNT("/2nd/", fs_passthru(NULL)); /* copies / under /2nd */
+ MOUNT("/3rd/", fs_passthru("/init/")); /* copies /init under /3rd */
}