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

Change readdir from returning bytes to returning a dir-entrys. #72

Merged
merged 1 commit into from
Dec 7, 2022

Conversation

sunfishcode
Copy link
Member

readdir returning bytes has been a source of complexity for both libc and engine implementors, with subtle issues about alignment and partial records.

Rename dirent to dir-entry for readability, and revamp it:

  • Make the name field a proper string rather than being represented by trailing bytes in the buffer.
  • Make the inode field optional, so that we can make it optional as discussed in dirent::d_ino #65 without special-casing zero, which is reportedly a valid inode number on some filesystems.

And remove the rewind parameter, which isn't needed when we return a stream, as users wanting to start at the beginning can just request a new stream.

`readdir` returning bytes has been a source of complexity for both libc
and engine implementors, with subtle issues about alignment and partial
records.

Rename `dirent` to `dir-entry` for readability, and revamp it:
 - Make the name field a proper `string` rather than being represented
   by trailing bytes in the buffer.
 - Make the inode field `optional`, so that we can make it optional
   as discussed in #65 without special-casing zero, which is reportedly
   a valid inode number on [some filesystems].

And remove the `rewind` parameter, which isn't needed when we return
a stream, as users wanting to start at the beginning can just request
a new stream.

[some filesystems]: https://sourceware.org/pipermail/libc-alpha/2022-September/142059.html
@sunfishcode sunfishcode merged commit 1d3e556 into main Dec 7, 2022
@sunfishcode sunfishcode deleted the sunfishcode/readdir branch December 8, 2022 00:01
sunfishcode added a commit to bytecodealliance/preview2-prototyping that referenced this pull request Dec 8, 2022
sunfishcode added a commit to bytecodealliance/preview2-prototyping that referenced this pull request Dec 8, 2022
sunfishcode added a commit to bytecodealliance/preview2-prototyping that referenced this pull request Dec 8, 2022
pchickey pushed a commit to pchickey/wasmtime that referenced this pull request May 16, 2023
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.

1 participant