diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f999054de..f4b67a0ba 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -148,6 +148,10 @@ jobs: - run: cargo check --workspace --release --no-default-features --features use-libc -vv - run: cargo check --workspace --release --no-default-features --features all-apis -vv - run: cargo check --workspace --release --no-default-features --features all-apis,use-libc -vv + - run: cargo check --workspace --release --no-default-features --features time -vv + - run: cargo check --workspace --release --no-default-features --features time,use-libc -vv + - run: rustup component add rust-src + - run: cargo check --workspace --release --no-default-features --target=i686-unknown-linux-gnu -Zbuild-std -vv check_nightly: name: Check nightly-only targets diff --git a/src/backend/linux_raw/c.rs b/src/backend/linux_raw/c.rs index 1afe894ff..8e77c82d7 100644 --- a/src/backend/linux_raw/c.rs +++ b/src/backend/linux_raw/c.rs @@ -21,7 +21,19 @@ pub(crate) use linux_raw_sys::general::{ #[cfg(test)] pub(crate) use linux_raw_sys::general::epoll_event; -#[cfg(feature = "fs")] +#[cfg(any( + feature = "fs", + all( + not(feature = "use-libc-auxv"), + not(target_vendor = "mustang"), + any( + feature = "param", + feature = "runtime", + feature = "time", + target_arch = "x86", + ) + ) +))] pub(crate) use linux_raw_sys::general::{ AT_FDCWD, NFS_SUPER_MAGIC, O_LARGEFILE, PROC_SUPER_MAGIC, UTIME_NOW, UTIME_OMIT, XATTR_CREATE, XATTR_REPLACE, diff --git a/src/backend/linux_raw/conv.rs b/src/backend/linux_raw/conv.rs index 18f061c1f..05d040204 100644 --- a/src/backend/linux_raw/conv.rs +++ b/src/backend/linux_raw/conv.rs @@ -34,8 +34,6 @@ use super::time::types::TimerfdClockId; use crate::clockid::ClockId; use crate::fd::OwnedFd; use crate::ffi::CStr; -#[cfg(feature = "fs")] -use crate::fs::{FileType, Mode, OFlags}; use crate::io; #[cfg(any(feature = "process", feature = "runtime", feature = "termios"))] use crate::pid::Pid; @@ -50,9 +48,6 @@ use core::ptr::null_mut; use linux_raw_sys::general::__kernel_clockid_t; #[cfg(target_pointer_width = "64")] use linux_raw_sys::general::__kernel_loff_t; -#[cfg(target_pointer_width = "32")] -#[cfg(feature = "fs")] -use linux_raw_sys::general::O_LARGEFILE; #[cfg(feature = "net")] use linux_raw_sys::net::socklen_t; @@ -301,75 +296,159 @@ pub(super) fn socklen_t<'a, Num: ArgNumber>(i: socklen_t) -> ArgReg<'a, Num> { pass_usize(i as usize) } -#[cfg(feature = "fs")] -impl<'a, Num: ArgNumber> From for ArgReg<'a, Num> { - #[inline] - fn from(mode: Mode) -> Self { - pass_usize(mode.bits() as usize) +#[cfg(any( + feature = "fs", + all( + not(feature = "use-libc-auxv"), + not(target_vendor = "mustang"), + any( + feature = "param", + feature = "runtime", + feature = "time", + target_arch = "x86", + ) + ) +))] +pub(crate) mod fs { + use super::*; + use crate::fs::{FileType, Mode, OFlags}; + #[cfg(target_pointer_width = "32")] + use linux_raw_sys::general::O_LARGEFILE; + + impl<'a, Num: ArgNumber> From for ArgReg<'a, Num> { + #[inline] + fn from(mode: Mode) -> Self { + pass_usize(mode.bits() as usize) + } } -} -#[cfg(feature = "fs")] -impl<'a, Num: ArgNumber> From<(Mode, FileType)> for ArgReg<'a, Num> { - #[inline] - fn from(pair: (Mode, FileType)) -> Self { - pass_usize(pair.0.as_raw_mode() as usize | pair.1.as_raw_mode() as usize) + impl<'a, Num: ArgNumber> From<(Mode, FileType)> for ArgReg<'a, Num> { + #[inline] + fn from(pair: (Mode, FileType)) -> Self { + pass_usize(pair.0.as_raw_mode() as usize | pair.1.as_raw_mode() as usize) + } } -} -#[cfg(feature = "fs")] -impl<'a, Num: ArgNumber> From for ArgReg<'a, Num> { - #[inline] - fn from(flags: crate::fs::AtFlags) -> Self { - c_uint(flags.bits()) + impl<'a, Num: ArgNumber> From for ArgReg<'a, Num> { + #[inline] + fn from(flags: crate::fs::AtFlags) -> Self { + c_uint(flags.bits()) + } } -} -#[cfg(feature = "fs")] -impl<'a, Num: ArgNumber> From for ArgReg<'a, Num> { - #[inline] - fn from(flags: crate::fs::XattrFlags) -> Self { - c_uint(flags.bits()) + impl<'a, Num: ArgNumber> From for ArgReg<'a, Num> { + #[inline] + fn from(flags: crate::fs::XattrFlags) -> Self { + c_uint(flags.bits()) + } } -} -#[cfg(feature = "fs")] -impl<'a, Num: ArgNumber> From for ArgReg<'a, Num> { - #[inline] - fn from(flags: crate::fs::inotify::CreateFlags) -> Self { - c_uint(flags.bits()) + impl<'a, Num: ArgNumber> From for ArgReg<'a, Num> { + #[inline] + fn from(flags: crate::fs::inotify::CreateFlags) -> Self { + c_uint(flags.bits()) + } } -} -#[cfg(feature = "fs")] -impl<'a, Num: ArgNumber> From for ArgReg<'a, Num> { - #[inline] - fn from(flags: crate::fs::inotify::WatchFlags) -> Self { - c_uint(flags.bits()) + impl<'a, Num: ArgNumber> From for ArgReg<'a, Num> { + #[inline] + fn from(flags: crate::fs::inotify::WatchFlags) -> Self { + c_uint(flags.bits()) + } + } + + impl<'a, Num: ArgNumber> From for ArgReg<'a, Num> { + #[inline] + fn from(flags: crate::fs::MemfdFlags) -> Self { + c_uint(flags.bits()) + } + } + + impl<'a, Num: ArgNumber> From for ArgReg<'a, Num> { + #[inline] + fn from(flags: crate::fs::RenameFlags) -> Self { + c_uint(flags.bits()) + } } -} -#[cfg(feature = "fs")] -impl<'a, Num: ArgNumber> From for ArgReg<'a, Num> { + impl<'a, Num: ArgNumber> From for ArgReg<'a, Num> { + #[inline] + fn from(flags: crate::fs::StatxFlags) -> Self { + c_uint(flags.bits()) + } + } + + #[cfg(target_pointer_width = "32")] #[inline] - fn from(flags: crate::fs::MemfdFlags) -> Self { - c_uint(flags.bits()) + fn oflags_bits(oflags: OFlags) -> c::c_uint { + let mut bits = oflags.bits(); + // Add `O_LARGEFILE`, unless `O_PATH` is set, as Linux returns `EINVAL` + // when both are set. + if !oflags.contains(OFlags::PATH) { + bits |= O_LARGEFILE; + } + bits } -} -#[cfg(feature = "fs")] -impl<'a, Num: ArgNumber> From for ArgReg<'a, Num> { + #[cfg(target_pointer_width = "64")] #[inline] - fn from(flags: crate::fs::RenameFlags) -> Self { - c_uint(flags.bits()) + const fn oflags_bits(oflags: OFlags) -> c::c_uint { + oflags.bits() } -} -#[cfg(feature = "fs")] -impl<'a, Num: ArgNumber> From for ArgReg<'a, Num> { + impl<'a, Num: ArgNumber> From for ArgReg<'a, Num> { + #[inline] + fn from(oflags: OFlags) -> Self { + pass_usize(oflags_bits(oflags) as usize) + } + } + + /// Convert an `OFlags` into a `u64` for use in the `open_how` struct. #[inline] - fn from(flags: crate::fs::StatxFlags) -> Self { - c_uint(flags.bits()) + pub(crate) fn oflags_for_open_how(oflags: OFlags) -> u64 { + u64::from(oflags_bits(oflags)) + } + + impl<'a, Num: ArgNumber> From for ArgReg<'a, Num> { + #[inline] + fn from(flags: crate::fs::FallocateFlags) -> Self { + c_uint(flags.bits()) + } + } + + impl<'a, Num: ArgNumber> From for ArgReg<'a, Num> { + #[inline] + fn from(advice: crate::fs::Advice) -> Self { + c_uint(advice as c::c_uint) + } + } + + impl<'a, Num: ArgNumber> From for ArgReg<'a, Num> { + #[inline] + fn from(flags: crate::fs::SealFlags) -> Self { + c_uint(flags.bits()) + } + } + + impl<'a, Num: ArgNumber> From for ArgReg<'a, Num> { + #[inline] + fn from(access: crate::fs::Access) -> Self { + c_uint(access.bits()) + } + } + + impl<'a, Num: ArgNumber> From for ArgReg<'a, Num> { + #[inline] + fn from(flags: crate::backend::fs::types::MountFlagsArg) -> Self { + c_uint(flags.0) + } + } + + impl<'a, Num: ArgNumber> From for ArgReg<'a, Num> { + #[inline] + fn from(flags: crate::backend::fs::types::UnmountFlags) -> Self { + c_uint(flags.bits()) + } } } @@ -536,49 +615,6 @@ pub(super) fn dev_t<'a, Num: ArgNumber>(dev: u64) -> io::Result> Ok(pass_usize(dev.try_into().map_err(|_err| io::Errno::INVAL)?)) } -#[cfg(target_pointer_width = "32")] -#[cfg(feature = "fs")] -#[inline] -fn oflags_bits(oflags: OFlags) -> c::c_uint { - let mut bits = oflags.bits(); - // Add `O_LARGEFILE`, unless `O_PATH` is set, as Linux returns `EINVAL` - // when both are set. - if !oflags.contains(OFlags::PATH) { - bits |= O_LARGEFILE; - } - bits -} - -#[cfg(target_pointer_width = "64")] -#[cfg(feature = "fs")] -#[inline] -const fn oflags_bits(oflags: OFlags) -> c::c_uint { - oflags.bits() -} - -#[cfg(feature = "fs")] -impl<'a, Num: ArgNumber> From for ArgReg<'a, Num> { - #[inline] - fn from(oflags: OFlags) -> Self { - pass_usize(oflags_bits(oflags) as usize) - } -} - -/// Convert an `OFlags` into a `u64` for use in the `open_how` struct. -#[cfg(feature = "fs")] -#[inline] -pub(super) fn oflags_for_open_how(oflags: OFlags) -> u64 { - u64::from(oflags_bits(oflags)) -} - -#[cfg(feature = "fs")] -impl<'a, Num: ArgNumber> From for ArgReg<'a, Num> { - #[inline] - fn from(flags: crate::fs::FallocateFlags) -> Self { - c_uint(flags.bits()) - } -} - /// Convert a `Resource` into a syscall argument. #[cfg(feature = "process")] impl<'a, Num: ArgNumber> From for ArgReg<'a, Num> { @@ -610,22 +646,6 @@ impl<'a, Num: ArgNumber> From for ArgReg<'a, Num> { } } -#[cfg(feature = "fs")] -impl<'a, Num: ArgNumber> From for ArgReg<'a, Num> { - #[inline] - fn from(advice: crate::fs::Advice) -> Self { - c_uint(advice as c::c_uint) - } -} - -#[cfg(feature = "fs")] -impl<'a, Num: ArgNumber> From for ArgReg<'a, Num> { - #[inline] - fn from(flags: crate::fs::SealFlags) -> Self { - c_uint(flags.bits()) - } -} - #[cfg(feature = "io_uring")] impl<'a, Num: ArgNumber> From for ArgReg<'a, Num> { #[inline] @@ -710,14 +730,6 @@ impl<'a, Num: ArgNumber> From<(crate::thread::FutexOperation, crate::thread::Fut } } -#[cfg(feature = "fs")] -impl<'a, Num: ArgNumber> From for ArgReg<'a, Num> { - #[inline] - fn from(access: crate::fs::Access) -> Self { - c_uint(access.bits()) - } -} - #[cfg(feature = "net")] impl<'a, Num: ArgNumber> From for ArgReg<'a, Num> { #[inline] @@ -751,22 +763,6 @@ impl<'a, Num: ArgNumber, T> From<&'a mut [MaybeUninit]> for ArgReg<'a, Num> { } } -#[cfg(feature = "fs")] -impl<'a, Num: ArgNumber> From for ArgReg<'a, Num> { - #[inline] - fn from(flags: crate::backend::fs::types::MountFlagsArg) -> Self { - c_uint(flags.0) - } -} - -#[cfg(feature = "fs")] -impl<'a, Num: ArgNumber> From for ArgReg<'a, Num> { - #[inline] - fn from(flags: crate::backend::fs::types::UnmountFlags) -> Self { - c_uint(flags.bits()) - } -} - #[cfg(any(feature = "process", feature = "thread"))] impl<'a, Num: ArgNumber> From for ArgReg<'a, Num> { #[inline] diff --git a/src/backend/linux_raw/fs/syscalls.rs b/src/backend/linux_raw/fs/syscalls.rs index 65dc12203..61a8fc4d7 100644 --- a/src/backend/linux_raw/fs/syscalls.rs +++ b/src/backend/linux_raw/fs/syscalls.rs @@ -7,9 +7,10 @@ #![allow(clippy::undocumented_unsafe_blocks)] use crate::backend::c; +use crate::backend::conv::fs::oflags_for_open_how; use crate::backend::conv::{ - by_ref, c_int, c_uint, dev_t, oflags_for_open_how, opt_mut, pass_usize, raw_fd, ret, ret_c_int, - ret_c_uint, ret_infallible, ret_owned_fd, ret_usize, size_of, slice, slice_mut, zero, + by_ref, c_int, c_uint, dev_t, opt_mut, pass_usize, raw_fd, ret, ret_c_int, ret_c_uint, + ret_infallible, ret_owned_fd, ret_usize, size_of, slice, slice_mut, zero, }; #[cfg(target_pointer_width = "64")] use crate::backend::conv::{loff_t, loff_t_from_u64, ret_u64}; diff --git a/src/backend/linux_raw/mod.rs b/src/backend/linux_raw/mod.rs index f675b6c13..cd5805f88 100644 --- a/src/backend/linux_raw/mod.rs +++ b/src/backend/linux_raw/mod.rs @@ -32,7 +32,19 @@ mod vdso_wrappers; #[cfg(feature = "event")] pub(crate) mod event; -#[cfg(feature = "fs")] +#[cfg(any( + feature = "fs", + all( + not(feature = "use-libc-auxv"), + not(target_vendor = "mustang"), + any( + feature = "param", + feature = "runtime", + feature = "time", + target_arch = "x86", + ) + ) +))] pub(crate) mod fs; pub(crate) mod io; #[cfg(feature = "io_uring")] @@ -82,7 +94,21 @@ pub(crate) mod c; pub(crate) mod pid; #[cfg(any(feature = "process", feature = "thread"))] pub(crate) mod prctl; -#[cfg(any(feature = "fs", feature = "thread", feature = "process"))] +#[cfg(any( + feature = "fs", + feature = "process", + feature = "thread", + all( + not(feature = "use-libc-auxv"), + not(target_vendor = "mustang"), + any( + feature = "param", + feature = "runtime", + feature = "time", + target_arch = "x86", + ) + ) +))] pub(crate) mod ugid; /// The maximum number of buffers that can be passed into a vectored I/O system diff --git a/src/lib.rs b/src/lib.rs index 6187a8355..3fcf92544 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -183,7 +183,20 @@ pub mod event; #[cfg(not(windows))] pub mod ffi; #[cfg(not(windows))] -#[cfg(feature = "fs")] +#[cfg(any( + feature = "fs", + all( + linux_raw, + not(feature = "use-libc-auxv"), + not(target_vendor = "mustang"), + any( + feature = "param", + feature = "runtime", + feature = "time", + target_arch = "x86", + ) + ) +))] #[cfg_attr(doc_cfg, doc(cfg(feature = "fs")))] pub mod fs; pub mod io; @@ -204,7 +217,21 @@ pub mod net; #[cfg_attr(doc_cfg, doc(cfg(feature = "param")))] pub mod param; #[cfg(not(windows))] -#[cfg(any(feature = "fs", feature = "net"))] +#[cfg(any( + feature = "fs", + feature = "net", + all( + linux_raw, + not(feature = "use-libc-auxv"), + not(target_vendor = "mustang"), + any( + feature = "param", + feature = "runtime", + feature = "time", + target_arch = "x86", + ) + ) +))] #[cfg_attr(doc_cfg, doc(cfg(any(feature = "fs", feature = "net"))))] pub mod path; #[cfg(feature = "pipe")] @@ -282,9 +309,35 @@ mod signal; feature = "fs", feature = "runtime", feature = "thread", - feature = "time" + feature = "time", + all( + linux_raw, + not(feature = "use-libc-auxv"), + not(target_vendor = "mustang"), + any( + feature = "param", + feature = "runtime", + feature = "time", + target_arch = "x86", + ) + ) ))] mod timespec; #[cfg(not(any(windows, target_os = "wasi")))] -#[cfg(any(feature = "fs", feature = "process", feature = "thread"))] +#[cfg(any( + feature = "fs", + feature = "process", + feature = "thread", + all( + linux_raw, + not(feature = "use-libc-auxv"), + not(target_vendor = "mustang"), + any( + feature = "param", + feature = "runtime", + feature = "time", + target_arch = "x86", + ) + ) +))] mod ugid;