emscripten-core / emscripten-core/emscripten

`FS.stat` has inconsistent `[a/m/c]time` values in WasmFS

Open
#21,983 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
27.6k
Forks
3.6k
Avg merge
1d 1h
Merged PRs (30d)
105

Description

**Version of emscripten/emsdk:**
```
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.58 (a41843e0860e52c948c1fce20307933c6631c800)
clang version 19.0.0git (https:/github.com/llvm/llvm-project 0a8cd1ed1f4f35905df318015b0dbcb69d81d7c2)
Target: wasm32-unknown-emscripten
Thread model: posix
InstalledDir: /home/foo/emsdk/upstream/bin
```

**Failing command line in full:**
N/A

**Full link command and output with `-v` appended:**
```
-O2 -sMODULARIZE=1 -sEXPORT_ES6=1 -sEXPORT_NAME=foo -sEXPORTED_FUNCTIONS=_free,_malloc,_main -sENVIRONMENT=web,worker -sEXPORTED_RUNTIME_METHODS=FS,OPFS,getValue,setValue,UTF8ToString,lengthBytesUTF8,stringToUTF8,cwrap,addFunction,PThread -sPTHREAD_POOL_SIZE=1 -sPTHREAD_POOL_SIZE_STRICT=0 -lopfs.js -sWASMFS -sFORCE_FILESYSTEM
```

**Problem:**
I'm using `FS.stat` function to track when a file was created in OPFS. I've just realized that these times are not persistent and changes on page reload. IIRC, OPFS doesn't provide this value as well. When I was using `WORKERFS` or similar I had access to `FS.trackingDelegate` which I could use to track whenever a file was created. Do we have a substitute for that functionality in `WasmFS`? Or much better, can we get persistent times for `[a/m/c]time`?

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.