Skip to content

Commit ffada0f

Browse files
committed
uucore: replace nix of FS related parts by rustix
1 parent abadd87 commit ffada0f

2 files changed

Lines changed: 7 additions & 7 deletions

File tree

src/uucore/src/lib/features/fs.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ macro_rules! has {
4343

4444
/// Information to uniquely identify a file
4545
pub struct FileInformation(
46-
#[cfg(unix)] nix::sys::stat::FileStat,
46+
#[cfg(unix)] rustix::fs::Stat,
4747
#[cfg(windows)] winapi_util::file::Information,
4848
// WASI does not have nix::sys::stat, so we store std::fs::Metadata instead.
4949
#[cfg(target_os = "wasi")] fs::Metadata,
@@ -53,7 +53,7 @@ impl FileInformation {
5353
/// Get information from a currently open file
5454
#[cfg(unix)]
5555
pub fn from_file(file: &impl AsFd) -> IOResult<Self> {
56-
let stat = nix::sys::stat::fstat(file)?;
56+
let stat = rustix::fs::fstat(file)?;
5757
Ok(Self(stat))
5858
}
5959

@@ -72,9 +72,9 @@ impl FileInformation {
7272
#[cfg(unix)]
7373
{
7474
let stat = if dereference {
75-
nix::sys::stat::stat(path.as_ref())
75+
rustix::fs::stat(path.as_ref())
7676
} else {
77-
nix::sys::stat::lstat(path.as_ref())
77+
rustix::fs::lstat(path.as_ref())
7878
};
7979
Ok(Self(stat?))
8080
}
@@ -798,8 +798,7 @@ pub fn is_stdin_directory(stdin: &Stdin) -> bool {
798798
#[cfg(unix)]
799799
{
800800
use mode::{S_IFDIR, S_IFMT};
801-
use nix::sys::stat::fstat;
802-
let mode = fstat(stdin.as_fd()).unwrap().st_mode as u32;
801+
let mode = rustix::fs::fstat(stdin.as_fd()).unwrap().st_mode as u32;
803802
// We use the S_IFMT mask ala S_ISDIR() to avoid mistaking
804803
// sockets for directories.
805804
mode & S_IFMT == S_IFDIR

src/uucore/src/lib/features/mode.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,8 @@ pub fn get_umask() -> u32 {
178178
// from /proc/self/status. But that's a lot of work.
179179
#[cfg(unix)]
180180
{
181-
use nix::sys::stat::{Mode, umask};
181+
use rustix::fs::Mode;
182+
use rustix::process::umask;
182183

183184
let mask = umask(Mode::empty());
184185
let _ = umask(mask);

0 commit comments

Comments
 (0)