Open corwin-of-amber opened 4 years ago
WASI recently added a way to set permissions on a file; we should consider adding a simple way to retrieve the permissions on a file too, which would allow us to implement this.
I just came across this bug again :D is there any way to do this now?
Looks like stat_impl.h
has to be modified to support it:
https://github.com/WebAssembly/wasi-libc/blob/659ff414560721b1660a19685110e484a081c3d4/libc-bottom-half/cloudlibc/src/libc/sys/stat/stat_impl.h
This needs WASI support first, and then we can add libc support for it. WASI has been focused on lower-level areas of the design lately, so we haven't had a chance to add this yet.
One question here is: what should implementations on Windows put in this field?
The internal struct used by
stat
calls does not have a field for the mode of the file (read/write/execute bits), andstat
,lstat
,fstat
,fstatat
all return zeros for these bits. The implementer of the API has no control over that.https://github.com/CraneStation/wasi-libc/blob/12f5832b45c7450f8320db271334081247191d58/libc-bottom-half/headers/public/wasi/api.h#L955
Most of the time it's alright, but some code checks file permissions occasionally (esp. execute permission) and behaves unexpectedly when the permissions set in
st_mode
are in fact lower than the actual permissions for the file.E.g. excerpt from
kpathsea
: