diff --git a/build.rs b/build.rs index 70adacbd1f..e45985c111 100644 --- a/build.rs +++ b/build.rs @@ -15,11 +15,12 @@ fn main() { watchos: { target_os = "watchos" }, tvos: { target_os = "tvos" }, visionos: { target_os = "visionos" }, + nto_qnx: { target_os = "nto"}, // cfg aliases we would like to use apple_targets: { any(ios, macos, watchos, tvos, visionos) }, - bsd: { any(freebsd, dragonfly, netbsd, openbsd, apple_targets) }, + bsd: { any(freebsd, dragonfly, netbsd, openbsd, apple_targets, nto_qnx) }, bsd_without_apple: { any(freebsd, dragonfly, netbsd, openbsd) }, linux_android: { any(android, linux) }, freebsdlike: { any(dragonfly, freebsd) }, diff --git a/src/dir.rs b/src/dir.rs index 20c5593702..c0b3bcb6a3 100644 --- a/src/dir.rs +++ b/src/dir.rs @@ -228,6 +228,7 @@ impl Entry { target_os = "emscripten", target_os = "fuchsia", target_os = "haiku", + target_os = "nto", target_os = "hurd", solarish, linux_android, @@ -250,7 +251,12 @@ impl Entry { /// notably, some Linux filesystems don't implement this. The caller should use `stat` or /// `fstat` if this returns `None`. pub fn file_type(&self) -> Option { - #[cfg(not(any(solarish, target_os = "aix", target_os = "haiku")))] + #[cfg(not(any( + solarish, + target_os = "aix", + target_os = "haiku", + target_os = "nto", + )))] match self.0.d_type { libc::DT_FIFO => Some(Type::Fifo), libc::DT_CHR => Some(Type::CharacterDevice), @@ -263,7 +269,12 @@ impl Entry { } // illumos, Solaris, and Haiku systems do not have the d_type member at all: - #[cfg(any(solarish, target_os = "aix", target_os = "haiku"))] + #[cfg(any( + solarish, + target_os = "aix", + target_os = "haiku", + target_os = "nto", + ))] None } } diff --git a/src/errno.rs b/src/errno.rs index 2e74a84454..c83986a0a8 100644 --- a/src/errno.rs +++ b/src/errno.rs @@ -48,6 +48,10 @@ cfg_if! { unsafe fn errno_location() -> *mut c_int { unsafe { libc::_Errno() } } + } else if #[cfg(target_os = "nto")] { + unsafe fn errno_location() -> *mut c_int { + unsafe { libc::__get_errno_ptr() } + } } } @@ -603,10 +607,20 @@ fn desc(errno: Errno) -> &'static str { #[cfg(freebsdlike)] EDOOFUS => "Programming error", - #[cfg(any(freebsdlike, target_os = "hurd", target_os = "redox"))] + #[cfg(any( + freebsdlike, + target_os = "hurd", + target_os = "redox", + target_os = "nto", + ))] EMULTIHOP => "Multihop attempted", - #[cfg(any(freebsdlike, target_os = "hurd", target_os = "redox"))] + #[cfg(any( + freebsdlike, + target_os = "hurd", + target_os = "redox", + target_os = "nto", + ))] ENOLINK => "Link has been severed", #[cfg(target_os = "freebsd")] @@ -615,7 +629,7 @@ fn desc(errno: Errno) -> &'static str { #[cfg(target_os = "freebsd")] ECAPMODE => "Not permitted in capability mode", - #[cfg(any(bsd, target_os = "hurd"))] + #[cfg(all(not(target_os = "nto"), any(bsd, target_os = "hurd")))] ENEEDAUTH => "Need authenticator", #[cfg(any(bsd, target_os = "redox", solarish))] @@ -627,17 +641,19 @@ fn desc(errno: Errno) -> &'static str { target_os = "netbsd", target_os = "redox", target_os = "haiku", + target_os = "nto", target_os = "hurd" ))] EILSEQ => "Illegal byte sequence", - #[cfg(any(bsd, target_os = "haiku"))] + #[cfg(all(not(target_os = "nto"), any(bsd, target_os = "haiku")))] ENOATTR => "Attribute not found", #[cfg(any( bsd, target_os = "redox", target_os = "haiku", + target_os = "nto", target_os = "hurd" ))] EBADMSG => "Bad message", @@ -670,7 +686,10 @@ fn desc(errno: Errno) -> &'static str { ))] ENOTSUP => "Operation not supported", - #[cfg(any(bsd, target_os = "aix", target_os = "hurd"))] + #[cfg(all( + not(target_os = "nto"), + any(bsd, target_os = "aix", target_os = "hurd") + ))] EPROCLIM => "Too many processes", #[cfg(any( @@ -718,10 +737,10 @@ fn desc(errno: Errno) -> &'static str { #[cfg(any(bsd, target_os = "hurd"))] EPROCUNAVAIL => "Bad procedure for program", - #[cfg(any(bsd, target_os = "hurd"))] + #[cfg(all(not(target_os = "nto"), any(bsd, target_os = "hurd")))] EFTYPE => "Inappropriate file type or format", - #[cfg(any(bsd, target_os = "hurd"))] + #[cfg(all(not(target_os = "nto"), any(bsd, target_os = "hurd")))] EAUTH => "Authentication error", #[cfg(any( @@ -757,7 +776,8 @@ fn desc(errno: Errno) -> &'static str { apple_targets, target_os = "aix", target_os = "netbsd", - target_os = "redox" + target_os = "redox", + target_os = "nto", ))] ENODATA => "No message available on STREAM", @@ -768,7 +788,8 @@ fn desc(errno: Errno) -> &'static str { apple_targets, target_os = "aix", target_os = "netbsd", - target_os = "redox" + target_os = "redox", + target_os = "nto", ))] ENOSR => "No STREAM resources", @@ -776,7 +797,8 @@ fn desc(errno: Errno) -> &'static str { apple_targets, target_os = "aix", target_os = "netbsd", - target_os = "redox" + target_os = "redox", + target_os = "nto", ))] ENOSTR => "Not a STREAM", @@ -784,7 +806,8 @@ fn desc(errno: Errno) -> &'static str { apple_targets, target_os = "aix", target_os = "netbsd", - target_os = "redox" + target_os = "redox", + target_os = "nto", ))] ETIME => "STREAM ioctl timeout", @@ -797,7 +820,11 @@ fn desc(errno: Errno) -> &'static str { #[cfg(apple_targets)] EQFULL => "Interface output queue is full", - #[cfg(any(target_os = "openbsd", target_os = "hurd"))] + #[cfg(any( + target_os = "openbsd", + target_os = "hurd", + target_os = "nto", + ))] EOPNOTSUPP => "Operation not supported", #[cfg(target_os = "openbsd")] @@ -3334,3 +3361,212 @@ mod consts { } } } + +#[cfg(target_os = "nto")] +mod consts { + #[derive(Clone, Copy, Debug, Eq, PartialEq)] + #[repr(i32)] + #[non_exhaustive] + pub enum Errno { + UnknownErrno = 0, + EPERM = libc::EPERM, + ENOENT = libc::ENOENT, + ESRCH = libc::ESRCH, + EINTR = libc::EINTR, + EIO = libc::EIO, + ENXIO = libc::ENXIO, + E2BIG = libc::E2BIG, + ENOEXEC = libc::ENOEXEC, + EBADF = libc::EBADF, + ECHILD = libc::ECHILD, + EDEADLK = libc::EDEADLK, + ENOMEM = libc::ENOMEM, + EACCES = libc::EACCES, + EFAULT = libc::EFAULT, + ENOTBLK = libc::ENOTBLK, + EBUSY = libc::EBUSY, + EEXIST = libc::EEXIST, + EXDEV = libc::EXDEV, + ENODEV = libc::ENODEV, + ENOTDIR = libc::ENOTDIR, + EISDIR = libc::EISDIR, + EINVAL = libc::EINVAL, + ENFILE = libc::ENFILE, + EMFILE = libc::EMFILE, + ENOTTY = libc::ENOTTY, + ETXTBSY = libc::ETXTBSY, + EFBIG = libc::EFBIG, + ENOSPC = libc::ENOSPC, + ESPIPE = libc::ESPIPE, + EROFS = libc::EROFS, + EMLINK = libc::EMLINK, + EPIPE = libc::EPIPE, + EDOM = libc::EDOM, + ERANGE = libc::ERANGE, + EAGAIN = libc::EAGAIN, + EINPROGRESS = libc::EINPROGRESS, + EALREADY = libc::EALREADY, + ENOTSOCK = libc::ENOTSOCK, + EDESTADDRREQ = libc::EDESTADDRREQ, + EMSGSIZE = libc::EMSGSIZE, + EPROTOTYPE = libc::EPROTOTYPE, + ENOPROTOOPT = libc::ENOPROTOOPT, + EPROTONOSUPPORT = libc::EPROTONOSUPPORT, + ESOCKTNOSUPPORT = libc::ESOCKTNOSUPPORT, + EOPNOTSUPP = libc::EOPNOTSUPP, + EPFNOSUPPORT = libc::EPFNOSUPPORT, + EAFNOSUPPORT = libc::EAFNOSUPPORT, + EADDRINUSE = libc::EADDRINUSE, + EADDRNOTAVAIL = libc::EADDRNOTAVAIL, + ENETDOWN = libc::ENETDOWN, + ENETUNREACH = libc::ENETUNREACH, + ENETRESET = libc::ENETRESET, + ECONNABORTED = libc::ECONNABORTED, + ECONNRESET = libc::ECONNRESET, + ENOBUFS = libc::ENOBUFS, + EISCONN = libc::EISCONN, + ENOTCONN = libc::ENOTCONN, + ESHUTDOWN = libc::ESHUTDOWN, + ETOOMANYREFS = libc::ETOOMANYREFS, + ETIMEDOUT = libc::ETIMEDOUT, + ECONNREFUSED = libc::ECONNREFUSED, + ELOOP = libc::ELOOP, + ENAMETOOLONG = libc::ENAMETOOLONG, + EHOSTDOWN = libc::EHOSTDOWN, + EHOSTUNREACH = libc::EHOSTUNREACH, + ENOTEMPTY = libc::ENOTEMPTY, + EUSERS = libc::EUSERS, + EDQUOT = libc::EDQUOT, + ESTALE = libc::ESTALE, + EREMOTE = libc::EREMOTE, + EBADRPC = libc::EBADRPC, + ERPCMISMATCH = libc::ERPCMISMATCH, + EPROGUNAVAIL = libc::EPROGUNAVAIL, + EPROGMISMATCH = libc::EPROGMISMATCH, + EPROCUNAVAIL = libc::EPROCUNAVAIL, + ENOLCK = libc::ENOLCK, + ENOSYS = libc::ENOSYS, + EIDRM = libc::EIDRM, + ENOMSG = libc::ENOMSG, + EOVERFLOW = libc::EOVERFLOW, + EILSEQ = libc::EILSEQ, + ENOTSUP = libc::ENOTSUP, + ECANCELED = libc::ECANCELED, + EBADMSG = libc::EBADMSG, + ENODATA = libc::ENODATA, + ENOSR = libc::ENOSR, + ENOSTR = libc::ENOSTR, + ETIME = libc::ETIME, + EMULTIHOP = libc::EMULTIHOP, + ENOLINK = libc::ENOLINK, + EPROTO = libc::EPROTO, + } + + impl Errno { + pub const ELAST: Errno = Errno::ENOTSUP; + pub const EWOULDBLOCK: Errno = Errno::EAGAIN; + } + + #[deprecated( + since = "0.28.0", + note = "please use `Errno::from_raw()` instead" + )] + pub const fn from_i32(e: i32) -> Errno { + use self::Errno::*; + + match e { + libc::EPERM => EPERM, + libc::ENOENT => ENOENT, + libc::ESRCH => ESRCH, + libc::EINTR => EINTR, + libc::EIO => EIO, + libc::ENXIO => ENXIO, + libc::E2BIG => E2BIG, + libc::ENOEXEC => ENOEXEC, + libc::EBADF => EBADF, + libc::ECHILD => ECHILD, + libc::EDEADLK => EDEADLK, + libc::ENOMEM => ENOMEM, + libc::EACCES => EACCES, + libc::EFAULT => EFAULT, + libc::ENOTBLK => ENOTBLK, + libc::EBUSY => EBUSY, + libc::EEXIST => EEXIST, + libc::EXDEV => EXDEV, + libc::ENODEV => ENODEV, + libc::ENOTDIR => ENOTDIR, + libc::EISDIR => EISDIR, + libc::EINVAL => EINVAL, + libc::ENFILE => ENFILE, + libc::EMFILE => EMFILE, + libc::ENOTTY => ENOTTY, + libc::ETXTBSY => ETXTBSY, + libc::EFBIG => EFBIG, + libc::ENOSPC => ENOSPC, + libc::ESPIPE => ESPIPE, + libc::EROFS => EROFS, + libc::EMLINK => EMLINK, + libc::EPIPE => EPIPE, + libc::EDOM => EDOM, + libc::ERANGE => ERANGE, + libc::EAGAIN => EAGAIN, + libc::EINPROGRESS => EINPROGRESS, + libc::EALREADY => EALREADY, + libc::ENOTSOCK => ENOTSOCK, + libc::EDESTADDRREQ => EDESTADDRREQ, + libc::EMSGSIZE => EMSGSIZE, + libc::EPROTOTYPE => EPROTOTYPE, + libc::ENOPROTOOPT => ENOPROTOOPT, + libc::EPROTONOSUPPORT => EPROTONOSUPPORT, + libc::ESOCKTNOSUPPORT => ESOCKTNOSUPPORT, + libc::EOPNOTSUPP => EOPNOTSUPP, + libc::EPFNOSUPPORT => EPFNOSUPPORT, + libc::EAFNOSUPPORT => EAFNOSUPPORT, + libc::EADDRINUSE => EADDRINUSE, + libc::EADDRNOTAVAIL => EADDRNOTAVAIL, + libc::ENETDOWN => ENETDOWN, + libc::ENETUNREACH => ENETUNREACH, + libc::ENETRESET => ENETRESET, + libc::ECONNABORTED => ECONNABORTED, + libc::ECONNRESET => ECONNRESET, + libc::ENOBUFS => ENOBUFS, + libc::EISCONN => EISCONN, + libc::ENOTCONN => ENOTCONN, + libc::ESHUTDOWN => ESHUTDOWN, + libc::ETOOMANYREFS => ETOOMANYREFS, + libc::ETIMEDOUT => ETIMEDOUT, + libc::ECONNREFUSED => ECONNREFUSED, + libc::ELOOP => ELOOP, + libc::ENAMETOOLONG => ENAMETOOLONG, + libc::EHOSTDOWN => EHOSTDOWN, + libc::EHOSTUNREACH => EHOSTUNREACH, + libc::ENOTEMPTY => ENOTEMPTY, + libc::EUSERS => EUSERS, + libc::EDQUOT => EDQUOT, + libc::ESTALE => ESTALE, + libc::EREMOTE => EREMOTE, + libc::EBADRPC => EBADRPC, + libc::ERPCMISMATCH => ERPCMISMATCH, + libc::EPROGUNAVAIL => EPROGUNAVAIL, + libc::EPROGMISMATCH => EPROGMISMATCH, + libc::EPROCUNAVAIL => EPROCUNAVAIL, + libc::ENOLCK => ENOLCK, + libc::ENOSYS => ENOSYS, + libc::EIDRM => EIDRM, + libc::ENOMSG => ENOMSG, + libc::EOVERFLOW => EOVERFLOW, + libc::EILSEQ => EILSEQ, + libc::ENOTSUP => ENOTSUP, + libc::ECANCELED => ECANCELED, + libc::EBADMSG => EBADMSG, + libc::ENODATA => ENODATA, + libc::ENOSR => ENOSR, + libc::ENOSTR => ENOSTR, + libc::ETIME => ETIME, + libc::EMULTIHOP => EMULTIHOP, + libc::ENOLINK => ENOLINK, + libc::EPROTO => EPROTO, + _ => UnknownErrno, + } + } +} diff --git a/src/fcntl.rs b/src/fcntl.rs index 043cdde473..2765b5c57d 100644 --- a/src/fcntl.rs +++ b/src/fcntl.rs @@ -38,7 +38,8 @@ use crate::{sys::stat::Mode, NixPath, Result}; target_os = "fuchsia", target_os = "wasi", target_env = "uclibc", - target_os = "freebsd" + target_os = "freebsd", + target_os = "nto", ))] #[cfg(feature = "fs")] pub use self::posix_fadvise::{posix_fadvise, PosixFadviseAdvice}; @@ -114,7 +115,7 @@ libc_bitflags!( /// If the specified path isn't a directory, fail. O_DIRECTORY; /// Implicitly follow each `write()` with an `fdatasync()`. - #[cfg(any(linux_android, apple_targets, netbsdlike))] + #[cfg(any(linux_android, apple_targets, netbsdlike, target_os = "nto",))] O_DSYNC; /// Error out if a file was not created. O_EXCL; @@ -162,7 +163,7 @@ libc_bitflags!( /// This should not be combined with `O_WRONLY` or `O_RDONLY`. O_RDWR; /// Similar to `O_DSYNC` but applies to `read`s instead. - #[cfg(any(target_os = "linux", netbsdlike))] + #[cfg(any(target_os = "linux", netbsdlike, target_os = "nto",))] O_RSYNC; /// Open directory for search only. Skip search permission checks on /// later `openat()` calls using the obtained file descriptor. @@ -458,13 +459,21 @@ fn readlink_maybe_at( match dirfd { #[cfg(target_os = "redox")] Some(_) => unreachable!(), - #[cfg(not(target_os = "redox"))] + #[cfg(not(any(target_os = "redox", target_os = "nto")))] Some(dirfd) => libc::readlinkat( dirfd, cstr.as_ptr(), v.as_mut_ptr().cast(), v.capacity() as size_t, ), + // On Neutrino QNX, libc::readlinkat returns an `int` instead of ssize_t + #[cfg(target_os = "nto")] + Some(dirfd) => libc::readlinkat( + dirfd, + cstr.as_ptr(), + v.as_mut_ptr().cast(), + v.capacity() as size_t, + ) as libc::ssize_t, None => libc::readlink( cstr.as_ptr(), v.as_mut_ptr().cast(), @@ -1323,7 +1332,8 @@ pub fn fspacectl_all( target_os = "fuchsia", target_os = "wasi", target_env = "uclibc", - target_os = "freebsd" + target_os = "freebsd", + target_os = "nto", ))] mod posix_fadvise { use crate::errno::Errno; @@ -1387,6 +1397,7 @@ mod posix_fadvise { target_os = "emscripten", target_os = "fuchsia", target_os = "wasi", + target_os = "nto", ))] pub fn posix_fallocate( fd: RawFd, diff --git a/src/features.rs b/src/features.rs index 0a0c618096..fce0703a81 100644 --- a/src/features.rs +++ b/src/features.rs @@ -116,7 +116,8 @@ mod os { apple_targets, target_os = "fuchsia", target_os = "haiku", - target_os = "solaris" + target_os = "solaris", + target_os = "nto", ))] mod os { /// Check if the OS supports atomic close-on-exec for sockets diff --git a/src/lib.rs b/src/lib.rs index c4c0fa53cc..7e9bbd5118 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -140,7 +140,12 @@ feature! { #![feature = "mount"] pub mod mount; } -#[cfg(any(freebsdlike, target_os = "linux", target_os = "netbsd"))] +#[cfg(any( + freebsdlike, + target_os = "linux", + target_os = "netbsd", + target_os = "nto", +))] feature! { #![feature = "mqueue"] pub mod mqueue; diff --git a/src/sys/mman.rs b/src/sys/mman.rs index a64f14f588..39c45ad91e 100644 --- a/src/sys/mman.rs +++ b/src/sys/mman.rs @@ -76,8 +76,8 @@ libc_bitflags! { MAP_LOCKED; /// Do not reserve swap space for this mapping. /// - /// This was removed in FreeBSD 11 and is unused in DragonFlyBSD. - #[cfg(not(any(freebsdlike, target_os = "aix", target_os = "hurd")))] + /// This was removed in FreeBSD 11 and is unused in DragonFlyBSD and QNX Neutrino. + #[cfg(not(any(freebsdlike, target_os = "aix", target_os = "hurd", target_os = "nto",)))] MAP_NORESERVE; /// Populate page tables for a mapping. #[cfg(linux_android)] @@ -206,6 +206,7 @@ libc_bitflags! { } } +#[cfg(not(target_os = "nto"))] libc_enum! { /// Usage information for a range of memory to allow for performance optimizations by the kernel. /// @@ -307,6 +308,27 @@ libc_enum! { } } +#[cfg(target_os = "nto")] +libc_enum! { + /// Usage information for a range of memory to allow for performance optimizations by the kernel. + /// + /// Used by [`madvise`](./fn.madvise.html). + #[repr(i32)] + #[non_exhaustive] + pub enum MmapAdvise { + /// No further special treatment. This is the default. + POSIX_MADV_NORMAL, + /// Expect random page references. + POSIX_MADV_RANDOM, + /// Expect sequential page references. + POSIX_MADV_SEQUENTIAL, + /// Expect access in the near future. + POSIX_MADV_WILLNEED, + /// Do not expect access in the near future. + POSIX_MADV_DONTNEED, + } +} + libc_bitflags! { /// Configuration flags for [`msync`]. pub struct MsFlags: c_int { @@ -523,10 +545,16 @@ pub unsafe fn madvise( length: size_t, advise: MmapAdvise, ) -> Result<()> { + #[cfg(not(target_os = "nto"))] unsafe { Errno::result(libc::madvise(addr.as_ptr(), length, advise as i32)) .map(drop) } + #[cfg(target_os = "nto")] + unsafe { + Errno::result(libc::posix_madvise(addr.as_ptr(), length, advise as i32)) + .map(drop) + } } /// Set protection of memory mapping. diff --git a/src/sys/resource.rs b/src/sys/resource.rs index 73d8a05e0f..8cb4b1f2d9 100644 --- a/src/sys/resource.rs +++ b/src/sys/resource.rs @@ -80,7 +80,7 @@ libc_enum! { /// this process may establish. RLIMIT_LOCKS, - #[cfg(any(linux_android, target_os = "freebsd", netbsdlike))] + #[cfg(any(linux_android, target_os = "freebsd", netbsdlike, target_os = "nto",))] /// The maximum size (in bytes) which a process may lock into memory /// using the mlock(2) system call. RLIMIT_MEMLOCK, @@ -100,6 +100,7 @@ libc_enum! { target_os = "freebsd", netbsdlike, target_os = "aix", + target_os = "nto", ))] /// The maximum number of simultaneous processes for this user id. RLIMIT_NPROC, diff --git a/src/sys/select.rs b/src/sys/select.rs index 64a8e258cf..7091ccf6f7 100644 --- a/src/sys/select.rs +++ b/src/sys/select.rs @@ -307,11 +307,25 @@ where let readfds = readfds.map(|set| set as *mut _ as *mut libc::fd_set).unwrap_or(null_mut()); let writefds = writefds.map(|set| set as *mut _ as *mut libc::fd_set).unwrap_or(null_mut()); let errorfds = errorfds.map(|set| set as *mut _ as *mut libc::fd_set).unwrap_or(null_mut()); - let timeout = timeout.map(|ts| ts.as_ref() as *const libc::timespec).unwrap_or(null()); let sigmask = sigmask.map(|sm| sm.as_ref() as *const libc::sigset_t).unwrap_or(null()); - let res = unsafe { - libc::pselect(nfds, readfds, writefds, errorfds, timeout, sigmask) + #[cfg(target_os = "nto")] + let res = match timeout { + Some(t) => { + let mut timeout = t.clone(); + unsafe {libc::pselect(nfds, readfds, writefds, errorfds, timeout.as_mut() as *mut libc::timespec, sigmask)} + }, + _ => { + unsafe {libc::pselect(nfds, readfds, writefds, errorfds, null_mut(), sigmask)} + }, + }; + + #[cfg(not(target_os = "nto"))] + let res = { + let timeout = timeout.map(|ts| ts.as_ref() as *const libc::timespec).unwrap_or(null()); + unsafe { + libc::pselect(nfds, readfds, writefds, errorfds, timeout, sigmask) + } }; Errno::result(res) diff --git a/src/sys/signal.rs b/src/sys/signal.rs index 2a9c0027a9..b9b9afaac4 100644 --- a/src/sys/signal.rs +++ b/src/sys/signal.rs @@ -102,7 +102,7 @@ libc_enum! { #[cfg(not(target_os = "haiku"))] SIGIO, #[cfg(any(linux_android, target_os = "emscripten", - target_os = "fuchsia", target_os = "aix"))] + target_os = "fuchsia", target_os = "aix", target_os = "nto",))] /// Power failure imminent. SIGPWR, /// Bad system call @@ -114,7 +114,7 @@ libc_enum! { SIGEMT, #[cfg(not(any(linux_android, target_os = "emscripten", target_os = "fuchsia", target_os = "redox", - target_os = "haiku", target_os = "aix")))] + target_os = "haiku", target_os = "aix", target_os = "nto",)))] /// Information request SIGINFO, } @@ -174,6 +174,7 @@ impl FromStr for Signal { linux_android, target_os = "emscripten", target_os = "fuchsia", + target_os = "nto", ))] "SIGPWR" => Signal::SIGPWR, "SIGSYS" => Signal::SIGSYS, @@ -191,7 +192,8 @@ impl FromStr for Signal { target_os = "fuchsia", target_os = "redox", target_os = "aix", - target_os = "haiku" + target_os = "haiku", + target_os = "nto", )))] "SIGINFO" => Signal::SIGINFO, _ => return Err(Errno::EINVAL), @@ -257,6 +259,7 @@ impl Signal { target_os = "emscripten", target_os = "fuchsia", target_os = "aix", + target_os = "nto", ))] Signal::SIGPWR => "SIGPWR", Signal::SIGSYS => "SIGSYS", @@ -274,7 +277,8 @@ impl Signal { target_os = "fuchsia", target_os = "redox", target_os = "aix", - target_os = "haiku" + target_os = "haiku", + target_os = "nto", )))] Signal::SIGINFO => "SIGINFO", } @@ -331,14 +335,17 @@ const SIGNALS: [Signal; 31] = [ SIGCONT, SIGSTOP, SIGTSTP, SIGTTIN, SIGTTOU, SIGURG, SIGXCPU, SIGXFSZ, SIGVTALRM, SIGPROF, SIGWINCH, SIGIO, SIGPWR, SIGSYS, ]; -#[cfg(all( - any(linux_android, target_os = "emscripten", target_os = "fuchsia"), - any( - target_arch = "mips", - target_arch = "mips32r6", - target_arch = "mips64", - target_arch = "mips64r6", - target_arch = "sparc64" +#[cfg(any( + target_os = "nto", + all( + any(linux_android, target_os = "emscripten", target_os = "fuchsia"), + any( + target_arch = "mips", + target_arch = "mips32r6", + target_arch = "mips64", + target_arch = "mips64r6", + target_arch = "sparc64" + ) ) ))] #[cfg(feature = "signal")] @@ -362,7 +369,8 @@ const SIGNALS: [Signal; 30] = [ target_os = "emscripten", target_os = "aix", target_os = "redox", - target_os = "haiku" + target_os = "haiku", + target_os = "nto", )))] #[cfg(feature = "signal")] const SIGNALS: [Signal; 31] = [ @@ -439,12 +447,14 @@ libc_bitflags! { SA_NODEFER; /// The system will deliver the signal to the process on a signal stack, /// specified by each thread with sigaltstack(2). + #[cfg(not(target_os = "nto"))] SA_ONSTACK; /// The handler is reset back to the default at the moment the signal is /// delivered. SA_RESETHAND; /// Requests that certain system calls restart if interrupted by this /// signal. See the man page for complete details. + #[cfg(not(target_os = "nto"))] SA_RESTART; /// This flag is controlled internally by Nix. SA_SIGINFO; diff --git a/src/sys/socket/addr.rs b/src/sys/socket/addr.rs index aa89ba9723..5c951c8221 100644 --- a/src/sys/socket/addr.rs +++ b/src/sys/socket/addr.rs @@ -5,6 +5,7 @@ target_os = "haiku", target_os = "fuchsia", target_os = "aix", + target_os = "nto", ))] #[cfg(feature = "net")] pub use self::datalink::LinkAddr; @@ -824,7 +825,7 @@ impl SockaddrIn { bsd, target_os = "aix", target_os = "haiku", - target_os = "hurd" + target_os = "hurd", ))] sin_len: Self::size() as u8, sin_family: AddressFamily::Inet as sa_family_t, @@ -898,7 +899,8 @@ impl From for SockaddrIn { bsd, target_os = "haiku", target_os = "hermit", - target_os = "hurd" + target_os = "hurd", + target_os = "nto", ))] sin_len: mem::size_of::() as u8, sin_family: AddressFamily::Inet as sa_family_t, @@ -1050,7 +1052,8 @@ impl From for SockaddrIn6 { bsd, target_os = "haiku", target_os = "hermit", - target_os = "hurd" + target_os = "hurd", + target_os = "nto", ))] sin6_len: mem::size_of::() as u8, sin6_family: AddressFamily::Inet6 as sa_family_t, diff --git a/src/sys/socket/mod.rs b/src/sys/socket/mod.rs index 3d1651bd3f..c321d3fde8 100644 --- a/src/sys/socket/mod.rs +++ b/src/sys/socket/mod.rs @@ -262,7 +262,8 @@ libc_bitflags! { #[cfg(any(linux_android, freebsdlike, netbsdlike, - solarish))] + solarish, + target_os = "nto",))] SOCK_CLOEXEC; /// Return `EPIPE` instead of raising `SIGPIPE` #[cfg(target_os = "netbsd")] @@ -468,6 +469,46 @@ cfg_if! { UnixCredentials(cred) } } + } else if #[cfg(target_os = "nto")] { + /// Unix credentials of the sending process. + /// + /// This struct is used with the `SCM_CREDS` ancillary message for UNIX sockets. + #[repr(transparent)] + #[derive(Clone, Copy, Debug, Eq, PartialEq)] + pub struct UnixCredentials(libc::sockcred); + + impl UnixCredentials { + /// Returns the real user identifier + pub fn uid(&self) -> libc::uid_t { + self.0.sc_uid + } + + /// Returns the effective user identifier + pub fn euid(&self) -> libc::uid_t { + self.0.sc_euid + } + + /// Returns the real group identifier + pub fn gid(&self) -> libc::gid_t { + self.0.sc_gid + } + + /// Returns the effective group identifier + pub fn egid(&self) -> libc::gid_t { + self.0.sc_egid + } + + /// Returns a list group identifiers (the first one being the effective GID) + pub fn groups(&self) -> &[libc::gid_t] { + unsafe { std::slice::from_raw_parts(self.0.sc_groups.as_ptr() as *const libc::gid_t, self.0.sc_ngroups as _) } + } + } + + impl From for UnixCredentials { + fn from(cred: libc::sockcred) -> Self { + UnixCredentials(cred) + } + } } } @@ -657,7 +698,7 @@ pub enum ControlMessageOwned { #[cfg(linux_android)] ScmCredentials(UnixCredentials), /// Received version of [`ControlMessage::ScmCreds`] - #[cfg(freebsdlike)] + #[cfg(any(freebsdlike, target_os = "nto"))] ScmCreds(UnixCredentials), /// A message of type `SCM_TIMESTAMP`, containing the time the /// packet was received by the kernel. @@ -737,7 +778,7 @@ pub enum ControlMessageOwned { /// [Further reading](https://man.freebsd.org/cgi/man.cgi?setsockopt) #[cfg(target_os = "freebsd")] ScmMonotonic(TimeSpec), - #[cfg(any(linux_android, apple_targets, target_os = "netbsd"))] + #[cfg(any(linux_android, apple_targets, target_os = "netbsd", target_os = "nto"))] #[cfg(feature = "net")] #[cfg_attr(docsrs, doc(cfg(feature = "net")))] Ipv4PacketInfo(libc::in_pktinfo), @@ -884,11 +925,12 @@ impl ControlMessageOwned { let cred: libc::cmsgcred = unsafe { ptr::read_unaligned(p as *const _) }; ControlMessageOwned::ScmCreds(cred.into()) } + #[cfg(target_os = "nto")] + (libc::SOL_SOCKET, libc::SCM_CREDS) => { + let cred: libc::sockcred = ptr::read_unaligned(p as *const _); + ControlMessageOwned::ScmCreds(cred.into()) + } #[cfg(not(any(target_os = "aix", target_os = "haiku")))] - (libc::SOL_SOCKET, libc::SCM_TIMESTAMP) => { - let tv: libc::timeval = unsafe { ptr::read_unaligned(p as *const _) }; - ControlMessageOwned::ScmTimestamp(TimeVal::from(tv)) - }, #[cfg(linux_android)] (libc::SOL_SOCKET, libc::SCM_TIMESTAMPNS) => { let ts: libc::timespec = unsafe { ptr::read_unaligned(p as *const _) }; @@ -916,13 +958,13 @@ impl ControlMessageOwned { let timestamping = Timestamps { system, hw_trans, hw_raw }; ControlMessageOwned::ScmTimestampsns(timestamping) } - #[cfg(any(target_os = "freebsd", linux_android, apple_targets))] + #[cfg(any(target_os = "freebsd", linux_android, apple_targets, target_os = "nto",))] #[cfg(feature = "net")] (libc::IPPROTO_IPV6, libc::IPV6_PKTINFO) => { let info = unsafe { ptr::read_unaligned(p as *const libc::in6_pktinfo) }; ControlMessageOwned::Ipv6PacketInfo(info) } - #[cfg(any(linux_android, apple_targets, target_os = "netbsd"))] + #[cfg(any(linux_android, apple_targets, target_os = "netbsd", target_os = "nto",))] #[cfg(feature = "net")] (libc::IPPROTO_IP, libc::IP_PKTINFO) => { let info = unsafe { ptr::read_unaligned(p as *const libc::in_pktinfo) }; @@ -1053,7 +1095,7 @@ pub enum ControlMessage<'a> { /// /// For further information, please refer to the /// [`unix(4)`](https://www.freebsd.org/cgi/man.cgi?query=unix) man page. - #[cfg(freebsdlike)] + #[cfg(any(freebsdlike, target_os = "nto",))] ScmCreds, /// Set IV for `AF_ALG` crypto API. @@ -1094,7 +1136,7 @@ pub enum ControlMessage<'a> { /// /// For further information, please refer to the /// [`ip(7)`](https://man7.org/linux/man-pages/man7/ip.7.html) man page. - #[cfg(any(linux_android, target_os = "netbsd", apple_targets))] + #[cfg(any(linux_android, target_os = "netbsd", apple_targets, target_os = "nto",))] #[cfg(feature = "net")] #[cfg_attr(docsrs, doc(cfg(feature = "net")))] Ipv4PacketInfo(&'a libc::in_pktinfo), @@ -1106,6 +1148,7 @@ pub enum ControlMessage<'a> { #[cfg(any(linux_android, target_os = "netbsd", target_os = "freebsd", + target_os = "nto", apple_targets))] #[cfg(feature = "net")] #[cfg_attr(docsrs, doc(cfg(feature = "net")))] @@ -1183,7 +1226,7 @@ impl<'a> ControlMessage<'a> { ControlMessage::ScmCredentials(creds) => { &creds.0 as *const libc::ucred as *const u8 } - #[cfg(freebsdlike)] + #[cfg(any(freebsdlike, target_os = "nto",))] ControlMessage::ScmCreds => { // The kernel overwrites the data, we just zero it // to make sure it's not uninitialized memory @@ -1228,7 +1271,7 @@ impl<'a> ControlMessage<'a> { ControlMessage::UdpGsoSegments(gso_size) => { gso_size as *const _ as *const u8 }, - #[cfg(any(linux_android, target_os = "netbsd", apple_targets))] + #[cfg(any(linux_android, target_os = "netbsd", apple_targets, target_os = "nto",))] #[cfg(feature = "net")] ControlMessage::Ipv4PacketInfo(info) => info as *const _ as *const u8, #[cfg(any(linux_android, target_os = "netbsd", @@ -1273,6 +1316,10 @@ impl<'a> ControlMessage<'a> { ControlMessage::ScmCreds => { mem::size_of::() } + #[cfg(target_os = "nto")] + ControlMessage::ScmCreds => { + mem::size_of::() + } #[cfg(linux_android)] ControlMessage::AlgSetIv(iv) => { mem::size_of::<&[u8]>() + iv.len() @@ -1290,11 +1337,11 @@ impl<'a> ControlMessage<'a> { ControlMessage::UdpGsoSegments(gso_size) => { mem::size_of_val(gso_size) }, - #[cfg(any(linux_android, target_os = "netbsd", apple_targets))] + #[cfg(any(linux_android, target_os = "netbsd", apple_targets, target_os = "nto",))] #[cfg(feature = "net")] ControlMessage::Ipv4PacketInfo(info) => mem::size_of_val(info), #[cfg(any(linux_android, target_os = "netbsd", - target_os = "freebsd", apple_targets))] + target_os = "freebsd", apple_targets, target_os = "nto",))] #[cfg(feature = "net")] ControlMessage::Ipv6PacketInfo(info) => mem::size_of_val(info), #[cfg(any(freebsdlike, netbsdlike))] @@ -1322,7 +1369,7 @@ impl<'a> ControlMessage<'a> { ControlMessage::ScmRights(_) => libc::SOL_SOCKET, #[cfg(linux_android)] ControlMessage::ScmCredentials(_) => libc::SOL_SOCKET, - #[cfg(freebsdlike)] + #[cfg(any(freebsdlike, target_os = "nto",))] ControlMessage::ScmCreds => libc::SOL_SOCKET, #[cfg(linux_android)] ControlMessage::AlgSetIv(_) | ControlMessage::AlgSetOp(_) | @@ -1330,11 +1377,11 @@ impl<'a> ControlMessage<'a> { #[cfg(target_os = "linux")] #[cfg(feature = "net")] ControlMessage::UdpGsoSegments(_) => libc::SOL_UDP, - #[cfg(any(linux_android, target_os = "netbsd", apple_targets))] + #[cfg(any(linux_android, target_os = "netbsd", apple_targets, target_os = "nto",))] #[cfg(feature = "net")] ControlMessage::Ipv4PacketInfo(_) => libc::IPPROTO_IP, #[cfg(any(linux_android, target_os = "netbsd", - target_os = "freebsd", apple_targets))] + target_os = "freebsd", apple_targets, target_os = "nto",))] #[cfg(feature = "net")] ControlMessage::Ipv6PacketInfo(_) => libc::IPPROTO_IPV6, #[cfg(any(freebsdlike, netbsdlike))] @@ -1356,7 +1403,7 @@ impl<'a> ControlMessage<'a> { ControlMessage::ScmRights(_) => libc::SCM_RIGHTS, #[cfg(linux_android)] ControlMessage::ScmCredentials(_) => libc::SCM_CREDENTIALS, - #[cfg(freebsdlike)] + #[cfg(any(freebsdlike, target_os = "nto",))] ControlMessage::ScmCreds => libc::SCM_CREDS, #[cfg(linux_android)] ControlMessage::AlgSetIv(_) => { @@ -1375,11 +1422,11 @@ impl<'a> ControlMessage<'a> { ControlMessage::UdpGsoSegments(_) => { libc::UDP_SEGMENT }, - #[cfg(any(linux_android, target_os = "netbsd", apple_targets))] + #[cfg(any(linux_android, target_os = "netbsd", apple_targets, target_os = "nto",))] #[cfg(feature = "net")] ControlMessage::Ipv4PacketInfo(_) => libc::IP_PKTINFO, #[cfg(any(linux_android, target_os = "netbsd", - target_os = "freebsd", apple_targets))] + target_os = "freebsd", apple_targets, target_os = "nto",))] #[cfg(feature = "net")] ControlMessage::Ipv6PacketInfo(_) => libc::IPV6_PKTINFO, #[cfg(any(freebsdlike, netbsdlike))] @@ -1558,7 +1605,7 @@ pub fn sendmmsg<'a, XS, AS, C, I, S>( } -#[cfg(any(linux_android, target_os = "freebsd", target_os = "netbsd"))] +#[cfg(any(linux_android, target_os = "freebsd", target_os = "netbsd", target_os = "nto",))] #[derive(Debug)] /// Preallocated structures needed for [`recvmmsg`] and [`sendmmsg`] functions pub struct MultiHeaders { @@ -1571,7 +1618,7 @@ pub struct MultiHeaders { msg_controllen: usize, } -#[cfg(any(linux_android, target_os = "freebsd", target_os = "netbsd"))] +#[cfg(any(linux_android, target_os = "freebsd", target_os = "netbsd", target_os = "nto",))] impl MultiHeaders { /// Preallocate structure used by [`recvmmsg`] and [`sendmmsg`] takes number of headers to preallocate /// @@ -1690,7 +1737,7 @@ where } /// Iterator over results of [`recvmmsg`]/[`sendmmsg`] -#[cfg(any(linux_android, target_os = "freebsd", target_os = "netbsd"))] +#[cfg(any(linux_android, target_os = "freebsd", target_os = "netbsd", target_os = "nto",))] #[derive(Debug)] pub struct MultiResults<'a, S> { // preallocated structures @@ -1699,7 +1746,7 @@ pub struct MultiResults<'a, S> { received: usize, } -#[cfg(any(linux_android, target_os = "freebsd", target_os = "netbsd"))] +#[cfg(any(linux_android, target_os = "freebsd", target_os = "netbsd", target_os = "nto",))] impl<'a, S> Iterator for MultiResults<'a, S> where S: Copy + SockaddrLike, diff --git a/src/sys/socket/sockopt.rs b/src/sys/socket/sockopt.rs index f66b54e1fa..c0072a9cd7 100644 --- a/src/sys/socket/sockopt.rs +++ b/src/sys/socket/sockopt.rs @@ -581,7 +581,8 @@ cfg_if! { #[cfg(not(any( target_os = "openbsd", target_os = "haiku", - target_os = "redox" + target_os = "redox", + target_os = "nto", )))] #[cfg(feature = "net")] sockopt_impl!( @@ -607,7 +608,8 @@ sockopt_impl!( #[cfg(not(any( target_os = "openbsd", target_os = "haiku", - target_os = "redox" + target_os = "redox", + target_os = "nto", )))] #[cfg(feature = "net")] sockopt_impl!( @@ -884,7 +886,7 @@ sockopt_impl!( libc::TCP_CONGESTION, OsString<[u8; TCP_CA_NAME_MAX]> ); -#[cfg(any(linux_android, apple_targets, target_os = "netbsd"))] +#[cfg(any(linux_android, apple_targets, target_os = "netbsd", target_os = "nto",))] #[cfg(feature = "net")] sockopt_impl!( #[cfg_attr(docsrs, doc(cfg(feature = "net")))] @@ -896,7 +898,7 @@ sockopt_impl!( libc::IP_PKTINFO, bool ); -#[cfg(any(linux_android, target_os = "freebsd", apple_targets, netbsdlike))] +#[cfg(any(linux_android, target_os = "freebsd", apple_targets, netbsdlike, target_os = "nto",))] #[cfg(feature = "net")] sockopt_impl!( #[cfg_attr(docsrs, doc(cfg(feature = "net")))] @@ -1026,7 +1028,7 @@ sockopt_impl!( libc::IP_MTU, libc::c_int ); -#[cfg(any(linux_android, target_os = "freebsd"))] +#[cfg(any(linux_android, target_os = "freebsd", target_os = "nto",))] sockopt_impl!( /// Set or retrieve the current time-to-live field that is used in every /// packet sent from this socket. @@ -1036,7 +1038,7 @@ sockopt_impl!( libc::IP_TTL, libc::c_int ); -#[cfg(any(apple_targets, linux_android, target_os = "freebsd"))] +#[cfg(any(apple_targets, linux_android, target_os = "freebsd", target_os = "nto",))] sockopt_impl!( /// Set the unicast hop limit for the socket. Ipv6Ttl, diff --git a/src/sys/termios.rs b/src/sys/termios.rs index e006c2f1b0..d9ee4045c4 100644 --- a/src/sys/termios.rs +++ b/src/sys/termios.rs @@ -299,7 +299,7 @@ libc_enum! { B115200, #[cfg(solarish)] B153600, - #[cfg(not(target_os = "aix"))] + #[cfg(not(any(target_os = "aix", target_os = "nto",)))] B230400, #[cfg(solarish)] B307200, @@ -425,7 +425,7 @@ libc_enum! { #[cfg(not(target_os = "haiku"))] VLNEXT, #[cfg(not(any(all(target_os = "linux", target_arch = "sparc64"), - solarish, target_os = "aix", target_os = "haiku")))] + solarish, target_os = "aix", target_os = "haiku", target_os = "nto",)))] VMIN, VQUIT, #[cfg(not(target_os = "haiku"))] @@ -437,10 +437,10 @@ libc_enum! { VSUSP, #[cfg(target_os = "linux")] VSWTC, - #[cfg(any(solarish, target_os = "haiku"))] + #[cfg(any(solarish, target_os = "haiku", target_os = "nto",))] VSWTCH, #[cfg(not(any(all(target_os = "linux", target_arch = "sparc64"), - solarish, target_os = "aix", target_os = "haiku")))] + solarish, target_os = "aix", target_os = "haiku", target_os = "nto",)))] VTIME, #[cfg(not(any(target_os = "aix", target_os = "haiku")))] VWERASE, @@ -482,7 +482,7 @@ libc_bitflags! { IXANY; #[cfg(not(any(target_os = "redox", target_os = "haiku")))] IMAXBEL; - #[cfg(any(linux_android, apple_targets))] + #[cfg(any(linux_android, apple_targets, target_os = "nto"))] IUTF8; } } @@ -493,7 +493,8 @@ libc_bitflags! { OPOST; #[cfg(any(linux_android, target_os = "haiku", - target_os = "openbsd"))] + target_os = "openbsd", + target_os = "nto",))] OLCUC; ONLCR; OCRNL as tcflag_t; @@ -501,74 +502,91 @@ libc_bitflags! { ONLRET as tcflag_t; #[cfg(any(linux_android, target_os = "haiku", - apple_targets))] + apple_targets, + target_os = "nto",))] OFDEL as tcflag_t; #[cfg(any(linux_android, target_os = "haiku", - apple_targets))] + apple_targets, + target_os = "nto",))] NL0 as tcflag_t; #[cfg(any(linux_android, target_os = "haiku", + target_os = "nto", apple_targets))] NL1 as tcflag_t; #[cfg(any(linux_android, target_os = "haiku", + target_os = "nto", apple_targets))] CR0 as tcflag_t; #[cfg(any(linux_android, target_os = "haiku", + target_os = "nto", apple_targets))] CR1 as tcflag_t; #[cfg(any(linux_android, target_os = "haiku", + target_os = "nto", apple_targets))] CR2 as tcflag_t; #[cfg(any(linux_android, target_os = "haiku", + target_os = "nto", apple_targets))] CR3 as tcflag_t; #[cfg(any(linux_android, target_os = "freebsd", target_os = "haiku", + target_os = "nto", apple_targets))] TAB0 as tcflag_t; #[cfg(any(linux_android, target_os = "haiku", + target_os = "nto", apple_targets))] TAB1 as tcflag_t; #[cfg(any(linux_android, target_os = "haiku", + target_os = "nto", apple_targets))] TAB2 as tcflag_t; #[cfg(any(linux_android, target_os = "freebsd", target_os = "haiku", + target_os = "nto", apple_targets))] TAB3 as tcflag_t; #[cfg(linux_android)] XTABS; #[cfg(any(linux_android, target_os = "haiku", + target_os = "nto", apple_targets))] BS0 as tcflag_t; #[cfg(any(linux_android, target_os = "haiku", + target_os = "nto", apple_targets))] BS1 as tcflag_t; #[cfg(any(linux_android, target_os = "haiku", + target_os = "nto", apple_targets))] VT0 as tcflag_t; #[cfg(any(linux_android, target_os = "haiku", + target_os = "nto", apple_targets))] VT1 as tcflag_t; #[cfg(any(linux_android, target_os = "haiku", + target_os = "nto", apple_targets))] FF0 as tcflag_t; #[cfg(any(linux_android, target_os = "haiku", + target_os = "nto", apple_targets))] FF1 as tcflag_t; #[cfg(bsd)] @@ -582,27 +600,33 @@ libc_bitflags! { #[cfg(any(linux_android, target_os = "haiku", + target_os = "nto", apple_targets))] NLDLY as tcflag_t; // FIXME: Datatype needs to be corrected in libc for mac #[cfg(any(linux_android, target_os = "haiku", + target_os = "nto", apple_targets))] CRDLY as tcflag_t; #[cfg(any(linux_android, target_os = "freebsd", target_os = "haiku", + target_os = "nto", apple_targets))] TABDLY as tcflag_t; #[cfg(any(linux_android, target_os = "haiku", + target_os = "nto", apple_targets))] BSDLY as tcflag_t; #[cfg(any(linux_android, target_os = "haiku", + target_os = "nto", apple_targets))] VTDLY as tcflag_t; #[cfg(any(linux_android, target_os = "haiku", + target_os = "nto", apple_targets))] FFDLY as tcflag_t; } @@ -623,7 +647,7 @@ libc_bitflags! { PARODD; HUPCL; CLOCAL; - #[cfg(not(any(target_os = "redox", target_os = "aix")))] + #[cfg(not(any(target_os = "redox", target_os = "aix", target_os = "nto",)))] CRTSCTS; #[cfg(linux_android)] CBAUD; @@ -667,7 +691,7 @@ libc_bitflags! { ECHOK; ECHO; ECHONL; - #[cfg(not(target_os = "redox"))] + #[cfg(not(any(target_os = "redox", target_os = "nto")))] ECHOPRT; #[cfg(not(target_os = "redox"))] ECHOCTL; @@ -676,14 +700,14 @@ libc_bitflags! { #[cfg(bsd)] ALTWERASE; IEXTEN; - #[cfg(not(any(target_os = "redox", target_os = "haiku", target_os = "aix")))] + #[cfg(not(any(target_os = "redox", target_os = "haiku", target_os = "aix", target_os = "nto",)))] EXTPROC; TOSTOP; - #[cfg(not(target_os = "redox"))] + #[cfg(not(any(target_os = "redox", target_os = "nto")))] FLUSHO; #[cfg(bsd)] NOKERNINFO; - #[cfg(not(target_os = "redox"))] + #[cfg(not(any(target_os = "redox", target_os = "nto")))] PENDIN; NOFLSH; } @@ -740,6 +764,7 @@ cfg_if! { /// /// `cfsetspeed()` sets the input and output baud rate in the given termios structure. Note that /// this is part of the 4.4BSD standard and not part of POSIX. + #[cfg(not(target_os = "nto"))] pub fn cfsetspeed>(termios: &mut Termios, baud: T) -> Result<()> { let inner_termios = unsafe { termios.get_libc_termios_mut() }; let res = unsafe { libc::cfsetspeed(inner_termios, baud.into() as libc::speed_t) }; @@ -810,6 +835,7 @@ cfg_if! { /// `cfmakeraw()` configures the termios structure such that input is available character-by- /// character, echoing is disabled, and all special input and output processing is disabled. Note /// that this is a non-standard function, but is available on Linux and BSDs. +#[cfg(not(target_os = "nto"))] pub fn cfmakeraw(termios: &mut Termios) { let inner_termios = unsafe { termios.get_libc_termios_mut() }; unsafe { diff --git a/src/sys/uio.rs b/src/sys/uio.rs index cdf380dd11..0b7aefacf0 100644 --- a/src/sys/uio.rs +++ b/src/sys/uio.rs @@ -53,7 +53,7 @@ pub fn readv(fd: Fd, iov: &mut [IoSliceMut<'_>]) -> Result { /// or an error occurs. The file offset is not changed. /// /// See also: [`writev`](fn.writev.html) and [`pwrite`](fn.pwrite.html) -#[cfg(not(any(target_os = "redox", target_os = "haiku", target_os = "solaris")))] +#[cfg(not(any(target_os = "redox", target_os = "haiku", target_os = "solaris", target_os = "nto",)))] pub fn pwritev( fd: Fd, iov: &[IoSlice<'_>], @@ -82,7 +82,7 @@ pub fn pwritev( /// changed. /// /// See also: [`readv`](fn.readv.html) and [`pread`](fn.pread.html) -#[cfg(not(any(target_os = "redox", target_os = "haiku", target_os = "solaris")))] +#[cfg(not(any(target_os = "redox", target_os = "haiku", target_os = "solaris", target_os = "nto",)))] // Clippy doesn't know that we need to pass iov mutably only because the // mutation happens after converting iov to a pointer #[allow(clippy::needless_pass_by_ref_mut)] diff --git a/src/sys/wait.rs b/src/sys/wait.rs index 844e165c18..78e90840da 100644 --- a/src/sys/wait.rs +++ b/src/sys/wait.rs @@ -29,6 +29,7 @@ libc_bitflags!( target_os = "freebsd", target_os = "haiku", target_os = "redox", + target_os = "nto", target_os = "netbsd"))] WEXITED; /// Report the status of selected processes that have continued from a @@ -41,6 +42,7 @@ libc_bitflags!( target_os = "freebsd", target_os = "haiku", target_os = "redox", + target_os = "nto", target_os = "netbsd"))] WSTOPPED; /// Don't reap, just poll status. @@ -49,6 +51,7 @@ libc_bitflags!( target_os = "freebsd", target_os = "haiku", target_os = "redox", + target_os = "nto", target_os = "netbsd"))] WNOWAIT; /// Don't wait on children of other threads in this group diff --git a/src/unistd.rs b/src/unistd.rs index 58ede6eb9b..e52f04fee7 100644 --- a/src/unistd.rs +++ b/src/unistd.rs @@ -882,7 +882,7 @@ pub fn execvp>( /// This functions like a combination of `execvp(2)` and `execve(2)` to pass an /// environment and have a search path. See these two for additional /// information. -#[cfg(any(target_os = "haiku", target_os = "hurd", target_os = "linux", target_os = "openbsd"))] +#[cfg(any(target_os = "haiku", target_os = "hurd", target_os = "linux", target_os = "openbsd", target_os = "nto",))] pub fn execvpe, SE: AsRef>( filename: &CStr, args: &[SA], @@ -989,7 +989,8 @@ pub fn execveat, SE: AsRef>( linux_android, freebsdlike, solarish, - netbsdlike + netbsdlike, + target_os = "nto", ))] pub fn daemon(nochdir: bool, noclose: bool) -> Result<()> { let res = unsafe { libc::daemon(nochdir as c_int, noclose as c_int) }; @@ -1377,7 +1378,7 @@ pub fn chroot(path: &P) -> Result<()> { /// Commit filesystem caches to disk /// /// See also [sync(2)](https://pubs.opengroup.org/onlinepubs/9699919799/functions/sync.html) -#[cfg(any(bsd, linux_android, solarish, target_os = "haiku", target_os = "aix", target_os = "hurd"))] +#[cfg(any(bsd, linux_android, solarish, target_os = "haiku", target_os = "aix", target_os = "hurd", target_os = "nto"))] pub fn sync() { unsafe { libc::sync() }; } @@ -1908,7 +1909,7 @@ feature! { #![feature = "acct"] /// Process accounting -#[cfg(not(any(target_os = "redox", target_os = "haiku")))] +#[cfg(not(any(target_os = "redox", target_os = "haiku", target_os = "nto",)))] pub mod acct { use crate::errno::Errno; use crate::{NixPath, Result}; @@ -2032,6 +2033,7 @@ pub enum PathconfVar { freebsdlike, netbsdlike, target_os = "linux", + target_os = "nto", target_os = "redox" ))] /// Minimum number of bits needed to represent, as a signed integer value, @@ -2075,6 +2077,9 @@ pub enum PathconfVar { netbsdlike, target_os = "dragonfly", target_os = "redox", + target_os = "nto", + target_os = "solaris", + target_os = "nto", ))] /// Symbolic links can be created. POSIX2_SYMLINKS = libc::_PC_2_SYMLINKS, @@ -2090,7 +2095,8 @@ pub enum PathconfVar { #[cfg(any( freebsdlike, linux_android, - target_os = "openbsd" + target_os = "openbsd", + target_os = "nto", ))] /// Recommended increment for file transfer sizes between the /// `POSIX_REC_MIN_XFER_SIZE` and `POSIX_REC_MAX_XFER_SIZE` values. @@ -2099,7 +2105,8 @@ pub enum PathconfVar { linux_android, freebsdlike, target_os = "openbsd", - target_os = "redox" + target_os = "redox", + target_os = "nto", ))] /// Maximum recommended file transfer size. POSIX_REC_MAX_XFER_SIZE = libc::_PC_REC_MAX_XFER_SIZE, @@ -2107,7 +2114,8 @@ pub enum PathconfVar { linux_android, freebsdlike, target_os = "openbsd", - target_os = "redox" + target_os = "redox", + target_os = "nto", ))] /// Minimum recommended file transfer size. POSIX_REC_MIN_XFER_SIZE = libc::_PC_REC_MIN_XFER_SIZE, @@ -2115,7 +2123,8 @@ pub enum PathconfVar { linux_android, freebsdlike, target_os = "openbsd", - target_os = "redox" + target_os = "redox", + target_os = "nto", ))] /// Recommended file transfer buffer alignment. POSIX_REC_XFER_ALIGN = libc::_PC_REC_XFER_ALIGN, @@ -2125,6 +2134,7 @@ pub enum PathconfVar { solarish, netbsdlike, target_os = "redox", + target_os = "nto", ))] /// Maximum number of bytes in a symbolic link. SYMLINK_MAX = libc::_PC_SYMLINK_MAX, @@ -2144,6 +2154,7 @@ pub enum PathconfVar { solarish, target_os = "openbsd", target_os = "redox", + target_os = "nto", ))] /// Asynchronous input or output operations may be performed for the /// associated file. @@ -2154,6 +2165,7 @@ pub enum PathconfVar { solarish, target_os = "openbsd", target_os = "redox", + target_os = "nto", ))] /// Prioritized input or output operations may be performed for the /// associated file. @@ -2281,7 +2293,8 @@ pub enum SysconfVar { linux_android, freebsdlike, apple_targets, - target_os = "openbsd" + target_os = "openbsd", + target_os = "nto", ))] /// The maximum amount by which a process can decrease its asynchronous I/O /// priority level from its own scheduling priority. @@ -2356,6 +2369,7 @@ pub enum SysconfVar { freebsdlike, apple_targets, target_os = "linux", + target_os = "nto", target_os = "openbsd" ))] /// The implementation supports the Advisory Information option. @@ -2381,6 +2395,7 @@ pub enum SysconfVar { solarish, target_os = "linux", target_os = "openbsd", + target_os = "nto", ))] /// The implementation supports the IPv6 option. _POSIX_IPV6 = libc::_SC_IPV6, @@ -2411,6 +2426,7 @@ pub enum SysconfVar { solarish, apple_targets, target_os = "openbsd", + target_os = "nto", ))] /// The implementation supports the Prioritized Input and Output option. _POSIX_PRIORITIZED_IO = libc::_SC_PRIORITIZED_IO, @@ -2423,6 +2439,7 @@ pub enum SysconfVar { apple_targets, target_os = "linux", target_os = "openbsd", + target_os = "nto", ))] /// The implementation supports the Raw Sockets option. _POSIX_RAW_SOCKETS = libc::_SC_RAW_SOCKETS, @@ -2437,7 +2454,8 @@ pub enum SysconfVar { linux_android, freebsdlike, apple_targets, - target_os = "openbsd" + target_os = "openbsd", + target_os = "nto", ))] /// The implementation supports realtime signals. _POSIX_REALTIME_SIGNALS = libc::_SC_REALTIME_SIGNALS, @@ -2479,6 +2497,7 @@ pub enum SysconfVar { #[cfg(any( apple_targets, target_os = "linux", + target_os = "nto", target_os = "openbsd" ))] _POSIX_SS_REPL_MAX = libc::_SC_SS_REPL_MAX, @@ -2494,6 +2513,7 @@ pub enum SysconfVar { #[cfg(any( apple_targets, target_os = "linux", + target_os = "nto", netbsdlike, ))] /// The implementation supports the Thread CPU-Time Clocks option. @@ -2533,6 +2553,7 @@ pub enum SysconfVar { freebsdlike, apple_targets, target_os = "linux", + target_os = "nto", target_os = "openbsd" ))] /// The implementation supports the Thread Sporadic Server option. @@ -2544,6 +2565,7 @@ pub enum SysconfVar { freebsdlike, apple_targets, target_os = "linux", + target_os = "nto", target_os = "openbsd" ))] /// The implementation supports timeouts. @@ -2555,6 +2577,7 @@ pub enum SysconfVar { freebsdlike, apple_targets, target_os = "linux", + target_os = "nto", target_os = "openbsd" ))] /// The implementation supports the Trace option. @@ -2571,6 +2594,7 @@ pub enum SysconfVar { #[cfg(any( apple_targets, target_os = "linux", + target_os = "nto", target_os = "openbsd" ))] _POSIX_TRACE_EVENT_NAME_MAX = libc::_SC_TRACE_EVENT_NAME_MAX, @@ -2578,6 +2602,7 @@ pub enum SysconfVar { freebsdlike, apple_targets, target_os = "linux", + target_os = "nto", target_os = "openbsd" ))] /// The implementation supports the Trace Inherit option. @@ -2586,6 +2611,7 @@ pub enum SysconfVar { freebsdlike, apple_targets, target_os = "linux", + target_os = "nto", target_os = "openbsd" ))] /// The implementation supports the Trace Log option. @@ -2594,6 +2620,7 @@ pub enum SysconfVar { #[cfg(any( apple_targets, target_os = "linux", + target_os = "nto", target_os = "openbsd" ))] _POSIX_TRACE_NAME_MAX = libc::_SC_TRACE_NAME_MAX, @@ -2602,6 +2629,7 @@ pub enum SysconfVar { #[cfg(any( apple_targets, target_os = "linux", + target_os = "nto", target_os = "openbsd" ))] _POSIX_TRACE_SYS_MAX = libc::_SC_TRACE_SYS_MAX, @@ -2609,6 +2637,7 @@ pub enum SysconfVar { #[cfg(any( apple_targets, target_os = "linux", + target_os = "nto", target_os = "openbsd" ))] _POSIX_TRACE_USER_EVENT_MAX = libc::_SC_TRACE_USER_EVENT_MAX, @@ -2616,6 +2645,7 @@ pub enum SysconfVar { freebsdlike, apple_targets, target_os = "linux", + target_os = "nto", target_os = "openbsd" ))] /// The implementation supports the Typed Memory Objects option. @@ -2659,7 +2689,7 @@ pub enum SysconfVar { _POSIX2_FORT_RUN = libc::_SC_2_FORT_RUN, /// The implementation supports the creation of locales by the localedef /// utility. - #[cfg(not(any(target_os = "redox", target_os = "haiku")))] + #[cfg(not(any(target_os = "redox", target_os = "haiku", target_os = "nto",)))] _POSIX2_LOCALEDEF = libc::_SC_2_LOCALEDEF, #[cfg(any(bsd, target_os = "linux"))] /// The implementation supports the Batch Environment Services and Utilities @@ -2717,6 +2747,7 @@ pub enum SysconfVar { linux_android, freebsdlike, apple_targets, + target_os = "nto", target_os = "openbsd" ))] RTSIG_MAX = libc::_SC_RTSIG_MAX, @@ -2728,6 +2759,7 @@ pub enum SysconfVar { linux_android, freebsdlike, apple_targets, + target_os = "nto", target_os = "openbsd" ))] SEM_VALUE_MAX = libc::_SC_SEM_VALUE_MAX, @@ -2737,6 +2769,7 @@ pub enum SysconfVar { linux_android, freebsdlike, apple_targets, + target_os = "nto", target_os = "openbsd" ))] SIGQUEUE_MAX = libc::_SC_SIGQUEUE_MAX, @@ -2757,6 +2790,7 @@ pub enum SysconfVar { linux_android, freebsdlike, apple_targets, + target_os = "nto", target_os = "openbsd" ))] /// The implementation supports the X/Open Encryption Option Group. @@ -2765,6 +2799,7 @@ pub enum SysconfVar { linux_android, freebsdlike, apple_targets, + target_os = "nto", target_os = "openbsd" ))] /// The implementation supports the Issue 4, Version 2 Enhanced @@ -2784,6 +2819,7 @@ pub enum SysconfVar { linux_android, freebsdlike, apple_targets, + target_os = "nto", target_os = "openbsd" ))] /// The implementation supports the X/Open Realtime Option Group. @@ -2792,6 +2828,7 @@ pub enum SysconfVar { linux_android, freebsdlike, apple_targets, + target_os = "nto", target_os = "openbsd" ))] /// The implementation supports the X/Open Realtime Threads Option Group. @@ -2804,6 +2841,7 @@ pub enum SysconfVar { freebsdlike, apple_targets, target_os = "linux", + target_os = "nto", target_os = "openbsd" ))] /// The implementation supports the XSI STREAMS Option Group. @@ -2812,6 +2850,7 @@ pub enum SysconfVar { linux_android, freebsdlike, apple_targets, + target_os = "nto", target_os = "openbsd" ))] /// The implementation supports the XSI option @@ -2820,6 +2859,7 @@ pub enum SysconfVar { linux_android, freebsdlike, apple_targets, + target_os = "nto", target_os = "openbsd" ))] /// Integer value indicating version of the X/Open Portability Guide to @@ -3190,6 +3230,7 @@ pub struct User { target_os = "fuchsia", target_os = "haiku", target_os = "hurd", + target_os = "nto", )))] pub class: CString, /// Last password change @@ -3200,6 +3241,7 @@ pub struct User { target_os = "fuchsia", target_os = "haiku", target_os = "hurd", + target_os = "nto", )))] pub change: libc::time_t, /// Expiration time of account @@ -3210,6 +3252,7 @@ pub struct User { target_os = "fuchsia", target_os = "haiku", target_os = "hurd", + target_os = "nto", )))] pub expire: libc::time_t, } @@ -3263,6 +3306,7 @@ impl From<&libc::passwd> for User { target_os = "fuchsia", target_os = "haiku", target_os = "hurd", + target_os = "nto", )))] class: CString::new(CStr::from_ptr(pw.pw_class).to_bytes()) .unwrap(), @@ -3273,6 +3317,7 @@ impl From<&libc::passwd> for User { target_os = "fuchsia", target_os = "haiku", target_os = "hurd", + target_os = "nto", )))] change: pw.pw_change, #[cfg(not(any( @@ -3282,6 +3327,7 @@ impl From<&libc::passwd> for User { target_os = "fuchsia", target_os = "haiku", target_os = "hurd", + target_os = "nto", )))] expire: pw.pw_expire, } @@ -3323,6 +3369,7 @@ impl From for libc::passwd { target_os = "fuchsia", target_os = "haiku", target_os = "hurd", + target_os = "nto", )))] pw_class: u.class.into_raw(), #[cfg(not(any( @@ -3332,6 +3379,7 @@ impl From for libc::passwd { target_os = "fuchsia", target_os = "haiku", target_os = "hurd", + target_os = "nto", )))] pw_change: u.change, #[cfg(not(any( @@ -3343,9 +3391,9 @@ impl From for libc::passwd { target_os = "hurd", )))] pw_expire: u.expire, - #[cfg(solarish)] + #[cfg(any(solarish, target_os = "nto",))] pw_age: CString::new("").unwrap().into_raw(), - #[cfg(solarish)] + #[cfg(any(solarish, target_os = "nto",))] pw_comment: CString::new("").unwrap().into_raw(), #[cfg(freebsdlike)] pw_fields: 0,