From ae7bc7d2e3dc60907cb1b7820d254ae088cd77d5 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Mon, 11 Mar 2024 09:59:26 +0100 Subject: [PATCH 1/5] Bump nix from 0.27 to 0.28 --- Cargo.lock | 17 ++++++++++++----- Cargo.toml | 2 +- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 626fcdb94..12213b26d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -236,6 +236,12 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "cfg_aliases" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd16c4719339c4530435d38e511904438d07cce7950afa3718a84ac36c10e89e" + [[package]] name = "chrono" version = "0.4.35" @@ -673,12 +679,12 @@ dependencies = [ [[package]] name = "ctrlc" -version = "3.4.1" +version = "3.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82e95fbd621905b854affdc67943b043a0fbb6ed7385fd5a25650d19a8a6cfdf" +checksum = "672465ae37dc1bc6380a6547a8883d5dd397b0f1faaad4f265726cc7042a5345" dependencies = [ "nix", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] @@ -1303,12 +1309,13 @@ dependencies = [ [[package]] name = "nix" -version = "0.27.1" +version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2eb04e9c688eff1c89d72b407f168cf79bb9e867a9d3323ed6c01519eb9cc053" +checksum = "ab2156c4fce2f8df6c499cc1c763e4394b7482525bf2a9701c9d79d215f519e4" dependencies = [ "bitflags 2.4.2", "cfg-if", + "cfg_aliases", "libc", ] diff --git a/Cargo.toml b/Cargo.toml index 2d1f50aeb..301834242 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -294,7 +294,7 @@ lscolors = { version = "0.16.0", default-features = false, features = [ ] } memchr = "2" memmap2 = "0.9" -nix = { version = "0.27", default-features = false } +nix = { version = "0.28", default-features = false } nom = "7.1.3" notify = { version = "=6.0.1", features = ["macos_kqueue"] } num-bigint = "0.4.4" From 15cb0242ea58ae0c102fc84c3044b4c2f5fc532c Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Mon, 11 Mar 2024 16:24:39 +0100 Subject: [PATCH 2/5] uucore/pipes: adapt to new return type of nix fn nix 0.28 changed the return type of unistd::pipe() from Result<(RawFd, RawFd), Error> to Result<(OwnedFd, OwnedFd), Error> --- src/uucore/src/lib/features/pipes.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/uucore/src/lib/features/pipes.rs b/src/uucore/src/lib/features/pipes.rs index 75749f721..17c5b1b32 100644 --- a/src/uucore/src/lib/features/pipes.rs +++ b/src/uucore/src/lib/features/pipes.rs @@ -8,7 +8,6 @@ use std::fs::File; use std::io::IoSlice; #[cfg(any(target_os = "linux", target_os = "android"))] use std::os::unix::io::AsRawFd; -use std::os::unix::io::FromRawFd; #[cfg(any(target_os = "linux", target_os = "android"))] use nix::fcntl::SpliceFFlags; @@ -21,8 +20,7 @@ pub use nix::{Error, Result}; /// from the first. pub fn pipe() -> Result<(File, File)> { let (read, write) = nix::unistd::pipe()?; - // SAFETY: The file descriptors do not have other owners. - unsafe { Ok((File::from_raw_fd(read), File::from_raw_fd(write))) } + Ok((File::from(read), File::from(write))) } /// Less noisy wrapper around [`nix::fcntl::splice`]. From 1413054c53564c634e912757889e5a379ece68d4 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Mon, 11 Mar 2024 16:43:15 +0100 Subject: [PATCH 3/5] tty: unistd::ttyname takes AsFd instead of RawFd change introduced by nix 0.28 --- src/uu/tty/src/tty.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/uu/tty/src/tty.rs b/src/uu/tty/src/tty.rs index efda4a7be..b7d3aedcd 100644 --- a/src/uu/tty/src/tty.rs +++ b/src/uu/tty/src/tty.rs @@ -9,7 +9,6 @@ use clap::{crate_version, Arg, ArgAction, Command}; use std::io::{IsTerminal, Write}; -use std::os::unix::io::AsRawFd; use uucore::error::{set_exit_code, UResult}; use uucore::{format_usage, help_about, help_usage}; @@ -37,8 +36,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { let mut stdout = std::io::stdout(); - // Get the ttyname via nix - let name = nix::unistd::ttyname(std::io::stdin().as_raw_fd()); + let name = nix::unistd::ttyname(std::io::stdin()); let write_result = match name { Ok(name) => writeln!(stdout, "{}", name.display()), From 6fd37da3e24bb428c8d1852586d56c6a87811bbc Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Mon, 11 Mar 2024 17:00:16 +0100 Subject: [PATCH 4/5] stty: remove ofill output flag flag was removed from nix::sys::termios::OutputFlags in nix 0.28 --- src/uu/stty/src/flags.rs | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/uu/stty/src/flags.rs b/src/uu/stty/src/flags.rs index 2c8e154e8..eac57151b 100644 --- a/src/uu/stty/src/flags.rs +++ b/src/uu/stty/src/flags.rs @@ -5,7 +5,7 @@ // spell-checker:ignore parenb parodd cmspar hupcl cstopb cread clocal crtscts CSIZE // spell-checker:ignore ignbrk brkint ignpar parmrk inpck istrip inlcr igncr icrnl ixoff ixon iuclc ixany imaxbel iutf -// spell-checker:ignore opost olcuc ocrnl onlcr onocr onlret ofill ofdel nldly crdly tabdly bsdly vtdly ffdly +// spell-checker:ignore opost olcuc ocrnl onlcr onocr onlret ofdel nldly crdly tabdly bsdly vtdly ffdly // spell-checker:ignore isig icanon iexten echoe crterase echok echonl noflsh xcase tostop echoprt prterase echoctl ctlecho echoke crtkill flusho extproc // spell-checker:ignore lnext rprnt susp swtch vdiscard veof veol verase vintr vkill vlnext vquit vreprint vstart vstop vsusp vswtc vwerase werase // spell-checker:ignore sigquit sigtstp @@ -86,14 +86,6 @@ pub const OUTPUT_FLAGS: &[Flag] = &[ target_os = "linux", target_os = "macos" ))] - Flag::new("ofill", O::OFILL), - #[cfg(any( - target_os = "android", - target_os = "haiku", - target_os = "ios", - target_os = "linux", - target_os = "macos" - ))] Flag::new("ofdel", O::OFDEL), #[cfg(any( target_os = "android", From 14ac1e160fbf010c5f400396b451a3725526d58a Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Tue, 12 Mar 2024 08:26:50 +0100 Subject: [PATCH 5/5] cat: adapt to type change of unistd::write() nix 0.28 changed "write(fd: RawFd, buf: &[u8]) -> Result" to "write(fd: Fd, buf: &[u8]) -> Result" --- src/uu/cat/src/splice.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/uu/cat/src/splice.rs b/src/uu/cat/src/splice.rs index 6c2b6d3da..13daae84d 100644 --- a/src/uu/cat/src/splice.rs +++ b/src/uu/cat/src/splice.rs @@ -5,7 +5,10 @@ use super::{CatResult, FdReadable, InputHandle}; use nix::unistd; -use std::os::unix::io::{AsRawFd, RawFd}; +use std::os::{ + fd::AsFd, + unix::io::{AsRawFd, RawFd}, +}; use uucore::pipes::{pipe, splice, splice_exact}; @@ -20,9 +23,9 @@ const BUF_SIZE: usize = 1024 * 16; /// The `bool` in the result value indicates if we need to fall back to normal /// copying or not. False means we don't have to. #[inline] -pub(super) fn write_fast_using_splice( +pub(super) fn write_fast_using_splice( handle: &InputHandle, - write_fd: &impl AsRawFd, + write_fd: &S, ) -> CatResult { let (pipe_rd, pipe_wr) = pipe()?; @@ -38,7 +41,7 @@ pub(super) fn write_fast_using_splice( // we can recover by copying the data that we have from the // intermediate pipe to stdout using normal read/write. Then // we tell the caller to fall back. - copy_exact(pipe_rd.as_raw_fd(), write_fd.as_raw_fd(), n)?; + copy_exact(pipe_rd.as_raw_fd(), write_fd, n)?; return Ok(true); } } @@ -52,7 +55,7 @@ pub(super) fn write_fast_using_splice( /// Move exactly `num_bytes` bytes from `read_fd` to `write_fd`. /// /// Panics if not enough bytes can be read. -fn copy_exact(read_fd: RawFd, write_fd: RawFd, num_bytes: usize) -> nix::Result<()> { +fn copy_exact(read_fd: RawFd, write_fd: &impl AsFd, num_bytes: usize) -> nix::Result<()> { let mut left = num_bytes; let mut buf = [0; BUF_SIZE]; while left > 0 {