Skip to content

Expose mknodat/mkfifoat on Apple targets#1625

Open
mattsu2020 wants to merge 5 commits into
bytecodealliance:mainfrom
mattsu2020:mknodat_macos
Open

Expose mknodat/mkfifoat on Apple targets#1625
mattsu2020 wants to merge 5 commits into
bytecodealliance:mainfrom
mattsu2020:mknodat_macos

Conversation

@mattsu2020

@mattsu2020 mattsu2020 commented May 16, 2026

Copy link
Copy Markdown

Summary

  • Expose rustix::fs::{mknodat, mkfifoat} on Apple targets, which were previously gated out with cfg(not(apple))
  • macOS 13 added mknodat/mkfifoat system calls;
  • mkfifoat works automatically as it delegates to mknodat

macOS 13 added mknodat/mkfifoat system calls. Use the same weak-linking
pattern as linkat/unlinkat/renameat: resolve the symbol at runtime via
dlsym, and fall back to mknod/mkfifo when the symbol is unavailable
and dirfd == AT_FDCWD.
macOS 13 and earlier are EOL. Use c::mknodat directly via libc
without weak-linking, matching other platforms.
The use declarations for Dev and FileType were gated with
cfg(not(apple)), causing compilation failures when mknodat became
available on Apple. Remove apple from the exclusion list.
@xtqqczze

xtqqczze commented May 17, 2026

Copy link
Copy Markdown
Contributor

I think a fallback is needed for macOS ≤ 13 since Apple macOS targets are supported as far back as macOS 10.12, and there are also additional Apple platforms to consider such as tvOS and watchOS.

It would also be good to add references for the newly exposed functions on Apple targets. For example, https://github.com/apple-oss-distributions/xnu/blob/main/bsd/man/man2/mkfifoat.2

@oech3

oech3 commented May 17, 2026

Copy link
Copy Markdown

Or add non-*at too for macOS?

@xtqqczze

Copy link
Copy Markdown
Contributor

Right, the POSIX mknod and mkfifo are currently absent from all platforms.

@mattsu2020

Copy link
Copy Markdown
Author

I'll revise this PR to restore weak-linking/runtime detection. When the symbol is unavailable, I'll only fall back to mknod/mkfifo for the AT_FDCWD case, and otherwise return an unsupported/error result. I'll also add Apple man page references for these functions.

@xtqqczze

Copy link
Copy Markdown
Contributor

On second thoughts, we probably don't need to implement a fallback for the libc backend. We can just return the appropriate Err and let callers handle it.

Comment thread src/backend/libc/fs/syscalls.rs Outdated
Co-authored-by: xtqqczze <45661989+xtqqczze@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants