Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
13 changes: 8 additions & 5 deletions src/uu/cat/src/splice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand All @@ -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<R: FdReadable>(
pub(super) fn write_fast_using_splice<R: FdReadable, S: AsRawFd + AsFd>(
handle: &InputHandle<R>,
write_fd: &impl AsRawFd,
write_fd: &S,
) -> CatResult<bool> {
let (pipe_rd, pipe_wr) = pipe()?;

Expand All @@ -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
// 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);
}
}
Expand All @@ -52,7 +55,7 @@ pub(super) fn write_fast_using_splice<R: FdReadable>(
/// 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 {
Expand Down
10 changes: 1 addition & 9 deletions src/uu/stty/src/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -86,14 +86,6 @@ pub const OUTPUT_FLAGS: &[Flag<O>] = &[
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",
Expand Down
4 changes: 1 addition & 3 deletions src/uu/tty/src/tty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down Expand Up @@ -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()),
Expand Down
4 changes: 1 addition & 3 deletions src/uucore/src/lib/features/pipes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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`].
Expand Down