Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
5333180
sort: add collation key arena storage to LineData
sylvestre Mar 18, 2026
6ca9146
deps: add rustix as workspace dependency
sylvestre Mar 27, 2026
bf79152
refactor: replace nix::libc re-exports with direct libc imports
sylvestre Mar 27, 2026
0901716
refactor: add libc-based signal wrappers in uucore::signals::csignal
sylvestre Mar 27, 2026
1efa0ac
refactor: migrate pipes.rs and cat splice.rs from nix to rustix
sylvestre Mar 28, 2026
ae2ecc5
refactor: migrate uucore process.rs from nix to rustix
sylvestre Mar 28, 2026
ef67921
refactor: migrate safe_traversal.rs from nix to rustix
sylvestre Mar 28, 2026
f9dc90d
refactor: migrate mode.rs, fs.rs, and buf_copy/linux.rs from nix to r…
sylvestre Mar 28, 2026
db9e2a0
refactor: migrate signals.rs and lib.rs from nix to csignal/rustix
sylvestre Mar 28, 2026
a588733
refactor: migrate all utilities from nix to rustix/libc
sylvestre Mar 28, 2026
620b07e
refactor: remove nix from uucore and date, complete source migration
sylvestre Mar 28, 2026
d503895
refactor(kill): remove unsafe libc::kill, use safe rustix process APIs
sylvestre Mar 28, 2026
9100ff3
refactor(mknod): remove unsafe libc::mknod and libc::umask calls
sylvestre Mar 28, 2026
3706b73
refactor(mkfifo): remove unsafe libc::mkfifo, use safe rustix::fs::mk…
sylvestre Mar 28, 2026
ab65949
refactor(mkdir): remove unsafe libc::umask, use safe rustix::process:…
sylvestre Mar 28, 2026
07a296a
refactor(sort): replace unsafe libc::fcntl with rustix::io::fcntl_getfd
sylvestre Mar 28, 2026
b26bb2a
refactor(sync): remove unsafe libc::open/close, use safe rustix::fs::…
sylvestre Mar 28, 2026
70efd2f
refresh cargo.lock
sylvestre Mar 30, 2026
a142d0c
spell: more jargon
sylvestre Mar 30, 2026
8fe9b3d
fix(env): skip uncatchable signals on OpenBSD when applying to all si…
sylvestre Mar 30, 2026
d564c7b
deps(rustix): enable use-libc to route syscalls through glibc
sylvestre Mar 31, 2026
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
26 changes: 26 additions & 0 deletions .vscode/cspell.dictionaries/jargon.wordlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -243,3 +243,29 @@ Hijri
Nowruz
charmap
hijri

csignal
noent
nptl
oldset
ptrs
rdband
rustix
setmask
sigaddset
sigemptyset
sigfillset
sighandler
sigmask
signum
sigprocmask
sigrtmin
sigset
sigsys
esrch
SRCH
Nofile
rprocess
statat
getdents
SIGTHR
44 changes: 25 additions & 19 deletions Cargo.lock

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

6 changes: 5 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,11 @@
rstest_reuse = "0.7.0"
rustc-hash = "2.1.1"
rust-ini = "0.21.0"
rustix = "1.1.4"
# use-libc: route syscalls through glibc instead of direct inline assembly,
# ensuring compatibility with LD_PRELOAD, sanitizers, and glibc optimizations (e.g. getpid cache)

Check failure on line 433 in Cargo.toml

View workflow job for this annotation

GitHub Actions / Style/spelling (ubuntu-latest, feat_os_unix)

ERROR: `cspell`: Unknown word 'getpid' (file:'Cargo.toml', line:433)
rustix = { version = "1.1.4", default-features = false, features = [
"use-libc",
] }
same-file = "1.0.6"
self_cell = "1.0.4"
selinux = "=0.6.0"
Expand Down
12 changes: 7 additions & 5 deletions 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/cat/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ uucore = { workspace = true, features = ["fast-inc", "fs", "pipes", "signals"] }
fluent = { workspace = true }

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

[target.'cfg(windows)'.dependencies]
winapi-util = { workspace = true }
Expand Down
4 changes: 2 additions & 2 deletions src/uu/cat/src/cat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,10 @@ enum CatError {
/// Wrapper around `io::Error`
#[error("{}", strip_errno(.0))]
Io(#[from] io::Error),
/// Wrapper around `nix::Error`
/// Wrapper around `rustix::io::Errno`
#[cfg(any(target_os = "linux", target_os = "android"))]
#[error("{0}")]
Nix(#[from] nix::Error),
Rustix(#[from] rustix::io::Errno),
/// Unknown file type; it's not a regular file, socket, etc.
#[error("{}", translate!("cat-error-unknown-filetype", "ft_debug" => .ft_debug))]
UnknownFiletype {
Expand Down
14 changes: 6 additions & 8 deletions src/uu/cat/src/platform/unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@

// spell-checker:ignore lseek seekable

use nix::fcntl::{FcntlArg, OFlag, fcntl};
use nix::unistd::{Whence, lseek};
use rustix::fs::{OFlags, SeekFrom, fcntl_getfl};
use std::os::fd::AsFd;
use uucore::fs::FileInformation;

Expand All @@ -31,10 +30,10 @@ pub fn is_unsafe_overwrite<I: AsFd, O: AsFd>(input: &I, output: &O) -> bool {
if file_size == 0 {
return false;
}
// `lseek` returns an error if the file descriptor is closed or it refers to
// `seek` returns an error if the file descriptor is closed or it refers to
// a non-seekable resource (e.g., pipe, socket, or some devices).
let input_pos = lseek(input.as_fd(), 0, Whence::SeekCur);
let output_pos = lseek(output.as_fd(), 0, Whence::SeekCur);
let input_pos = rustix::fs::seek(input, SeekFrom::Current(0)).map(|v| v as i64);
let output_pos = rustix::fs::seek(output, SeekFrom::Current(0)).map(|v| v as i64);
if is_appending(output) {
if let Ok(pos) = input_pos {
if pos >= 0 && (pos as u64) >= file_size {
Expand All @@ -54,9 +53,8 @@ pub fn is_unsafe_overwrite<I: AsFd, O: AsFd>(input: &I, output: &O) -> bool {

/// Whether the file is opened with the `O_APPEND` flag
fn is_appending<F: AsFd>(file: &F) -> bool {
let flags_raw = fcntl(file.as_fd(), FcntlArg::F_GETFL).unwrap_or_default();
let flags = OFlag::from_bits_truncate(flags_raw);
flags.contains(OFlag::O_APPEND)
let flags = fcntl_getfl(file).unwrap_or(OFlags::empty());
flags.contains(OFlags::APPEND)
}

#[cfg(test)]
Expand Down
16 changes: 8 additions & 8 deletions src/uu/cat/src/splice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// file that was distributed with this source code.
use super::{CatResult, FdReadable, InputHandle};

use nix::unistd;
use rustix::io::{read, write};
use std::os::{fd::AsFd, unix::io::AsRawFd};

use uucore::pipes::{pipe, splice, splice_exact};
Expand Down Expand Up @@ -52,20 +52,20 @@ pub(super) fn write_fast_using_splice<R: FdReadable, S: AsRawFd + AsFd>(
/// Move exactly `num_bytes` bytes from `read_fd` to `write_fd`.
///
/// Panics if not enough bytes can be read.
fn copy_exact(read_fd: &impl AsFd, write_fd: &impl AsFd, num_bytes: usize) -> nix::Result<()> {
fn copy_exact(read_fd: &impl AsFd, write_fd: &impl AsFd, num_bytes: usize) -> std::io::Result<()> {
let mut left = num_bytes;
let mut buf = [0; BUF_SIZE];
while left > 0 {
let read = unistd::read(read_fd, &mut buf)?;
assert_ne!(read, 0, "unexpected end of pipe");
let n = read(read_fd, &mut buf)?;
assert_ne!(n, 0, "unexpected end of pipe");
let mut written = 0;
while written < read {
match unistd::write(write_fd, &buf[written..read])? {
while written < n {
match write(write_fd, &buf[written..n])? {
0 => panic!(),
n => written += n,
w => written += w,
}
}
left -= read;
left -= n;
}
Ok(())
}
1 change: 0 additions & 1 deletion src/uu/cp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ fluent = { workspace = true }

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

[[bin]]
name = "cp"
Expand Down
Loading
Loading