WebAssembly / WebAssembly/WASI

No st_mode from stat?

Open
#774 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

P-filesystem
Dominant language
Rust
Stars
5.8k
Forks
333
Avg merge
2d 13h
Merged PRs (30d)
3

Description

The internal struct used by stat calls does not have a field for the mode of the file (read/write/execute bits), and stat, 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:

      if (stat (name, &s) == 0 && s.st_mode & (S_IXUSR|S_IXGRP|S_IXOTH)
                               /* Do not stop at directories. */
                               && !S_ISDIR(s.st_mode))
        self = name;
      else
        free (name);

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the WASI API definition linked at libc-bottom-half/headers/public/wasi/api.h around line 955, then trace how stat, lstat, fstat, and fstatat populate their internal result. Confirm the current zero mode bits and determine the API change needed so permission and file-type information is represented accurately; done means affected callers receive correct st_mode bits.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, wasm
Domain
operating-systems
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.