Skip to content

Commit

Permalink
Merge branch 'nix-rust:master' into largefile
Browse files Browse the repository at this point in the history
  • Loading branch information
inglorion authored Jun 30, 2023
2 parents 20c25cf + 1376e15 commit 5b22580
Show file tree
Hide file tree
Showing 23 changed files with 106 additions and 86 deletions.
48 changes: 20 additions & 28 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,28 @@ env:
RUSTFLAGS: -D warnings
RUSTDOCFLAGS: -D warnings
TOOL: cargo
# The MSRV
TOOLCHAIN: 1.63.0
MSRV: 1.63.0
ZFLAGS:

# Tests that don't require executing the build binaries
build: &BUILD
build_script:
- . $HOME/.cargo/env || true
- $TOOL +$TOOLCHAIN -Vv
- rustc +$TOOLCHAIN -Vv
- $TOOL +$TOOLCHAIN $BUILD $ZFLAGS --target $TARGET --all-targets
- $TOOL +$TOOLCHAIN doc $ZFLAGS --no-deps --target $TARGET
- $TOOL +$TOOLCHAIN clippy $ZFLAGS --target $TARGET --all-targets -- -D warnings
- $TOOL -Vv
- rustc -Vv
- $TOOL $BUILD $ZFLAGS --target $TARGET --all-targets
- $TOOL doc $ZFLAGS --no-deps --target $TARGET
- $TOOL clippy $ZFLAGS --target $TARGET --all-targets -- -D warnings
- if [ -z "$NOHACK" ]; then mkdir -p $HOME/.cargo/bin; export PATH=$HOME/.cargo/bin:$PATH; fi
- if [ -z "$NOHACK" ]; then curl -LsSf https://github.com/taiki-e/cargo-hack/releases/latest/download/cargo-hack-${HOST:-$TARGET}.tar.gz | tar xzf - -C ~/.cargo/bin; fi
- if [ -z "$NOHACK" ]; then $TOOL +$TOOLCHAIN hack $ZFLAGS check --target $TARGET --each-feature; fi
- if [ -z "$NOHACK" ]; then $TOOL hack $ZFLAGS check --target $TARGET --each-feature; fi

# Tests that do require executing the binaries
test: &TEST
<< : *BUILD
test_script:
- . $HOME/.cargo/env || true
- $TOOL +$TOOLCHAIN test --target $TARGET
- $TOOL test --target $TARGET

# Test FreeBSD in a full VM. Test the i686 target too, in the
# same VM. The binary will be built in 32-bit mode, but will execute on a
Expand All @@ -52,10 +51,10 @@ task:
setup_script:
- kldload mqueuefs
- fetch https://sh.rustup.rs -o rustup.sh
- sh rustup.sh -y --profile=minimal --default-toolchain $TOOLCHAIN
- sh rustup.sh -y --profile=minimal --default-toolchain $MSRV
- . $HOME/.cargo/env
- rustup target add i686-unknown-freebsd
- rustup component add --toolchain $TOOLCHAIN clippy
- rustup component add clippy
<< : *TEST
i386_test_script:
- . $HOME/.cargo/env
Expand All @@ -76,9 +75,9 @@ task:
image: ghcr.io/cirruslabs/macos-ventura-base:latest
setup_script:
- curl --proto '=https' --tlsv1.2 -sSf -o rustup.sh https://sh.rustup.rs
- sh rustup.sh -y --profile=minimal --default-toolchain $TOOLCHAIN
- sh rustup.sh -y --profile=minimal --default-toolchain $MSRV
- . $HOME/.cargo/env
- rustup component add --toolchain $TOOLCHAIN clippy
- rustup component add clippy
<< : *TEST
before_cache_script: rm -rf $CARGO_HOME/registry/index

Expand Down Expand Up @@ -129,7 +128,7 @@ task:
setup_script:
- mkdir /tmp/home
- curl --proto '=https' --tlsv1.2 -sSf -o rustup.sh https://sh.rustup.rs
- sh rustup.sh -y --profile=minimal --default-toolchain $TOOLCHAIN
- sh rustup.sh -y --profile=minimal --default-toolchain $MSRV
- . $HOME/.cargo/env
- cargo install cross --version 0.2.1 # cross 0.2.2 bumped the MSRV to 1.58.1
<< : *TEST
Expand Down Expand Up @@ -165,9 +164,7 @@ task:
image: rust:latest
env:
TARGET: x86_64-unknown-linux-gnu
TOOLCHAIN:
setup_script:
- rustup target add $TARGET
- rustup component add clippy
<< : *TEST
before_cache_script: rm -rf $CARGO_HOME/registry/index
Expand Down Expand Up @@ -242,37 +239,33 @@ task:
TARGET: x86_64-unknown-netbsd
setup_script:
- rustup target add $TARGET
- rustup toolchain install $TOOLCHAIN --profile minimal --target $TARGET
- rustup component add --toolchain $TOOLCHAIN clippy
- rustup component add clippy
<< : *BUILD
before_cache_script: rm -rf $CARGO_HOME/registry/index

task:
container:
image: rust:1.63.0
# Redox's MSRV policy is unclear. Until they define it, use nightly.
image: rustlang/rust:nightly
env:
BUILD: check
name: Redox x86_64
env:
HOST: x86_64-unknown-linux-gnu
TARGET: x86_64-unknown-redox
# Redox's MSRV policy is unclear. Until they define it, use nightly.
TOOLCHAIN: nightly
setup_script:
- rustup target add $TARGET
- rustup toolchain install $TOOLCHAIN --profile minimal --target $TARGET
- rustup component add --toolchain $TOOLCHAIN clippy
- rustup component add clippy
<< : *BUILD
before_cache_script: rm -rf $CARGO_HOME/registry/index

# Rust Tier 3 targets can't use Rustup
## Rust Tier 3 targets can't use Rustup
task:
container:
image: rustlang/rust:nightly
env:
BUILD: check
HOST: x86_64-unknown-linux-gnu
TOOLCHAIN: nightly
ZFLAGS: -Zbuild-std
matrix:
- name: DragonFly BSD x86_64
Expand All @@ -299,7 +292,6 @@ task:
name: Minver
env:
HOST: x86_64-unknown-linux-gnu
TOOLCHAIN: nightly
container:
image: rustlang/rust:nightly
setup_script:
Expand All @@ -313,5 +305,5 @@ task:
name: Rust Formatter
container:
image: rust:latest
setup_script: rustup +$TOOLCHAIN component add rustfmt
test_script: $TOOL +$TOOLCHAIN fmt --all -- --check **/*.rs
setup_script: rustup component add rustfmt
test_script: cargo fmt --all -- --check **/*.rs
19 changes: 16 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ This project adheres to [Semantic Versioning](https://semver.org/).
- Added `mq_timedreceive` to `::nix::mqueue`.
([#1966])(https://github.com/nix-rust/nix/pull/1966)
- Added `LocalPeerPid` to `nix::sys::socket::sockopt` for macOS. ([#1967](https://github.com/nix-rust/nix/pull/1967))
- Added `TFD_TIMER_CANCEL_ON_SET` to `::nix::sys::time::TimerSetTimeFlags` on Linux and Android.
([#2040](https://github.com/nix-rust/nix/pull/2040))

### Changed

Expand All @@ -34,10 +36,13 @@ This project adheres to [Semantic Versioning](https://semver.org/).
([#2012](https://github.com/nix-rust/nix/pull/2012))

### Fixed
- Fix `SockaddrIn6` bug that was swapping flowinfo and scope_id byte ordering.
([#1964](https://github.com/nix-rust/nix/pull/1964))
- Fix: send ETH_P_ALL in htons format
- Fix: send `ETH_P_ALL` in htons format
([#1925](https://github.com/nix-rust/nix/pull/1925))
- Fix potentially invalid conversions in
`SockaddrIn::from<std::net::SocketAddrV4>`,
`SockaddrIn6::from<std::net::SockaddrV6>`, `IpMembershipRequest::new`, and
`Ipv6MembershipRequest::new` with future Rust versions.
([#2061](https://github.com/nix-rust/nix/pull/2061))

### Removed

Expand All @@ -49,6 +54,14 @@ This project adheres to [Semantic Versioning](https://semver.org/).
`nix::sys::signalfd::SignalFd` instead.
([#1938](https://github.com/nix-rust/nix/pull/1938))

## [0.26.2] - 2023-01-18

### Fixed

- Fix `SockaddrIn6` bug that was swapping `flowinfo` and `scope_id` byte
ordering.
([#1964](https://github.com/nix-rust/nix/pull/1964))

## [0.26.1] - 2022-11-29
### Fixed
- Fix UB with `sys::socket::sockopt::SockType` using `SOCK_PACKET`.
Expand Down
5 changes: 2 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,10 @@ targets = [

[dependencies]
libc = { version = "0.2.141", features = ["extra_traits"] }
bitflags = "1.1"
bitflags = "2.3.1"
cfg-if = "1.0"
pin-utils = { version = "0.1.0", optional = true }
static_assertions = "1"
memoffset = { version = "0.8", optional = true }
memoffset = { version = "0.9", optional = true }

[features]
default = [
Expand Down
4 changes: 2 additions & 2 deletions src/fcntl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,7 @@ pub fn vmsplice(
}
}

#[cfg(any(target_os = "linux"))]
#[cfg(target_os = "linux")]
#[cfg(feature = "fs")]
libc_bitflags!(
/// Mode argument flags for fallocate determining operation performed on a given range.
Expand Down Expand Up @@ -752,7 +752,7 @@ feature! {
///
/// Allows the caller to directly manipulate the allocated disk space for the
/// file referred to by fd.
#[cfg(any(target_os = "linux"))]
#[cfg(target_os = "linux")]
#[cfg(feature = "fs")]
pub fn fallocate(
fd: RawFd,
Expand Down
15 changes: 8 additions & 7 deletions src/features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ mod os {
use crate::sys::utsname::uname;
use crate::Result;
use std::os::unix::ffi::OsStrExt;
use std::sync::atomic::{AtomicUsize, Ordering};

// Features:
// * atomic cloexec on socket: 2.6.27
Expand Down Expand Up @@ -72,15 +73,15 @@ mod os {
}

fn kernel_version() -> Result<usize> {
static mut KERNEL_VERS: usize = 0;
static KERNEL_VERS: AtomicUsize = AtomicUsize::new(0);
let mut kernel_vers = KERNEL_VERS.load(Ordering::Relaxed);

unsafe {
if KERNEL_VERS == 0 {
KERNEL_VERS = parse_kernel_version()?;
}

Ok(KERNEL_VERS)
if kernel_vers == 0 {
kernel_vers = parse_kernel_version()?;
KERNEL_VERS.store(kernel_vers, Ordering::Relaxed);
}

Ok(kernel_vers)
}

/// Check if the OS supports atomic close-on-exec for sockets
Expand Down
2 changes: 2 additions & 0 deletions src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ macro_rules! libc_bitflags {
}
) => {
::bitflags::bitflags! {
#[derive(Copy, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[repr(transparent)]
$(#[$outer])*
pub struct $BitFlags: $T {
$(
Expand Down
4 changes: 2 additions & 2 deletions src/mount/bsd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ impl<'a> Nmount<'a> {

let niov = self.iov.len() as c_uint;
let iovp = self.iov.as_mut_ptr() as *mut libc::iovec;
let res = unsafe { libc::nmount(iovp, niov, flags.bits) };
let res = unsafe { libc::nmount(iovp, niov, flags.bits()) };
match Errno::result(res) {
Ok(_) => Ok(()),
Err(error) => {
Expand Down Expand Up @@ -446,7 +446,7 @@ where
P: ?Sized + NixPath,
{
let res = mountpoint.with_nix_path(|cstr| unsafe {
libc::unmount(cstr.as_ptr(), flags.bits)
libc::unmount(cstr.as_ptr(), flags.bits())
})?;

Errno::result(res).map(drop)
Expand Down
4 changes: 2 additions & 2 deletions src/mount/linux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ pub fn mount<
s,
t.as_ptr(),
ty,
flags.bits,
flags.bits(),
d as *const libc::c_void,
)
})
Expand All @@ -156,7 +156,7 @@ pub fn umount<P: ?Sized + NixPath>(target: &P) -> Result<()> {
/// See also [`umount`](https://man7.org/linux/man-pages/man2/umount.2.html)
pub fn umount2<P: ?Sized + NixPath>(target: &P, flags: MntFlags) -> Result<()> {
let res = target.with_nix_path(|cstr| unsafe {
libc::umount2(cstr.as_ptr(), flags.bits)
libc::umount2(cstr.as_ptr(), flags.bits())
})?;

Errno::result(res).map(drop)
Expand Down
2 changes: 1 addition & 1 deletion src/mqueue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ impl MqAttr {
/// Open a message queue
///
/// See also [`mq_open(2)`](https://pubs.opengroup.org/onlinepubs/9699919799/functions/mq_open.html)
// The mode.bits cast is only lossless on some OSes
// The mode.bits() cast is only lossless on some OSes
#[allow(clippy::cast_lossless)]
pub fn mq_open(
name: &CStr,
Expand Down
6 changes: 3 additions & 3 deletions src/sys/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ impl Kqueue {
timeout as *const timespec
} else {
ptr::null()
}
},
)
};
Errno::result(res).map(|r| r as usize)
Expand All @@ -86,7 +86,7 @@ impl Kqueue {
target_os = "openbsd"
))]
type type_of_udata = *mut libc::c_void;
#[cfg(any(target_os = "netbsd"))]
#[cfg(target_os = "netbsd")]
type type_of_udata = intptr_t;

#[cfg(target_os = "netbsd")]
Expand Down Expand Up @@ -171,7 +171,7 @@ libc_enum! {
))]
#[doc(hidden)]
pub type type_of_event_flag = u16;
#[cfg(any(target_os = "netbsd"))]
#[cfg(target_os = "netbsd")]
#[doc(hidden)]
pub type type_of_event_flag = u32;
libc_bitflags! {
Expand Down
5 changes: 4 additions & 1 deletion src/sys/personality.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,10 @@ pub fn get() -> Result<Persona> {
///
/// Example:
///
/// ```
// Disable test on aarch64 until we know why it fails.
// https://github.com/nix-rust/nix/issues/2060
#[cfg_attr(target_arch = "aarch64", doc = " ```no_run")]
#[cfg_attr(not(target_arch = "aarch64"), doc = " ```")]
/// # use nix::sys::personality::{self, Persona};
/// let mut pers = personality::get().unwrap();
/// assert!(!pers.contains(Persona::ADDR_NO_RANDOMIZE));
Expand Down
Loading

0 comments on commit 5b22580

Please sign in to comment.