From cf8ec3d3623f24cec91025ebdf1237935a970e40 Mon Sep 17 00:00:00 2001 From: dzwdz Date: Fri, 1 Jul 2022 21:41:21 +0200 Subject: init/fs: move the kernel stuff to /kdev/ --- src/init/fs/misc.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'src/init/fs/misc.c') 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 { -- cgit v1.2.3