# wasi: always grant fd_readdir right · gitcafe/zig

[View on GitCafe](https://git.cafe/gitcafe/zig/commit/b0ee911c2389e507d36a2f9c2442046133c18b93)

Repository: [gitcafe/zig](https://git.cafe/gitcafe/zig)

Visibility: public

Requested revision: b0ee911c2389e507d36a2f9c2442046133c18b93

Requested commit: b0ee911c2389e507d36a2f9c2442046133c18b93

Commit: b0ee911c2389e507d36a2f9c2442046133c18b93

Tree: 6eabd7a69ee1acffec6b2765b41026a9816bd40e

Author: Jakub Konka

Committer: Jakub Konka

## Message

```
wasi: always grant fd_readdir right

Since v0.23 release of Wasmtime, if we want to iterate a directory
Y then directory Y needed to have been granted `fd_readdir` right.
However, it is now also required for directory X to carry `fd_readdir`
right, and so on, up-chain all the way until we reach the preopen
(which possesses all rights by default).

This caused problems for us since our libstd implementation is more
fine-grained and allowed for parent dirs not to carry the right while
allow for iterating on its children. My proposal here is to always
grant `fd_readdir` right as part of
`std.fs.Dir.OpenDirOptions.access_sub_paths`. This seems to be the
approach taken by Rust also, plus we should be justified to take this
approach since WASI is experimental and snapshot1 will be discontinued
eventually and replaced with a new approach to access management
that will require a complete rewrite of our libstd anyhow.

```

## Parents

- [7462b0e5b9d03ed6704c83f444b083a973278da5](https://git.cafe/gitcafe/zig/commit/7462b0e5b9d03ed6704c83f444b083a973278da5?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zig/tree/b0ee911c2389e507d36a2f9c2442046133c18b93?format=markdown)
