From 0301b22b702205c9540539ba0c33beb9f08dff4b Mon Sep 17 00:00:00 2001 From: oech3 <79379754+oech3@users.noreply.github.com> Date: Tue, 7 Jul 2026 00:29:58 +0900 Subject: [PATCH] uptime: remove /proc dependency Use clock_gettime instead of /proc on many unix platforms to run uptime without mounting /proc --- src/uucore/src/lib/features/uptime.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/uucore/src/lib/features/uptime.rs b/src/uucore/src/lib/features/uptime.rs index 29015098ae..fcf0ab1b24 100644 --- a/src/uucore/src/lib/features/uptime.rs +++ b/src/uucore/src/lib/features/uptime.rs @@ -96,7 +96,8 @@ fn get_macos_boot_time_sysctl() -> Option { /// # Returns /// /// Returns a UResult with the uptime in seconds if successful, otherwise an UptimeError. -#[cfg(target_os = "openbsd")] +#[cfg(unix)] +#[cfg(not(any(target_os = "cygwin", target_os = "netbsd", target_vendor = "apple")))] #[allow(clippy::unnecessary_wraps, reason = "needed on some platforms")] pub fn get_uptime(_boot_time: Option) -> UResult { use rustix::time::{ClockId, clock_gettime}; @@ -115,8 +116,7 @@ pub fn get_uptime(_boot_time: Option) -> UResult { /// # Returns /// /// Returns a UResult with the uptime in seconds if successful, otherwise an UptimeError. -#[cfg(unix)] -#[cfg(not(target_os = "openbsd"))] +#[cfg(any(target_os = "cygwin", target_os = "netbsd", target_vendor = "apple"))] pub fn get_uptime(boot_time: Option) -> UResult { use crate::utmpx::BOOT_TIME; use crate::utmpx::Utmpx;