diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/user/app/shell/shell.c | 2 | ||||
-rw-r--r-- | src/user/app/tests/kernel/path.c | 2 | ||||
-rw-r--r-- | src/user/lib/fs/misc.c | 26 | ||||
-rw-r--r-- | src/user/lib/include/camellia/fs/misc.h | 6 |
4 files changed, 14 insertions, 22 deletions
diff --git a/src/user/app/shell/shell.c b/src/user/app/shell/shell.c index 65f08b6..185aa7e 100644 --- a/src/user/app/shell/shell.c +++ b/src/user/app/shell/shell.c @@ -63,7 +63,7 @@ void run_args(int argc, char **argv, struct redir *redir) { _sys_mount(HANDLE_PROCFS, argv[1], strlen(argv[1])); /* if (!(3 <= argc && !strcmp(argv[2], "raw"))) { - if (!fork2_n_mount("/")) { + if (!mount_at("/")) { fs_dirinject(argv[1]); exit(1); } diff --git a/src/user/app/tests/kernel/path.c b/src/user/app/tests/kernel/path.c index 5392681..5a22c36 100644 --- a/src/user/app/tests/kernel/path.c +++ b/src/user/app/tests/kernel/path.c @@ -64,7 +64,7 @@ static void test_path_simplify(void) { } static void mount_resolve_drv(const char *path) { - if (fork2_n_mount(path)) return; + if (mount_at(path) != 0) return; struct ufs_request res; while (!c0_fs_wait(NULL, 0, &res)) { 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)) |