thermald, redbear-upower: probe ACPI surface via read_dir

Both daemons previously checked /scheme/acpi/thermal (thermald) and
/scheme/acpi/power (redbear-upower) existence with Path::exists or
is_dir, which use stat/lstat. On Redox these syscalls can return
errors for scheme paths even when the scheme IS registered, leading
to false 'unavailable' warnings even after the new acpid thermal/
power directories were added.

Use fs::read_dir (which already worked for actual zone enumeration)
as the existence probe instead. The match expression intentionally
calls read_dir to discard the iterator and keep only the Result;
using ? here would break the warn-once pattern.
This commit is contained in:
2026-06-28 18:54:05 +03:00
parent dbb7bf74e9
commit b8e8774252
2 changed files with 7 additions and 2 deletions
@@ -211,7 +211,9 @@ impl PowerRuntime {
}
fn available(&self) -> bool {
self.root.exists()
// is_dir() uses stat which misbehaves on Redox schemes; read_dir
// is the only reliable existence probe.
self.root.read_dir().is_ok()
}
fn adapter_dir(&self, id: &str) -> PathBuf {
@@ -534,7 +534,10 @@ fn monitor_loop(shared: Arc<RwLock<ThermalState>>) -> ! {
let mut warned_missing_surface = false;
loop {
if !Path::new(ACPI_THERMAL_ROOT).exists() {
// is_dir() / exists() use stat/lstat which return errors on
// Redox schemes; read_dir is the only reliable existence probe.
let surface_available = fs::read_dir(ACPI_THERMAL_ROOT).is_ok();
if !surface_available {
if !warned_missing_surface {
warn!(
"{} is unavailable; thermald will keep polling and serve an empty thermal surface",