Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--mapdir flag #458

Closed
willemneal opened this issue May 20, 2019 · 2 comments · Fixed by #451
Closed

--mapdir flag #458

willemneal opened this issue May 20, 2019 · 2 comments · Fixed by #451
Labels
🎉 enhancement New feature!

Comments

@willemneal
Copy link

Great stuff! I've been implementing my own Wasi library in Assemblyscript and have had some initial successes using wasmer!

Motivation

It would be nice for end users if their initial directory path was root, "/" instead of either a fullpath or ".".

Wasmtime has this option so that you can map an external pathname to an internal one.

e.g. --mapdir=/tmp:/var/tmp

Proposed solution

Add command line option and open directories on the host with the path left of the ":" and name it with the left half in the runtime.

Currently this is done here.

Wasmtime does it here

Alternatives

One alternative is to just interpret each path as a mapped directory if there is a ":" in the name. This seems like the faster way, but it would be better if the API reflected the difference.

@willemneal willemneal added the 🎉 enhancement New feature! label May 20, 2019
@MarkMcCaskey
Copy link
Contributor

Thanks -- we're glad to hear that! This is a great idea and we agree it's super nice to have!

I've started work on it in #451 actually, but am blocked by myself (well, due to mysterious CI issues) setting up tests (#457). I wanted to have more confidence that I wasn't breaking core features before shipping/continuing development on it.

@willemneal
Copy link
Author

Awesome! Look forward to it!

bors bot added a commit that referenced this issue May 21, 2019
451: implement map-dir for WASI; fix bug in path_open r=MarkMcCaskey a=MarkMcCaskey

Colon separated mapping, implemented to be compatible with wasmtime

resolves #458 

example:
```Rust
use std::fs;

fn main() {
    let read_dir = fs::read_dir(".").unwrap();
    for entry in read_dir {
        println!("{:?}", entry.unwrap().path());
    }
}
```
```shell
$ cargo run --release --bin wasmer -- run --mapdir=.:src list-files.wasm
"./bin"
"./installer"
"./lib"
"./update"
"./utils"
"./webassembly"
```

Co-authored-by: Mark McCaskey <mark@wasmer.io>
Co-authored-by: Mark McCaskey <markmccaskey@users.noreply.github.com>
@bors bors bot closed this as completed in #451 May 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🎉 enhancement New feature!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants