summaryrefslogtreecommitdiff
path: root/src/user/lib/fs/misc.c
diff options
context:
space:
mode:
authordzwdz2023-08-13 23:29:46 +0200
committerdzwdz2023-08-13 23:29:46 +0200
commit8050069c57b729c18c19b1a03ab6e4bf63b4735e (patch)
tree6c1ee4beae0519e06dc24ee42c5fde758137d17f /src/user/lib/fs/misc.c
parentfa06b2c9cb7c128243f603dd3f23ddbb3d542e51 (diff)
libc: replace fork2_n_mount with mount_at
Diffstat (limited to 'src/user/lib/fs/misc.c')
-rw-r--r--src/user/lib/fs/misc.c26
1 files changed, 10 insertions, 16 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;
}