[libc] Implement fstatat in sys/stat
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
### Summary
Implement the standard POSIX.1-2008 function `fstatat` in ``.
POSIX specification: https://pubs.opengroup.org/onlinepubs/9799919799/functions/fstatat.html
### Background & Context
`fstatat` is currently listed as missing in [`libc/utils/docgen/sys/stat.yaml`](https://github.com/llvm/llvm-project/blob/main/libc/utils/docgen/sys/stat.yaml#L95) and is not yet exposed in `libc/include/sys/stat.yaml`.
The internal Linux helper is already implemented in `libc/src/__support/OSUtil/linux/stat/stat_via_statx.h`:
```cpp
ErrorOr stat_via_statx(int dirfd, const char *__restrict path,
int flags, struct stat *__restrict statbuf);
```
Both `stat` and `lstat` already delegate to this helper (passing `AT_FDCWD` and `0` or `AT_SYMLINK_NOFOLLOW`). Implementing `fstatat` directly exposes `stat_via_statx(dirfd, path, flags, statbuf)` to userspace with standard error handling.
Contributor guide
Research direction
Start with libc/utils/docgen/sys/stat.yaml and libc/include/sys/stat.yaml, then read libc/src/__support/OSUtil/linux/stat/stat_via_statx.h along with the existing stat and lstat implementations. Expose fstatat with the POSIX signature, delegate through the helper with standard error handling, and verify its declaration and behavior against the linked POSIX specification.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, linux
- Domain
- operating-systems
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 78/100