`fd_readdir` returns a "bufused" value, which indicates the number of bytes read into the buffer. WASI libc expects this value to be equal to the size of the buffer if the end of the directory has not yet been scanned. Previously, wasi-common's `fd_readdir` was writing as many complete entries as it could fit and then stopping, but this meant it was returning size less than the buffer size even when the directory had more entries. This patch makes it continue writing up until the end of the buffer, and return that number of bytes, to let WASI libc know that there's more to be read. Fixes #2493.
This is the test-programs crate, which builds and runs whole programs
compiled to wasm32-wasi.
To actually run these tests, the test-programs feature must be enabled, e.g.:
cargo test --features test-programs/test_programs --package test-programs