mirror of
https://github.com/uutils/coreutils
synced 2025-01-05 17:59:00 +00:00
Merge pull request #6055 from cakebaker/bump_nix
Bump nix from 0.27 to 0.28 & fix issues due to API changes
This commit is contained in:
commit
9de409de97
6 changed files with 24 additions and 26 deletions
17
Cargo.lock
generated
17
Cargo.lock
generated
|
@ -236,6 +236,12 @@ version = "1.0.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "cfg_aliases"
|
||||||
|
version = "0.1.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "fd16c4719339c4530435d38e511904438d07cce7950afa3718a84ac36c10e89e"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "chrono"
|
name = "chrono"
|
||||||
version = "0.4.35"
|
version = "0.4.35"
|
||||||
|
@ -673,12 +679,12 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ctrlc"
|
name = "ctrlc"
|
||||||
version = "3.4.1"
|
version = "3.4.4"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "82e95fbd621905b854affdc67943b043a0fbb6ed7385fd5a25650d19a8a6cfdf"
|
checksum = "672465ae37dc1bc6380a6547a8883d5dd397b0f1faaad4f265726cc7042a5345"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"nix",
|
"nix",
|
||||||
"windows-sys 0.48.0",
|
"windows-sys 0.52.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -1303,12 +1309,13 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "nix"
|
name = "nix"
|
||||||
version = "0.27.1"
|
version = "0.28.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "2eb04e9c688eff1c89d72b407f168cf79bb9e867a9d3323ed6c01519eb9cc053"
|
checksum = "ab2156c4fce2f8df6c499cc1c763e4394b7482525bf2a9701c9d79d215f519e4"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 2.4.2",
|
"bitflags 2.4.2",
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
|
"cfg_aliases",
|
||||||
"libc",
|
"libc",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -294,7 +294,7 @@ lscolors = { version = "0.16.0", default-features = false, features = [
|
||||||
] }
|
] }
|
||||||
memchr = "2"
|
memchr = "2"
|
||||||
memmap2 = "0.9"
|
memmap2 = "0.9"
|
||||||
nix = { version = "0.27", default-features = false }
|
nix = { version = "0.28", default-features = false }
|
||||||
nom = "7.1.3"
|
nom = "7.1.3"
|
||||||
notify = { version = "=6.0.1", features = ["macos_kqueue"] }
|
notify = { version = "=6.0.1", features = ["macos_kqueue"] }
|
||||||
num-bigint = "0.4.4"
|
num-bigint = "0.4.4"
|
||||||
|
|
|
@ -5,7 +5,10 @@
|
||||||
use super::{CatResult, FdReadable, InputHandle};
|
use super::{CatResult, FdReadable, InputHandle};
|
||||||
|
|
||||||
use nix::unistd;
|
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};
|
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
|
/// 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.
|
/// copying or not. False means we don't have to.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub(super) fn write_fast_using_splice<R: FdReadable>(
|
pub(super) fn write_fast_using_splice<R: FdReadable, S: AsRawFd + AsFd>(
|
||||||
handle: &InputHandle<R>,
|
handle: &InputHandle<R>,
|
||||||
write_fd: &impl AsRawFd,
|
write_fd: &S,
|
||||||
) -> CatResult<bool> {
|
) -> CatResult<bool> {
|
||||||
let (pipe_rd, pipe_wr) = pipe()?;
|
let (pipe_rd, pipe_wr) = pipe()?;
|
||||||
|
|
||||||
|
@ -38,7 +41,7 @@ pub(super) fn write_fast_using_splice<R: FdReadable>(
|
||||||
// we can recover by copying the data that we have from the
|
// we can recover by copying the data that we have from the
|
||||||
// intermediate pipe to stdout using normal read/write. Then
|
// intermediate pipe to stdout using normal read/write. Then
|
||||||
// we tell the caller to fall back.
|
// 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);
|
return Ok(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -52,7 +55,7 @@ pub(super) fn write_fast_using_splice<R: FdReadable>(
|
||||||
/// Move exactly `num_bytes` bytes from `read_fd` to `write_fd`.
|
/// Move exactly `num_bytes` bytes from `read_fd` to `write_fd`.
|
||||||
///
|
///
|
||||||
/// Panics if not enough bytes can be read.
|
/// 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 left = num_bytes;
|
||||||
let mut buf = [0; BUF_SIZE];
|
let mut buf = [0; BUF_SIZE];
|
||||||
while left > 0 {
|
while left > 0 {
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
// spell-checker:ignore parenb parodd cmspar hupcl cstopb cread clocal crtscts CSIZE
|
// 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 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 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 lnext rprnt susp swtch vdiscard veof veol verase vintr vkill vlnext vquit vreprint vstart vstop vsusp vswtc vwerase werase
|
||||||
// spell-checker:ignore sigquit sigtstp
|
// spell-checker:ignore sigquit sigtstp
|
||||||
|
@ -86,14 +86,6 @@ pub const OUTPUT_FLAGS: &[Flag<O>] = &[
|
||||||
target_os = "linux",
|
target_os = "linux",
|
||||||
target_os = "macos"
|
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),
|
Flag::new("ofdel", O::OFDEL),
|
||||||
#[cfg(any(
|
#[cfg(any(
|
||||||
target_os = "android",
|
target_os = "android",
|
||||||
|
|
|
@ -9,7 +9,6 @@
|
||||||
|
|
||||||
use clap::{crate_version, Arg, ArgAction, Command};
|
use clap::{crate_version, Arg, ArgAction, Command};
|
||||||
use std::io::{IsTerminal, Write};
|
use std::io::{IsTerminal, Write};
|
||||||
use std::os::unix::io::AsRawFd;
|
|
||||||
use uucore::error::{set_exit_code, UResult};
|
use uucore::error::{set_exit_code, UResult};
|
||||||
use uucore::{format_usage, help_about, help_usage};
|
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();
|
let mut stdout = std::io::stdout();
|
||||||
|
|
||||||
// Get the ttyname via nix
|
let name = nix::unistd::ttyname(std::io::stdin());
|
||||||
let name = nix::unistd::ttyname(std::io::stdin().as_raw_fd());
|
|
||||||
|
|
||||||
let write_result = match name {
|
let write_result = match name {
|
||||||
Ok(name) => writeln!(stdout, "{}", name.display()),
|
Ok(name) => writeln!(stdout, "{}", name.display()),
|
||||||
|
|
|
@ -8,7 +8,6 @@ use std::fs::File;
|
||||||
use std::io::IoSlice;
|
use std::io::IoSlice;
|
||||||
#[cfg(any(target_os = "linux", target_os = "android"))]
|
#[cfg(any(target_os = "linux", target_os = "android"))]
|
||||||
use std::os::unix::io::AsRawFd;
|
use std::os::unix::io::AsRawFd;
|
||||||
use std::os::unix::io::FromRawFd;
|
|
||||||
|
|
||||||
#[cfg(any(target_os = "linux", target_os = "android"))]
|
#[cfg(any(target_os = "linux", target_os = "android"))]
|
||||||
use nix::fcntl::SpliceFFlags;
|
use nix::fcntl::SpliceFFlags;
|
||||||
|
@ -21,8 +20,7 @@ pub use nix::{Error, Result};
|
||||||
/// from the first.
|
/// from the first.
|
||||||
pub fn pipe() -> Result<(File, File)> {
|
pub fn pipe() -> Result<(File, File)> {
|
||||||
let (read, write) = nix::unistd::pipe()?;
|
let (read, write) = nix::unistd::pipe()?;
|
||||||
// SAFETY: The file descriptors do not have other owners.
|
Ok((File::from(read), File::from(write)))
|
||||||
unsafe { Ok((File::from_raw_fd(read), File::from_raw_fd(write))) }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Less noisy wrapper around [`nix::fcntl::splice`].
|
/// Less noisy wrapper around [`nix::fcntl::splice`].
|
||||||
|
|
Loading…
Reference in a new issue