From 382c223500016b11d2065192346f35d6aa1cefa0 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Wed, 14 Aug 2024 10:42:51 +0200 Subject: [PATCH 1/6] Bump nix and ctrlc nix from 0.28 to 0.29 and ctrlc from 3.4.4 to 3.4.5 --- Cargo.lock | 25 +++++++++++++++++-------- Cargo.toml | 2 +- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 22df950a8..2aa4c061c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -297,9 +297,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "cfg_aliases" -version = "0.1.1" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd16c4719339c4530435d38e511904438d07cce7950afa3718a84ac36c10e89e" +checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" [[package]] name = "chrono" @@ -730,12 +730,12 @@ dependencies = [ [[package]] name = "ctrlc" -version = "3.4.4" +version = "3.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "672465ae37dc1bc6380a6547a8883d5dd397b0f1faaad4f265726cc7042a5345" +checksum = "90eeab0aa92f3f9b4e87f258c72b139c207d251f9cbc1080a0086b86a8870dd3" dependencies = [ "nix", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -1444,9 +1444,9 @@ dependencies = [ [[package]] name = "nix" -version = "0.28.0" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab2156c4fce2f8df6c499cc1c763e4394b7482525bf2a9701c9d79d215f519e4" +checksum = "71e2746dc3a24dd78b3cfcb7be93368c6de9963d30f43a6a73998a9cf4b17b46" dependencies = [ "bitflags 2.6.0", "cfg-if", @@ -3657,7 +3657,7 @@ version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" dependencies = [ - "windows-sys 0.52.0", + "windows-sys 0.48.0", ] [[package]] @@ -3712,6 +3712,15 @@ dependencies = [ "windows-targets 0.52.6", ] +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets 0.52.6", +] + [[package]] name = "windows-targets" version = "0.42.2" diff --git a/Cargo.toml b/Cargo.toml index 3219d50b2..528268301 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -303,7 +303,7 @@ lscolors = { version = "0.18.0", default-features = false, features = [ ] } memchr = "2.7.2" memmap2 = "0.9.4" -nix = { version = "0.28", default-features = false } +nix = { version = "0.29", default-features = false } nom = "7.1.3" notify = { version = "=6.0.1", features = ["macos_kqueue"] } num-bigint = "0.4.4" From 612ae271d334686e5690bd8db36d099903b65128 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Wed, 14 Aug 2024 16:54:42 +0200 Subject: [PATCH 2/6] uucore: use AsFd instead AsRawFw in pipes API to match changes in the API of nix --- src/uucore/src/lib/features/pipes.rs | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/src/uucore/src/lib/features/pipes.rs b/src/uucore/src/lib/features/pipes.rs index c40dca21c..5ac590b7b 100644 --- a/src/uucore/src/lib/features/pipes.rs +++ b/src/uucore/src/lib/features/pipes.rs @@ -9,7 +9,7 @@ use std::fs::File; #[cfg(any(target_os = "linux", target_os = "android"))] use std::io::IoSlice; #[cfg(any(target_os = "linux", target_os = "android"))] -use std::os::unix::io::AsRawFd; +use std::os::fd::AsFd; #[cfg(any(target_os = "linux", target_os = "android"))] use nix::fcntl::SpliceFFlags; @@ -35,15 +35,8 @@ pub fn pipe() -> Result<(File, File)> { /// a [`pipe`] and then from the pipe into your target (with `splice_exact`): /// this is still very efficient. #[cfg(any(target_os = "linux", target_os = "android"))] -pub fn splice(source: &impl AsRawFd, target: &impl AsRawFd, len: usize) -> Result { - nix::fcntl::splice( - source.as_raw_fd(), - None, - target.as_raw_fd(), - None, - len, - SpliceFFlags::empty(), - ) +pub fn splice(source: &impl AsFd, target: &impl AsFd, len: usize) -> Result { + nix::fcntl::splice(source, None, target, None, len, SpliceFFlags::empty()) } /// Splice wrapper which fully finishes the write. @@ -52,7 +45,7 @@ pub fn splice(source: &impl AsRawFd, target: &impl AsRawFd, len: usize) -> Resul /// /// Panics if `source` runs out of data before `len` bytes have been moved. #[cfg(any(target_os = "linux", target_os = "android"))] -pub fn splice_exact(source: &impl AsRawFd, target: &impl AsRawFd, len: usize) -> Result<()> { +pub fn splice_exact(source: &impl AsFd, target: &impl AsFd, len: usize) -> Result<()> { let mut left = len; while left != 0 { let written = splice(source, target, left)?; @@ -66,10 +59,6 @@ pub fn splice_exact(source: &impl AsRawFd, target: &impl AsRawFd, len: usize) -> /// /// Returns the number of successfully copied bytes. #[cfg(any(target_os = "linux", target_os = "android"))] -pub fn vmsplice(target: &impl AsRawFd, bytes: &[u8]) -> Result { - nix::fcntl::vmsplice( - target.as_raw_fd(), - &[IoSlice::new(bytes)], - SpliceFFlags::empty(), - ) +pub fn vmsplice(target: &impl AsFd, bytes: &[u8]) -> Result { + nix::fcntl::vmsplice(target, &[IoSlice::new(bytes)], SpliceFFlags::empty()) } From 5342bae38dc346506f88cf7413994e34071fffaf Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Wed, 14 Aug 2024 17:15:53 +0200 Subject: [PATCH 3/6] cat: adapt to API changes of uucore/pipes --- src/uu/cat/src/cat.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/uu/cat/src/cat.rs b/src/uu/cat/src/cat.rs index d0a33a171..44c4be0fd 100644 --- a/src/uu/cat/src/cat.rs +++ b/src/uu/cat/src/cat.rs @@ -13,7 +13,7 @@ use uucore::error::UResult; use uucore::fs::FileInformation; #[cfg(unix)] -use std::os::unix::io::AsRawFd; +use std::os::fd::{AsFd, AsRawFd}; /// Linux splice support #[cfg(any(target_os = "linux", target_os = "android"))] @@ -125,12 +125,12 @@ struct OutputState { } #[cfg(unix)] -trait FdReadable: Read + AsRawFd {} +trait FdReadable: Read + AsFd + AsRawFd {} #[cfg(not(unix))] trait FdReadable: Read {} #[cfg(unix)] -impl FdReadable for T where T: Read + AsRawFd {} +impl FdReadable for T where T: Read + AsFd + AsRawFd {} #[cfg(not(unix))] impl FdReadable for T where T: Read {} From 563e3cefd0bcc5c170895e8d48e75d8397c0d76f Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Wed, 14 Aug 2024 17:17:44 +0200 Subject: [PATCH 4/6] wc: adapt to API changes of uucore/pipes --- src/uu/wc/src/count_fast.rs | 4 ++-- src/uu/wc/src/countable.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/uu/wc/src/count_fast.rs b/src/uu/wc/src/count_fast.rs index 85d3d1d2b..7edc02437 100644 --- a/src/uu/wc/src/count_fast.rs +++ b/src/uu/wc/src/count_fast.rs @@ -19,7 +19,7 @@ use nix::sys::stat; #[cfg(unix)] use std::io::{Seek, SeekFrom}; #[cfg(any(target_os = "linux", target_os = "android"))] -use std::os::unix::io::AsRawFd; +use std::os::fd::{AsFd, AsRawFd}; #[cfg(windows)] use std::os::windows::fs::MetadataExt; #[cfg(windows)] @@ -43,7 +43,7 @@ const SPLICE_SIZE: usize = 128 * 1024; /// caller will fall back to a simpler method. #[inline] #[cfg(any(target_os = "linux", target_os = "android"))] -fn count_bytes_using_splice(fd: &impl AsRawFd) -> Result { +fn count_bytes_using_splice(fd: &impl AsFd) -> Result { let null_file = OpenOptions::new() .write(true) .open("/dev/null") diff --git a/src/uu/wc/src/countable.rs b/src/uu/wc/src/countable.rs index d27c7fb59..5b2ad7a99 100644 --- a/src/uu/wc/src/countable.rs +++ b/src/uu/wc/src/countable.rs @@ -11,10 +11,10 @@ use std::fs::File; use std::io::{BufRead, BufReader, Read, StdinLock}; #[cfg(unix)] -use std::os::unix::io::AsRawFd; +use std::os::fd::{AsFd, AsRawFd}; #[cfg(unix)] -pub trait WordCountable: AsRawFd + Read { +pub trait WordCountable: AsFd + AsRawFd + Read { type Buffered: BufRead; fn buffered(self) -> Self::Buffered; fn inner_file(&mut self) -> Option<&mut File>; From 9fcf3ee48bb7fb2478cb15eede3e40902470de1e Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Wed, 14 Aug 2024 17:18:54 +0200 Subject: [PATCH 5/6] yes: adapt to API changes of uucore/pipes --- src/uu/yes/src/splice.rs | 10 ++++++++-- src/uu/yes/src/yes.rs | 4 +++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/uu/yes/src/splice.rs b/src/uu/yes/src/splice.rs index a95fc35af..5537d55e1 100644 --- a/src/uu/yes/src/splice.rs +++ b/src/uu/yes/src/splice.rs @@ -20,13 +20,19 @@ //! make any effort to rescue data from the pipe if splice() fails, we can //! just fall back and start over from the beginning. -use std::{io, os::unix::io::AsRawFd}; +use std::{ + io, + os::fd::{AsFd, AsRawFd}, +}; use nix::{errno::Errno, libc::S_IFIFO, sys::stat::fstat}; use uucore::pipes::{pipe, splice_exact, vmsplice}; -pub(crate) fn splice_data(bytes: &[u8], out: &impl AsRawFd) -> Result<()> { +pub(crate) fn splice_data(bytes: &[u8], out: &T) -> Result<()> +where + T: AsRawFd + AsFd, +{ let is_pipe = fstat(out.as_raw_fd())?.st_mode as nix::libc::mode_t & S_IFIFO != 0; if is_pipe { diff --git a/src/uu/yes/src/yes.rs b/src/uu/yes/src/yes.rs index b1d8f9f49..b344feaa8 100644 --- a/src/uu/yes/src/yes.rs +++ b/src/uu/yes/src/yes.rs @@ -9,6 +9,8 @@ use clap::{builder::ValueParser, crate_version, Arg, ArgAction, Command}; use std::error::Error; use std::ffi::OsString; use std::io::{self, Write}; +#[cfg(any(target_os = "linux", target_os = "android"))] +use std::os::fd::AsFd; use uucore::error::{UResult, USimpleError}; #[cfg(unix)] use uucore::signals::enable_pipe_errors; @@ -118,7 +120,7 @@ pub fn exec(bytes: &[u8]) -> io::Result<()> { #[cfg(any(target_os = "linux", target_os = "android"))] { - match splice::splice_data(bytes, &stdout) { + match splice::splice_data(bytes, &stdout.as_fd()) { Ok(_) => return Ok(()), Err(splice::Error::Io(err)) => return Err(err), Err(splice::Error::Unsupported) => (), From 5db3b47ecbcf72ce1c6d217c17703756f469e8dc Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Wed, 14 Aug 2024 17:25:35 +0200 Subject: [PATCH 6/6] deny.toml: add windows-sys 0.52.0 to skip list --- deny.toml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/deny.toml b/deny.toml index 3ee9df5c1..67176a7f3 100644 --- a/deny.toml +++ b/deny.toml @@ -62,6 +62,8 @@ skip = [ { name = "windows-sys", version = "0.45.0" }, # various crates { name = "windows-sys", version = "0.48.0" }, + # various crates + { name = "windows-sys", version = "0.52.0" }, # windows-sys { name = "windows-targets", version = "0.42.2" }, # windows-sys