summaryrefslogtreecommitdiff
path: root/src/init/fs/misc.c
diff options
context:
space:
mode:
authordzwdz2022-07-01 21:41:21 +0200
committerdzwdz2022-07-01 21:41:21 +0200
commitcf8ec3d3623f24cec91025ebdf1237935a970e40 (patch)
treea5176ff53f6a0371729575ce919d4766478e0848 /src/init/fs/misc.c
parent5af715e76d65e0c8e5f9e3f066ae66475958689f (diff)
init/fs: move the kernel stuff to /kdev/
Diffstat (limited to 'src/init/fs/misc.c')
-rw-r--r--src/init/fs/misc.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/init/fs/misc.c b/src/init/fs/misc.c
index 257ed32..f406ee2 100644
--- a/src/init/fs/misc.c
+++ b/src/init/fs/misc.c
@@ -122,6 +122,34 @@ void fs_passthru(const char *prefix) {
_syscall_exit(0);
}
+void fs_whitelist(const char **list) {
+ struct fs_wait_response res;
+ static char buf[1024];
+ bool allow;
+
+ while (!_syscall_fs_wait(buf, sizeof(buf), &res)) {
+ switch (res.op) {
+ case VFSOP_OPEN:
+ allow = false;
+ // TODO reverse dir_inject
+ for (const char **iter = list; *iter; iter++) {
+ size_t len = strlen(*iter); // inefficient, whatever
+ if (len <= res.len && !memcmp(buf, *iter, len)) {
+ allow = true;
+ break;
+ }
+ }
+ _syscall_fs_respond(NULL, allow ? _syscall_open(buf, res.len, res.flags) : -1);
+ break;
+
+ default:
+ fs_respond_delegate(&res, res.id, buf);
+ break;
+ }
+ }
+ _syscall_exit(0);
+}
+
void fs_dir_inject(const char *path) {
struct fs_dir_handle {