Expose mknodat/mkfifoat on Apple targets - #1625
mattsu2020 wants to merge 1 commit into
Conversation
|
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 |
|
Or add non-*at too for macOS? |
|
Right, the POSIX |
|
I'll revise this PR to restore weak-linking/runtime detection. When the symbol is unavailable, I'll only fall back to |
|
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. |
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as duplicate.
This comment was marked as duplicate.
|
@mattsu2020 The fix for the CI failure #1620 has been merged. Could you update this PR? |
I’ve updated it. |
|
@sunfishcode Could you take a look at this? The code change seems relatively straightforward, and it passes CI. |
|
Resolve conflicts |
fix it |
|
@mattsu2020 please squash your commits and write a new commit description in your own words |
macOS 13 and corresponding Apple platforms added mknodat/mkfifoat. These APIs were previously excluded with cfg(not(apple)). On Apple, resolve mknodat at runtime with the same weak-linking pattern used for linkat/unlinkat/renameat. If the symbol is absent (macOS < 13 and older Apple OS variants), return NOSYS so a binary built against a newer SDK can still run on older systems. Other targets keep calling libc mknodat directly. mkfifoat goes through the same path. Also import Dev and FileType on Apple so the public wrappers compile, add XNU man-page references, and shrink the unsafe block around the syscall.
70fccf0 to
c9532b1
Compare
I performed a squash merge and added a comment. |
There was a problem hiding this comment.
Can we clarify the platform support for mknodat and mkfifoat in src/fs/at.rs?
The macro-expanded declaration in sys/stat.h shows that it was introduced in macOS 13.0, iOS 16.0, tvOS 16.0, and watchOS 9.0.
Macro-expanded declaration
int mkfifoat(int, const char *, mode_t)
__attribute__((availability(macos,introduced=13.0)))
__attribute__((availability(ios,introduced=16.0)))
__attribute__((availability(tvos,introduced=16.0)))
__attribute__((availability(watchos,introduced=9.0)));Also, please amend the commit message to summarize the changes rather than describing every implementation detail. For example:
Expose mknodat and mkfifoat on Apple targets.
Weak-link
mknodaton Apple and returnNOSYSwhen unavailable on older systems. Keep direct libc calls on other targets.
This will make the PR easier to review when the maintainer gets to it.
c9532b1 to
9e729e7
Compare
Weak-link mknodat on Apple and return NOSYS when unavailable on older systems. Keep direct libc calls on other targets. Document availability starting in macOS 13.0, iOS 16.0, tvOS 16.0, and watchOS 9.0 for both APIs.
9e729e7 to
3835644
Compare
|
Thank you for your feedback. I have incorporated your comments accordingly. |
|
@mattsu2020 Please don't include PR number in commit. Also, please update the PR description to remove unnecessary details, was that generated by an LLM? I opened an issue for the rustdoc warnings: #1685 |
Weak-link mknodat on Apple and return NOSYS when unavailable on older systems. Keep direct libc calls on other targets.
3835644 to
cdce881
Compare
|
I added it because I thought it was necessary, but I'll remove it. |
|
Should the rustdoc warnings be addressed in this PR? I'm also fine with handling them in a separate PR. |
Summary
rustix::fs::{mknodat, mkfifoat}on Apple targets, with support starting in macOS 13.0, iOS 16.0, tvOS 16.0, and watchOS 9.0.mknodaton Apple and returnNOSYSwhen unavailable on older systems.mkfifoatdelegates to the same implementation. Other targets retain direct libc calls.Validation
cargo doc --no-deps --features all-apisgit diff --checkThe documentation build succeeded on macOS with 10 unresolved-link warnings in unchanged documentation; none were in the updated API documentation.