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
2 changes: 1 addition & 1 deletion 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 fuzz/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 src/uu/wc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ unicode-width = { workspace = true }

[target.'cfg(unix)'.dependencies]
libc = { workspace = true }
nix = { workspace = true }
rustix = { workspace = true, features = ["fs"] }

[dev-dependencies]
divan = { workspace = true }
Expand Down
8 changes: 4 additions & 4 deletions src/uu/wc/src/count_fast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ use std::io::{self, ErrorKind, Read};
#[cfg(unix)]
use libc::{_SC_PAGESIZE, S_IFREG, sysconf};
#[cfg(unix)]
use nix::sys::stat;
#[cfg(unix)]
use std::io::{Seek, SeekFrom};
#[cfg(unix)]
use std::os::fd::{AsFd, AsRawFd};
Expand Down Expand Up @@ -49,7 +47,9 @@ fn count_bytes_using_splice(fd: &impl AsFd) -> Result<usize, usize> {
.write(true)
.open("/dev/null")
.map_err(|_| 0_usize)?;
let null_rdev = stat::fstat(null_file.as_fd()).map_err(|_| 0_usize)?.st_rdev as libc::dev_t;
let null_rdev = rustix::fs::fstat(null_file.as_fd())
.map_err(|_| 0_usize)?
.st_rdev as libc::dev_t;
if (libc::major(null_rdev), libc::minor(null_rdev)) != (1, 3) {
// This is not a proper /dev/null, writing to it is probably bad
// Bit of an edge case, but it has been known to happen
Expand Down Expand Up @@ -92,7 +92,7 @@ pub(crate) fn count_bytes_fast<T: WordCountable>(handle: &mut T) -> (usize, Opti
#[cfg(unix)]
{
let fd = handle.as_fd();
if let Ok(stat) = stat::fstat(fd) {
if let Ok(stat) = rustix::fs::fstat(fd) {
// If the file is regular, then the `st_size` should hold
// the file's size in bytes.
// If stat.st_size = 0 then
Expand Down
3 changes: 1 addition & 2 deletions src/uu/wc/src/wc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,11 +297,10 @@ impl<'a> Input<'a> {

#[cfg(unix)]
fn is_stdin_small_file() -> bool {
use nix::sys::stat;
use std::os::fd::AsFd;

matches!(
stat::fstat(io::stdin().as_fd()),
rustix::fs::fstat(io::stdin().as_fd()),
Ok(meta) if meta.st_mode as libc::mode_t & libc::S_IFMT == libc::S_IFREG && meta.st_size <= (10 << 20)
)
}
Expand Down
Loading