diff options
Diffstat (limited to 'src/user/lib/fs')
-rw-r--r-- | src/user/lib/fs/dir.c | 6 | ||||
-rw-r--r-- | src/user/lib/fs/misc.c | 44 | ||||
-rw-r--r-- | src/user/lib/fs/whitelist.c | 14 |
3 files changed, 32 insertions, 32 deletions
diff --git a/src/user/lib/fs/dir.c b/src/user/lib/fs/dir.c index 71b2209..b7f840d 100644 --- a/src/user/lib/fs/dir.c +++ b/src/user/lib/fs/dir.c @@ -45,13 +45,13 @@ bool dir_appendl(struct dirbuild *db, const char *name, size_t len) { return false; } -bool dir_append_from(struct dirbuild *db, handle_t h) { +bool dir_append_from(struct dirbuild *db, hid_t h) { if (db->error) return true; if (db->buf && db->bpos == db->blen) return false; int ret; if (db->buf) { - ret = _syscall_read(h, db->buf + db->bpos, db->blen - db->bpos, db->offset); + ret = _sys_read(h, db->buf + db->bpos, db->blen - db->bpos, db->offset); if (ret < 0) { db->error = ret; return true; @@ -63,7 +63,7 @@ bool dir_append_from(struct dirbuild *db, handle_t h) { } /* else ret == 0, EOF, need getsize */ } - ret = _syscall_getsize(h); + ret = _sys_getsize(h); if (ret < 0) { db->error = ret; return true; diff --git a/src/user/lib/fs/misc.c b/src/user/lib/fs/misc.c index ee0b54c..c68d2be 100644 --- a/src/user/lib/fs/misc.c +++ b/src/user/lib/fs/misc.c @@ -11,9 +11,9 @@ #include <camellia/fs/misc.h> bool fork2_n_mount(const char *path) { - handle_t h; - if (_syscall_fork(FORK_NEWFS, &h) > 0) { /* parent */ - _syscall_mount(h, path, strlen(path)); + hid_t h; + if (_sys_fork(FORK_NEWFS, &h) > 0) { /* parent */ + _sys_mount(h, path, strlen(path)); close(h); return true; } @@ -34,7 +34,7 @@ static int dir_seglen(const char *path) { return len; } -void forward_open(handle_t reqh, const char *path, long len, int flags) { +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 /* done in a separate thread/process because open() can block, @@ -43,8 +43,8 @@ void forward_open(handle_t reqh, const char *path, long len, int flags) { * for example, running `httpd` in one term would prevent you from doing * basically anything on the second term, because fs_dir_inject would be * stuck on open()ing the socket */ - if (!_syscall_fork(FORK_NOREAP, NULL)) { - _syscall_fs_respond(reqh, NULL, _syscall_open(path, len, flags), FSR_DELEGATE); + if (!_sys_fork(FORK_NOREAP, NULL)) { + _sys_fs_respond(reqh, NULL, _sys_open(path, len, flags), FSR_DELEGATE); exit(0); } close(reqh); @@ -58,13 +58,13 @@ void fs_passthru(const char *prefix) { for (;;) { struct ufs_request res; - handle_t reqh = _syscall_fs_wait(buf, buflen, &res); + hid_t reqh = _sys_fs_wait(buf, buflen, &res); if (reqh < 0) break; switch (res.op) { case VFSOP_OPEN: if (prefix) { if (prefix_len + res.len > buflen) { - _syscall_fs_respond(reqh, NULL, -1, 0); + _sys_fs_respond(reqh, NULL, -1, 0); break; } @@ -76,7 +76,7 @@ void fs_passthru(const char *prefix) { break; default: - _syscall_fs_respond(reqh, NULL, -1, 0); + _sys_fs_respond(reqh, NULL, -1, 0); break; } } @@ -114,7 +114,7 @@ void fs_union(const char **list) { char *path = post - prefixlen; memcpy(path, prefix, prefixlen); - ret = _syscall_open(path, prefixlen + res.len, res.flags); + ret = _sys_open(path, prefixlen + res.len, res.flags); post[res.len] = '\0'; } @@ -134,10 +134,10 @@ void fs_union(const char **list) { size_t prefixlen = strlen(prefix); // TODO only open the directories once // TODO ensure trailing slash - handle_t h = _syscall_open(prefix, prefixlen, OPEN_READ); + hid_t h = _sys_open(prefix, prefixlen, OPEN_READ); if (h < 0) continue; end = end || dir_append_from(&db, h); - _syscall_close(h); + _sys_close(h); } c0_fs_respond(target, dir_finish(&db), 0); break; @@ -163,7 +163,7 @@ void fs_dir_inject(const char *path) { for (;;) { struct ufs_request res; - handle_t reqh = _syscall_fs_wait(buf, buflen, &res); + hid_t reqh = _sys_fs_wait(buf, buflen, &res); if (reqh < 0) break; struct fs_dir_handle *data = res.id; switch (res.op) { @@ -174,10 +174,10 @@ void fs_dir_inject(const char *path) { { /* opening a directory that we're injecting into */ data = malloc(sizeof *data); - data->delegate = _syscall_open(buf, res.len, res.flags); + data->delegate = _sys_open(buf, res.len, res.flags); data->inject = path + res.len; data->inject_len = dir_seglen(data->inject); - _syscall_fs_respond(reqh, data, 0, 0); + _sys_fs_respond(reqh, data, 0, 0); } else { forward_open(reqh, buf, res.len, res.flags); } @@ -187,7 +187,7 @@ void fs_dir_inject(const char *path) { if (data->delegate >= 0) close(data->delegate); free(data); - _syscall_fs_respond(reqh, NULL, 0, 0); + _sys_fs_respond(reqh, NULL, 0, 0); break; case VFSOP_READ: @@ -199,25 +199,25 @@ void fs_dir_inject(const char *path) { dir_appendl(&db, data->inject, data->inject_len); if (data->delegate >= 0) dir_append_from(&db, data->delegate); - _syscall_fs_respond(reqh, target, dir_finish(&db), 0); + _sys_fs_respond(reqh, target, dir_finish(&db), 0); break; default: - _syscall_fs_respond(reqh, NULL, -1, 0); + _sys_fs_respond(reqh, NULL, -1, 0); break; } } exit(0); } -handle_t ufs_wait(char *buf, size_t len, struct ufs_request *req) { - handle_t reqh; +hid_t ufs_wait(char *buf, size_t len, struct ufs_request *req) { + hid_t reqh; for (;;) { - reqh = _syscall_fs_wait(buf, len, req); + reqh = _sys_fs_wait(buf, len, req); if (reqh < 0) break; if (req->op == VFSOP_OPEN) { if (req->len == len) { - _syscall_fs_respond(reqh, NULL, -ENAMETOOLONG, 0); + _sys_fs_respond(reqh, NULL, -ENAMETOOLONG, 0); continue; } buf[req->len] = '\0'; diff --git a/src/user/lib/fs/whitelist.c b/src/user/lib/fs/whitelist.c index 5612d9a..54a79c3 100644 --- a/src/user/lib/fs/whitelist.c +++ b/src/user/lib/fs/whitelist.c @@ -43,7 +43,7 @@ void fs_whitelist(const char **whitelist) { if (!buf) exit(1); for (;;) { struct ufs_request res; - handle_t reqh = _syscall_fs_wait(buf, buflen, &res); + hid_t reqh = _sys_fs_wait(buf, buflen, &res); if (reqh < 0) break; char *ipath = res.id; /* the path of the open()ed directory */ @@ -70,7 +70,7 @@ void fs_whitelist(const char **whitelist) { } } if (error) { - _syscall_fs_respond(reqh, NULL, -EACCES, 0); + _sys_fs_respond(reqh, NULL, -EACCES, 0); } else if (passthru) { forward_open(reqh, buf, res.len, res.flags); } else if (inject) { @@ -78,9 +78,9 @@ void fs_whitelist(const char **whitelist) { ipath = malloc(res.len + 1); memcpy(ipath, buf, res.len); ipath[res.len] = '\0'; - _syscall_fs_respond(reqh, ipath, 0, 0); + _sys_fs_respond(reqh, ipath, 0, 0); } else { - _syscall_fs_respond(reqh, NULL, -1, 0); + _sys_fs_respond(reqh, NULL, -1, 0); } break; } @@ -96,16 +96,16 @@ void fs_whitelist(const char **whitelist) { if (ilen < elen && !memcmp(ipath, *entry, ilen)) dir_appendl(&db, *entry + ilen, dir_seglen2(*entry + ilen, elen - ilen)); } - _syscall_fs_respond(reqh, target, dir_finish(&db), 0); + _sys_fs_respond(reqh, target, dir_finish(&db), 0); break; } case VFSOP_CLOSE: { free(ipath); - _syscall_fs_respond(reqh, NULL, 0, 0); + _sys_fs_respond(reqh, NULL, 0, 0); break; } default: { - _syscall_fs_respond(reqh, NULL, -1, 0); + _sys_fs_respond(reqh, NULL, -1, 0); break; } } |