std: don't reference libc::O_NOFOLLOW on VxWorks in set_perm_nofollow - #162065
std: don't reference libc::O_NOFOLLOW on VxWorks in set_perm_nofollow#162065physwkim wants to merge 3 commits into
libc::O_NOFOLLOW on VxWorks in set_perm_nofollow#162065Conversation
|
r? @ChrisDenton rustbot has assigned @ChrisDenton. Use Why was this reviewer chosen?The reviewer was selected based on:
|
This comment has been minimized.
This comment has been minimized.
…low` VxWorks' libc defines no `O_NOFOLLOW` (the platform's <sys/fcntlcom.h> stops at `O_CLOEXEC`), but the `set_permissions_nofollow` refactor that consolidated the implementation into `sys/fs/unix.rs` dropped the `not(target_os = "vxworks")` guard the old `sys/fs/mod.rs` implementation carried, so `-Zbuild-std` for `x86_64-wrs-vxworks` fails with E0425 at the `custom_flags(libc::O_NOFOLLOW)` call. The target is tier 3 and not built in CI, so this went unnoticed. VxWorks has symbolic links (`O_NOLINK`), unlike ESP-IDF/Horizon, so it cannot skip `O_NOFOLLOW` and follow silently; return `Unsupported` instead, matching the Android stub and the previous behavior.
4e8c17a to
74a9f8c
Compare
There was a problem hiding this comment.
I can't verify on-target that VxWorks honors AT_SYMLINK_NOFOLLOW, so this only restores the build with conservative semantics.
It would be nice to verify this one way or another, even if we don't implement it just yet. cc @biabbas @hax0kartik
Co-authored-by: Chris Denton <chris@chrisdenton.dev>
|
Tested on VxWorks 7 under QEMU: |
set_permissions_nofollowwas consolidated intosys/fs/unix.rs::set_perm_nofollowby #160170, which dropped thenot(target_os = "vxworks")guard the previoussys/fs/mod.rsimplementation carried. VxWorks' libc defines noO_NOFOLLOW(the platform's<sys/fcntlcom.h>stops atO_CLOEXEC, andrust-lang/libccorrectly does not bind it forvxworks), so buildingstdforx86_64-wrs-vxworksnow fails:x86_64-wrs-vxworksis tier 3 and isn't built in CI, so this wasn't caught.set_perm_nofollowis the onlyO_NOFOLLOWreference compiled for VxWorks — theremove_dir_all"modern" path already listsvxworksin its fallback set, and the remaining occurrences are a doc example and comments.Unlike ESP-IDF and Horizon (which skip
O_NOFOLLOWbecause their filesystems have no symbolic links), VxWorks does have symlinks, so it can't just dropO_NOFOLLOWand follow the link silently. This returnsErrorKind::Unsupported, matching the existing Android stub.Unsupportedis the platform-correct resultVerified on-target against the shipped VxWorks 7 SDK (
wrsdk-vxworks7-qemu-1.17.0, the QEMU BSP). VxWorks has no way to express a no-follow permission change:O_NOFOLLOW. The only related flag isO_NOLINK("open the symlink itself"), which is different semantics and not what theopen+fchmodpath wants.fchmodatis provided — by the UTILS_UNIX component inlibunix, not corelibc— andAT_SYMLINK_NOFOLLOWis defined as0x100. But the shippedlibunix.sorejects the flag withENOTSUP:So
fchmodat(.., AT_SYMLINK_NOFOLLOW)returns-1/ENOTSUP, andflag == 0degrades tochmod, which follows symlinks. Afchmodat-based implementation is not viable on this release — the platform's ownfchmodatreportsENOTSUPfor exactly this request, which is whyUnsupportedis correct rather than merely conservative. cc @biabbas @hax0kartikBuild verification
On
1.100.0-nightly (908501772 2026-08-30)+rust-src(stocklibc0.2.189):cargo +nightly build -Zbuild-std=std,panic_abort --target x86_64-wrs-vxworksfails with the E0425 above (1 error).