diff --git a/library/std/src/os/unix/fs.rs b/library/std/src/os/unix/fs.rs index 970023d8..9e5903ca 100644 --- a/library/std/src/os/unix/fs.rs +++ b/library/std/src/os/unix/fs.rs @@ -1040,6 +1040,7 @@ pub fn fchown(fd: F, uid: Option, gid: Option) -> io::Result< /// } /// ``` #[stable(feature = "unix_chown", since = "1.73.0")] +#[cfg(not(any(target_os = "vxworks")))] pub fn lchown>(dir: P, uid: Option, gid: Option) -> io::Result<()> { sys::fs::lchown(dir.as_ref(), uid.unwrap_or(u32::MAX), gid.unwrap_or(u32::MAX)) } diff --git a/library/std/src/os/unix/net/listener.rs b/library/std/src/os/unix/net/listener.rs index 7e53acbc..d4a04a09 100644 --- a/library/std/src/os/unix/net/listener.rs +++ b/library/std/src/os/unix/net/listener.rs @@ -97,7 +97,7 @@ pub fn bind>(path: P) -> io::Result { target_os = "espidf", target_os = "horizon" )))] - const backlog: libc::c_int = libc::SOMAXCONN; + const backlog: libc::c_int = 128; cvt(libc::bind( inner.as_inner().as_raw_fd(), diff --git a/library/std/src/sys/pal/unix/fd.rs b/library/std/src/sys/pal/unix/fd.rs index 203c7180..a9e8833b 100644 --- a/library/std/src/sys/pal/unix/fd.rs +++ b/library/std/src/sys/pal/unix/fd.rs @@ -119,6 +119,7 @@ pub fn read_to_end(&self, buf: &mut Vec) -> io::Result { (&mut me).read_to_end(buf) } + #[allow(unused_unsafe)] pub fn read_at(&self, buf: &mut [u8], offset: u64) -> io::Result { #[cfg(not(any( all(target_os = "linux", not(target_env = "musl")), @@ -312,6 +313,7 @@ pub fn is_write_vectored(&self) -> bool { cfg!(not(any(target_os = "espidf", target_os = "horizon", target_os = "vita"))) } + #[allow(unused_unsafe)] pub fn write_at(&self, buf: &[u8], offset: u64) -> io::Result { #[cfg(not(any( all(target_os = "linux", not(target_env = "musl")), diff --git a/library/std/src/sys/pal/unix/fs.rs b/library/std/src/sys/pal/unix/fs.rs index c37332ac..d950a52e 100644 --- a/library/std/src/sys/pal/unix/fs.rs +++ b/library/std/src/sys/pal/unix/fs.rs @@ -1351,7 +1351,7 @@ pub fn set_permissions(&self, perm: FilePermissions) -> io::Result<()> { } pub fn set_times(&self, times: FileTimes) -> io::Result<()> { - #[cfg(not(any(target_os = "redox", target_os = "espidf", target_os = "horizon")))] + #[cfg(not(any(target_os = "redox", target_os = "espidf", target_os = "horizon", target_os = "vxworks")))] let to_timespec = |time: Option| match time { Some(time) if let Some(ts) = time.t.to_timespec() => Ok(ts), Some(time) if time > crate::sys::time::UNIX_EPOCH => Err(io::const_io_error!( @@ -1365,7 +1365,7 @@ pub fn set_times(&self, times: FileTimes) -> io::Result<()> { None => Ok(libc::timespec { tv_sec: 0, tv_nsec: libc::UTIME_OMIT as _ }), }; cfg_if::cfg_if! { - if #[cfg(any(target_os = "redox", target_os = "espidf", target_os = "horizon"))] { + if #[cfg(any(target_os = "redox", target_os = "espidf", target_os = "horizon", target_os = "vxworks"))] { // Redox doesn't appear to support `UTIME_OMIT`. // ESP-IDF and HorizonOS do not support `futimens` at all and the behavior for those OS is therefore // the same as for Redox. @@ -1688,7 +1688,7 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.write_char(if mode & libc::S_IROTH != 0 { 'r' } else { '-' })?; f.write_char(if mode & libc::S_IWOTH != 0 { 'w' } else { '-' })?; let other_executable = mode & libc::S_IXOTH != 0; - let sticky = mode as c_int & libc::S_ISVTX as c_int != 0; + let sticky = mode as c_int & 0o1000 as c_int != 0; f.write_char(match (entry_type, other_executable, sticky) { ('d', true, true) => 't', // searchable and restricted deletion ('d', false, true) => 'T', // restricted deletion @@ -2040,6 +2040,7 @@ pub fn fchown(fd: c_int, uid: u32, gid: u32) -> io::Result<()> { Ok(()) } +#[cfg(not(any(target_os = "vxworks")))] pub fn lchown(path: &Path, uid: u32, gid: u32) -> io::Result<()> { run_path_with_cstr(path, &|path| { cvt(unsafe { libc::lchown(path.as_ptr(), uid as libc::uid_t, gid as libc::gid_t) }) @@ -2061,6 +2062,7 @@ pub fn chroot(dir: &Path) -> io::Result<()> { target_os = "horizon", target_os = "vita", target_os = "nto", + target_os = "vxworks", miri ))] mod remove_dir_impl { @@ -2074,6 +2076,7 @@ mod remove_dir_impl { target_os = "horizon", target_os = "vita", target_os = "nto", + target_os = "vxworks", miri )))] mod remove_dir_impl { diff --git a/library/std/src/sys/pal/unix/mod.rs b/library/std/src/sys/pal/unix/mod.rs index 3ef43a92..313af856 100644 --- a/library/std/src/sys/pal/unix/mod.rs +++ b/library/std/src/sys/pal/unix/mod.rs @@ -168,6 +168,7 @@ unsafe fn reset_sigpipe(#[allow(unused_variables)] sigpipe: u8) { target_os = "emscripten", target_os = "fuchsia", target_os = "horizon", + target_os = "vxworks", // Unikraft's `signal` implementation is currently broken: // https://github.com/unikraft/lib-musl/issues/57 target_vendor = "unikraft", @@ -213,6 +214,7 @@ mod sigpipe { target_os = "emscripten", target_os = "fuchsia", target_os = "horizon", + target_os = "vxworks", )))] static UNIX_SIGPIPE_ATTR_SPECIFIED: crate::sync::atomic::AtomicBool = crate::sync::atomic::AtomicBool::new(false); @@ -222,6 +224,7 @@ mod sigpipe { target_os = "emscripten", target_os = "fuchsia", target_os = "horizon", + target_os = "vxworks", )))] pub(crate) fn unix_sigpipe_attr_specified() -> bool { UNIX_SIGPIPE_ATTR_SPECIFIED.load(crate::sync::atomic::Ordering::Relaxed) diff --git a/library/std/src/sys/pal/unix/net.rs b/library/std/src/sys/pal/unix/net.rs index 7237989c..c63e8678 100644 --- a/library/std/src/sys/pal/unix/net.rs +++ b/library/std/src/sys/pal/unix/net.rs @@ -206,15 +206,9 @@ pub fn connect_timeout(&self, addr: &SocketAddr, timeout: Duration) -> io::Resul } 0 => {} _ => { - // linux returns POLLOUT|POLLERR|POLLHUP for refused connections (!), so look - // for POLLHUP rather than read readiness - if pollfd.revents & libc::POLLHUP != 0 { - let e = self.take_error()?.unwrap_or_else(|| { - io::const_io_error!( - io::ErrorKind::Uncategorized, - "no error set after POLLHUP", - ) - }); + // Check if the connnection actually succeeded and return ok only when + // the socket is ready and no errors were found + if let Some(e) = self.take_error()? { return Err(e); } diff --git a/library/std/src/sys/pal/unix/process/process_vxworks.rs b/library/std/src/sys/pal/unix/process/process_vxworks.rs index 76179e09..655bcc63 100644 --- a/library/std/src/sys/pal/unix/process/process_vxworks.rs +++ b/library/std/src/sys/pal/unix/process/process_vxworks.rs @@ -1,10 +1,9 @@ use crate::fmt; -use crate::io::{self, Error, ErrorKind}; +use crate::io::{self, ErrorKind}; use crate::num::NonZero; use crate::sys; use crate::sys::cvt; use crate::sys::process::process_common::*; -use crate::sys_common::thread; use libc::RTP_ID; use libc::{self, c_char, c_int}; @@ -68,7 +67,7 @@ macro_rules! t { .as_ref() .map(|c| c.as_ptr()) .unwrap_or_else(|| *sys::os::environ() as *const _); - let stack_size = thread::min_stack(); + let stack_size = libc::PTHREAD_STACK_MIN; // ensure that access to the environment is synchronized let _lock = sys::os::env_read_lock();