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

The mapdir option unexpectedly maps to the current working directory #1503

Closed
caspervonb opened this issue Jul 15, 2020 · 2 comments · Fixed by #1660
Closed

The mapdir option unexpectedly maps to the current working directory #1503

caspervonb opened this issue Jul 15, 2020 · 2 comments · Fixed by #1660
Labels
bug Something isn't working 📦 lib-wasi About wasmer-wasi

Comments

@caspervonb
Copy link

caspervonb commented Jul 15, 2020

Describe the bug

Take the following rename(2) test from the wasi-test project.

// { "preopens": { "/scratch": "scratch" } }

#include <assert.h>
#include <stdio.h>

int main(void) {
	char oldname[] = "/scratch/oldfile";
	char newname[] = "/scratch/newfile";

	FILE *oldfile = fopen(oldname, "w");
	assert(oldfile != NULL);
	assert(fclose(oldfile) == 0);

	assert(rename(oldname, newname) == 0);

	FILE *newfile = fopen(newname, "r");
	assert(newfile != NULL);
	assert(fclose(newfile) == 0);

	return 0;
}

Which gets invoked as the following command

 wasmer run --mapdir=/scratch:scratch integration/rename.wasm 
echo "`wasmer -V` | `rustc -V` | `uname -m`"
wasmer 0.16.2 | rustc 1.43.1 (8d69840ab 2020-05-04) | x86_64

Steps to reproduce

  1. git clone https://github.com/caspervonb/wasi-test
  2. python3 build.py
  3. wasmer run --mapdir=/scratch:scratch integration/rename.wasm
  4. mkdir scratch
  5. ls scratch

Expected behavior

/scratch to be mapped to ./scratch and it to contain a single file

Actual behavior

/scratch is mapped to . which contains the created file

Additional context

@caspervonb caspervonb added the bug Something isn't working label Jul 15, 2020
@syrusakbary
Copy link
Member

Thanks for the report @caspervonb !

@MarkMcCaskey MarkMcCaskey added the 📦 lib-wasi About wasmer-wasi label Sep 24, 2020
@MarkMcCaskey
Copy link
Contributor

MarkMcCaskey commented Sep 30, 2020

On wasmer on master I can confirm that wasmer run --mapdir=/scratch:scratch integration/rename.wasm does not work but wasmer run --mapdir=scratch:scratch integration/rename.wasm and wasmer run --mapdir=./scratch:scratch integration/rename.wasm seem to.

I'll look into it some more.

Also the actual commands I've been running look like wasmer run --mapdir=./fixtures:fixtures target/wasm32-wasi/debug/std_fs_rename.wasm

bors bot added a commit that referenced this issue Oct 1, 2020
1660: Allow mapdir aliases with starting `/` r=syrusakbary a=MarkMcCaskey

Stripping leading `/` is valid because we mount mapped dirs at `/` regardless.

Resolves #1503 

This solution is a bit hacky, there may be a more elegant solution.  I'll look for one tomorrow morning when I'm more mentally fresh.

- [ ] Add a short description of the the change to the CHANGELOG.md file


Co-authored-by: Mark McCaskey <mark@wasmer.io>
bors bot added a commit that referenced this issue Oct 1, 2020
1660: Allow mapdir aliases with starting `/` r=MarkMcCaskey a=MarkMcCaskey

Stripping leading `/` is valid because we mount mapped dirs at `/` regardless.

Resolves #1503 

This solution is a bit hacky, there may be a more elegant solution.  I'll look for one tomorrow morning when I'm more mentally fresh.

- [ ] Add a short description of the the change to the CHANGELOG.md file


Co-authored-by: Mark McCaskey <mark@wasmer.io>
bors bot added a commit that referenced this issue Oct 1, 2020
1660: Allow mapdir aliases with starting `/` r=MarkMcCaskey a=MarkMcCaskey

Stripping leading `/` is valid because we mount mapped dirs at `/` regardless.

Resolves #1503 

This solution is a bit hacky, there may be a more elegant solution.  I'll look for one tomorrow morning when I'm more mentally fresh.

- [ ] Add a short description of the the change to the CHANGELOG.md file


Co-authored-by: Mark McCaskey <mark@wasmer.io>
bors bot added a commit that referenced this issue Oct 1, 2020
1660: Allow mapdir aliases with starting `/` r=MarkMcCaskey a=MarkMcCaskey

Stripping leading `/` is valid because we mount mapped dirs at `/` regardless.

Resolves #1503 

This solution is a bit hacky, there may be a more elegant solution.  I'll look for one tomorrow morning when I'm more mentally fresh.

- [ ] Add a short description of the the change to the CHANGELOG.md file


Co-authored-by: Mark McCaskey <mark@wasmer.io>
@bors bors bot closed this as completed in cebf0cd Oct 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working 📦 lib-wasi About wasmer-wasi
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants