summaryrefslogtreecommitdiff
path: root/src/user
diff options
context:
space:
mode:
authordzwdz2023-08-10 00:07:35 +0200
committerdzwdz2023-08-10 00:07:35 +0200
commitfe2767219e22eda853cb1ad30c44c49afc1bed66 (patch)
tree251531bc8cef34b8d7c31d421ba3a0ba9020198c /src/user
parent6126525ed2ad3fb2543c43dbca6b01106af02180 (diff)
user/fs: no longer inject MOUNT_ATs by default
arguably the wrong choice from an usability standpoint, but the right choice from a performance standpoint. there's definitely a nicer way to do this
Diffstat (limited to 'src/user')
-rw-r--r--src/user/app/init/init.c11
-rw-r--r--src/user/app/shell/shell.c3
-rw-r--r--src/user/bootstrap/main.c12
-rw-r--r--src/user/lib/fs/misc.c11
-rw-r--r--src/user/lib/include/camellia/fs/misc.h4
5 files changed, 25 insertions, 16 deletions
diff --git a/src/user/app/init/init.c b/src/user/app/init/init.c
index 61fb27b..ca50699 100644
--- a/src/user/app/init/init.c
+++ b/src/user/app/init/init.c
@@ -45,9 +45,14 @@ int main(void) {
MOUNT_AT("/") {
fs_dirinject2((const char*[]){
- "/fake/b/c",
- "/fake/c",
- "/faker",
+ "/keyboard/",
+ "/usr/",
+ "/bin/",
+ "/Users/",
+ "/tmp/",
+ "/vtty",
+ "/net/",
+ "/initctl",
NULL
});
}
diff --git a/src/user/app/shell/shell.c b/src/user/app/shell/shell.c
index e9293bc..65f08b6 100644
--- a/src/user/app/shell/shell.c
+++ b/src/user/app/shell/shell.c
@@ -41,6 +41,9 @@ void run_args(int argc, char **argv, struct redir *redir) {
fprintf(stderr, "mount: not enough arguments\n");
return;
}
+ MOUNT_AT("/") {
+ fs_dirinject(argv[1]);
+ }
MOUNT_AT(argv[1]) {
run_args(argc - 2, argv + 2, redir);
exit(1);
diff --git a/src/user/bootstrap/main.c b/src/user/bootstrap/main.c
index 348486c..d27da39 100644
--- a/src/user/bootstrap/main.c
+++ b/src/user/bootstrap/main.c
@@ -18,8 +18,16 @@ int main(void) {
setprogname("bootstrap");
_sys_mount(HANDLE_PROCFS, "/proc/", strlen("/proc/"));
- MOUNT_AT("/") { fs_dirinject("/proc/"); }
- MOUNT_AT("/init/") { tar_driver(&_initrd); }
+ MOUNT_AT("/") {
+ fs_dirinject2((const char*[]) {
+ "/proc/",
+ "/init/",
+ NULL
+ });
+ }
+ MOUNT_AT("/init/") {
+ tar_driver(&_initrd);
+ }
const char *initpath = "bin/amd64/init";
char *initargv[] = {"init", NULL};
diff --git a/src/user/lib/fs/misc.c b/src/user/lib/fs/misc.c
index 2a39e9a..a23f05f 100644
--- a/src/user/lib/fs/misc.c
+++ b/src/user/lib/fs/misc.c
@@ -154,20 +154,13 @@ hid_t ufs_wait(char *buf, size_t len, struct ufs_request *req) {
return reqh;
}
-bool mount_at_pred(const char *path) {
+bool mount_at(const char *path) {
// TODO preprocess path - simplify & ensure trailing slash
if (!fork2_n_mount(path)) {
/* child -> go into the for body */
_klogf("%s: impl", path);
- setproctitle("i'%s'", path);
+ setproctitle("%s", path);
return true;
}
-
- if (strcmp("/", path) && !fork2_n_mount("/")) {
- _klogf("%s: dir", path);
- setproctitle("d'%s'", path);
- fs_dirinject(path);
- exit(1);
- }
return false; /* continue after the for loop */
}
diff --git a/src/user/lib/include/camellia/fs/misc.h b/src/user/lib/include/camellia/fs/misc.h
index 92679e9..0b2a018 100644
--- a/src/user/lib/include/camellia/fs/misc.h
+++ b/src/user/lib/include/camellia/fs/misc.h
@@ -13,7 +13,7 @@ void fs_union(const char **list);
void fs_dirinject(const char *path);
void fs_dirinject2(const char *injects[]);
-bool mount_at_pred(const char *path);
+bool mount_at(const char *path);
// TODO separate fs drivers and wrappers around syscalls
@@ -21,4 +21,4 @@ bool mount_at_pred(const char *path);
hid_t ufs_wait(char *buf, size_t len, struct ufs_request *req);
/** Mounts something and injects its path into the fs */
-#define MOUNT_AT(path) for (; mount_at_pred(path); exit(1))
+#define MOUNT_AT(path) for (; mount_at(path); exit(1))