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.
This commit is contained in:
Sang-Woo Kim
2026-09-01 08:43:32 +00:00
parent 45f215f136
commit cb5e3df331

View File

@@ -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