Skip to content

Rustix/uucore migration#11822

Draft
sylvestre wants to merge 7 commits intomainfrom
rustix/uucore-migration
Draft

Rustix/uucore migration#11822
sylvestre wants to merge 7 commits intomainfrom
rustix/uucore-migration

Conversation

@sylvestre
Copy link
Copy Markdown
Contributor

No description provided.

Replace nix pipe/splice/vmsplice wrappers with rustix equivalents
in uucore's pipes module. Also migrate cat's splice.rs to use
rustix::io::{read, write} instead of nix::unistd.

The return types change from nix::Result to std::io::Result, which
is more idiomatic and compatible with the broader ecosystem.
Replace nix process functions with rustix equivalents:
- geteuid/getegid/getuid/getgid/getpid/getpgrp/getsid -> rustix::process
- kill/test_kill -> rustix::process::kill_process/test_kill_process
- Signal::try_from -> signal_from_raw helper using from_raw_unchecked
- SigHandler for send_signal_group -> csignal wrapper

The getsid return type changes from Result<pid_t, Errno> to
io::Result<pid_t>, which is more idiomatic.
Replace all nix APIs with rustix equivalents in the security-critical
TOCTOU-safe filesystem traversal module:

- nix::dir::Dir -> rustix::fs::Dir (uses Dir::read_from which borrows fd)
- nix::fcntl::{OFlag, openat} -> rustix::fs::{OFlags, openat}
- nix::sys::stat::{fstat, fstatat, fchmod, fchmodat, mkdirat} -> rustix::fs
- nix::unistd::{fchown, fchownat, unlinkat} -> rustix::fs
- FchmodatFlags/UnlinkatFlags -> rustix::fs::AtFlags
- Error handling simplified: rustix Errno implements Into<io::Error>

Also update rm's unix platform code to use the new Stat type.

All 31 safe_traversal unit tests pass.
Replace all nix signal and poll APIs in uucore:
- signals.rs: nix::sys::signal -> csignal wrappers
- signals.rs: nix::poll -> rustix::event::poll
- signals.rs: nix::sys::stat -> rustix::fs::fstat + libc constants
- lib.rs: nix sigaction -> csignal::set_signal_action
- dd/progress.rs: update install_sigusr1_handler to use libc::SIGUSR1

Return types change from nix::Result/Errno to std::io::Result.
Migrate 19 utility crates from nix to rustix and direct libc calls:

- kill, timeout, env: signal handling via csignal wrappers + libc
- sync, cat, tail, dd, tsort: file operations via rustix::fs
- touch: futimens via rustix::fs::futimens
- stty, tty: terminal ops via rustix::termios + libc ioctl
- sort: getrlimit via rustix::process, sysconf via libc
- wc, cp, df: stat/fstat via rustix::fs
- nice: priority via rustix::process
- mkfifo, mknod: via direct libc calls

Also add rustix::io::Errno conversions to uucore error.rs.
- Remove nix dependency from uucore Cargo.toml
- Remove nix error conversion impls from error.rs, replace with rustix
- Migrate date's clock_settime/clock_getres from nix to rustix::time
- Replace nix dependency with rustix in date's Cargo.toml
- Update test nix features for test utilities that still need it

The nix crate is now completely removed from all source code (src/).
It remains only as a dev-dependency for test code.
@oech3
Copy link
Copy Markdown
Contributor

oech3 commented Apr 15, 2026

sync previously failed GnuTests with rustix (raw-backend).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants