-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
uptime: Support files in uptime
#6400
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
uptime: Support files in uptime
#6400
Conversation
|
GNU testsuite comparison: |
4fc2074 to
3a5ce83
Compare
|
GNU testsuite comparison: |
ea305b8 to
3a5ce83
Compare
76a5692 to
7dd90ba
Compare
… failing for macos
7dd90ba to
ce55ec1
Compare
ce55ec1 to
de56e06
Compare
b5cab86 to
de6a550
Compare
c6e9990 to
002edae
Compare
|
Changes since last push: The test |
|
GNU testsuite comparison: |
|
The failing CI tests are unrelated to my PR. |
|
GNU testsuite comparison: |
266de7b to
4a8c460
Compare
|
GNU testsuite comparison: |
|
GNU testsuite comparison: |
|
@sylvestre does this require any more changes ? |
|
GNU testsuite comparison: |
2d8d270 to
2b94a69
Compare
|
GNU testsuite comparison: |
|
Changes since last push:
|
|
thanks! |
If utmpx BOOT_TIME is unavailable, derive boot time via sysctl CTL_KERN.KERN_BOOTTIME to reduce intermittent macOS failures (e.g., uutils#3621). Context (blame/history): - 2774274 ("uptime: Support files in uptime (uutils#6400)"): added macOS utmpxname validation and non-fatal 'unknown uptime' fallback with tests (tests/by-util/test_uptime.rs). - 920d29f ("uptime: add support for OpenBSD using utmp"): reorganized uptime.rs and solidified utmp/utmpx-driven paths.
If utmpx BOOT_TIME is unavailable, derive boot time via sysctl CTL_KERN.KERN_BOOTTIME to reduce intermittent macOS failures (e.g., uutils#3621). Context (blame/history): - 2774274 ("uptime: Support files in uptime (uutils#6400)"): added macOS utmpxname validation and non-fatal 'unknown uptime' fallback with tests (tests/by-util/test_uptime.rs). - 920d29f ("uptime: add support for OpenBSD using utmp"): reorganized uptime.rs and solidified utmp/utmpx-driven paths.
If utmpx BOOT_TIME is unavailable, derive boot time via sysctl CTL_KERN.KERN_BOOTTIME to reduce intermittent macOS failures (e.g., uutils#3621). Context (blame/history): - 2774274 ("uptime: Support files in uptime (uutils#6400)"): added macOS utmpxname validation and non-fatal 'unknown uptime' fallback with tests (tests/by-util/test_uptime.rs). - 920d29f ("uptime: add support for OpenBSD using utmp"): reorganized uptime.rs and solidified utmp/utmpx-driven paths.
If utmpx BOOT_TIME is unavailable, derive boot time via sysctl CTL_KERN.KERN_BOOTTIME to reduce intermittent macOS failures (e.g., uutils#3621). Context (blame/history): - 2774274 ("uptime: Support files in uptime (uutils#6400)"): added macOS utmpxname validation and non-fatal 'unknown uptime' fallback with tests (tests/by-util/test_uptime.rs). - 920d29f ("uptime: add support for OpenBSD using utmp"): reorganized uptime.rs and solidified utmp/utmpx-driven paths.
* fix(uucore): use sysctl kern.boottime on macOS as fallback for uptime If utmpx BOOT_TIME is unavailable, derive boot time via sysctl CTL_KERN.KERN_BOOTTIME to reduce intermittent macOS failures (e.g., #3621). Context (blame/history): - 2774274 ("uptime: Support files in uptime (#6400)"): added macOS utmpxname validation and non-fatal 'unknown uptime' fallback with tests (tests/by-util/test_uptime.rs). - 920d29f ("uptime: add support for OpenBSD using utmp"): reorganized uptime.rs and solidified utmp/utmpx-driven paths. * test: add comprehensive macOS tests for sysctl kern.boottime fallback Add unit tests for sysctl boottime availability and get_uptime reliability on macOS, verifying the fallback mechanism works correctly when utmpx BOOT_TIME is unavailable. Add integration tests to ensure uptime command consistently succeeds on macOS with various flags (default, --since) and produces properly formatted output. Enhance documentation of the sysctl fallback code with detailed comments explaining why it exists, the issue it addresses (#3621), and comprehensive SAFETY comments for the unsafe sysctl call. All tests are properly gated with #[cfg(target_os = "macos")] to ensure they only run on macOS and don't interfere with other platforms. * refactor(uucore): replace unsafe sysctl with safe command-line approach for macOS boot time - Remove unsafe libc::sysctl() system call entirely - Replace with safe std::process::Command executing 'sysctl -n kern.boottime' - Parse sysctl output format to extract boot time seconds - Maintains same API and functionality while eliminating unsafe blocks - Addresses reviewer feedback to completely remove unsafe code
Fixes #6393
Edit1 : I strace-d the whole thing , we seem to use more than 2x amount of read sys calls (will result in more than 100 extra read calls for very large iterations)compared to GNU uptime, which i believe is due to
iter_all_records_fromfunction in uucore::src::lib::features::utmpx