Skip to content

Fix umask being ignored on file creation#26763

Merged
sbc100 merged 1 commit intoemscripten-core:mainfrom
sbc100:fix_umask
Apr 23, 2026
Merged

Fix umask being ignored on file creation#26763
sbc100 merged 1 commit intoemscripten-core:mainfrom
sbc100:fix_umask

Conversation

@sbc100
Copy link
Copy Markdown
Collaborator

@sbc100 sbc100 commented Apr 23, 2026

A process-wide umask was being ignored by both the default JavaScript filesystem and the new C++ WasmFS when creating files and directories.

For the default filesystem:

  • Moved __syscall_umask implementation from C to JavaScript in libsyscall.js.
  • Stored the umask state in $SYSCALLS.currentUmask.
  • Applied the umask in __syscall_openat, __syscall_mkdirat, and __syscall_mknodat.
  • This makes umask thread-local (per JS instance), consistent with how cwd is handled.

For WasmFS:

  • Added umask state and accessors to the WasmFS class in wasmfs.h.
  • Implemented __syscall_umask in syscalls.cpp as an extern "C" function to satisfy Musl's umask.c.
  • Applied the umask in doOpen and doMkdir in syscalls.cpp.

Fixes: #26707

@sbc100 sbc100 requested a review from kripken April 23, 2026 17:28
Comment thread system/lib/wasmfs/wasmfs.h
Comment thread test/fs/test_trackingdelegate.out Outdated
@sbc100 sbc100 force-pushed the fix_umask branch 2 times, most recently from 2c1c569 to 0eaf83f Compare April 23, 2026 20:39
A process-wide umask was being ignored by both the default JavaScript
filesystem and the new C++ WasmFS when creating files and directories.

For the default filesystem:
- Moved __syscall_umask implementation from C to JavaScript in libsyscall.js.
- Stored the umask state in $SYSCALLS.currentUmask.
- Applied the umask in __syscall_openat, __syscall_mkdirat, and __syscall_mknodat.
- This makes umask thread-local (per JS instance), consistent with how cwd is handled.

For WasmFS:
- Added umask state and accessors to the WasmFS class in wasmfs.h.
- Implemented __syscall_umask in syscalls.cpp as an extern "C" function to satisfy Musl's umask.c.
- Applied the umask in doOpen and doMkdir in syscalls.cpp.

Test updates:
- Updated test_umask.c to use raw mode 0666 and added a test for mkdir.

Fixes: emscripten-core#26707
@sbc100 sbc100 merged commit 94f825e into emscripten-core:main Apr 23, 2026
4 of 14 checks passed
@sbc100 sbc100 deleted the fix_umask branch April 23, 2026 22:19
@hoodmane
Copy link
Copy Markdown
Collaborator

I wonder if this fixes some Python tests that are currently xfailed.

@hoodmane
Copy link
Copy Markdown
Collaborator

There are currently three Python tests that are xfailed because "Emscripten's umask is a stub". There's also several others that probably should be xfailed but pass due to the test environment coincidentally having a specific umask.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

umask seems to be ignored on file creation

3 participants