Samsung / walrus

WebAssembly Lightweight RUntime
Apache License 2.0
39 stars 10 forks source link

Implement directory mapping and WASI file functions #208

Closed kulcsaradam closed 7 months ago

kulcsaradam commented 10 months ago

Refactor the importing of WASI functions to be clearer. Implement path_open, fd_seek, fd_read, environ_sizes_get, environ_get for file acces. Implement the mapping of real directories to virtual ones so that WASI can use different directories. Add flag '--mapdirs' 'real' 'virtual' for mapping directories. Add flag '--env' for sharing host envrionment variables. Add flag '--help' for printing available walrus options. Also improve random_get test to not have a result.

clover2123 commented 10 months ago

@kulcsaradam Would you please elaborate more about the following?

Implement the mapping of real directories to virtual ones so that WASI can use different directories.

What is the main feature of mapping directories and where is this used?

kulcsaradam commented 9 months ago

@clover2123 Of course, my sources: https://github.com/WebAssembly/wasi-filesystem/blob/main/path-resolution.md https://github.com/bytecodealliance/wasmtime/blob/main/docs/WASI-overview.md - Section: Capability-Oriented

WASI by design has an idea, where for security reasons runtimes may not allow programs to freely move between host directories. By default they only allow files to manipulate in their own directories and in directories which they have handles to. Also, to obfuscate the system they are on, inside they use virtual directories like '/var' or '/home' which are actualy directories like 'home/user/walrus/test' for example.

Use cases are any file manipulation operations like reading from a file or writing to one.

I hope this is an acceptable answer!

kulcsaradam commented 8 months ago

The pr was closed by a mistake I caused while tinkering with Visual Studio. Reopened it now.