Skip to content

Conversation

@alexcrichton
Copy link
Collaborator

The main goal of this commit is to simplify what's located in the descriptor table of libc. Primarily directory streams are no longer located in the table and are instead stored directly in the DIR* structure. Additionally the wasip1-style cookie is removed in favor of a wasip2-specific offset counter. Along the way
__wasilibc_nocwd_scandirat was rewritten for both wasip1 and wasip2 to be built on openat + fdopendir. This removes WASI-version-specific code and makes this look more similar to scandir elsewhere in libc.

@alexcrichton alexcrichton changed the title Reimplement directory streams wasip2: Reimplement directory streams Nov 8, 2025
Copy link
Collaborator

@pchickey pchickey left a comment

Choose a reason for hiding this comment

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

It would be good to have a test that exercises rewinddir and seekdir - https://github.com/WebAssembly/wasi-libc/blob/main/test/src/misc/opendir.c and https://github.com/WebAssembly/wasi-libc/blob/main/test/src/misc/scandir.c are the existing coverage in this area.

The main goal of this commit is to simplify what's located in the
descriptor table of libc. Primarily directory streams are no longer
located in the table and are instead stored directly in the `DIR*`
structure. Additionally the wasip1-style `cookie` is removed in favor of
a wasip2-specific offset counter. Along the way
`__wasilibc_nocwd_scandirat` was rewritten for both wasip1 and wasip2 to
be built on `openat` + `fdopendir`. This removes WASI-version-specific
code and makes this look more similar to `scandir` elsewhere in libc.
@alexcrichton alexcrichton force-pushed the less-directories-in-descriptor-table branch from a7ea6d6 to d039b01 Compare November 10, 2025 19:45
@alexcrichton alexcrichton merged commit 9c52274 into WebAssembly:main Nov 10, 2025
16 checks passed
@alexcrichton alexcrichton deleted the less-directories-in-descriptor-table branch November 10, 2025 19:47
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.

2 participants