bytecodealliance / bytecodealliance/wasmtime

CLI option for read-only directory mounting

Open
#9,608 4 comments 4 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
18.6k
Forks
1.8k
Avg merge
1d 19h
Merged PRs (30d)
121

Description

#### Feature

When using the `wasmtime run` command I'd like to be able to attach a directory as read-only.

#### Benefit

Currently this works:
```
wget https://github.com/brettcannon/cpython-wasi-build/releases/download/v3.13.0/python-3.13.0-wasi_sdk-24.zip
unzip python-3.13.0-wasi_sdk-24.zip
wasmtime run --dir .::/ python.wasm -c 'print("hello world")'
```
But you can break the installation if you run code like this:
```
wasmtime run --dir .::/ python.wasm -c 'open("python.wasm", "wb").write(b"blah")'
```
I'd like to be able to open a directory as readonly - maybe something like this:
```
wasmtime run --dir-ro .::/ python.wasm -c 'open("python.wasm", "wb").write(b"blah")'
```
#### Implementation

The underlying library has support for this:

```rust
pub fn preopened_dir(
&mut self,
host_path: impl AsRef,
guest_path: impl AsRef,
dir_perms: DirPerms,
file_perms: FilePerms,
) -> Result<&mut Self>
```
https://docs.rs/wasmtime-wasi/latest/wasmtime_wasi/struct.WasiCtxBuilder.html#method.preopened_dir

Exposing that in the CLI would be very useful.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.