haiku support (#407)

* haiku support

* cargo format

Co-authored-by: Al Hoang <3811822-hoanga@users.noreply.gitlab.com>
This commit is contained in:
Al Hoang
2022-09-25 14:25:02 -05:00
committed by GitHub
parent 4302598df7
commit 175c20e182
16 changed files with 206 additions and 31 deletions
+1
View File
@@ -3,6 +3,7 @@
pub(crate) mod dir;
#[cfg(not(any(
target_os = "dragonfly",
target_os = "haiku",
target_os = "freebsd",
target_os = "illumos",
target_os = "ios",
+13
View File
@@ -10,6 +10,7 @@ use super::super::conv::{syscall_ret, syscall_ret_owned_fd, syscall_ret_ssize_t}
use super::super::offset::libc_fallocate;
#[cfg(not(any(
target_os = "dragonfly",
target_os = "haiku",
target_os = "illumos",
target_os = "ios",
target_os = "macos",
@@ -35,6 +36,7 @@ use super::super::offset::libc_posix_fadvise;
use super::super::offset::libc_posix_fallocate;
use super::super::offset::{libc_fstat, libc_fstatat, libc_ftruncate, libc_lseek, libc_off_t};
#[cfg(not(any(
target_os = "haiku",
target_os = "illumos",
target_os = "netbsd",
target_os = "redox",
@@ -43,6 +45,7 @@ use super::super::offset::{libc_fstat, libc_fstatat, libc_ftruncate, libc_lseek,
)))]
use super::super::offset::{libc_fstatfs, libc_statfs};
#[cfg(not(any(
target_os = "haiku",
target_os = "illumos",
target_os = "redox",
target_os = "solaris",
@@ -64,6 +67,7 @@ use crate::ffi::CString;
use crate::fs::Access;
#[cfg(not(any(
target_os = "dragonfly",
target_os = "haiku",
target_os = "illumos",
target_os = "ios",
target_os = "macos",
@@ -94,6 +98,7 @@ use crate::fs::MemfdFlags;
))]
use crate::fs::SealFlags;
#[cfg(not(any(
target_os = "haiku",
target_os = "illumos",
target_os = "netbsd",
target_os = "redox",
@@ -112,6 +117,7 @@ use crate::fs::{cwd, RenameFlags, ResolveFlags, Statx, StatxFlags};
use crate::fs::{Dev, FileType};
use crate::fs::{FdFlags, Mode, OFlags, Stat, Timestamps};
#[cfg(not(any(
target_os = "haiku",
target_os = "illumos",
target_os = "redox",
target_os = "solaris",
@@ -215,6 +221,7 @@ pub(crate) fn openat(
}
#[cfg(not(any(
target_os = "haiku",
target_os = "illumos",
target_os = "netbsd",
target_os = "redox",
@@ -231,6 +238,7 @@ pub(crate) fn statfs(filename: &CStr) -> io::Result<StatFs> {
}
#[cfg(not(any(
target_os = "haiku",
target_os = "illumos",
target_os = "redox",
target_os = "solaris",
@@ -797,6 +805,7 @@ pub(crate) fn copy_file_range(
#[cfg(not(any(
target_os = "dragonfly",
target_os = "haiku",
target_os = "illumos",
target_os = "ios",
target_os = "macos",
@@ -984,6 +993,7 @@ fn fstat_old(fd: BorrowedFd<'_>) -> io::Result<Stat> {
}
#[cfg(not(any(
target_os = "haiku",
target_os = "illumos",
target_os = "netbsd",
target_os = "redox",
@@ -999,6 +1009,7 @@ pub(crate) fn fstatfs(fd: BorrowedFd<'_>) -> io::Result<StatFs> {
}
#[cfg(not(any(
target_os = "haiku",
target_os = "illumos",
target_os = "redox",
target_os = "solaris",
@@ -1013,6 +1024,7 @@ pub(crate) fn fstatvfs(fd: BorrowedFd<'_>) -> io::Result<StatVfs> {
}
#[cfg(not(any(
target_os = "haiku",
target_os = "illumos",
target_os = "redox",
target_os = "solaris",
@@ -1209,6 +1221,7 @@ pub(crate) fn fsync(fd: BorrowedFd<'_>) -> io::Result<()> {
#[cfg(not(any(
target_os = "dragonfly",
target_os = "haiku",
target_os = "ios",
target_os = "macos",
target_os = "redox",
+11
View File
@@ -461,6 +461,7 @@ impl FileType {
/// [`fadvise`]: crate::fs::fadvise
#[cfg(not(any(
target_os = "dragonfly",
target_os = "haiku",
target_os = "illumos",
target_os = "ios",
target_os = "macos",
@@ -697,6 +698,7 @@ bitflags! {
#[cfg(not(any(
target_os = "dragonfly",
target_os = "freebsd",
target_os = "haiku",
target_os = "ios",
target_os = "macos",
target_os = "netbsd",
@@ -708,6 +710,7 @@ bitflags! {
#[cfg(not(any(
target_os = "dragonfly",
target_os = "freebsd",
target_os = "haiku",
target_os = "ios",
target_os = "macos",
target_os = "netbsd",
@@ -719,6 +722,7 @@ bitflags! {
#[cfg(not(any(
target_os = "dragonfly",
target_os = "freebsd",
target_os = "haiku",
target_os = "ios",
target_os = "linux",
target_os = "macos",
@@ -733,6 +737,7 @@ bitflags! {
#[cfg(not(any(
target_os = "dragonfly",
target_os = "freebsd",
target_os = "haiku",
target_os = "ios",
target_os = "macos",
target_os = "netbsd",
@@ -745,6 +750,7 @@ bitflags! {
#[cfg(not(any(
target_os = "dragonfly",
target_os = "freebsd",
target_os = "haiku",
target_os = "ios",
target_os = "macos",
target_os = "netbsd",
@@ -757,6 +763,7 @@ bitflags! {
#[cfg(not(any(
target_os = "dragonfly",
target_os = "freebsd",
target_os = "haiku",
target_os = "ios",
target_os = "macos",
target_os = "netbsd",
@@ -769,6 +776,7 @@ bitflags! {
#[cfg(not(any(
target_os = "dragonfly",
target_os = "freebsd",
target_os = "haiku",
target_os = "ios",
target_os = "macos",
target_os = "netbsd",
@@ -781,6 +789,7 @@ bitflags! {
}
#[cfg(not(any(
target_os = "haiku",
target_os = "illumos",
target_os = "redox",
target_os = "solaris",
@@ -912,6 +921,7 @@ pub struct Stat {
#[cfg(not(any(
target_os = "android",
target_os = "emscripten",
target_os = "haiku",
target_os = "illumos",
target_os = "linux",
target_os = "l4re",
@@ -940,6 +950,7 @@ pub type StatFs = c::statfs64;
/// [`statvfs`]: crate::fs::statvfs
/// [`fstatvfs`]: crate::fs::fstatvfs
#[cfg(not(any(
target_os = "haiku",
target_os = "illumos",
target_os = "redox",
target_os = "solaris",
+67 -8
View File
@@ -28,6 +28,7 @@ impl Errno {
windows,
target_os = "dragonfly",
target_os = "freebsd",
target_os = "haiku",
target_os = "ios",
target_os = "macos",
target_os = "netbsd",
@@ -56,6 +57,7 @@ impl Errno {
windows,
target_os = "dragonfly",
target_os = "freebsd",
target_os = "haiku",
target_os = "ios",
target_os = "macos",
target_os = "netbsd",
@@ -70,6 +72,7 @@ impl Errno {
windows,
target_os = "dragonfly",
target_os = "freebsd",
target_os = "haiku",
target_os = "ios",
target_os = "macos",
target_os = "netbsd",
@@ -85,6 +88,7 @@ impl Errno {
windows,
target_os = "dragonfly",
target_os = "freebsd",
target_os = "haiku",
target_os = "ios",
target_os = "macos",
target_os = "netbsd",
@@ -107,6 +111,7 @@ impl Errno {
windows,
target_os = "dragonfly",
target_os = "freebsd",
target_os = "haiku",
target_os = "ios",
target_os = "macos",
target_os = "netbsd",
@@ -119,6 +124,7 @@ impl Errno {
windows,
target_os = "dragonfly",
target_os = "freebsd",
target_os = "haiku",
target_os = "ios",
target_os = "macos",
target_os = "netbsd",
@@ -131,6 +137,7 @@ impl Errno {
windows,
target_os = "dragonfly",
target_os = "freebsd",
target_os = "haiku",
target_os = "ios",
target_os = "macos",
target_os = "netbsd",
@@ -154,6 +161,7 @@ impl Errno {
windows,
target_os = "dragonfly",
target_os = "freebsd",
target_os = "haiku",
target_os = "ios",
target_os = "macos",
target_os = "netbsd",
@@ -166,6 +174,7 @@ impl Errno {
windows,
target_os = "dragonfly",
target_os = "freebsd",
target_os = "haiku",
target_os = "ios",
target_os = "macos",
target_os = "netbsd",
@@ -188,6 +197,7 @@ impl Errno {
target_os = "android",
target_os = "dragonfly",
target_os = "freebsd",
target_os = "haiku",
target_os = "ios",
target_os = "macos",
target_os = "netbsd",
@@ -211,6 +221,7 @@ impl Errno {
windows,
target_os = "dragonfly",
target_os = "freebsd",
target_os = "haiku",
target_os = "illumos",
target_os = "ios",
target_os = "macos",
@@ -252,6 +263,7 @@ impl Errno {
target_os = "android",
target_os = "dragonfly",
target_os = "freebsd",
target_os = "haiku",
target_os = "illumos",
target_os = "ios",
target_os = "macos",
@@ -298,6 +310,7 @@ impl Errno {
windows,
target_os = "dragonfly",
target_os = "freebsd",
target_os = "haiku",
target_os = "illumos",
target_os = "ios",
target_os = "macos",
@@ -312,6 +325,7 @@ impl Errno {
windows,
target_os = "dragonfly",
target_os = "freebsd",
target_os = "haiku",
target_os = "illumos",
target_os = "ios",
target_os = "macos",
@@ -326,6 +340,7 @@ impl Errno {
windows,
target_os = "dragonfly",
target_os = "freebsd",
target_os = "haiku",
target_os = "illumos",
target_os = "ios",
target_os = "macos",
@@ -340,6 +355,7 @@ impl Errno {
windows,
target_os = "dragonfly",
target_os = "freebsd",
target_os = "haiku",
target_os = "illumos",
target_os = "ios",
target_os = "macos",
@@ -354,6 +370,7 @@ impl Errno {
windows,
target_os = "dragonfly",
target_os = "freebsd",
target_os = "haiku",
target_os = "ios",
target_os = "macos",
target_os = "netbsd",
@@ -366,6 +383,7 @@ impl Errno {
windows,
target_os = "dragonfly",
target_os = "freebsd",
target_os = "haiku",
target_os = "ios",
target_os = "macos",
target_os = "netbsd",
@@ -378,6 +396,7 @@ impl Errno {
windows,
target_os = "dragonfly",
target_os = "freebsd",
target_os = "haiku",
target_os = "ios",
target_os = "macos",
target_os = "netbsd",
@@ -390,6 +409,7 @@ impl Errno {
windows,
target_os = "dragonfly",
target_os = "freebsd",
target_os = "haiku",
target_os = "ios",
target_os = "macos",
target_os = "netbsd",
@@ -402,6 +422,7 @@ impl Errno {
windows,
target_os = "dragonfly",
target_os = "freebsd",
target_os = "haiku",
target_os = "ios",
target_os = "macos",
target_os = "netbsd",
@@ -414,6 +435,7 @@ impl Errno {
windows,
target_os = "dragonfly",
target_os = "freebsd",
target_os = "haiku",
target_os = "ios",
target_os = "macos",
target_os = "netbsd",
@@ -426,6 +448,7 @@ impl Errno {
windows,
target_os = "dragonfly",
target_os = "freebsd",
target_os = "haiku",
target_os = "ios",
target_os = "macos",
target_os = "netbsd",
@@ -438,6 +461,7 @@ impl Errno {
windows,
target_os = "dragonfly",
target_os = "freebsd",
target_os = "haiku",
target_os = "ios",
target_os = "macos",
target_os = "netbsd",
@@ -450,6 +474,7 @@ impl Errno {
windows,
target_os = "dragonfly",
target_os = "freebsd",
target_os = "haiku",
target_os = "ios",
target_os = "macos",
target_os = "netbsd",
@@ -462,6 +487,7 @@ impl Errno {
windows,
target_os = "dragonfly",
target_os = "freebsd",
target_os = "haiku",
target_os = "ios",
target_os = "macos",
target_os = "netbsd",
@@ -476,6 +502,7 @@ impl Errno {
windows,
target_os = "dragonfly",
target_os = "freebsd",
target_os = "haiku",
target_os = "illumos",
target_os = "ios",
target_os = "macos",
@@ -502,6 +529,7 @@ impl Errno {
windows,
target_os = "dragonfly",
target_os = "freebsd",
target_os = "haiku",
target_os = "illumos",
target_os = "ios",
target_os = "macos",
@@ -535,6 +563,7 @@ impl Errno {
windows,
target_os = "dragonfly",
target_os = "freebsd",
target_os = "haiku",
target_os = "ios",
target_os = "macos",
target_os = "netbsd",
@@ -546,6 +575,7 @@ impl Errno {
#[cfg(any(
target_os = "dragonfly",
target_os = "freebsd",
target_os = "haiku",
target_os = "ios",
target_os = "macos",
target_os = "netbsd",
@@ -559,6 +589,7 @@ impl Errno {
windows,
target_os = "dragonfly",
target_os = "freebsd",
target_os = "haiku",
target_os = "ios",
target_os = "macos",
target_os = "netbsd",
@@ -571,6 +602,7 @@ impl Errno {
windows,
target_os = "dragonfly",
target_os = "freebsd",
target_os = "haiku",
target_os = "openbsd",
target_os = "wasi",
)))]
@@ -589,6 +621,7 @@ impl Errno {
windows,
target_os = "dragonfly",
target_os = "freebsd",
target_os = "haiku",
target_os = "illumos",
target_os = "ios",
target_os = "macos",
@@ -609,6 +642,7 @@ impl Errno {
windows,
target_os = "dragonfly",
target_os = "freebsd",
target_os = "haiku",
target_os = "illumos",
target_os = "ios",
target_os = "macos",
@@ -632,6 +666,7 @@ impl Errno {
windows,
target_os = "dragonfly",
target_os = "freebsd",
target_os = "haiku",
target_os = "ios",
target_os = "macos",
target_os = "netbsd",
@@ -644,6 +679,7 @@ impl Errno {
windows,
target_os = "dragonfly",
target_os = "freebsd",
target_os = "haiku",
target_os = "ios",
target_os = "macos",
target_os = "netbsd",
@@ -661,6 +697,7 @@ impl Errno {
windows,
target_os = "dragonfly",
target_os = "freebsd",
target_os = "haiku",
target_os = "openbsd",
target_os = "wasi",
)))]
@@ -670,6 +707,7 @@ impl Errno {
windows,
target_os = "dragonfly",
target_os = "freebsd",
target_os = "haiku",
target_os = "openbsd",
target_os = "wasi",
)))]
@@ -678,7 +716,7 @@ impl Errno {
#[cfg(not(windows))]
pub const NOSYS: Self = Self(c::ENOSYS);
/// `ENOTBLK`
#[cfg(not(any(windows, target_os = "wasi")))]
#[cfg(not(any(windows, target_os = "haiku", target_os = "wasi")))]
pub const NOTBLK: Self = Self(c::ENOTBLK);
/// `ENOTCAPABLE`
#[cfg(any(target_os = "freebsd", target_os = "wasi"))]
@@ -695,6 +733,7 @@ impl Errno {
windows,
target_os = "dragonfly",
target_os = "freebsd",
target_os = "haiku",
target_os = "illumos",
target_os = "ios",
target_os = "macos",
@@ -705,12 +744,17 @@ impl Errno {
)))]
pub const NOTNAM: Self = Self(c::ENOTNAM);
/// `ENOTRECOVERABLE`
#[cfg(not(any(windows, target_os = "dragonfly", target_os = "netbsd")))]
#[cfg(not(any(
windows,
target_os = "dragonfly",
target_os = "haiku",
target_os = "netbsd"
)))]
pub const NOTRECOVERABLE: Self = Self(c::ENOTRECOVERABLE);
/// `ENOTSOCK`
pub const NOTSOCK: Self = Self(c::ENOTSOCK);
/// `ENOTSUP`
#[cfg(not(any(windows, target_os = "redox")))]
#[cfg(not(any(windows, target_os = "haiku", target_os = "redox")))]
pub const NOTSUP: Self = Self(c::ENOTSUP);
/// `ENOTTY`
#[cfg(not(windows))]
@@ -720,6 +764,7 @@ impl Errno {
windows,
target_os = "dragonfly",
target_os = "freebsd",
target_os = "haiku",
target_os = "ios",
target_os = "macos",
target_os = "netbsd",
@@ -736,7 +781,12 @@ impl Errno {
#[cfg(not(windows))]
pub const OVERFLOW: Self = Self(c::EOVERFLOW);
/// `EOWNERDEAD`
#[cfg(not(any(windows, target_os = "dragonfly", target_os = "netbsd")))]
#[cfg(not(any(
windows,
target_os = "haiku",
target_os = "dragonfly",
target_os = "netbsd"
)))]
pub const OWNERDEAD: Self = Self(c::EOWNERDEAD);
/// `EPERM`
#[cfg(not(windows))]
@@ -808,6 +858,7 @@ impl Errno {
windows,
target_os = "dragonfly",
target_os = "freebsd",
target_os = "haiku",
target_os = "ios",
target_os = "macos",
target_os = "netbsd",
@@ -816,13 +867,14 @@ impl Errno {
)))]
pub const REMCHG: Self = Self(c::EREMCHG);
/// `EREMOTE`
#[cfg(not(target_os = "wasi"))]
#[cfg(not(any(target_os = "haiku", target_os = "wasi")))]
pub const REMOTE: Self = Self(c::EREMOTE);
/// `EREMOTEIO`
#[cfg(not(any(
windows,
target_os = "dragonfly",
target_os = "freebsd",
target_os = "haiku",
target_os = "illumos",
target_os = "ios",
target_os = "macos",
@@ -837,6 +889,7 @@ impl Errno {
windows,
target_os = "dragonfly",
target_os = "freebsd",
target_os = "haiku",
target_os = "ios",
target_os = "macos",
target_os = "netbsd",
@@ -850,6 +903,7 @@ impl Errno {
target_os = "android",
target_os = "dragonfly",
target_os = "freebsd",
target_os = "haiku",
target_os = "illumos",
target_os = "ios",
target_os = "macos",
@@ -877,7 +931,7 @@ impl Errno {
#[cfg(not(target_os = "wasi"))]
pub const SHUTDOWN: Self = Self(c::ESHUTDOWN);
/// `ESOCKTNOSUPPORT`
#[cfg(not(target_os = "wasi"))]
#[cfg(not(any(target_os = "haiku", target_os = "wasi")))]
pub const SOCKTNOSUPPORT: Self = Self(c::ESOCKTNOSUPPORT);
/// `ESPIPE`
#[cfg(not(windows))]
@@ -890,6 +944,7 @@ impl Errno {
windows,
target_os = "dragonfly",
target_os = "freebsd",
target_os = "haiku",
target_os = "ios",
target_os = "macos",
target_os = "netbsd",
@@ -904,6 +959,7 @@ impl Errno {
windows,
target_os = "dragonfly",
target_os = "freebsd",
target_os = "haiku",
target_os = "ios",
target_os = "macos",
target_os = "netbsd",
@@ -927,7 +983,7 @@ impl Errno {
#[doc(alias = "2BIG")]
pub const TOOBIG: Self = Self(c::E2BIG);
/// `ETOOMANYREFS`
#[cfg(not(target_os = "wasi"))]
#[cfg(not(any(target_os = "haiku", target_os = "wasi")))]
pub const TOOMANYREFS: Self = Self(c::ETOOMANYREFS);
/// `ETXTBSY`
#[cfg(not(windows))]
@@ -937,6 +993,7 @@ impl Errno {
windows,
target_os = "dragonfly",
target_os = "freebsd",
target_os = "haiku",
target_os = "illumos",
target_os = "ios",
target_os = "macos",
@@ -951,6 +1008,7 @@ impl Errno {
windows,
target_os = "dragonfly",
target_os = "freebsd",
target_os = "haiku",
target_os = "ios",
target_os = "macos",
target_os = "netbsd",
@@ -959,7 +1017,7 @@ impl Errno {
)))]
pub const UNATCH: Self = Self(c::EUNATCH);
/// `EUSERS`
#[cfg(not(target_os = "wasi"))]
#[cfg(not(any(target_os = "haiku", target_os = "wasi")))]
pub const USERS: Self = Self(c::EUSERS);
/// `EWOULDBLOCK`
pub const WOULDBLOCK: Self = Self(c::EWOULDBLOCK);
@@ -971,6 +1029,7 @@ impl Errno {
windows,
target_os = "dragonfly",
target_os = "freebsd",
target_os = "haiku",
target_os = "ios",
target_os = "macos",
target_os = "netbsd",
+19 -7
View File
@@ -7,14 +7,19 @@ use super::super::conv::{
borrowed_fd, ret, ret_c_int, ret_discarded_fd, ret_owned_fd, ret_ssize_t,
};
use super::super::offset::{libc_pread, libc_pwrite};
#[cfg(not(any(target_os = "redox", target_os = "solaris")))]
#[cfg(not(any(target_os = "haiku", target_os = "redox", target_os = "solaris")))]
use super::super::offset::{libc_preadv, libc_pwritev};
#[cfg(all(target_os = "linux", target_env = "gnu"))]
use super::super::offset::{libc_preadv2, libc_pwritev2};
use crate::fd::{AsFd, BorrowedFd, OwnedFd, RawFd};
#[cfg(not(target_os = "wasi"))]
use crate::io::DupFlags;
#[cfg(not(any(target_os = "ios", target_os = "macos", target_os = "wasi")))]
#[cfg(not(any(
target_os = "haiku",
target_os = "ios",
target_os = "macos",
target_os = "wasi"
)))]
use crate::io::PipeFlags;
use crate::io::{self, IoSlice, IoSliceMut, PollFd};
#[cfg(any(target_os = "android", target_os = "linux"))]
@@ -103,7 +108,7 @@ pub(crate) fn writev(fd: BorrowedFd<'_>, bufs: &[IoSlice]) -> io::Result<usize>
Ok(nwritten as usize)
}
#[cfg(not(any(target_os = "redox", target_os = "solaris")))]
#[cfg(not(any(target_os = "haiku", target_os = "redox", target_os = "solaris")))]
pub(crate) fn preadv(
fd: BorrowedFd<'_>,
bufs: &mut [IoSliceMut],
@@ -122,7 +127,7 @@ pub(crate) fn preadv(
Ok(nread as usize)
}
#[cfg(not(any(target_os = "redox", target_os = "solaris")))]
#[cfg(not(any(target_os = "haiku", target_os = "redox", target_os = "solaris")))]
pub(crate) fn pwritev(fd: BorrowedFd<'_>, bufs: &[IoSlice], offset: u64) -> io::Result<usize> {
// Silently cast; we'll get `EINVAL` if the value is negative.
let offset = offset as i64;
@@ -379,6 +384,7 @@ pub(crate) fn dup2(fd: BorrowedFd<'_>, new: &mut OwnedFd) -> io::Result<()> {
#[cfg(not(any(
target_os = "android",
target_os = "dragonfly",
target_os = "haiku",
target_os = "ios",
target_os = "macos",
target_os = "redox",
@@ -397,6 +403,7 @@ pub(crate) fn dup3(fd: BorrowedFd<'_>, new: &mut OwnedFd, flags: DupFlags) -> io
#[cfg(any(
target_os = "android",
target_os = "dragonfly",
target_os = "haiku",
target_os = "ios",
target_os = "macos",
target_os = "redox",
@@ -414,12 +421,12 @@ pub(crate) fn ioctl_fioclex(fd: BorrowedFd<'_>) -> io::Result<()> {
unsafe { ret(c::ioctl(borrowed_fd(fd), c::FIOCLEX)) }
}
#[cfg(not(any(target_os = "redox", target_os = "wasi")))]
#[cfg(not(any(target_os = "haiku", target_os = "redox", target_os = "wasi")))]
pub(crate) fn ioctl_tiocexcl(fd: BorrowedFd) -> io::Result<()> {
unsafe { ret(c::ioctl(borrowed_fd(fd), c::TIOCEXCL as _)) }
}
#[cfg(not(any(target_os = "redox", target_os = "wasi")))]
#[cfg(not(any(target_os = "haiku", target_os = "redox", target_os = "wasi")))]
pub(crate) fn ioctl_tiocnxcl(fd: BorrowedFd) -> io::Result<()> {
unsafe { ret(c::ioctl(borrowed_fd(fd), c::TIOCNXCL as _)) }
}
@@ -434,7 +441,12 @@ pub(crate) fn pipe() -> io::Result<(OwnedFd, OwnedFd)> {
}
}
#[cfg(not(any(target_os = "ios", target_os = "macos", target_os = "wasi")))]
#[cfg(not(any(
target_os = "haiku",
target_os = "ios",
target_os = "macos",
target_os = "wasi"
)))]
pub(crate) fn pipe_with(flags: PipeFlags) -> io::Result<(OwnedFd, OwnedFd)> {
unsafe {
let mut result = MaybeUninit::<[OwnedFd; 2]>::uninit();
+2
View File
@@ -54,6 +54,7 @@ bitflags! {
const CLOEXEC = c::O_CLOEXEC;
/// `O_DIRECT`
#[cfg(not(any(
target_os = "haiku",
target_os = "illumos",
target_os = "openbsd",
target_os = "redox",
@@ -82,6 +83,7 @@ bitflags! {
/// `PIPE_BUF`—The maximum size of a write to a pipe guaranteed to be atomic.
#[cfg(not(any(
target_os = "haiku",
target_os = "illumos",
target_os = "redox",
target_os = "solaris",
+6
View File
@@ -43,6 +43,7 @@ pub(super) use c::mmap as libc_mmap;
target_os = "linux",
target_os = "emscripten",
target_os = "fuchsia",
target_os = "haiku",
target_os = "l4re",
target_os = "redox",
target_os = "wasi",
@@ -54,6 +55,7 @@ pub(super) use c::{rlimit as libc_rlimit, RLIM_INFINITY as LIBC_RLIM_INFINITY};
target_os = "android",
target_os = "fuchsia",
target_os = "emscripten",
target_os = "haiku",
target_os = "l4re",
target_os = "linux",
target_os = "wasi",
@@ -168,6 +170,7 @@ pub(super) use c::fallocate64 as libc_fallocate;
target_os = "android",
target_os = "dragonfly",
target_os = "emscripten",
target_os = "haiku",
target_os = "illumos",
target_os = "ios",
target_os = "linux",
@@ -289,6 +292,7 @@ mod readwrite_pv64 {
windows,
target_os = "android",
target_os = "emscripten",
target_os = "haiku",
target_os = "ios",
target_os = "linux",
target_os = "macos",
@@ -346,6 +350,7 @@ pub(super) use c::posix_fallocate64 as libc_posix_fallocate;
windows,
target_os = "android",
target_os = "emscripten",
target_os = "haiku",
target_os = "illumos",
target_os = "linux",
target_os = "l4re",
@@ -359,6 +364,7 @@ pub(super) use {c::fstatfs as libc_fstatfs, c::statfs as libc_statfs};
windows,
target_os = "android",
target_os = "emscripten",
target_os = "haiku",
target_os = "illumos",
target_os = "linux",
target_os = "l4re",
+30 -5
View File
@@ -20,7 +20,12 @@ use crate::fd::BorrowedFd;
use crate::ffi::CStr;
use crate::io;
use core::mem::MaybeUninit;
#[cfg(not(any(target_os = "fuchsia", target_os = "redox", target_os = "wasi")))]
#[cfg(not(any(
target_os = "fuchsia",
target_os = "haiku",
target_os = "redox",
target_os = "wasi"
)))]
use {
super::super::conv::ret_infallible,
super::super::offset::{libc_getrlimit, libc_rlimit, libc_setrlimit, LIBC_RLIM_INFINITY},
@@ -298,7 +303,12 @@ pub(crate) fn setpriority_process(pid: Option<Pid>, priority: i32) -> io::Result
}
}
#[cfg(not(any(target_os = "fuchsia", target_os = "redox", target_os = "wasi")))]
#[cfg(not(any(
target_os = "fuchsia",
target_os = "haiku",
target_os = "redox",
target_os = "wasi"
)))]
#[inline]
pub(crate) fn getrlimit(limit: Resource) -> Rlimit {
let mut result = MaybeUninit::<libc_rlimit>::uninit();
@@ -308,7 +318,12 @@ pub(crate) fn getrlimit(limit: Resource) -> Rlimit {
}
}
#[cfg(not(any(target_os = "fuchsia", target_os = "redox", target_os = "wasi")))]
#[cfg(not(any(
target_os = "fuchsia",
target_os = "haiku",
target_os = "redox",
target_os = "wasi"
)))]
#[inline]
pub(crate) fn setrlimit(limit: Resource, new: Rlimit) -> io::Result<()> {
let lim = rlimit_to_libc(new)?;
@@ -332,7 +347,12 @@ pub(crate) fn prlimit(pid: Option<Pid>, limit: Resource, new: Rlimit) -> io::Res
}
/// Convert a Rust [`Rlimit`] to a C `libc_rlimit`.
#[cfg(not(any(target_os = "fuchsia", target_os = "redox", target_os = "wasi")))]
#[cfg(not(any(
target_os = "fuchsia",
target_os = "haiku",
target_os = "redox",
target_os = "wasi"
)))]
fn rlimit_from_libc(lim: libc_rlimit) -> Rlimit {
let current = if lim.rlim_cur == LIBC_RLIM_INFINITY {
None
@@ -348,7 +368,12 @@ fn rlimit_from_libc(lim: libc_rlimit) -> Rlimit {
}
/// Convert a C `libc_rlimit` to a Rust `Rlimit`.
#[cfg(not(any(target_os = "fuchsia", target_os = "redox", target_os = "wasi")))]
#[cfg(not(any(
target_os = "fuchsia",
target_os = "haiku",
target_os = "redox",
target_os = "wasi"
)))]
fn rlimit_to_libc(lim: Rlimit) -> io::Result<libc_rlimit> {
let Rlimit { current, maximum } = lim;
let rlim_cur = match current {
+12 -1
View File
@@ -41,7 +41,12 @@ pub enum MembarrierCommand {
/// [`getrlimit`]: crate::process::getrlimit
/// [`setrlimit`]: crate::process::setrlimit
/// [`prlimit`]: crate::process::prlimit
#[cfg(not(any(target_os = "fuchsia", target_os = "redox", target_os = "wasi")))]
#[cfg(not(any(
target_os = "fuchsia",
target_os = "haiku",
target_os = "redox",
target_os = "wasi"
)))]
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
#[repr(i32)]
pub enum Resource {
@@ -204,6 +209,7 @@ pub enum Signal {
#[cfg(not(any(
target_os = "dragonfly",
target_os = "freebsd",
target_os = "haiku",
target_os = "illumos",
target_os = "ios",
target_os = "macos",
@@ -244,11 +250,13 @@ pub enum Signal {
Winch = c::SIGWINCH,
/// `SIGIO`, aka `SIGPOLL`
#[doc(alias = "Poll")]
#[cfg(not(target_os = "haiku"))]
Io = c::SIGIO,
/// `SIGPWR`
#[cfg(not(any(
target_os = "dragonfly",
target_os = "freebsd",
target_os = "haiku",
target_os = "ios",
target_os = "macos",
target_os = "netbsd",
@@ -284,6 +292,7 @@ impl Signal {
#[cfg(not(any(
target_os = "dragonfly",
target_os = "freebsd",
target_os = "haiku",
target_os = "illumos",
target_os = "ios",
target_os = "macos",
@@ -308,10 +317,12 @@ impl Signal {
c::SIGVTALRM => Some(Self::Vtalarm),
c::SIGPROF => Some(Self::Prof),
c::SIGWINCH => Some(Self::Winch),
#[cfg(not(target_os = "haiku"))]
c::SIGIO => Some(Self::Io),
#[cfg(not(any(
target_os = "dragonfly",
target_os = "freebsd",
target_os = "haiku",
target_os = "ios",
target_os = "macos",
target_os = "netbsd",
+5
View File
@@ -24,6 +24,7 @@ pub use backend::fs::types::FallocateFlags;
pub use backend::fs::types::Stat;
#[cfg(not(any(
target_os = "haiku",
target_os = "illumos",
target_os = "netbsd",
target_os = "redox",
@@ -33,6 +34,7 @@ pub use backend::fs::types::Stat;
pub use backend::fs::types::StatFs;
#[cfg(not(any(
target_os = "haiku",
target_os = "illumos",
target_os = "redox",
target_os = "solaris",
@@ -164,6 +166,7 @@ pub fn fstat<Fd: AsFd>(fd: Fd) -> io::Result<Stat> {
///
/// [Linux]: https://man7.org/linux/man-pages/man2/fstatfs.2.html
#[cfg(not(any(
target_os = "haiku",
target_os = "illumos",
target_os = "netbsd",
target_os = "redox",
@@ -190,6 +193,7 @@ pub fn fstatfs<Fd: AsFd>(fd: Fd) -> io::Result<StatFs> {
/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/fstatvfs.html
/// [Linux]: https://man7.org/linux/man-pages/man2/fstatvfs.2.html
#[cfg(not(any(
target_os = "haiku",
target_os = "illumos",
target_os = "redox",
target_os = "solaris",
@@ -306,6 +310,7 @@ pub fn fsync<Fd: AsFd>(fd: Fd) -> io::Result<()> {
/// [Linux]: https://man7.org/linux/man-pages/man2/fdatasync.2.html
#[cfg(not(any(
target_os = "dragonfly",
target_os = "haiku",
target_os = "ios",
target_os = "macos",
target_os = "redox",
+7
View File
@@ -22,6 +22,7 @@ mod cwd;
mod dir;
#[cfg(not(any(
target_os = "dragonfly",
target_os = "haiku",
target_os = "illumos",
target_os = "ios",
target_os = "macos",
@@ -43,6 +44,7 @@ mod getpath;
#[cfg(not(any(
target_os = "dragonfly",
target_os = "freebsd",
target_os = "haiku",
target_os = "illumos",
target_os = "ios",
target_os = "macos",
@@ -134,6 +136,7 @@ pub use cwd::cwd;
pub use dir::{Dir, DirEntry};
#[cfg(not(any(
target_os = "dragonfly",
target_os = "haiku",
target_os = "illumos",
target_os = "ios",
target_os = "macos",
@@ -162,6 +165,7 @@ pub use fcopyfile::{
};
#[cfg(not(any(
target_os = "dragonfly",
target_os = "haiku",
target_os = "ios",
target_os = "macos",
target_os = "redox",
@@ -182,6 +186,7 @@ pub use fd::{fchmod, fchown};
pub use fd::{flock, FlockOperation};
pub use fd::{fstat, fsync, ftruncate, futimens, is_file_read_write, seek, tell, Stat, Timestamps};
#[cfg(not(any(
target_os = "haiku",
target_os = "illumos",
target_os = "netbsd",
target_os = "redox",
@@ -190,6 +195,7 @@ pub use fd::{fstat, fsync, ftruncate, futimens, is_file_read_write, seek, tell,
)))]
pub use fd::{fstatfs, StatFs};
#[cfg(not(any(
target_os = "haiku",
target_os = "illumos",
target_os = "redox",
target_os = "solaris",
@@ -204,6 +210,7 @@ pub use getpath::getpath;
#[cfg(not(any(
target_os = "dragonfly",
target_os = "freebsd",
target_os = "haiku",
target_os = "illumos",
target_os = "ios",
target_os = "macos",
+2 -2
View File
@@ -12,7 +12,7 @@ use backend::fd::AsFd;
/// - [Linux]
///
/// [Linux]: https://man7.org/linux/man-pages/man4/tty_ioctl.4.html
#[cfg(not(any(windows, target_os = "redox", target_os = "wasi")))]
#[cfg(not(any(windows, target_os = "haiku", target_os = "redox", target_os = "wasi")))]
#[inline]
#[doc(alias = "TIOCEXCL")]
pub fn ioctl_tiocexcl<Fd: AsFd>(fd: Fd) -> io::Result<()> {
@@ -25,7 +25,7 @@ pub fn ioctl_tiocexcl<Fd: AsFd>(fd: Fd) -> io::Result<()> {
/// - [Linux]
///
/// [Linux]: https://man7.org/linux/man-pages/man4/tty_ioctl.4.html
#[cfg(not(any(windows, target_os = "redox", target_os = "wasi")))]
#[cfg(not(any(windows, target_os = "haiku", target_os = "redox", target_os = "wasi")))]
#[inline]
#[doc(alias = "TIOCNXCL")]
pub fn ioctl_tiocnxcl<Fd: AsFd>(fd: Fd) -> io::Result<()> {
+15 -3
View File
@@ -39,7 +39,7 @@ pub use ioctl::ioctl_fionbio;
pub use ioctl::ioctl_fionread;
#[cfg(any(target_os = "android", target_os = "linux"))]
pub use ioctl::{ioctl_blkpbszget, ioctl_blksszget};
#[cfg(not(any(windows, target_os = "redox", target_os = "wasi")))]
#[cfg(not(any(windows, target_os = "haiku", target_os = "redox", target_os = "wasi")))]
pub use ioctl::{ioctl_tiocexcl, ioctl_tiocnxcl};
#[cfg(not(any(windows, target_os = "redox")))]
#[cfg(feature = "net")]
@@ -48,20 +48,32 @@ pub use is_read_write::is_read_write;
pub use pipe::pipe;
#[cfg(not(any(
windows,
target_os = "haiku",
target_os = "illumos",
target_os = "redox",
target_os = "solaris",
target_os = "wasi",
)))]
pub use pipe::PIPE_BUF;
#[cfg(not(any(windows, target_os = "ios", target_os = "macos", target_os = "wasi")))]
#[cfg(not(any(
windows,
target_os = "haiku",
target_os = "ios",
target_os = "macos",
target_os = "wasi"
)))]
pub use pipe::{pipe_with, PipeFlags};
pub use poll::{poll, PollFd, PollFlags};
#[cfg(all(feature = "procfs", any(target_os = "android", target_os = "linux")))]
pub use procfs::{proc_self_fd, proc_self_fdinfo_fd, proc_self_maps, proc_self_pagemap};
#[cfg(not(windows))]
pub use read_write::{pread, pwrite, read, readv, write, writev, IoSlice, IoSliceMut};
#[cfg(not(any(windows, target_os = "redox", target_os = "solaris")))]
#[cfg(not(any(
windows,
target_os = "haiku",
target_os = "redox",
target_os = "solaris"
)))]
pub use read_write::{preadv, pwritev};
#[cfg(any(target_os = "android", target_os = "linux"))]
pub use read_write::{preadv2, pwritev2, ReadWriteFlags};
+2 -1
View File
@@ -15,6 +15,7 @@ pub use backend::io::types::PipeFlags;
/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/write.html
#[cfg(not(any(
windows,
target_os = "haiku",
target_os = "illumos",
target_os = "redox",
target_os = "solaris",
@@ -47,7 +48,7 @@ pub fn pipe() -> io::Result<(OwnedFd, OwnedFd)> {
/// - [Linux]
///
/// [Linux]: https://man7.org/linux/man-pages/man2/pipe2.2.html
#[cfg(not(any(target_os = "ios", target_os = "macos")))]
#[cfg(not(any(target_os = "haiku", target_os = "ios", target_os = "macos")))]
#[inline]
#[doc(alias = "pipe2")]
pub fn pipe_with(flags: PipeFlags) -> io::Result<(OwnedFd, OwnedFd)> {
+2 -2
View File
@@ -112,7 +112,7 @@ pub fn writev<Fd: AsFd>(fd: Fd, bufs: &[IoSlice<'_>]) -> io::Result<usize> {
/// - [Linux]
///
/// [Linux]: https://man7.org/linux/man-pages/man2/preadv.2.html
#[cfg(not(any(target_os = "redox", target_os = "solaris")))]
#[cfg(not(any(target_os = "haiku", target_os = "redox", target_os = "solaris")))]
#[inline]
pub fn preadv<Fd: AsFd>(fd: Fd, bufs: &mut [IoSliceMut<'_>], offset: u64) -> io::Result<usize> {
backend::io::syscalls::preadv(fd.as_fd(), bufs, offset)
@@ -125,7 +125,7 @@ pub fn preadv<Fd: AsFd>(fd: Fd, bufs: &mut [IoSliceMut<'_>], offset: u64) -> io:
/// - [Linux]
///
/// [Linux]: https://man7.org/linux/man-pages/man2/pwritev.2.html
#[cfg(not(any(target_os = "redox", target_os = "solaris")))]
#[cfg(not(any(target_os = "haiku", target_os = "redox", target_os = "solaris")))]
#[inline]
pub fn pwritev<Fd: AsFd>(fd: Fd, bufs: &[IoSlice<'_>], offset: u64) -> io::Result<usize> {
backend::io::syscalls::pwritev(fd.as_fd(), bufs, offset)
+12 -2
View File
@@ -13,7 +13,12 @@ mod membarrier;
mod prctl;
#[cfg(not(any(target_os = "fuchsia", target_os = "wasi")))] // WASI doesn't have [gs]etpriority.
mod priority;
#[cfg(not(any(target_os = "fuchsia", target_os = "redox", target_os = "wasi")))]
#[cfg(not(any(
target_os = "fuchsia",
target_os = "haiku",
target_os = "redox",
target_os = "wasi"
)))]
mod rlimit;
#[cfg(any(
target_os = "android",
@@ -61,7 +66,12 @@ pub use priority::{
};
#[cfg(any(target_os = "android", target_os = "linux"))]
pub use rlimit::prlimit;
#[cfg(not(any(target_os = "fuchsia", target_os = "redox", target_os = "wasi")))]
#[cfg(not(any(
target_os = "fuchsia",
target_os = "haiku",
target_os = "redox",
target_os = "wasi"
)))]
pub use rlimit::{getrlimit, setrlimit, Resource, Rlimit};
#[cfg(any(
target_os = "android",