authorgravatar for topolarity@tapscott.meCody Tapscott <topolarity@tapscott.me> 2022-03-01 10:42:34-07:00
committergravatar for topolarity@tapscott.meCody Tapscott <topolarity@tapscott.me> 2022-04-18 10:20:20-07:00
log692ccd01b4ebaa78f6702b15459437228e6a790d
treec7423e8ade27fb1a961b5a4abf8adf4d021ba404
parent089651716c3d326f8540f4e415fc88443e42f5f2

stage2: Initialize WASI preopens on startup


1 files changed, 10 insertions(+), 0 deletions(-)

src/main.zig+10
...@@ -162,6 +162,16 @@ pub fn main() anyerror!void {...@@ -162,6 +162,16 @@ pub fn main() anyerror!void {
162 return mainArgs(gpa_tracy.allocator(), arena, args);162 return mainArgs(gpa_tracy.allocator(), arena, args);
163 }163 }
164164
165 // WASI: `--dir` instructs the WASM runtime to "preopen" a directory, making
166 // it available to the us, the guest program. This is the only way for us to
167 // access files/dirs on the host filesystem
168 if (builtin.os.tag == .wasi) {
169 // This sets our CWD to "/preopens/cwd"
170 // Dot-prefixed preopens like `--dir=.` are "mounted" at "/preopens/cwd"
171 // Other preopens like `--dir=lib` are "mounted" at "/"
172 try std.os.initPreopensWasi(std.heap.page_allocator, "/preopens/cwd");
173 }
174
165 return mainArgs(gpa, arena, args);175 return mainArgs(gpa, arena, args);
166}176}
167177