Fix NT path handling and stat in eio_windows - #932
Merged
Conversation
The stubs checked an uninitialized handle before the NtCreateFile status
avsm
commented
Sep 7, 2026
talex5
approved these changes
Sep 7, 2026
talex5
left a comment
Collaborator
There was a problem hiding this comment.
Thanks - this looks like a huge improvement!
Absolute and relative paths given to fs are passed to NtCreateFile unqualified and fail with ENOENT, unless already in NT form (ocaml-multicore#931).
Unqualified paths (like `C:\foo`) raised ENOENT. We now convert such paths before passing them through to Win32. Fixes ocaml-multicore#931.
Filename doesn know about volume prefixes, so it splits a UNC root or a bare drive as if it were an ordinary path.
nofollow formerly replaced the NT create options with a Win32 flag, dropping the directory/non-directory constraints.
The ELOOP handler ran readlink relative to the process directory instead of the sandbox root.
The openat call was only partially applied inside Err.run, so the syscall ran outside it and Unix errors escaped.
stat always passed FILE_NON_DIRECTORY_FILE, so statting a directory failed.
stat needs a third mode that opens the link rather than its target, to match the posix backend. fstat now reports the length of the target as the size, as lstat does (the odd looking division by 2 in the stub is because Windows comes back with a 2-byte WCHAR array).
avsm
force-pushed
the
issue-931-nt-paths
branch
from
September 7, 2026 20:59
e85667a to
eea7d54
Compare
Contributor
Author
|
Weird unrelated (?) error on fedora: |
Contributor
Author
|
That was a transient error, gone on re-run. This is good to go I think. |
Collaborator
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
While fixing #931 and adding tests, I went into a rabbithole of fixes involving Windows symlinks. For anyone who want to follow (pun intended) in my footsteps, beware of Windows Redirect Guard which is now active on OpenSSH by default and completely destroys the symlink-using Flexlink OCaml toolchain.
This fixes the issue reported in #931 and uses Nt_path consistently (exposing some new functions there too). I found some other bugs in symlink handling too:
openat/unlinkatstubs checked an uninitialized handle before theNtCreateFilestatus, so failures were misreported.nofollowreplaced the create options with a Win32 flag, dropping the directory/non-directory constraints so stat kinds didnt' workopen_outELOOPrecovery ranreadlinkrelative to the process directory rather than the sandbox root.openatwas only partially applied insideErr.run, soUnixerrors fromopen_inescaped unmapped.statcould create a missing file.statalways passedFILE_NON_DIRECTORY_FILE, so statting a directory failed.statwith~follow:falsefollowed the link anyway; there is now a third open mode that opens the symlink, andfstatreports the target length as the size like the Posix backend does.Best reviewed commit by commit and the testcases are separate so I could verify they failed before and worked after.