emscripten-core / emscripten-core/emscripten
WasmFS NodeRawFS is not consistent with NodeRawFS (non-WasmFS version)
- Dominant language
- C++
- Stars
- 27.6k
- Forks
- 3.6k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 105
Description
Please include the following in your bug report:
**Version of emscripten/emsdk:**
```
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 4.0.11 (d3432e7a2a6585331c94b041973fb16c9f332ce4)
clang version 21.0.0git (https:/github.com/llvm/llvm-project 0f0079c29da4b4d5bbd43dced1db9ad6c6d11008)
Target: wasm32-unknown-emscripten
Thread model: posix
```
Consider this example:
```cpp
/* test.cc */
#include
#include
#include
int main(int argc, char** argv) {
char buf[PATH_MAX + 1];
ssize_t len = readlink("/proc/self/exe", buf, sizeof(buf));
if (len > PATH_MAX) {
return 2;
}
printf("self exe: %s", buf);
fflush(stdout);
return 0;
}
```
```
% emcc -sEXIT_RUNTIME -sNODERAWFS test.cc && node a.out.js
self exe: /home/trybka/.nvm/versions/node/v22.13.1/bin/node
```
vs.
```
% emcc -sEXIT_RUNTIME -sNODERAWFS -sWASMFS test.cc && node a.out.js
self exe:
```
This is because the "root" of the VFS for NodeRawFS should be `/`, but when using WasmFS it is `.` (I assume, via https://github.com/emscripten-core/emscripten/blob/e5c41dbbc93b3a4ab3e0c30935223865facfdbcb/system/lib/wasmfs/backends/noderawfs_root.cpp#L11)
If I change the `.` to `/` then it works the same in both cases.
Contributor guide
Assessment
This issue has not been assessed yet.