llvm / llvm/llvm-project

[libc] Implement mkfifoat in sys/stat

Open Beginner friendly
#224,587 2 comments 0 reactions 0 assignees View on GitHub
libc
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

### Summary
Implement the standard POSIX.1-2008 function `mkfifoat` in ``.

POSIX specification: https://pubs.opengroup.org/onlinepubs/9799919799/functions/mkfifoat.html

### Background & Context
`mkfifoat` 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#L107) and is not yet declared in `libc/include/sys/stat.yaml`.

The underlying Linux syscall wrapper is already implemented in `libc/src/__support/OSUtil/linux/syscall_wrappers/mknodat.h`:
```cpp
namespace LIBC_NAMESPACE_DECL {
namespace linux_syscalls {

LIBC_INLINE ErrorOr mknodat(int dfd, const char *path, mode_t mode,
dev_t dev);

} // namespace linux_syscalls
} // namespace LIBC_NAMESPACE_DECL
```

`mkfifo` in `libc/src/sys/stat/linux/mkfifo.cpp` already delegates to this helper by passing `AT_FDCWD` and `mode | S_IFIFO`:
```cpp
LLVM_LIBC_FUNCTION(int, mkfifo, (const char *path, mode_t mode)) {
auto result = linux_syscalls::mknodat(AT_FDCWD, path, mode | S_IFIFO, 0);
if (!result) {
libc_errno = result.error();
return -1;
}
return 0;
}
```

Implementing `mkfifoat(int dirfd, const char *path, mode_t mode)` will complete the directory-relative `*at` family in `` (`fchmodat`, `fstatat`, `mkdirat`, `utimensat`, `mkfifoat`).

Contributor guide

Open the contributing guide

Research direction

Start with libc/src/sys/stat/linux/mkfifo.cpp and the mknodat declaration in libc/src/__support/OSUtil/linux/syscall_wrappers/mknodat.h. Compare the missing entries in libc/utils/docgen/sys/stat.yaml and libc/include/sys/stat.yaml with the existing *at functions. Done means mkfifoat is declared and implemented as the directory-relative FIFO operation described by POSIX.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
operating-systems
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
84/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.