From cb5e3df331e1684fd591c95658c033aed368175d Mon Sep 17 00:00:00 2001 From: Sang-Woo Kim Date: Tue, 1 Sep 2026 08:43:32 +0000 Subject: [PATCH] std: don't reference `libc::O_NOFOLLOW` on VxWorks in `set_perm_nofollow` VxWorks' libc defines no `O_NOFOLLOW`, so building std for x86_64-wrs-vxworks stopped compiling once `set_perm_nofollow` was consolidated into `sys/fs/unix.rs` without a vxworks guard. VxWorks also has no way to express a no-follow permission change: its `fchmodat` rejects `AT_SYMLINK_NOFOLLOW` with `ENOTSUP`. Return `Unsupported`, matching the existing Android stub. --- library/std/src/sys/fs/unix.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/library/std/src/sys/fs/unix.rs b/library/std/src/sys/fs/unix.rs index 1045a7b7e2f56..acd2c7f5dfbd1 100644 --- a/library/std/src/sys/fs/unix.rs +++ b/library/std/src/sys/fs/unix.rs @@ -1884,6 +1884,13 @@ pub fn set_perm(p: &CStr, perm: FilePermissions) -> io::Result<()> { cvt_r(|| unsafe { libc::chmod(p.as_ptr(), perm.mode) }).map(|_| ()) } +#[cfg(target_os = "vxworks")] +pub fn set_perm_nofollow(_p: &CStr, _perm: FilePermissions) -> io::Result<()> { + // VxWorks has no `O_NOFOLLOW`, and its `fchmodat` rejects + // `AT_SYMLINK_NOFOLLOW` with `ENOTSUP`, so a no-follow chmod is unsupported. + Err(crate::io::ErrorKind::Unsupported.into()) +} + #[cfg(target_os = "android")] pub fn set_perm_nofollow(_p: &CStr, _perm: FilePermissions) -> io::Result<()> { // Currently Android seems to be having inconsistent behavior with fchmodat @@ -1896,7 +1903,7 @@ pub fn set_perm_nofollow(_p: &CStr, _perm: FilePermissions) -> io::Result<()> { Err(crate::io::ErrorKind::Unsupported.into()) } -#[cfg(not(target_os = "android"))] +#[cfg(not(any(target_os = "android", target_os = "vxworks")))] pub fn set_perm_nofollow(p: &CStr, perm: FilePermissions) -> io::Result<()> { #[inline] /// Helper function for fallback open with `O_NOFOLLOW` + `fchmod` behavior