Skip to content

Commit 5b22580

Browse files
authored
Merge branch 'nix-rust:master' into largefile
2 parents 20c25cf + 1376e15 commit 5b22580

23 files changed

+106
-86
lines changed

.cirrus.yml

+20-28
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,28 @@ env:
88
RUSTFLAGS: -D warnings
99
RUSTDOCFLAGS: -D warnings
1010
TOOL: cargo
11-
# The MSRV
12-
TOOLCHAIN: 1.63.0
11+
MSRV: 1.63.0
1312
ZFLAGS:
1413

1514
# Tests that don't require executing the build binaries
1615
build: &BUILD
1716
build_script:
1817
- . $HOME/.cargo/env || true
19-
- $TOOL +$TOOLCHAIN -Vv
20-
- rustc +$TOOLCHAIN -Vv
21-
- $TOOL +$TOOLCHAIN $BUILD $ZFLAGS --target $TARGET --all-targets
22-
- $TOOL +$TOOLCHAIN doc $ZFLAGS --no-deps --target $TARGET
23-
- $TOOL +$TOOLCHAIN clippy $ZFLAGS --target $TARGET --all-targets -- -D warnings
18+
- $TOOL -Vv
19+
- rustc -Vv
20+
- $TOOL $BUILD $ZFLAGS --target $TARGET --all-targets
21+
- $TOOL doc $ZFLAGS --no-deps --target $TARGET
22+
- $TOOL clippy $ZFLAGS --target $TARGET --all-targets -- -D warnings
2423
- if [ -z "$NOHACK" ]; then mkdir -p $HOME/.cargo/bin; export PATH=$HOME/.cargo/bin:$PATH; fi
2524
- 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
26-
- if [ -z "$NOHACK" ]; then $TOOL +$TOOLCHAIN hack $ZFLAGS check --target $TARGET --each-feature; fi
25+
- if [ -z "$NOHACK" ]; then $TOOL hack $ZFLAGS check --target $TARGET --each-feature; fi
2726

2827
# Tests that do require executing the binaries
2928
test: &TEST
3029
<< : *BUILD
3130
test_script:
3231
- . $HOME/.cargo/env || true
33-
- $TOOL +$TOOLCHAIN test --target $TARGET
32+
- $TOOL test --target $TARGET
3433

3534
# Test FreeBSD in a full VM. Test the i686 target too, in the
3635
# same VM. The binary will be built in 32-bit mode, but will execute on a
@@ -52,10 +51,10 @@ task:
5251
setup_script:
5352
- kldload mqueuefs
5453
- fetch https://sh.rustup.rs -o rustup.sh
55-
- sh rustup.sh -y --profile=minimal --default-toolchain $TOOLCHAIN
54+
- sh rustup.sh -y --profile=minimal --default-toolchain $MSRV
5655
- . $HOME/.cargo/env
5756
- rustup target add i686-unknown-freebsd
58-
- rustup component add --toolchain $TOOLCHAIN clippy
57+
- rustup component add clippy
5958
<< : *TEST
6059
i386_test_script:
6160
- . $HOME/.cargo/env
@@ -76,9 +75,9 @@ task:
7675
image: ghcr.io/cirruslabs/macos-ventura-base:latest
7776
setup_script:
7877
- curl --proto '=https' --tlsv1.2 -sSf -o rustup.sh https://sh.rustup.rs
79-
- sh rustup.sh -y --profile=minimal --default-toolchain $TOOLCHAIN
78+
- sh rustup.sh -y --profile=minimal --default-toolchain $MSRV
8079
- . $HOME/.cargo/env
81-
- rustup component add --toolchain $TOOLCHAIN clippy
80+
- rustup component add clippy
8281
<< : *TEST
8382
before_cache_script: rm -rf $CARGO_HOME/registry/index
8483

@@ -129,7 +128,7 @@ task:
129128
setup_script:
130129
- mkdir /tmp/home
131130
- curl --proto '=https' --tlsv1.2 -sSf -o rustup.sh https://sh.rustup.rs
132-
- sh rustup.sh -y --profile=minimal --default-toolchain $TOOLCHAIN
131+
- sh rustup.sh -y --profile=minimal --default-toolchain $MSRV
133132
- . $HOME/.cargo/env
134133
- cargo install cross --version 0.2.1 # cross 0.2.2 bumped the MSRV to 1.58.1
135134
<< : *TEST
@@ -165,9 +164,7 @@ task:
165164
image: rust:latest
166165
env:
167166
TARGET: x86_64-unknown-linux-gnu
168-
TOOLCHAIN:
169167
setup_script:
170-
- rustup target add $TARGET
171168
- rustup component add clippy
172169
<< : *TEST
173170
before_cache_script: rm -rf $CARGO_HOME/registry/index
@@ -242,37 +239,33 @@ task:
242239
TARGET: x86_64-unknown-netbsd
243240
setup_script:
244241
- rustup target add $TARGET
245-
- rustup toolchain install $TOOLCHAIN --profile minimal --target $TARGET
246-
- rustup component add --toolchain $TOOLCHAIN clippy
242+
- rustup component add clippy
247243
<< : *BUILD
248244
before_cache_script: rm -rf $CARGO_HOME/registry/index
249245

250246
task:
251247
container:
252-
image: rust:1.63.0
248+
# Redox's MSRV policy is unclear. Until they define it, use nightly.
249+
image: rustlang/rust:nightly
253250
env:
254251
BUILD: check
255252
name: Redox x86_64
256253
env:
257254
HOST: x86_64-unknown-linux-gnu
258255
TARGET: x86_64-unknown-redox
259-
# Redox's MSRV policy is unclear. Until they define it, use nightly.
260-
TOOLCHAIN: nightly
261256
setup_script:
262257
- rustup target add $TARGET
263-
- rustup toolchain install $TOOLCHAIN --profile minimal --target $TARGET
264-
- rustup component add --toolchain $TOOLCHAIN clippy
258+
- rustup component add clippy
265259
<< : *BUILD
266260
before_cache_script: rm -rf $CARGO_HOME/registry/index
267261

268-
# Rust Tier 3 targets can't use Rustup
262+
## Rust Tier 3 targets can't use Rustup
269263
task:
270264
container:
271265
image: rustlang/rust:nightly
272266
env:
273267
BUILD: check
274268
HOST: x86_64-unknown-linux-gnu
275-
TOOLCHAIN: nightly
276269
ZFLAGS: -Zbuild-std
277270
matrix:
278271
- name: DragonFly BSD x86_64
@@ -299,7 +292,6 @@ task:
299292
name: Minver
300293
env:
301294
HOST: x86_64-unknown-linux-gnu
302-
TOOLCHAIN: nightly
303295
container:
304296
image: rustlang/rust:nightly
305297
setup_script:
@@ -313,5 +305,5 @@ task:
313305
name: Rust Formatter
314306
container:
315307
image: rust:latest
316-
setup_script: rustup +$TOOLCHAIN component add rustfmt
317-
test_script: $TOOL +$TOOLCHAIN fmt --all -- --check **/*.rs
308+
setup_script: rustup component add rustfmt
309+
test_script: cargo fmt --all -- --check **/*.rs

CHANGELOG.md

+16-3
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ This project adheres to [Semantic Versioning](https://semver.org/).
1616
- Added `mq_timedreceive` to `::nix::mqueue`.
1717
([#1966])(https://github.com/nix-rust/nix/pull/1966)
1818
- Added `LocalPeerPid` to `nix::sys::socket::sockopt` for macOS. ([#1967](https://github.com/nix-rust/nix/pull/1967))
19+
- Added `TFD_TIMER_CANCEL_ON_SET` to `::nix::sys::time::TimerSetTimeFlags` on Linux and Android.
20+
([#2040](https://github.com/nix-rust/nix/pull/2040))
1921

2022
### Changed
2123

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

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

4247
### Removed
4348

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

57+
## [0.26.2] - 2023-01-18
58+
59+
### Fixed
60+
61+
- Fix `SockaddrIn6` bug that was swapping `flowinfo` and `scope_id` byte
62+
ordering.
63+
([#1964](https://github.com/nix-rust/nix/pull/1964))
64+
5265
## [0.26.1] - 2022-11-29
5366
### Fixed
5467
- Fix UB with `sys::socket::sockopt::SockType` using `SOCK_PACKET`.

Cargo.toml

+2-3
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,10 @@ targets = [
2828

2929
[dependencies]
3030
libc = { version = "0.2.141", features = ["extra_traits"] }
31-
bitflags = "1.1"
31+
bitflags = "2.3.1"
3232
cfg-if = "1.0"
3333
pin-utils = { version = "0.1.0", optional = true }
34-
static_assertions = "1"
35-
memoffset = { version = "0.8", optional = true }
34+
memoffset = { version = "0.9", optional = true }
3635

3736
[features]
3837
default = [

src/fcntl.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -712,7 +712,7 @@ pub fn vmsplice(
712712
}
713713
}
714714

715-
#[cfg(any(target_os = "linux"))]
715+
#[cfg(target_os = "linux")]
716716
#[cfg(feature = "fs")]
717717
libc_bitflags!(
718718
/// Mode argument flags for fallocate determining operation performed on a given range.
@@ -752,7 +752,7 @@ feature! {
752752
///
753753
/// Allows the caller to directly manipulate the allocated disk space for the
754754
/// file referred to by fd.
755-
#[cfg(any(target_os = "linux"))]
755+
#[cfg(target_os = "linux")]
756756
#[cfg(feature = "fs")]
757757
pub fn fallocate(
758758
fd: RawFd,

src/features.rs

+8-7
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ mod os {
66
use crate::sys::utsname::uname;
77
use crate::Result;
88
use std::os::unix::ffi::OsStrExt;
9+
use std::sync::atomic::{AtomicUsize, Ordering};
910

1011
// Features:
1112
// * atomic cloexec on socket: 2.6.27
@@ -72,15 +73,15 @@ mod os {
7273
}
7374

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

77-
unsafe {
78-
if KERNEL_VERS == 0 {
79-
KERNEL_VERS = parse_kernel_version()?;
80-
}
81-
82-
Ok(KERNEL_VERS)
79+
if kernel_vers == 0 {
80+
kernel_vers = parse_kernel_version()?;
81+
KERNEL_VERS.store(kernel_vers, Ordering::Relaxed);
8382
}
83+
84+
Ok(kernel_vers)
8485
}
8586

8687
/// Check if the OS supports atomic close-on-exec for sockets

src/macros.rs

+2
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ macro_rules! libc_bitflags {
6565
}
6666
) => {
6767
::bitflags::bitflags! {
68+
#[derive(Copy, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
69+
#[repr(transparent)]
6870
$(#[$outer])*
6971
pub struct $BitFlags: $T {
7072
$(

src/mount/bsd.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ impl<'a> Nmount<'a> {
392392

393393
let niov = self.iov.len() as c_uint;
394394
let iovp = self.iov.as_mut_ptr() as *mut libc::iovec;
395-
let res = unsafe { libc::nmount(iovp, niov, flags.bits) };
395+
let res = unsafe { libc::nmount(iovp, niov, flags.bits()) };
396396
match Errno::result(res) {
397397
Ok(_) => Ok(()),
398398
Err(error) => {
@@ -446,7 +446,7 @@ where
446446
P: ?Sized + NixPath,
447447
{
448448
let res = mountpoint.with_nix_path(|cstr| unsafe {
449-
libc::unmount(cstr.as_ptr(), flags.bits)
449+
libc::unmount(cstr.as_ptr(), flags.bits())
450450
})?;
451451

452452
Errno::result(res).map(drop)

src/mount/linux.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ pub fn mount<
132132
s,
133133
t.as_ptr(),
134134
ty,
135-
flags.bits,
135+
flags.bits(),
136136
d as *const libc::c_void,
137137
)
138138
})
@@ -156,7 +156,7 @@ pub fn umount<P: ?Sized + NixPath>(target: &P) -> Result<()> {
156156
/// See also [`umount`](https://man7.org/linux/man-pages/man2/umount.2.html)
157157
pub fn umount2<P: ?Sized + NixPath>(target: &P, flags: MntFlags) -> Result<()> {
158158
let res = target.with_nix_path(|cstr| unsafe {
159-
libc::umount2(cstr.as_ptr(), flags.bits)
159+
libc::umount2(cstr.as_ptr(), flags.bits())
160160
})?;
161161

162162
Errno::result(res).map(drop)

src/mqueue.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ impl MqAttr {
139139
/// Open a message queue
140140
///
141141
/// See also [`mq_open(2)`](https://pubs.opengroup.org/onlinepubs/9699919799/functions/mq_open.html)
142-
// The mode.bits cast is only lossless on some OSes
142+
// The mode.bits() cast is only lossless on some OSes
143143
#[allow(clippy::cast_lossless)]
144144
pub fn mq_open(
145145
name: &CStr,

src/sys/event.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ impl Kqueue {
7171
timeout as *const timespec
7272
} else {
7373
ptr::null()
74-
}
74+
},
7575
)
7676
};
7777
Errno::result(res).map(|r| r as usize)
@@ -86,7 +86,7 @@ impl Kqueue {
8686
target_os = "openbsd"
8787
))]
8888
type type_of_udata = *mut libc::c_void;
89-
#[cfg(any(target_os = "netbsd"))]
89+
#[cfg(target_os = "netbsd")]
9090
type type_of_udata = intptr_t;
9191

9292
#[cfg(target_os = "netbsd")]
@@ -171,7 +171,7 @@ libc_enum! {
171171
))]
172172
#[doc(hidden)]
173173
pub type type_of_event_flag = u16;
174-
#[cfg(any(target_os = "netbsd"))]
174+
#[cfg(target_os = "netbsd")]
175175
#[doc(hidden)]
176176
pub type type_of_event_flag = u32;
177177
libc_bitflags! {

src/sys/personality.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,10 @@ pub fn get() -> Result<Persona> {
8080
///
8181
/// Example:
8282
///
83-
/// ```
83+
// Disable test on aarch64 until we know why it fails.
84+
// https://github.com/nix-rust/nix/issues/2060
85+
#[cfg_attr(target_arch = "aarch64", doc = " ```no_run")]
86+
#[cfg_attr(not(target_arch = "aarch64"), doc = " ```")]
8487
/// # use nix::sys::personality::{self, Persona};
8588
/// let mut pers = personality::get().unwrap();
8689
/// assert!(!pers.contains(Persona::ADDR_NO_RANDOMIZE));

0 commit comments

Comments
 (0)