Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[2/3] Proper path resolution: add readlinkat functionality #2264

Closed
wants to merge 10 commits into from

Conversation

yagehu
Copy link
Contributor

@yagehu yagehu commented Jun 24, 2024

This PR is the second in a series that will implement the path resolution algorithm described by wasi-filesystem. This PR currently targets the main branch and thus includes changes in part 1 (#2254). When #2254 is merged I'll rebase this PR.

This PR adds the readlinkat(2) syscall to Linux and Darwin and the equivalent on Windows. This is needed to support the path resolution algorithm by expanding symlinks as we encounter them when resolving paths.

yagehu added 10 commits June 17, 2024 09:21
This commit adds the `openat` functionality to `sys.FS`.  On UNIX-like
platforms, this is done with the `openat(2)` syscall.  On Windows, this
is done with [`NtCreateFile`][1].  This is the first in a series of
commit that overhauls how paths are resolved.  The wasi-filesystem spec
now [describes][2] a path resolution implementation that uses `openat`.

[1]: https://learn.microsoft.com/en-us/windows/win32/api/winternl/nf-winternl-ntcreatefile
[2]: https://github.com/WebAssembly/wasi-filesystem/blob/main/path-resolution.md

Signed-off-by: Yage Hu <[email protected]>
Signed-off-by: Yage Hu <[email protected]>
Signed-off-by: Yage Hu <[email protected]>
This commit adds the `ReadLinkAt` functionality needed to implement
proper path resolution in WASI.  On Linux, it's implemented by stringing
together `fstatat` and `readlinkat(2)`.  On Darwin, since `fstatat(2)`
does not support the `AT_SYMLINK_NOFOLLOW` flag, we use `lstat(2)`.

Signed-off-by: Yage Hu <[email protected]>
@evacchi evacchi self-assigned this Jun 24, 2024
@mathetake
Copy link
Member

feel free to reopen when ready to continue the work

@mathetake mathetake closed this Dec 23, 2024
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.

3 participants