From 546e50846e13bc99e99d443d615bdfe928553c85 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Thu, 29 May 2025 10:17:04 +0200 Subject: [PATCH 1/2] cp: rewrite test to remove procfs dependency --- tests/by-util/test_cp.rs | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/tests/by-util/test_cp.rs b/tests/by-util/test_cp.rs index cb7eea5cd..fc3576861 100644 --- a/tests/by-util/test_cp.rs +++ b/tests/by-util/test_cp.rs @@ -3,7 +3,7 @@ // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. -// spell-checker:ignore (flags) reflink (fs) tmpfs (linux) rlimit Rlim NOFILE clob btrfs neve ROOTDIR USERDIR procfs outfile uufs xattrs +// spell-checker:ignore (flags) reflink (fs) tmpfs (linux) rlimit Rlim NOFILE clob btrfs neve ROOTDIR USERDIR outfile uufs xattrs // spell-checker:ignore bdfl hlsl IRWXO IRWXG nconfined matchpathcon libselinux-devel use uucore::display::Quotable; use uutests::util::TestScenario; @@ -2556,22 +2556,21 @@ fn test_cp_reflink_insufficient_permission() { #[cfg(target_os = "linux")] #[test] fn test_closes_file_descriptors() { - use procfs::process::Process; use rlimit::Resource; - let me = Process::myself().unwrap(); + + let pid = std::process::id(); + let fd_path = format!("/proc/{pid}/fd"); // The test suite runs in parallel, we have pipe, sockets // opened by other tests. // So, we take in account the various fd to increase the limit - let number_file_already_opened: u64 = me.fd_count().unwrap().try_into().unwrap(); + let number_file_already_opened: u64 = std::fs::read_dir(fd_path) + .unwrap() + .count() + .try_into() + .unwrap(); let limit_fd: u64 = number_file_already_opened + 9; - // For debugging purposes: - for f in me.fd().unwrap() { - let fd = f.unwrap(); - println!("{fd:?} {:?}", fd.mode()); - } - new_ucmd!() .arg("-r") .arg("--reflink=auto") From 5bbcb4ee630c98e0404797458eaf7b524c3ed60f Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Thu, 29 May 2025 10:19:44 +0200 Subject: [PATCH 2/2] Cargo.toml: remove procfs dependency --- Cargo.lock | 54 ++++++------------------------------------------------ Cargo.toml | 5 +---- 2 files changed, 7 insertions(+), 52 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 079120422..4e2b95dbd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -457,7 +457,6 @@ dependencies = [ "phf", "phf_codegen", "pretty_assertions", - "procfs", "rand 0.9.1", "regex", "rlimit", @@ -686,7 +685,7 @@ dependencies = [ "filedescriptor", "mio", "parking_lot", - "rustix 1.0.1", + "rustix", "signal-hook", "signal-hook-mio", "winapi", @@ -1444,12 +1443,6 @@ dependencies = [ "zlib-rs", ] -[[package]] -name = "linux-raw-sys" -version = "0.4.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab" - [[package]] name = "linux-raw-sys" version = "0.9.4" @@ -1912,28 +1905,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "procfs" -version = "0.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc5b72d8145275d844d4b5f6d4e1eef00c8cd889edb6035c21675d1bb1f45c9f" -dependencies = [ - "bitflags 2.9.0", - "hex", - "procfs-core", - "rustix 0.38.44", -] - -[[package]] -name = "procfs-core" -version = "0.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "239df02d8349b06fc07398a3a1697b06418223b1c7725085e801e7c0fc6a12ec" -dependencies = [ - "bitflags 2.9.0", - "hex", -] - [[package]] name = "quick-error" version = "2.0.1" @@ -2149,19 +2120,6 @@ dependencies = [ "semver", ] -[[package]] -name = "rustix" -version = "0.38.44" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154" -dependencies = [ - "bitflags 2.9.0", - "errno", - "libc", - "linux-raw-sys 0.4.15", - "windows-sys 0.59.0", -] - [[package]] name = "rustix" version = "1.0.1" @@ -2171,7 +2129,7 @@ dependencies = [ "bitflags 2.9.0", "errno", "libc", - "linux-raw-sys 0.9.4", + "linux-raw-sys", "windows-sys 0.59.0", ] @@ -2415,7 +2373,7 @@ dependencies = [ "fastrand", "getrandom 0.3.1", "once_cell", - "rustix 1.0.1", + "rustix", "windows-sys 0.59.0", ] @@ -2425,7 +2383,7 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "45c6481c4829e4cc63825e62c49186a34538b7b2750b73b266581ffb612fb5ed" dependencies = [ - "rustix 1.0.1", + "rustix", "windows-sys 0.59.0", ] @@ -2794,7 +2752,7 @@ dependencies = [ "filetime", "indicatif", "libc", - "linux-raw-sys 0.9.4", + "linux-raw-sys", "quick-error", "selinux", "uucore", @@ -4168,7 +4126,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0d65cbf2f12c15564212d48f4e3dfb87923d25d611f2aed18f4cb23f0413d89e" dependencies = [ "libc", - "rustix 1.0.1", + "rustix", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 1b58faf6b..cec7ae21c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ # coreutils (uutils) # * see the repository LICENSE, README, and CONTRIBUTING files for more information -# spell-checker:ignore (libs) bigdecimal datetime serde bincode gethostid kqueue libselinux mangen memmap procfs uuhelp startswith constness expl +# spell-checker:ignore (libs) bigdecimal datetime serde bincode gethostid kqueue libselinux mangen memmap uuhelp startswith constness expl [package] name = "coreutils" @@ -526,9 +526,6 @@ hex-literal = "1.0.0" rstest = { workspace = true } ctor = "0.4.1" -[target.'cfg(any(target_os = "linux", target_os = "android"))'.dev-dependencies] -procfs = { version = "0.17", default-features = false } - [target.'cfg(unix)'.dev-dependencies] nix = { workspace = true, features = ["process", "signal", "user", "term"] } rlimit = "0.10.1"