WebAssembly / WebAssembly/wasi-libc

chdir("..") from "/bin" changes the current directory to "/bin/.." instead of "/"

Open
#260 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
1k
Forks
251
Avg merge
7h 15m
Merged PRs (30d)
3

Description

I've mapped a single directory (which contains a "bin" subdirectory) as "/" like that:

wasmtime run --mapdir /::testdir prog.wasm

On program start, getcwd() returns "/", which is expected.
Calling chdir("bin") causes getcwd() to return "/bin", which is also expected.
Then, calling chdir(".") causes getcwd() to still return "/bin", which is also expected and great.
However, calling chdir("..") causes getcwd() to return "/bin/..". I think in this case, it should return "/".

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the behavior with wasmtime run --mapdir /::testdir prog.wasm, then trace the WASI libc handling behind chdir() and getcwd(). Done means changing from /bin to .. reports / rather than /bin/.., with coverage for the mapped-root case.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
operating-systems
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.