Stream: wasi

Topic: Clarification on mutate-directory flag


view this post on Zulip appcypher (Apr 26 2024 at 21:25):

Need some clarification here. Why do we need a different mutate-directory flag, when we already have write flag?

flags descriptor-flags {
    /// Read mode: Data can be read.
    read,
    /// Write mode: Data can be written to.
    write,

    // ...

    /// Mutating directories mode: Directory contents may be mutated.
    ///
    /// When this flag is unset on a descriptor, operations using the
    /// descriptor which would create, rename, delete, modify the data or
    /// metadata of filesystem objects, or obtain another handle which
    /// would permit any of those, shall fail with `error-code::read-only` if
    /// they would otherwise succeed.
    ///
    /// This may only be set on directories.
    mutate-directory,
}

view this post on Zulip Dan Gohman (Apr 26 2024 at 21:52):

It fits better with POSIX compatibility. In POSIX, write access for a file is obtained by opening the file with O_WRONLY or O_RDWR, but opening a directory with O_WRONLY or O_RDWRfails, with EISDIR.

view this post on Zulip appcypher (Apr 26 2024 at 21:58):

Right. That makes sense. So would specifying write fail on directories? What about read?

view this post on Zulip Dan Gohman (Apr 26 2024 at 22:18):

Yes, opening a directory with write fails. But it succeeds with just read.


Last updated: Dec 23 2024 at 12:05 UTC