Skip to content

Commit daa7bcb

Browse files
authored
Update to rustix 0.37. (#297)
The only code change here is due to `copy_file_range`'s `len` argument changing from `u64` to `usize`.
1 parent 684a62f commit daa7bcb

File tree

8 files changed

+15
-8
lines changed

8 files changed

+15
-8
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ libc = "0.2.100"
3232
io-lifetimes = "1.0.0"
3333

3434
[target.'cfg(not(windows))'.dev-dependencies]
35-
rustix = { version = "0.36.0", features = ["fs"] }
35+
rustix = { version = "0.37.0", features = ["fs"] }
3636

3737
[target.'cfg(windows)'.dev-dependencies]
3838
# nt_version uses internal Windows APIs, however we're only using it

cap-async-std/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ io-extras = { version = "0.17.0", features = ["use_async_std"] }
2424
camino = { version = "1.0.5", optional = true }
2525

2626
[target.'cfg(not(windows))'.dependencies]
27-
rustix = { version = "0.36.0", features = ["fs"] }
27+
rustix = { version = "0.37.0", features = ["fs"] }
2828

2929
[features]
3030
default = []

cap-directories/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ cap-std = { path = "../cap-std", version = "^1.0.5" }
1717
directories-next = "2.0.0"
1818

1919
[target.'cfg(not(windows))'.dependencies]
20-
rustix = { version = "0.36.0" }
20+
rustix = { version = "0.37.0" }
2121

2222
[target.'cfg(windows)'.dependencies.windows-sys]
2323
version = "0.45.0"

cap-primitives/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ ambient-authority = "0.0.1"
1717
arbitrary = { version = "1.0.0", optional = true, features = ["derive"] }
1818
ipnet = "2.3.0"
1919
maybe-owned = "0.3.4"
20-
fs-set-times = "0.18.0"
20+
fs-set-times = "0.19.0"
2121
io-extras = "0.17.0"
2222
io-lifetimes = { version = "1.0.0", default-features = false }
2323

2424
[dev-dependencies]
2525
cap-tempfile = { path = "../cap-tempfile" }
2626

2727
[target.'cfg(not(windows))'.dependencies]
28-
rustix = { version = "0.36.0", features = ["fs", "process", "procfs", "termios", "time"] }
28+
rustix = { version = "0.37.0", features = ["fs", "process", "procfs", "termios", "time"] }
2929

3030
[target.'cfg(windows)'.dependencies]
3131
winx = "0.35.0"

cap-primitives/src/rustix/fs/copy_impl.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ use rustix::fs::{
1010
copyfile_state_alloc, copyfile_state_free, copyfile_state_get_copied, copyfile_state_t,
1111
fclonefileat, fcopyfile, CloneFlags, CopyfileFlags,
1212
};
13+
#[cfg(any(target_os = "android", target_os = "linux"))]
14+
use std::convert::TryFrom;
1315
use std::path::Path;
1416
use std::{fs, io};
1517

@@ -115,6 +117,11 @@ pub(crate) fn copy_impl(
115117
while written < len {
116118
let copy_result = if has_copy_file_range {
117119
let bytes_to_copy = cmp::min(len - written, usize::MAX as u64);
120+
121+
// `copy_file_range` takes a `usize`; convert with saturation so
122+
// that we copy as many bytes as we can.
123+
let bytes_to_copy = usize::try_from(bytes_to_copy).unwrap_or(usize::MAX);
124+
118125
// We actually don't have to adjust the offsets,
119126
// because copy_file_range adjusts the file offset automatically
120127
let copy_result = copy_file_range(&reader, None, &writer, None, bytes_to_copy);

cap-std/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ io-lifetimes = { version = "1.0.0", default-features = false }
2525
camino = { version = "1.0.5", optional = true }
2626

2727
[target.'cfg(not(windows))'.dependencies]
28-
rustix = { version = "0.36.0", features = ["fs"] }
28+
rustix = { version = "0.37.0", features = ["fs"] }
2929

3030
[features]
3131
default = []

cap-tempfile/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ camino = { version = "1.0.5", optional = true }
2121
rand = "0.8.1"
2222

2323
[target.'cfg(not(windows))'.dependencies]
24-
rustix = { version = "0.36.0", features = ["procfs"] }
24+
rustix = { version = "0.37.0", features = ["procfs"] }
2525

2626
[target.'cfg(windows)'.dev-dependencies.windows-sys]
2727
version = "0.45.0"

cap-time-ext/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ cap-primitives = { path = "../cap-primitives", version = "^1.0.5" }
1717
cap-std = { path = "../cap-std", optional = true, version = "^1.0.5" }
1818

1919
[target.'cfg(not(windows))'.dependencies]
20-
rustix = { version = "0.36.0", features = ["time"] }
20+
rustix = { version = "0.37.0", features = ["time"] }
2121

2222
[target.'cfg(windows)'.dependencies]
2323
once_cell = "1.5.2"

0 commit comments

Comments
 (0)