summaryrefslogtreecommitdiff
path: root/src/user/lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/user/lib')
-rw-r--r--src/user/lib/fs/misc.c26
-rw-r--r--src/user/lib/include/camellia/fs/misc.h6
2 files changed, 12 insertions, 20 deletions
diff --git a/src/user/lib/fs/misc.c b/src/user/lib/fs/misc.c
index a23f05f..30e5ab4 100644
--- a/src/user/lib/fs/misc.c
+++ b/src/user/lib/fs/misc.c
@@ -10,16 +10,6 @@
#include <camellia/fs/dir.h>
#include <camellia/fs/misc.h>
-bool fork2_n_mount(const char *path) {
- hid_t h;
- if (_sys_fork(FORK_NEWFS, &h) > 0) { /* parent */
- _sys_mount(h, path, strlen(path));
- close(h);
- return true;
- }
- return false;
-}
-
void forward_open(hid_t reqh, const char *path, long len, int flags) {
// TODO use threads
// TODO solve for more complex cases, e.g. fs_union
@@ -154,13 +144,17 @@ hid_t ufs_wait(char *buf, size_t len, struct ufs_request *req) {
return reqh;
}
-bool mount_at(const char *path) {
- // TODO preprocess path - simplify & ensure trailing slash
- if (!fork2_n_mount(path)) {
- /* child -> go into the for body */
+int mount_at(const char *path) {
+ hid_t h;
+ int ret = _sys_fork(FORK_NEWFS, &h);
+ if (ret == 0) {
_klogf("%s: impl", path);
setproctitle("%s", path);
- return true;
+ } else if (ret > 0) {
+ _sys_mount(h, path, strlen(path));
+ close(h);
+ } else {
+ _sys_mount(HANDLE_NULLFS, path, strlen(path));
}
- return false; /* continue after the for loop */
+ return ret;
}
diff --git a/src/user/lib/include/camellia/fs/misc.h b/src/user/lib/include/camellia/fs/misc.h
index 0b2a018..301c604 100644
--- a/src/user/lib/include/camellia/fs/misc.h
+++ b/src/user/lib/include/camellia/fs/misc.h
@@ -2,8 +2,6 @@
#include <stdbool.h>
#include <stdlib.h>
-bool fork2_n_mount(const char *path);
-
void forward_open(hid_t reqh, const char *path, long len, int flags);
void fs_passthru(const char *prefix);
@@ -13,7 +11,7 @@ void fs_union(const char **list);
void fs_dirinject(const char *path);
void fs_dirinject2(const char *injects[]);
-bool mount_at(const char *path);
+int mount_at(const char *path);
// TODO separate fs drivers and wrappers around syscalls
@@ -21,4 +19,4 @@ bool mount_at(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(path); exit(1))
+#define MOUNT_AT(path) for (; mount_at(path) == 0; exit(1))