Skip to content

Suggestion: no-op set_permissions for WASI #68560

Closed
@RReverser

Description

@RReverser

Currently, WASI target implements retrieving permissions with a no-op and just returning a default value:

pub fn perm(&self) -> FilePermissions {
// not currently implemented in wasi yet
FilePermissions { readonly: false }
}

However, the corresponding setter method is instead implemented by returning an error:

pub fn set_permissions(&self, _perm: FilePermissions) -> io::Result<()> {
// Permissions haven't been fully figured out in wasi yet, so this is
// likely temporary
unsupported()
}

This is unfortunate and breaks higher-level APIs like std::fs::copy which currently manages to successfully copy contents of file on a WASI target but then fails because the default implementation unconditionally calls set_permissions:

let ret = io::copy(&mut reader, &mut writer)?;
fs::set_permissions(to, perm)?;
Ok(ret)

To both fix such issues and from a semantic point of view, too, it seems it would be better to mirror the behaviour of the getter (permissions method) and just perform no-op in set_permissions on a WASI target, at least until WASI specification decides to extend support and add real permissions model.

Would the team be open to this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions