Skip to content

Conversation

@Tango992
Copy link
Contributor

@Tango992 Tango992 commented Aug 4, 2025

Fixes #30299

I decided to build the OpenOptions on the Rust side, because it's cheaper to pass integers to the op function and we can enable the fast op call. Also the tests that I added to the config.toml were already passing before this PR.

Comment on lines +155 to +159
if (flags & libc::O_EXCL) == libc::O_EXCL {
options.create_new = true;
options.write = true;
flags &= !libc::O_EXCL;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's the current logic from Deno 2.4.3:

if ((flag & O_EXCL) === O_EXCL) {
openOptions.createNew = true;
openOptions.read = true;
openOptions.write = true;
}

I intentionally omitted the read permission as the Rust stdlib only requires write permission when chained with create_new:
https://doc.rust-lang.org/src/std/sys/fs/unix.rs.html#1118-1152

@dsherret dsherret requested review from kt3k and littledivy August 4, 2025 07:57
Copy link
Member

@bartlomieju bartlomieju left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks, great fix

@bartlomieju bartlomieju merged commit 55f74e8 into denoland:main Aug 5, 2025
18 checks passed
@Tango992 Tango992 deleted the fix-node-fs-open–access-flags branch August 5, 2025 09:30
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.

node:fs open and openSync always enables read permission

2 participants