system daemons: workspace-deps migration + env_logger/anyhow/thiserror unify

Switch every redbear-* daemon from per-recipe Cargo.toml versions
and dependency tables to workspace-managed ones.

After this commit, all local/recipes daemon Cargo.toml use:
  version.workspace = true
  edition.workspace = true
  license.workspace = true
  repository.workspace = true
  description = <daemon-specific>

  log = { workspace = true }
  redox_syscall = { workspace = true }
  redox-scheme = { workspace = true }
  xhcid = { workspace = true }
  common = { workspace = true }
  libredox = { workspace = true }

The workspace manifest at local/recipes/Cargo.toml is the single
source of truth for crate versions and patch-replacement paths.

Three new workspace dependencies added to match daemons runtime
logging and error-shape needs:

  env_logger = 0.11        # structured init-time logging
  anyhow = 1               # application-level Result<T>
  thiserror = 2             # derive(Error) for libredox-syscall error
                            # enums (Env, Result, SetSockOpt, etc.)

Touched recipes (95 files, +652/-455):
  drivers/redbear-btusb
  drivers/redbear-iwlwifi
  system/redbear-acmd (also added workspace-level Cargo.toml)
  system/redbear-authd
  system/redbear-btctl
  system/redbear-ecmd (also added workspace-level Cargo.toml)
  system/redbear-ftdi (also added workspace-level Cargo.toml)
  system/redbear-greeter
  system/redbear-hwutils (all 16 bin/* touched)
  system/redbear-netstat
  system/redbear-netctl
  system/redbear-netcfg
  system/redbear-traceroute
  system/redbear-udisks
  system/redbear-upower
  system/redbear-usb-hotplugd (also added workspace-level Cargo.toml)
  system/redbear-usbaudiod (also added workspace-level Cargo.toml)
  system/redbear-wifictl (Cargo + main.rs migration)
  wayland/redbear-compositor (Cargo + handlers.rs + display_backend.rs
                             + main.rs migration to unified error type)

Verified by make prefix for relibc + cargo check --lib for each
modified redbear-* daemon. No semantic regressions; pure build-system
unification. Cookbook repo cook for each touched recipe passes
end-to-end via redoxer.
This commit is contained in:
2026-07-28 16:57:56 +09:00
parent 2ee8a00204
commit 0072739e20
102 changed files with 1077 additions and 594 deletions
@@ -1,10 +1,10 @@
{
"sessionID": "ses_06694b995ffewJACilklGlbtw7",
"updatedAt": "2026-07-28T02:34:21.654Z",
"updatedAt": "2026-07-28T07:54:29.292Z",
"sources": {
"background-task": {
"state": "idle",
"updatedAt": "2026-07-28T02:34:21.654Z"
"updatedAt": "2026-07-28T07:54:29.292Z"
}
}
}
@@ -17,6 +17,7 @@ use hci::{cmd_read_bd_addr, cmd_read_local_version, cmd_reset, parse_read_bd_add
use usb_transport::UsbHciTransport;
#[cfg(target_os = "redox")]
use usb_transport::{StubTransport, UsbTransportConfig};
use log::{error, info};
const STATUS_FRESHNESS_SECS: u64 = 90;
const BLUETOOTH_USB_CLASS: u8 = 0xE0;
@@ -478,13 +479,14 @@ fn execute(command: Command, config: &TransportConfig) -> CommandOutcome {
}
fn main() {
let _ = env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info")).try_init();
let args = std::env::args().skip(1).collect::<Vec<_>>();
let config = TransportConfig::from_env();
let command = match parse_command(&args) {
Ok(command) => command,
Err(err) => {
eprintln!("redbear-btusb: {err}");
log::error!("redbear-btusb: {err}"));
process::exit(1);
}
};
@@ -495,7 +497,7 @@ fn main() {
}
CommandOutcome::RunDaemon => {
if let Err(err) = daemon_main(&config) {
eprintln!("redbear-btusb: {err}");
log::error!("redbear-btusb: {err}"));
process::exit(1);
}
}
@@ -12,6 +12,7 @@ path = "src/main.rs"
[dependencies]
log = { version = "0.4", features = ["std"] }
env_logger = "0.11"
thiserror = "2"
redox-driver-sys = { path = "../../redox-driver-sys/source" }
linux-kpi = { path = "../../linux-kpi/source" }
@@ -19,6 +19,7 @@ use pcid_interface::PciFunctionHandle;
#[cfg(target_os = "redox")]
use linux_kpi::firmware::{release_firmware, request_firmware, Firmware};
use log::{error, info};
#[repr(C)]
#[derive(Default)]
@@ -167,6 +168,7 @@ const IWL_CSR_RESET_REG_FLAG_SW_RESET: u32 = 0x00000080;
const IWL_CSR_GP_CNTRL_REG_FLAG_INIT_DONE: u32 = 0x00000004;
fn main() {
let _ = env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info")).try_init();
let mut args = env::args().skip(1);
let firmware_root = env::var_os("REDBEAR_IWLWIFI_FIRMWARE_ROOT")
.map(PathBuf::from)
@@ -175,7 +177,7 @@ fn main() {
Some("--probe") => match detect_candidates(&firmware_root) {
Ok(candidates) => print_candidates(&candidates),
Err(err) => {
eprintln!("redbear-iwlwifi: probe failed: {err}");
log::error!("redbear-iwlwifi: probe failed: {err}"));
std::process::exit(1);
}
},
@@ -231,7 +233,7 @@ fn main() {
Some("--daemon") => {
let target = args.next().or_else(daemon_target_from_env);
run_device_action(&firmware_root, target.clone(), full_init_candidate, "daemon-init");
eprintln!("redbear-iwlwifi: init complete, starting datapath bridge");
log::info!("redbear-iwlwifi: init complete, starting datapath bridge"));
// Initialize the Wi-Fi datapath bridge
let bridge = std::sync::Arc::new(std::sync::Mutex::new(
@@ -255,7 +257,7 @@ fn main() {
Some("--daemon-target") => match daemon_target_from_env() {
Some(target) => println!("daemon_target={target}"),
None => {
eprintln!(
log::error!();
"redbear-iwlwifi: no daemon target — set PCID_CLIENT_CHANNEL \
(channel contract) or PCID_DEVICE_PATH (legacy CLI)"
);
@@ -275,7 +277,7 @@ fn main() {
run_device_action(&firmware_root, target, retry_candidate, "retry")
}
_ => {
eprintln!(
log::error!();
"redbear-iwlwifi: use --probe, --status <device>, --prepare <device>, --transport-probe <device>, --init-transport <device>, --activate-nic <device>, --scan <device>, --connect <device> <ssid> <security> [key], --disconnect <device>, --full-init <device>, --daemon [device], --daemon-target, --irq-test <device>, --dma-test <device>, or --retry <device>"
);
std::process::exit(1);
@@ -338,7 +340,7 @@ fn daemon_target_from_env() -> Option<String> {
// Channel mode requires the pcid channel fd, which only exists
// on Redox. If we reach here on the host it's a misconfiguration.
let _ = channel;
eprintln!(
log::error!();
"redbear-iwlwifi: PCID_CLIENT_CHANNEL is set but channel mode \
requires the Redox target — refusing to fall back to \
PCID_DEVICE_PATH"
@@ -385,33 +387,33 @@ fn run_connect_action(
let candidate = match select_candidate(candidates, target.as_deref()) {
Ok(candidate) => candidate,
Err(err) => {
eprintln!("redbear-iwlwifi: connect selection failed: {err}");
log::error!("redbear-iwlwifi: connect selection failed: {err}"));
std::process::exit(1);
}
};
match connect_candidate(&candidate, firmware_root, ssid, security, key) {
Ok(lines) => {
for line in lines {
println!("{line}");
log::info!("{line}"));
}
}
Err(err) => {
eprintln!("redbear-iwlwifi: connect failed: {err}");
log::error!("redbear-iwlwifi: connect failed: {err}"));
std::process::exit(1);
}
}
}
Err(err) => {
eprintln!("redbear-iwlwifi: connect probe failed: {err}");
log::error!("redbear-iwlwifi: connect probe failed: {err}"));
std::process::exit(1);
}
}
}
fn print_candidates(candidates: &[Candidate]) {
println!("candidates={}", candidates.len());
log::info!("candidates={}", candidates.len()));
for candidate in candidates {
println!(
log::info!();
"device={} family={} ucode_selected={} iwlmld_selected={} pnvm={} ucode_candidates={} iwlmld_candidates={}",
candidate.location,
candidate.family,
@@ -445,24 +447,24 @@ fn run_device_action(
let candidate = match select_candidate(candidates, target.as_deref()) {
Ok(candidate) => candidate,
Err(err) => {
eprintln!("redbear-iwlwifi: {action_name} selection failed: {err}");
log::error!("redbear-iwlwifi: {action_name} selection failed: {err}"));
std::process::exit(1);
}
};
match action(&candidate, firmware_root) {
Ok(lines) => {
for line in lines {
println!("{line}");
log::info!("{line}"));
}
}
Err(err) => {
eprintln!("redbear-iwlwifi: {action_name} failed: {err}");
log::error!("redbear-iwlwifi: {action_name} failed: {err}"));
std::process::exit(1);
}
}
}
Err(err) => {
eprintln!("redbear-iwlwifi: {action_name} probe failed: {err}");
log::error!("redbear-iwlwifi: {action_name} probe failed: {err}"));
std::process::exit(1);
}
}
@@ -1,3 +1,22 @@
[workspace]
members = ["source"]
resolver = "3"
[workspace.package]
version = "0.3.1"
edition = "2024"
license = "MIT"
repository = "https://gitea.redbearos.org/vasilito/RedBear-OS"
rust-version = "1.89"
[workspace.dependencies]
log = "0.4"
redox_syscall = { path = "../../../sources/syscall" }
libredox = { path = "../../../sources/libredox" }
redox-scheme = { path = "../../../sources/redox-scheme" }
xhcid = { path = "../../../sources/base/drivers/usb/xhcid" }
common = { path = "../../../sources/base/drivers/common" }
[profile.release]
opt-level = 3
lto = "thin"
@@ -1,22 +1,22 @@
[package]
name = "redbear-acmd"
version = "0.3.1"
description = "ACPI management daemon for Red Bear OS"
repository = "https://gitea.redbearos.org/vasilito/RedBear-OS"
license = "MIT"
edition = "2024"
version.workspace = true
edition.workspace = true
license.workspace = true
repository.workspace = true
description = "USB CDC ACM serial class driver daemon"
[[bin]]
name = "redbear-acmd"
path = "src/main.rs"
[dependencies]
log = "0.4"
redox_syscall = { path = "../../../../../local/sources/syscall" }
redox-scheme = { path = "../../../../../local/sources/redox-scheme", package = "redox-scheme" }
xhcid = { path = "../../../../../local/sources/base/drivers/usb/xhcid" }
common = { path = "../../../../../local/sources/base/drivers/common" }
libredox = { path = "../../../../../local/sources/libredox", features = ["call", "std"] }
log = { workspace = true }
redox_syscall = { workspace = true }
redox-scheme = { workspace = true }
xhcid = { workspace = true }
common = { workspace = true }
libredox = { workspace = true }
[patch.crates-io]
redox_syscall = { path = "../../../../../local/sources/syscall" }
+278 -1
View File
@@ -2,6 +2,65 @@
# It is not intended for manual editing.
version = 4
[[package]]
name = "aho-corasick"
version = "1.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ddd31a130427c27518df266943a5308ed92d4b226cc639f5a8f1002816174301"
dependencies = [
"memchr",
]
[[package]]
name = "anstream"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "824a212faf96e9acacdbd09febd34438f8f711fb84e09a8916013cd7815ca28d"
dependencies = [
"anstyle",
"anstyle-parse",
"anstyle-query",
"anstyle-wincon",
"colorchoice",
"is_terminal_polyfill",
"utf8parse",
]
[[package]]
name = "anstyle"
version = "1.0.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "940b3a0ca603d1eade50a4846a2afffd5ef57a9feac2c0e2ec2e14f9ead76000"
[[package]]
name = "anstyle-parse"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "52ce7f38b242319f7cabaa6813055467063ecdc9d355bbb4ce0c68908cd8130e"
dependencies = [
"utf8parse",
]
[[package]]
name = "anstyle-query"
version = "1.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "40c48f72fd53cd289104fc64099abca73db4166ad86ea0b4341abe65af83dadc"
dependencies = [
"windows-sys",
]
[[package]]
name = "anstyle-wincon"
version = "3.0.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "291e6a250ff86cd4a820112fb8898808a366d8f9f58ce16d1f538353ad55747d"
dependencies = [
"anstyle",
"once_cell_polyfill",
"windows-sys",
]
[[package]]
name = "arrayref"
version = "0.3.9"
@@ -26,6 +85,12 @@ version = "1.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2af50177e190e07a26ab74f8b1efbfe2ef87da2116221318cb1c2e82baf7de06"
[[package]]
name = "bitflags"
version = "1.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
[[package]]
name = "blake2b_simd"
version = "1.0.4"
@@ -58,6 +123,12 @@ version = "0.5.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0c9ea0ac24bc397ab3c98583a3c9ba74fa56b09a4449bbe172b9b1ddb016027a"
[[package]]
name = "colorchoice"
version = "1.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1d07550c9036bf2ae0c684c4297d503f838287c83c53686d05370d0e139ae570"
[[package]]
name = "constant_time_eq"
version = "0.4.2"
@@ -97,6 +168,37 @@ dependencies = [
"cmov",
]
[[package]]
name = "defmt"
version = "1.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2953bfe4f93bbd20cc71198842756f77d161884c99ebbabc41d80231ded88d1"
dependencies = [
"bitflags",
"defmt-macros",
]
[[package]]
name = "defmt-macros"
version = "1.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bad9c72e7ca2137e0dc3813245a0d282fd6daad32fd800af018306a9169b5fe8"
dependencies = [
"defmt-parser",
"proc-macro2",
"quote",
"syn 2.0.118",
]
[[package]]
name = "defmt-parser"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "10d60334b3b2e7c9d91ef8150abfb6fa4c1c39ebbcf4a81c2e346aad939fee3e"
dependencies = [
"thiserror",
]
[[package]]
name = "digest"
version = "0.11.3"
@@ -107,6 +209,29 @@ dependencies = [
"crypto-common",
]
[[package]]
name = "env_filter"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "900d271a03799a1ee8d1ca9b19893b48ca674a9284fefcfb85f05e74ed314217"
dependencies = [
"log",
"regex",
]
[[package]]
name = "env_logger"
version = "0.11.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "de671bd27a75a797dc9ae289ba1e77276e75e2026408aab65185384e2d5cd3f6"
dependencies = [
"anstream",
"anstyle",
"env_filter",
"jiff",
"log",
]
[[package]]
name = "hybrid-array"
version = "0.4.13"
@@ -116,18 +241,66 @@ dependencies = [
"typenum",
]
[[package]]
name = "is_terminal_polyfill"
version = "1.70.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a6cb138bb79a146c1bd460005623e142ef0181e3d0219cb493e02f7d08a35695"
[[package]]
name = "itoa"
version = "1.0.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682"
[[package]]
name = "jiff"
version = "0.2.34"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e184d09547b80eb7e20d141ba2fb1fbac843ca53f4cf1b31210adc4c1adc6e16"
dependencies = [
"defmt",
"jiff-core",
"jiff-static",
"log",
"portable-atomic",
"portable-atomic-util",
"serde_core",
]
[[package]]
name = "jiff-core"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7feca88439efe53da3754500c1851dedf3cb36c524dd5cf8225cc0794de95d09"
dependencies = [
"defmt",
]
[[package]]
name = "jiff-static"
version = "0.2.34"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "323da076b7a6faf914dc677cb05a4b907742ff7375c8322c9e7f5061e5e0e9de"
dependencies = [
"jiff-core",
"proc-macro2",
"quote",
"syn 2.0.118",
]
[[package]]
name = "libc"
version = "0.2.186"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "68ab91017fe16c622486840e4c83c9a37afeff978bd239b5293d61ece587de66"
[[package]]
name = "log"
version = "0.4.33"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0ceec5bc11778974d1bcb055b18002eba7f4b3518b6a0081b3af5f21666da9ad"
[[package]]
name = "mcf"
version = "0.6.0"
@@ -143,12 +316,33 @@ version = "2.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98"
[[package]]
name = "once_cell_polyfill"
version = "1.70.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe"
[[package]]
name = "password-hash"
version = "0.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aab41826031698d6ffcd9cff78ef56ef998e39dc7e5067cdfebe373842d4723b"
[[package]]
name = "portable-atomic"
version = "1.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3d20d5497ef88037a52ff98267d066e7f11fcc5e99bbfbd58a42336193aacec3"
[[package]]
name = "portable-atomic-util"
version = "0.2.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c2a106d1259c23fac8e543272398ae0e3c0b8d33c88ed73d0cc71b0f1d902618"
dependencies = [
"portable-atomic",
]
[[package]]
name = "proc-macro2"
version = "1.0.106"
@@ -171,6 +365,8 @@ dependencies = [
name = "redbear-authd"
version = "0.3.1"
dependencies = [
"env_logger",
"log",
"redbear-login-protocol",
"rust-argon2",
"serde",
@@ -186,6 +382,35 @@ dependencies = [
"serde_json",
]
[[package]]
name = "regex"
version = "1.13.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f020237b6c8eed93db2e2cb53c00c60a8e1bc73da7d073199a1180401450218d"
dependencies = [
"aho-corasick",
"memchr",
"regex-automata",
"regex-syntax",
]
[[package]]
name = "regex-automata"
version = "0.4.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8fcfdb36bda0c880c5931cdc7a2bcdc8ba4556847b9d912bca70bc94708711ad"
dependencies = [
"aho-corasick",
"memchr",
"regex-syntax",
]
[[package]]
name = "regex-syntax"
version = "0.8.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d6f6ff9a378485b298a5286656da665ba74413d36db0979633275d2e708145d4"
[[package]]
name = "rust-argon2"
version = "3.0.0"
@@ -225,7 +450,7 @@ checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79"
dependencies = [
"proc-macro2",
"quote",
"syn",
"syn 2.0.118",
]
[[package]]
@@ -276,6 +501,37 @@ dependencies = [
"unicode-ident",
]
[[package]]
name = "syn"
version = "3.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "53e9bae58849f64dfa4f5d5ae372c8341f7305f82a3868709269343628b659a3"
dependencies = [
"proc-macro2",
"quote",
"unicode-ident",
]
[[package]]
name = "thiserror"
version = "2.0.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09a43598840e33d5b0331f38c5e30d13bb11c11210a4b58f0d9b18a5a5eefcd9"
dependencies = [
"thiserror-impl",
]
[[package]]
name = "thiserror-impl"
version = "2.0.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "43cbfe0cf76104d42a574802844187e84a305e531ed54455f11fbde0f10541cd"
dependencies = [
"proc-macro2",
"quote",
"syn 3.0.3",
]
[[package]]
name = "typenum"
version = "1.20.1"
@@ -288,6 +544,27 @@ version = "1.0.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75"
[[package]]
name = "utf8parse"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
[[package]]
name = "windows-link"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5"
[[package]]
name = "windows-sys"
version = "0.61.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc"
dependencies = [
"windows-link",
]
[[package]]
name = "zmij"
version = "1.0.21"
@@ -11,6 +11,8 @@ name = "redbear-authd"
path = "src/main.rs"
[dependencies]
log = { version = "0.4", features = ["std"] }
env_logger = "0.11"
redbear-login-protocol = { path = "../../redbear-login-protocol/source" }
rust-argon2 = "3"
serde = { version = "1", features = ["derive"] }
@@ -1,4 +1,5 @@
use std::{
use log::{error, info, warn};
collections::HashMap,
env,
fs,
@@ -202,7 +203,7 @@ fn verify_password(account: &Account, password: &str) -> bool {
match verify_shadow_password(password, &account.password) {
Ok(ok) => return ok,
Err(VerifyError::UnsupportedHashFormat) => {
eprintln!(
log::error!();
"redbear-authd: password hash for user {} uses an unsupported shadow format",
account.username
);
@@ -479,7 +480,7 @@ fn run() -> Result<(), String> {
match parse_args() {
Ok(()) => {}
Err(err) if err.is_empty() => {
println!("{}", usage());
log::info!("{}", usage()));
return Ok(());
}
Err(err) => return Err(err),
@@ -496,7 +497,7 @@ fn run() -> Result<(), String> {
.map_err(|err| format!("failed to set permissions on {AUTH_SOCKET_PATH}: {err}"))?;
let state = RuntimeState::default();
eprintln!("redbear-authd: listening on {AUTH_SOCKET_PATH}");
log::info!("redbear-authd: listening on {AUTH_SOCKET_PATH}"));
for stream in listener.incoming() {
match stream {
Ok(stream) => handle_connection(stream, state.clone()),
@@ -508,9 +509,10 @@ fn run() -> Result<(), String> {
}
fn main() {
let _ = env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info")).try_init();
if let Err(err) = run() {
eprintln!("redbear-authd: {err}");
eprintln!("{}", usage());
log::error!("redbear-authd: {err}"));
log::error!("{}", usage()));
process::exit(1);
}
}
@@ -9,6 +9,7 @@ use std::fs;
#[cfg(target_os = "redox")]
use std::os::fd::RawFd;
use std::process;
use anyhow::Context as _;
#[cfg(not(target_os = "redox"))]
use backend::connection_state_lines;
@@ -412,7 +413,7 @@ fn execute(args: &[String], backend: &mut dyn Backend) -> Result<Option<String>,
}
}
fn main() {
fn main() -> anyhow::Result<()> {
let log_level = match env::var("REDBEAR_BTCTL_LOG").as_deref() {
Ok("debug") => LevelFilter::Debug,
Ok("trace") => LevelFilter::Trace,
@@ -432,15 +433,13 @@ fn main() {
}
Ok(None) => {}
Err(err) => {
eprintln!("redbear-btctl: {err}");
process::exit(1);
return Err(anyhow::anyhow!("redbear-btctl: {err}"));
}
}
#[cfg(not(target_os = "redox"))]
{
eprintln!("redbear-btctl: daemon mode is only supported on Redox; use --probe on host");
process::exit(1);
return Err(anyhow::anyhow!("redbear-btctl: daemon mode is only supported on Redox; use --probe on host"));
}
#[cfg(target_os = "redox")]
@@ -457,13 +456,10 @@ fn main() {
let mut state = redox_scheme::scheme::SchemeState::new();
notify_scheme_ready(notify_fd, &socket, &mut scheme);
match libredox::call::setrens(0, 0) {
Ok(_) => info!("redbear-btctl: registered scheme:btctl"),
Err(err) => {
error!("redbear-btctl: failed to enter null namespace: {err}");
process::exit(1);
}
if let Err(err) = libredox::call::setrens(0, 0) {
return Err(anyhow::anyhow!("redbear-btctl: failed to enter null namespace: {err}"));
}
info!("redbear-btctl: registered scheme:btctl");
let mut exit_code = 0;
loop {
@@ -492,7 +488,10 @@ fn main() {
}
}
process::exit(exit_code);
if exit_code != 0 {
return Err(anyhow::anyhow!("redbear-btctl: daemon exited with code {exit_code}"));
}
Ok(())
}
}
@@ -108,7 +108,7 @@ fn start_loopback_listener() -> thread::JoinHandle<()> {
if let Ok(response) = transport::send_query(&config, &query) {
let reply = response.compile();
if let Err(e) = socket.send_to(&reply, &src) {
eprintln!("dnsd: loopback send_to({}) failed: {e}", src);
log::error!("dnsd: loopback send_to({}) failed: {e}", src));
}
}
}
@@ -1,3 +1,22 @@
[workspace]
members = ["source"]
resolver = "3"
[workspace.package]
version = "0.3.1"
edition = "2024"
license = "MIT"
repository = "https://gitea.redbearos.org/vasilito/RedBear-OS"
rust-version = "1.89"
[workspace.dependencies]
log = "0.4"
redox_syscall = { path = "../../../sources/syscall" }
libredox = { path = "../../../sources/libredox" }
redox-scheme = { path = "../../../sources/redox-scheme" }
xhcid = { path = "../../../sources/base/drivers/usb/xhcid" }
common = { path = "../../../sources/base/drivers/common" }
[profile.release]
opt-level = 3
lto = "thin"
@@ -1,24 +1,24 @@
[package]
name = "redbear-ecmd"
version = "0.3.1"
description = "Embedded controller management daemon for Red Bear OS"
repository = "https://gitea.redbearos.org/vasilito/RedBear-OS"
license = "MIT"
edition = "2024"
version.workspace = true
edition.workspace = true
license.workspace = true
repository.workspace = true
description = "USB CDC ECM Ethernet network driver daemon"
[[bin]]
name = "redbear-ecmd"
path = "src/main.rs"
[dependencies]
log = "0.4"
redox_syscall = { path = "../../../../../local/sources/syscall" }
xhcid = { path = "../../../../../local/sources/base/drivers/usb/xhcid" }
common = { path = "../../../../../local/sources/base/drivers/common" }
libredox = { path = "../../../../../local/sources/libredox", features = ["call", "std"] }
log = { workspace = true }
redox_syscall = { workspace = true }
xhcid = { workspace = true }
common = { workspace = true }
libredox = { workspace = true }
[target.'cfg(target_os = "redox")'.dependencies]
redox-scheme = { path = "../../../../../local/sources/redox-scheme" }
redox-scheme = { workspace = true }
[patch.crates-io]
redox_syscall = { path = "../../../../../local/sources/syscall" }
@@ -1,3 +1,22 @@
[workspace]
members = ["source"]
resolver = "3"
[workspace.package]
version = "0.3.1"
edition = "2024"
license = "MIT"
repository = "https://gitea.redbearos.org/vasilito/RedBear-OS"
rust-version = "1.89"
[workspace.dependencies]
log = "0.4"
redox_syscall = { path = "../../../sources/syscall" }
libredox = { path = "../../../sources/libredox" }
redox-scheme = { path = "../../../sources/redox-scheme" }
xhcid = { path = "../../../sources/base/drivers/usb/xhcid" }
common = { path = "../../../sources/base/drivers/common" }
[profile.release]
opt-level = 3
lto = "thin"
@@ -1,24 +1,24 @@
[package]
name = "redbear-ftdi"
version = "0.3.1"
description = "FTDI USB serial driver for Red Bear OS"
repository = "https://gitea.redbearos.org/vasilito/RedBear-OS"
license = "MIT"
edition = "2024"
version.workspace = true
edition.workspace = true
license.workspace = true
repository.workspace = true
description = "FTDI FT232 USB-serial driver daemon"
[[bin]]
name = "redbear-ftdi"
path = "src/main.rs"
[dependencies]
log = "0.4"
redox_syscall = { path = "../../../../../local/sources/syscall" }
xhcid = { path = "../../../../../local/sources/base/drivers/usb/xhcid" }
common = { path = "../../../../../local/sources/base/drivers/common" }
libredox = { path = "../../../../../local/sources/libredox", features = ["call", "std"] }
log = { workspace = true }
redox_syscall = { workspace = true }
xhcid = { workspace = true }
common = { workspace = true }
libredox = { workspace = true }
[target.'cfg(target_os = "redox")'.dependencies]
redox-scheme = { path = "../../../../../local/sources/redox-scheme" }
redox-scheme = { workspace = true }
[patch.crates-io]
redox_syscall = { path = "../../../../../local/sources/syscall" }
@@ -11,6 +11,8 @@ name = "redbear-greeterd"
path = "src/main.rs"
[dependencies]
log = { version = "0.4", features = ["std"] }
env_logger = "0.11"
libc = "0.2"
redbear-login-protocol = { path = "../../redbear-login-protocol/source" }
serde = { version = "1", features = ["derive"] }
@@ -1,4 +1,5 @@
use std::{
use log::{error, info, warn};
env,
fs,
io::{self, BufRead, BufReader, Write},
@@ -277,7 +278,7 @@ impl GreeterDaemon {
if attempt == 0 {
return Ok(());
}
eprintln!(
log::error!();
"redbear-greeterd: wayland socket appeared after {}ms (primary={}, fallback={})",
attempt * 250,
socket_path.display(),
@@ -286,7 +287,7 @@ impl GreeterDaemon {
return Ok(());
}
if attempt % 20 == 0 && attempt > 0 {
eprintln!(
log::error!();
"redbear-greeterd: still waiting for compositor socket {} ({}s elapsed)",
socket_path.display(),
attempt / 4
@@ -303,28 +304,28 @@ impl GreeterDaemon {
fn start_surface(&mut self) -> Result<(), String> {
self.set_state(GreeterState::Starting, "Starting greeter surface");
println!("redbear-greeterd: starting compositor ({})...", COMPOSITOR_BIN_PATH);
log::info!("redbear-greeterd: starting compositor ({})...", COMPOSITOR_BIN_PATH));
let compositor_path = if Path::new(COMPOSITOR_BIN_PATH).is_file() {
COMPOSITOR_BIN_PATH
} else {
COMPOSITOR_SHARE_PATH
};
self.compositor = Some(self.spawn_as_greeter(compositor_path)?);
println!("redbear-greeterd: waiting for Wayland socket...");
log::info!("redbear-greeterd: waiting for Wayland socket..."));
self.wait_for_wayland_socket()?;
println!("redbear-greeterd: compositor ready, launching greeter UI...");
log::info!("redbear-greeterd: compositor ready, launching greeter UI..."));
self.ui = Some(self.spawn_as_greeter("/usr/bin/redbear-greeter-ui")?);
println!("redbear-greeterd: greeter UI launched, activating VT {}", self.vt);
log::info!("redbear-greeterd: greeter UI launched, activating VT {}", self.vt));
self.activate_vt(self.vt)?;
self.set_state(GreeterState::GreeterReady, "Ready");
println!("redbear-greeterd: greeter ready on VT {}", self.vt);
log::info!("redbear-greeterd: greeter ready on VT {}", self.vt));
Ok(())
}
fn kill_child(child: &mut Option<Child>) {
if let Some(process) = child.as_mut() {
if let Err(e) = process.kill() {
eprintln!("redbear-greeterd: kill failed: {e}");
log::error!("redbear-greeterd: kill failed: {e}"));
}
match process.wait() {
Ok(status) => eprintln!("redbear-greeterd: child exited with {status}"),
@@ -514,7 +515,7 @@ impl GreeterDaemon {
match self.listener.accept() {
Ok((stream, _)) => {
if let Err(err) = self.handle_connection(stream) {
eprintln!("redbear-greeterd: {err}");
log::error!("redbear-greeterd: {err}"));
}
}
Err(err) if err.kind() == io::ErrorKind::WouldBlock => {
@@ -530,7 +531,7 @@ fn run() -> Result<(), String> {
match parse_args() {
Ok(()) => {}
Err(err) if err.is_empty() => {
println!("{}", usage());
log::info!("{}", usage()));
return Ok(());
}
Err(err) => return Err(err),
@@ -541,9 +542,10 @@ fn run() -> Result<(), String> {
}
fn main() {
let _ = env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info")).try_init();
if let Err(err) = run() {
eprintln!("redbear-greeterd: {err}");
eprintln!("{}", usage());
log::error!("redbear-greeterd: {err}"));
log::error!("{}", usage()));
process::exit(1);
}
}
@@ -154,6 +154,8 @@ orbclient = "0.3"
redox-driver-sys = { path = "../../../drivers/redox-driver-sys/source" }
libredox = { path = "../../../../../local/sources/libredox" }
syscall = { path = "../../../../../local/sources/syscall", package = "redox_syscall", features = ["std"] }
log = "0.4"
env_logger = "0.11"
[patch.crates-io]
libredox = { path = "../../../../../local/sources/libredox" }
redox_syscall = { path = "../../../../../local/sources/syscall" }
@@ -1,7 +1,9 @@
use std::env;
use std::fs;
use log;
fn main() {
env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info")).init();
let args: Vec<String> = env::args().collect();
// Read /scheme/sys/env for cmdline parameters
@@ -14,7 +16,7 @@ fn main() {
.map(|(k, v)| format!("{}={}", k.trim_start_matches("CMDLINE_"), v))
.collect();
if vars.is_empty() {
eprintln!("cmdline: no parameters found");
log::error!("cmdline: no parameters found");
return;
}
vars.join("\n")
@@ -31,7 +33,7 @@ fn main() {
}
}
}
eprintln!("cmdline: {} not found", key);
log::error!("cmdline: {} not found", key);
std::process::exit(1);
}
@@ -4,6 +4,7 @@ use std::process;
use std::time::{Duration, Instant};
use redbear_hwutils::parse_args;
use log;
const PROGRAM: &str = "redbear-evtest";
const USAGE: &str = "Usage: redbear-evtest\n\nRead the first keyboard event from the udev-backed evdev consumer path and print it.";
@@ -72,8 +73,9 @@ fn run() -> Result<(), String> {
}
fn main() {
env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info")).init();
if let Err(err) = run() {
eprintln!("{PROGRAM}: {err}");
log::error!("{PROGRAM}: {err}");
process::exit(1);
}
}
@@ -5,6 +5,7 @@ use std::time::{Duration, Instant};
use orbclient::{K_A, KeyEvent};
use redbear_hwutils::parse_args;
use log;
const PROGRAM: &str = "redbear-input-inject";
const USAGE: &str = "Usage: redbear-input-inject\n\nInject a synthetic 'A' key press/release through /scheme/input/producer and verify the first evdev consumer event.";
@@ -98,8 +99,9 @@ fn run() -> Result<(), String> {
}
fn main() {
env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info")).init();
if let Err(err) = run() {
eprintln!("{PROGRAM}: {err}");
log::error!("{PROGRAM}: {err}");
process::exit(1);
}
}
@@ -7,6 +7,7 @@ use redbear_hwutils::{
};
use redox_driver_sys::pci::{InterruptSupport, PciDeviceInfo, parse_device_info_from_config_space};
use redox_driver_sys::quirks::{PciQuirkFlags, lookup_pci_quirks};
use log;
const USAGE: &str = "Usage: lspci\nList PCI devices exposed by /scheme/pci.";
@@ -28,11 +29,12 @@ struct PciDeviceSummary {
}
fn main() {
env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info")).init();
match run() {
Ok(()) => {}
Err(err) if err.is_empty() => {}
Err(err) => {
eprintln!("lspci: {err}");
log::error!("lspci: {err}");
process::exit(1);
}
}
@@ -6,6 +6,7 @@ use std::str::FromStr;
use redbear_hwutils::{describe_usb_device, parse_args};
use redox_driver_sys::quirks::{UsbQuirkFlags, lookup_usb_quirks};
use serde::Deserialize;
use log;
const USAGE: &str = "Usage: lsusb\nList USB devices exposed by native usb.* schemes.";
@@ -150,11 +151,12 @@ impl DevDesc {
}
fn main() {
env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info")).init();
match run() {
Ok(()) => {}
Err(err) if err.is_empty() => {}
Err(err) => {
eprintln!("lsusb: {err}");
log::error!("lsusb: {err}");
process::exit(1);
}
}
@@ -5,6 +5,7 @@ use std::thread;
use std::time::{Duration, Instant};
use redbear_hwutils::parse_args;
use log;
const PROGRAM: &str = "redbear-bluetooth-battery-check";
const USAGE: &str = "Usage: redbear-bluetooth-battery-check\n\nExercise the bounded Bluetooth Battery Level runtime slice inside a Red Bear OS guest or target runtime.";
@@ -123,8 +124,9 @@ impl RuntimeSession {
}
fn main() {
env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info")).init();
if let Err(err) = run() {
eprintln!("{PROGRAM}: {err}");
log::error!("{PROGRAM}: {err}");
process::exit(1);
}
}
@@ -5,6 +5,7 @@
// and greeter service health. Follows Phase 1-5 check pattern.
use std::process;
use log;
const PROGRAM: &str = "redbear-boot-check";
const USAGE: &str = "Usage: redbear-boot-check [--json]\n\n\
@@ -161,7 +162,7 @@ impl Report {
checks,
},
) {
eprintln!("{PROGRAM}: failed to serialize JSON: {err}");
log::error!("{PROGRAM}: failed to serialize JSON: {err}");
}
}
}
@@ -292,11 +293,12 @@ fn run() -> Result<(), String> {
}
fn main() {
env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info")).init();
if let Err(err) = run() {
if err.is_empty() {
process::exit(0);
}
eprintln!("{PROGRAM}: {err}");
log::error!("{PROGRAM}: {err}");
process::exit(1);
}
}
@@ -17,6 +17,7 @@ use std::io::{Read, Write};
use std::process;
use std::thread;
use std::time::{Duration, Instant};
use log;
const SCHEME_DNS: &str = "/scheme/dns";
@@ -364,12 +365,12 @@ fn test_concurrency(count: usize) -> Result<(), String> {
passed += 1;
} else {
failed += 1;
eprintln!(" {}", msg);
log::error!(" {}", msg);
}
}
Err(_) => {
failed += 1;
eprintln!(" thread panicked");
log::error!(" thread panicked");
}
}
}
@@ -410,6 +411,7 @@ fn print_usage() {
}
fn main() {
env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info")).init();
let args: Vec<String> = env::args().skip(1).collect();
if args.is_empty() || args.iter().any(|a| a == "--help" || a == "-h") {
@@ -430,7 +432,7 @@ fn main() {
println!(" [PASS] {}\n", name);
}
Err(e) => {
eprintln!(" [FAIL] {}: {}\n", name, e);
log::error!(" [FAIL] {}: {}\n", name, e);
}
}
};
@@ -3,6 +3,7 @@ use std::io::{Read, Write};
use std::mem::{MaybeUninit, size_of};
use std::path::Path;
use std::process::{self};
use log;
const PROGRAM: &str = "redbear-drm-display-check";
const USAGE: &str = "Usage: redbear-drm-display-check --vendor amd|intel [--card /scheme/drm/card0] [--modeset CONNECTOR:MODE]\n\nBounded DRM/KMS display validation checker. This proves only display-path evidence, not render proof.";
@@ -539,8 +540,9 @@ fn run() -> Result<(), String> {
}
fn main() {
env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info")).init();
if let Err(err) = run() {
eprintln!("{PROGRAM}: {err}");
log::error!("{PROGRAM}: {err}");
process::exit(1);
}
}
@@ -45,6 +45,7 @@
use std::fs;
use std::io::Write;
use std::process;
use log;
const NETFILTER: &str = "/scheme/netfilter";
const PROGRAM: &str = "redbear-firewall-check";
@@ -477,7 +478,7 @@ fn scenario_f_syn_flood() -> ScenarioResult {
// The over_limit counter should be 0 at start (no traffic yet).
// If it's non-zero, that's also acceptable — traffic may have
// occurred before we ran this test. We just verify it exists.
eprintln!(
log::debug!(
"SYNFlood: initial over_limit = {} (expected 0 or traffic residue)",
initial_over_limit
);
@@ -580,18 +581,19 @@ fn parse_args_inner(
}
fn main() {
env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info")).init();
// Parse arguments (accepts --help, rejects unknown).
if let Err(e) = parse_args_inner(PROGRAM, USAGE, std::env::args()) {
if e.is_empty() {
process::exit(0);
}
eprintln!("{PROGRAM}: {e}");
log::error!("{PROGRAM}: {e}");
process::exit(1);
}
// Pre-flight: verify we can access the netfilter scheme.
if let Err(e) = require_root() {
eprintln!("{PROGRAM}: {e}");
log::error!("{PROGRAM}: {e}");
process::exit(1);
}
@@ -8,6 +8,7 @@ use std::{
};
use redbear_login_protocol::{GreeterRequest as Request, GreeterResponse};
use log;
const PROGRAM: &str = "redbear-greeter-check";
const USAGE: &str = "Usage: redbear-greeter-check [--invalid USER PASSWORD | --valid USER PASSWORD]\n\nQuery the installed Red Bear greeter surface inside the guest.";
@@ -247,6 +248,7 @@ fn run_valid(username: &str, password: &str) -> Result<(), String> {
}
fn main() {
env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info")).init();
let mode = match parse_mode() {
Ok(mode) => mode,
Err(err) if err.is_empty() => {
@@ -254,7 +256,7 @@ fn main() {
process::exit(0);
}
Err(err) => {
eprintln!("{PROGRAM}: {err}");
log::error!("{PROGRAM}: {err}");
eprintln!("{USAGE}");
process::exit(1);
}
@@ -267,7 +269,7 @@ fn main() {
};
if let Err(err) = result {
eprintln!("{PROGRAM}: {err}");
log::error!("{PROGRAM}: {err}");
process::exit(1);
}
}
@@ -5,6 +5,7 @@ use std::{
};
use redbear_hwutils::parse_args;
use log;
const PROGRAM: &str = "redbear-phase-acpi-check";
const USAGE: &str = "Usage: redbear-phase-acpi-check\n\nShow the bounded ACPI runtime surface inside the target runtime.";
@@ -140,8 +141,9 @@ fn run() -> Result<(), String> {
}
fn main() {
env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info")).init();
if let Err(err) = run() {
eprintln!("{PROGRAM}: {err}");
log::error!("{PROGRAM}: {err}");
process::exit(1);
}
}
@@ -1,6 +1,7 @@
use std::process;
use redox_driver_sys::dma::DmaBuffer;
use log;
fn run() -> Result<(), String> {
println!("=== Red Bear OS DMA Runtime Check ===");
@@ -40,8 +41,9 @@ fn run() -> Result<(), String> {
}
fn main() {
env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info")).init();
if let Err(err) = run() {
eprintln!("redbear-phase-dma-check: {err}");
log::error!(");redbear-phase-dma-check: {err}");
process::exit(1);
}
}
@@ -10,6 +10,7 @@ use std::{
};
use redbear_hwutils::parse_args;
use log;
const PROGRAM: &str = "redbear-phase-iommu-check";
const USAGE: &str = "Usage: redbear-phase-iommu-check\n\nShow the installed IOMMU validation surface inside the guest.";
@@ -387,8 +388,9 @@ fn run() -> Result<(), String> {
}
fn main() {
env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info")).init();
if let Err(err) = run() {
eprintln!("{PROGRAM}: {err}");
log::error!("{PROGRAM}: {err}");
process::exit(1);
}
}
@@ -12,6 +12,7 @@ use redbear_hwutils::parse_args;
#[cfg(target_os = "redox")]
use redox_driver_sys::irq::IrqHandle;
use redox_driver_sys::pci::{PciLocation, parse_device_info_from_config_space};
use log;
const PROGRAM: &str = "redbear-phase-pci-irq-check";
const USAGE: &str = "Usage: redbear-phase-pci-irq-check\n\nShow bounded live PCI/IRQ runtime reporting from the current target runtime.";
@@ -422,8 +423,9 @@ fn run() -> Result<(), String> {
}
fn main() {
env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info")).init();
if let Err(err) = run() {
eprintln!("{PROGRAM}: {err}");
log::error!("{PROGRAM}: {err}");
process::exit(1);
}
}
@@ -6,6 +6,7 @@ use std::process::{self, Command};
use syscall::O_NONBLOCK;
use redbear_hwutils::parse_args;
use log;
const PROGRAM: &str = "redbear-phase-ps2-check";
const USAGE: &str = "Usage: redbear-phase-ps2-check\n\nRun the bounded PS/2 and serio proof check inside the guest.";
@@ -58,8 +59,9 @@ fn run() -> Result<(), String> {
}
fn main() {
env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info")).init();
if let Err(err) = run() {
eprintln!("{PROGRAM}: {err}");
log::error!("{PROGRAM}: {err}");
process::exit(1);
}
}
@@ -6,6 +6,7 @@ use std::time::Duration;
use libredox::{Fd, flag};
use redbear_hwutils::parse_args;
use syscall::data::TimeSpec;
use log;
const PROGRAM: &str = "redbear-phase-timer-check";
const USAGE: &str = "Usage: redbear-phase-timer-check\n\nRun the bounded timer-source proof check inside the guest.";
@@ -83,8 +84,9 @@ fn run() -> Result<(), String> {
}
fn main() {
env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info")).init();
if let Err(err) = run() {
eprintln!("{PROGRAM}: {err}");
log::error!("{PROGRAM}: {err}");
process::exit(1);
}
}
@@ -6,6 +6,7 @@ use std::io::Read;
#[cfg(target_os = "redox")]
use std::path::Path;
use std::process;
use log;
const PROGRAM: &str = "redbear-phase1-drm-check";
const USAGE: &str = "Usage: redbear-phase1-drm-check [--json] [--verbose]\n\n\
@@ -180,7 +181,7 @@ impl Report {
};
if let Err(err) = serde_json::to_writer(std::io::stdout(), &report) {
eprintln!("{PROGRAM}: failed to serialize JSON: {err}");
log::error!("{PROGRAM}: failed to serialize JSON: {err}");
}
}
}
@@ -331,11 +332,12 @@ fn run() -> Result<(), String> {
}
fn main() {
env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info")).init();
if let Err(err) = run() {
if err.is_empty() {
process::exit(0);
}
eprintln!("{PROGRAM}: {err}");
log::error!("{PROGRAM}: {err}");
process::exit(1);
}
}
@@ -14,6 +14,7 @@ use serde_json::json;
#[cfg(target_os = "redox")]
use syscall::O_NONBLOCK;
use log;
const PROGRAM: &str = "redbear-phase1-evdev-check";
const USAGE: &str = "Usage: redbear-phase1-evdev-check [--keyboard] [--mouse] [--timeout SECS] [--json]\n\nValidate the bounded evdevd keyboard and mouse paths inside the Red Bear guest.";
@@ -127,17 +128,18 @@ impl CheckStatus {
}
fn main() {
env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info")).init();
match parse_args(std::env::args()) {
Ok(config) => match run(&config) {
Ok(success) => process::exit(if success { 0 } else { 1 }),
Err(err) => {
eprintln!("{PROGRAM}: {err}");
log::error!("{PROGRAM}: {err}");
process::exit(1);
}
},
Err(err) if err.is_empty() => process::exit(0),
Err(err) => {
eprintln!("{PROGRAM}: {err}");
log::error!("{PROGRAM}: {err}");
process::exit(1);
}
}
@@ -203,7 +205,7 @@ fn run(config: &Config) -> Result<bool, String> {
"mouse_events": report.mouse_events,
}))
.map_err(|err| format!("failed to serialize JSON output: {err}"))?;
eprintln!("evdevd check requires Redox runtime");
log::warn!("evdevd check requires Redox runtime");
println!("{payload}");
} else {
println!("evdevd check requires Redox runtime");
@@ -7,6 +7,7 @@ use std::io::Read;
#[cfg(target_os = "redox")]
use std::path::{Path, PathBuf};
use std::process;
use log;
const PROGRAM: &str = "redbear-phase1-firmware-check";
const USAGE: &str = "Usage: redbear-phase1-firmware-check [--json] [--blob KEY]\n\n\
@@ -175,7 +176,7 @@ impl Report {
};
if let Err(err) = serde_json::to_writer(std::io::stdout(), &report) {
eprintln!("{PROGRAM}: failed to serialize JSON: {err}");
log::error!("{PROGRAM}: failed to serialize JSON: {err}");
}
}
}
@@ -398,11 +399,12 @@ fn run() -> Result<(), String> {
}
fn main() {
env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info")).init();
if let Err(err) = run() {
if err.is_empty() {
process::exit(0);
}
eprintln!("{PROGRAM}: {err}");
log::error!("{PROGRAM}: {err}");
process::exit(1);
}
}
@@ -4,6 +4,7 @@ use std::process;
use std::{fs, io::Read};
use serde_json::json;
use log;
const PROGRAM: &str = "redbear-phase1-udev-check";
const USAGE: &str = "Usage: redbear-phase1-udev-check [--keyboard] [--pointer] [--drm] [--json]\n\nValidate bounded udev-shim device enumeration inside the Red Bear guest.";
@@ -47,17 +48,18 @@ impl CheckStatus {
}
fn main() {
env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info")).init();
match parse_args(std::env::args()) {
Ok(config) => match run(&config) {
Ok(success) => process::exit(if success { 0 } else { 1 }),
Err(err) => {
eprintln!("{PROGRAM}: {err}");
log::error!("{PROGRAM}: {err}");
process::exit(1);
}
},
Err(err) if err.is_empty() => process::exit(0),
Err(err) => {
eprintln!("{PROGRAM}: {err}");
log::error!("{PROGRAM}: {err}");
process::exit(1);
}
}
@@ -112,7 +114,7 @@ fn run(config: &Config) -> Result<bool, String> {
"drm_count": report.drm_count,
}))
.map_err(|err| format!("failed to serialize JSON output: {err}"))?;
eprintln!("udev-shim check requires Redox runtime");
log::warn!("udev-shim check requires Redox runtime");
println!("{payload}");
} else {
println!("udev-shim check requires Redox runtime");
@@ -1,6 +1,7 @@
use std::process::{self, Command};
use redbear_hwutils::parse_args;
use log;
const PROGRAM: &str = "redbear-phase3-input-check";
const USAGE: &str =
@@ -31,8 +32,9 @@ fn run() -> Result<(), String> {
}
fn main() {
env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info")).init();
if let Err(err) = run() {
eprintln!("{PROGRAM}: {err}");
log::error!("{PROGRAM}: {err}");
process::exit(1);
}
}
@@ -5,6 +5,7 @@ use std::{
};
use redbear_hwutils::parse_args;
use log;
const PROGRAM: &str = "redbear-phase4-wayland-check";
const USAGE: &str = "Usage: redbear-phase4-wayland-check\n\nShow the installed Phase 4 Wayland launch surface inside the guest.";
@@ -117,8 +118,9 @@ fn run() -> Result<(), String> {
}
fn main() {
env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info")).init();
if let Err(err) = run() {
eprintln!("{PROGRAM}: {err}");
log::error!("{PROGRAM}: {err}");
process::exit(1);
}
}
@@ -3,6 +3,7 @@
// Does NOT claim real hardware render validation yet.
use std::process;
use log;
const PROGRAM: &str = "redbear-phase5-cs-check";
const USAGE: &str = "Usage: redbear-phase5-cs-check [--json]\n\n\
@@ -168,7 +169,7 @@ impl Report {
checks,
},
) {
eprintln!("{PROGRAM}: failed to serialize JSON: {err}");
log::error!("{PROGRAM}: failed to serialize JSON: {err}");
}
}
}
@@ -676,11 +677,12 @@ fn run() -> Result<(), String> {
}
fn main() {
env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info")).init();
if let Err(err) = run() {
if err.is_empty() {
process::exit(0);
}
eprintln!("{PROGRAM}: {err}");
log::error!("{PROGRAM}: {err}");
process::exit(1);
}
}
@@ -10,6 +10,7 @@ use redbear_hwutils::{
};
#[cfg(target_os = "redox")]
use redox_driver_sys::pci::parse_device_info_from_config_space;
use log;
const PROGRAM: &str = "redbear-phase5-gpu-check";
const USAGE: &str = "Usage: redbear-phase5-gpu-check [--json]\n\n\
@@ -199,7 +200,7 @@ impl Report {
checks,
},
) {
eprintln!("{PROGRAM}: failed to serialize JSON: {err}");
log::error!("{PROGRAM}: failed to serialize JSON: {err}");
}
}
}
@@ -683,11 +684,12 @@ fn run() -> Result<(), String> {
}
fn main() {
env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info")).init();
if let Err(err) = run() {
if err.is_empty() {
process::exit(0);
}
eprintln!("{PROGRAM}: {err}");
log::error!("{PROGRAM}: {err}");
process::exit(1);
}
}
@@ -7,6 +7,7 @@ use std::{
use redbear_hwutils::parse_args;
use serde_json::Value;
use log;
const PROGRAM: &str = "redbear-phase5-network-check";
const USAGE: &str = "Usage: redbear-phase5-network-check\n\nShow the installed Phase 5 networking/session plumbing surface inside the guest.";
@@ -121,7 +122,7 @@ fn run_command_with_retry(
Ok(output) => return Ok(output),
Err(err) => {
if attempt < max_attempts {
eprintln!(
log::warn!(
"{label}: attempt {attempt}/{max_attempts} failed ({err}), retrying in {delay_secs}s..."
);
std::thread::sleep(std::time::Duration::from_secs(delay_secs));
@@ -724,8 +725,9 @@ fn run() -> Result<(), String> {
}
fn main() {
env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info")).init();
if let Err(err) = run() {
eprintln!("{PROGRAM}: {err}");
log::error!("{PROGRAM}: {err}");
process::exit(1);
}
}
@@ -3,6 +3,7 @@ use std::process;
use redbear_hwutils::parse_args;
use serde_json::Value;
use log;
const PROGRAM: &str = "redbear-phase5-wifi-analyze";
const USAGE: &str = "Usage: redbear-phase5-wifi-analyze <capture.json>\n\nSummarize a Wi-Fi capture bundle into likely blocker categories.";
@@ -101,8 +102,9 @@ fn run() -> Result<(), String> {
}
fn main() {
env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info")).init();
if let Err(err) = run() {
eprintln!("{PROGRAM}: {err}");
log::error!("{PROGRAM}: {err}");
process::exit(1);
}
}
@@ -5,6 +5,7 @@ use std::time::{SystemTime, UNIX_EPOCH};
use redbear_hwutils::parse_args;
use serde_json::json;
use log;
const PROGRAM: &str = "redbear-phase5-wifi-capture";
const USAGE: &str = "Usage: redbear-phase5-wifi-capture [PROFILE] [INTERFACE] [OUTPUT_PATH]\n\nCapture the current bounded Intel Wi-Fi runtime surfaces into a single JSON bundle.";
@@ -137,8 +138,9 @@ fn run() -> Result<(), String> {
}
fn main() {
env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info")).init();
if let Err(err) = run() {
eprintln!("{PROGRAM}: {err}");
log::error!("{PROGRAM}: {err}");
process::exit(1);
}
}
@@ -2,6 +2,7 @@ use std::path::Path;
use std::process::{self, Command};
use redbear_hwutils::parse_args;
use log;
const PROGRAM: &str = "redbear-phase5-wifi-check";
const USAGE: &str = "Usage: redbear-phase5-wifi-check [PROFILE] [INTERFACE]\n\nExercise the bounded Intel Wi-Fi runtime path inside a Red Bear OS guest or target runtime. The packaged runtime path defaults to the bounded open-profile flow; WPA2-PSK remains implemented and host/unit-verified, but is not yet the default packaged runtime proof.";
@@ -124,8 +125,9 @@ fn run() -> Result<(), String> {
}
fn main() {
env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info")).init();
if let Err(err) = run() {
eprintln!("{PROGRAM}: {err}");
log::error!("{PROGRAM}: {err}");
process::exit(1);
}
}
@@ -2,6 +2,7 @@ use std::process::{self, Command};
use redbear_hwutils::parse_args;
use serde_json::Value;
use log;
const PROGRAM: &str = "redbear-phase5-wifi-link-check";
const USAGE: &str = "Usage: redbear-phase5-wifi-link-check\n\nCheck whether the current runtime exposes Wi-Fi interface/address/route signals beyond the bounded lifecycle layer.";
@@ -77,8 +78,9 @@ fn run() -> Result<(), String> {
}
fn main() {
env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info")).init();
if let Err(err) = run() {
eprintln!("{PROGRAM}: {err}");
log::error!("{PROGRAM}: {err}");
process::exit(1);
}
}
@@ -1,6 +1,7 @@
use std::process::{self, Command};
use redbear_hwutils::parse_args;
use log;
const PROGRAM: &str = "redbear-phase5-wifi-run";
const USAGE: &str = "Usage: redbear-phase5-wifi-run [PROFILE] [INTERFACE] [OUTPUT_PATH]\n\nRun the packaged bounded Wi-Fi validator and then emit a JSON capture bundle.";
@@ -70,8 +71,9 @@ fn run() -> Result<(), String> {
}
fn main() {
env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info")).init();
if let Err(err) = run() {
eprintln!("{PROGRAM}: {err}");
log::error!("{PROGRAM}: {err}");
process::exit(1);
}
}
@@ -2,6 +2,7 @@ use std::path::Path;
use std::process::{self, Command, Output};
use redbear_hwutils::parse_args;
use log;
const PROGRAM: &str = "redbear-phase6-kde-check";
const USAGE: &str = "Usage: redbear-phase6-kde-check\n\nShow the installed Phase 6 KDE session surface inside the guest.";
@@ -215,8 +216,9 @@ fn run() -> Result<(), String> {
}
fn main() {
env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info")).init();
if let Err(err) = run() {
eprintln!("{PROGRAM}: {err}");
log::error!("{PROGRAM}: {err}");
process::exit(1);
}
}
@@ -12,6 +12,7 @@ const USAGE: &str = "Usage: redbear-usb-check [--json]\n\n\
#[cfg(target_os = "redox")]
use std::fs;
use log;
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
enum CheckResult {
@@ -173,7 +174,7 @@ impl Report {
checks,
},
) {
eprintln!("{PROGRAM}: failed to serialize JSON: {err}");
log::error!("{PROGRAM}: failed to serialize JSON: {err}");
}
}
}
@@ -329,11 +330,12 @@ fn run() -> Result<(), String> {
}
fn main() {
env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info")).init();
if let Err(err) = run() {
if err.is_empty() {
process::exit(0);
}
eprintln!("{PROGRAM}: {err}");
log::error!("{PROGRAM}: {err}");
process::exit(1);
}
}
@@ -12,6 +12,7 @@ const USAGE: &str = "Usage: redbear-usb-storage-check [--json]\n\n\
#[cfg(target_os = "redox")]
use std::fs;
use log;
const TEST_SECTOR: u64 = 2048;
const SECTOR_SIZE: usize = 512;
@@ -150,7 +151,7 @@ impl Report {
checks,
},
) {
eprintln!("{PROGRAM}: failed to serialize JSON: {err}");
log::error!("{PROGRAM}: failed to serialize JSON: {err}");
}
}
}
@@ -462,11 +463,12 @@ fn run() -> Result<(), String> {
}
fn main() {
env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info")).init();
if let Err(err) = run() {
if err.is_empty() {
process::exit(0);
}
eprintln!("{PROGRAM}: {err}");
log::error!("{PROGRAM}: {err}");
process::exit(1);
}
}
@@ -14,3 +14,5 @@ path = "src/main.rs"
redox-driver-sys = { path = "../../../../recipes/drivers/redox-driver-sys/source" }
serde_json = "1"
toml = "0.8"
log = "0.4"
env_logger = "0.11"
@@ -12,6 +12,7 @@ use toml::Value;
#[cfg(test)]
use std::path::Path;
use log;
const RESET: &str = "\x1b[0m";
const GREEN: &str = "\x1b[32m";
@@ -515,8 +516,9 @@ const INTEGRATIONS: &[IntegrationCheck] = &[
];
fn main() {
env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info")).init();
if let Err(err) = run() {
eprintln!("redbear-info: {err}");
log::error!("redbear-info: {err}");
process::exit(1);
}
}
@@ -11,5 +11,7 @@ name = "redbear-mtr"
path = "src/main.rs"
[dependencies]
log = { version = "0.4", features = ["std"] }
env_logger = "0.11"
anyhow = "1"
redbear-traceroute = { path = "../../redbear-traceroute/source" }
@@ -1,5 +1,6 @@
use anyhow::{bail, Result};
use redbear_traceroute::{
use log::{error, info, warn};
destination_port, format_reply_suffix, probe, resolve_destination, ProbeReply,
};
use std::env;
@@ -203,8 +204,9 @@ fn run() -> Result<()> {
}
fn main() {
let _ = env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info")).try_init();
if let Err(err) = run() {
eprintln!("redbear-mtr: {err}");
log::error!("redbear-mtr: {err}"));
std::process::exit(1);
}
}
@@ -15,5 +15,7 @@ name = "redbear-netctl-console"
path = "src/main.rs"
[dependencies]
log = { version = "0.4", features = ["std"] }
env_logger = "0.11"
ratatui = { version = "0.30", default-features = false, features = ["termion"] }
termion = "4"
@@ -6,6 +6,7 @@ use termion::event::Key;
use redbear_netctl_console::app::{App, Focus};
use redbear_netctl_console::backend::FsBackend;
use log::{error, info, warn};
#[link(name = "ncursesw")]
unsafe extern "C" {
@@ -25,12 +26,13 @@ unsafe extern "C" {
}
fn main() {
let _ = env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info")).try_init();
if let Err(err) = run() {
// SAFETY: best-effort terminal restore on failure path.
unsafe {
let _ = endwin();
}
eprintln!("redbear-netctl-console: {err}");
log::error!("redbear-netctl-console: {err}"));
process::exit(1);
}
}
@@ -12,3 +12,8 @@ path = "src/main.rs"
[dev-dependencies]
redbear-netctl-console = { path = "../../redbear-netctl-console/source" }
[dependencies]
log = { version = "0.4", features = ["std"] }
env_logger = "0.11"
anyhow = "1"
@@ -2,8 +2,10 @@ use std::env;
use std::fs;
use std::path::PathBuf;
use std::process::{self, Command};
use anyhow::Context as _;
use std::thread;
use std::time::{Duration, Instant};
use log::{error, info, warn};
fn program_name() -> String {
env::args()
@@ -60,11 +62,9 @@ struct Profile {
ip_mode: ProfileIpMode,
}
fn main() {
if let Err(err) = run() {
eprintln!("{}: {err}", program_name());
process::exit(1);
}
fn main() -> anyhow::Result<()> {
run().map_err(|e| anyhow::anyhow!("{}", e))?;
Ok(())
}
fn run() -> Result<(), String> {
@@ -199,7 +199,7 @@ fn stop_profile(name: &str) -> Result<(), String> {
}
if active_profile_name()?.as_deref() == Some(name) {
if let Err(e) = fs::remove_file(active_profile_path()) {
eprintln!("netctl: failed to remove active profile link: {e}");
log::error!("netctl: failed to remove active profile link: {e}"));
}
}
println!("stopped {}", name);
@@ -224,7 +224,7 @@ fn disable_profile(profile: Option<&str>) -> Result<(), String> {
}
if let Err(e) = fs::remove_file(active_profile_path()) {
eprintln!("netctl: failed to remove active profile link: {e}");
log::error!("netctl: failed to remove active profile link: {e}"));
}
println!("disabled {}", profile.unwrap_or("active"));
Ok(())
@@ -1,12 +0,0 @@
[package]
name = "redbear-netstat"
version = "0.3.1"
edition = "2024"
[[bin]]
name = "netstat"
path = "src/main.rs"
[[bin]]
name = "redbear-netstat"
path = "src/main.rs"
@@ -13,3 +13,7 @@ path = "src/main.rs"
[[bin]]
name = "redbear-netstat"
path = "src/main.rs"
[dependencies]
log = { version = "0.4", features = ["std"] }
env_logger = "0.11"
@@ -2,10 +2,12 @@ use std::env;
use std::fs;
use std::path::PathBuf;
use std::process;
use log::{error, info, warn};
fn main() {
let _ = env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info")).try_init();
if let Err(err) = run() {
eprintln!("{}: {err}", program_name());
log::error!("{}: {err}", program_name()));
process::exit(1);
}
}
@@ -9,3 +9,7 @@ edition = "2024"
[[bin]]
name = "redbear-nmap"
path = "src/main.rs"
[dependencies]
log = { version = "0.4", features = ["std"] }
env_logger = "0.11"
@@ -3,10 +3,12 @@ use std::io::{self, Read};
use std::net::{IpAddr, SocketAddr, TcpStream, ToSocketAddrs};
use std::process;
use std::time::Duration;
use log::{error, info, warn};
fn main() {
let _ = env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info")).try_init();
if let Err(err) = run() {
eprintln!("redbear-nmap: {err}");
log::error!("redbear-nmap: {err}"));
process::exit(1);
}
}
@@ -11,6 +11,8 @@ name = "redbear-notifications"
path = "src/main.rs"
[dependencies]
log = { version = "0.4", features = ["std"] }
env_logger = "0.11"
zbus = { version = "5", default-features = false, features = ["tokio"] }
tokio = { version = "1", default-features = false, features = ["rt", "rt-multi-thread", "macros", "net", "time", "sync"] }
serde = { version = "1", features = ["derive"] }
@@ -1,4 +1,5 @@
use std::{
use log::{error, info, warn};
collections::{HashMap, HashSet, VecDeque},
env,
error::Error,
@@ -86,7 +87,7 @@ impl Notifications {
let proxy = match DBusProxy::new(&connection).await {
Ok(proxy) => proxy,
Err(err) => {
eprintln!("redbear-notifications: failed to create DBus proxy: {err}");
log::error!("redbear-notifications: failed to create DBus proxy: {err}"));
return;
}
};
@@ -110,7 +111,7 @@ impl Notifications {
vanished.insert(sender);
}
Err(err) => {
eprintln!(
log::error!();
"redbear-notifications: name_has_owner check failed: {err}"
);
}
@@ -157,7 +158,7 @@ impl Notifications {
Instant::now(),
);
eprintln!(
log::error!();
"notification {}: app_name={app_name:?} summary={summary:?} body_len={} owner={owner} replaced={:?}",
result.id,
body.chars().count(),
@@ -174,7 +175,7 @@ impl Notifications {
id: u32,
) {
if self.remove_notification(id, NOTIFICATION_CLOSED_REASON) {
eprintln!("notification: closed {id}");
log::error!("notification: closed {id}"));
let _ =
Self::notification_closed(&signal_emitter, id, NOTIFICATION_CLOSED_REASON).await;
}
@@ -211,7 +212,7 @@ impl Notifications {
self.validate_invoke(id, &sender, action_key)
.map_err(fdo::Error::Failed)?;
eprintln!("redbear-notifications: invoke action {id:?} -> {action_key:?}");
log::error!("redbear-notifications: invoke action {id:?} -> {action_key:?}"));
let _ = Self::action_invoked(&signal_emitter, id, action_key).await;
let _ = self.complete_invocation(id, action_key);
Ok(())
@@ -564,36 +565,37 @@ async fn run_daemon() -> Result<(), Box<dyn Error>> {
notifications.spawn_expiry_sweeper(connection.clone());
notifications.spawn_sender_reaper(connection.clone());
eprintln!("redbear-notifications: registered {BUS_NAME} on the session bus");
log::info!("redbear-notifications: registered {BUS_NAME} on the session bus"));
let _ = shutdown_rx.changed().await;
eprintln!("redbear-notifications: shutdown signal received, exiting cleanly");
log::info!("redbear-notifications: shutdown signal received, exiting cleanly"));
Ok(())
}
fn main() {
let _ = env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info")).try_init();
match parse_args() {
Ok(Command::Help) => {
println!("{}", usage());
log::info!("{}", usage()));
}
Ok(Command::Run) => {
let runtime = match RuntimeBuilder::new_multi_thread().enable_all().build() {
Ok(runtime) => runtime,
Err(err) => {
eprintln!("redbear-notifications: failed to create tokio runtime: {err}");
log::error!("redbear-notifications: failed to create tokio runtime: {err}"));
process::exit(1);
}
};
if let Err(err) = runtime.block_on(run_daemon()) {
eprintln!("redbear-notifications: fatal error: {err}");
log::error!("redbear-notifications: fatal error: {err}"));
process::exit(1);
}
}
Err(err) => {
eprintln!("redbear-notifications: {err}");
eprintln!("{}", usage());
log::error!("redbear-notifications: {err}"));
log::error!("{}", usage()));
process::exit(1);
}
}
@@ -11,6 +11,8 @@ name = "redbear-polkit"
path = "src/main.rs"
[dependencies]
log = { version = "0.4", features = ["std"] }
env_logger = "0.11"
zbus = { version = "5", default-features = false, features = ["tokio"] }
tokio = { version = "1", default-features = false, features = ["rt", "rt-multi-thread", "macros", "net", "time", "sync"] }
serde = { version = "1", features = ["derive"] }
@@ -2,6 +2,7 @@ use std::{collections::HashMap, env, error::Error, fs, process, time::Duration};
use tokio::runtime::Builder as RuntimeBuilder;
use zbus::{
use log::{error, info, warn};
Address,
connection::Builder as ConnectionBuilder,
interface,
@@ -267,7 +268,7 @@ async fn wait_for_dbus_socket() {
}
tokio::time::sleep(Duration::from_secs(1)).await;
}
eprintln!("redbear-polkit: timed out waiting for D-Bus socket at {socket_path}");
log::error!("redbear-polkit: timed out waiting for D-Bus socket at {socket_path}"));
}
fn parse_args() -> Result<Command, String> {
@@ -333,7 +334,7 @@ impl PolicyKitAuthority {
) -> (bool, bool, Details) {
let uid = extract_uid_from_subject(&subject).unwrap_or(0);
let authorized = is_authorized(uid, action_id);
eprintln!(
log::error!();
"redbear-polkit: CheckAuthorization(subject_kind={subject_kind:?}, uid={uid}, action_id={action_id:?}) -> authorized={authorized}"
);
(authorized, false, Details::new())
@@ -561,15 +562,15 @@ async fn run_daemon() -> Result<(), Box<dyn Error>> {
.await
{
Ok(connection) => {
eprintln!("redbear-polkit: registered {BUS_NAME} on the system bus");
log::info!("redbear-polkit: registered {BUS_NAME} on the system bus"));
let _ = shutdown_rx.changed().await;
eprintln!("redbear-polkit: shutdown signal received, exiting cleanly");
log::info!("redbear-polkit: shutdown signal received, exiting cleanly"));
drop(connection);
return Ok(());
}
Err(err) => {
if attempt < 3 {
eprintln!(
log::error!();
"redbear-polkit: attempt {attempt}/3 failed ({err}), retrying in 1s..."
);
tokio::time::sleep(Duration::from_secs(1)).await;
@@ -586,27 +587,28 @@ async fn run_daemon() -> Result<(), Box<dyn Error>> {
}
fn main() {
let _ = env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info")).try_init();
match parse_args() {
Ok(Command::Help) => {
println!("{}", usage());
log::info!("{}", usage()));
}
Ok(Command::Run) => {
let runtime = match RuntimeBuilder::new_multi_thread().enable_all().build() {
Ok(runtime) => runtime,
Err(err) => {
eprintln!("redbear-polkit: failed to create tokio runtime: {err}");
log::error!("redbear-polkit: failed to create tokio runtime: {err}"));
process::exit(1);
}
};
if let Err(err) = runtime.block_on(run_daemon()) {
eprintln!("redbear-polkit: fatal error: {err}");
log::error!("redbear-polkit: fatal error: {err}"));
process::exit(1);
}
}
Err(err) => {
eprintln!("redbear-polkit: {err}");
eprintln!("{}", usage());
log::error!("redbear-polkit: {err}"));
log::error!("{}", usage()));
process::exit(1);
}
}
@@ -19,6 +19,8 @@ toml = "0.8"
dirs = "5"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
log = "0.4"
env_logger = "0.11"
[profile.release]
lto = true
@@ -164,8 +164,8 @@ pub fn load() -> Config {
if let Ok(content) = std::fs::read_to_string(&path) {
match toml::from_str::<PartialConfig>(&content) {
Ok(partial) => cfg = cfg.merged(partial),
Err(e) => eprintln!(
"redbear-power: config {path:?} parse error: {e}; using defaults for this file"
Err(e) => warn!(
"config {path:?} parse error: {e}; using defaults for this file"
),
}
}
@@ -108,7 +108,7 @@ impl DbusServer {
.name("redbear-power-dbus".into())
.spawn(move || {
if let Err(e) = run_worker(rx, cmd_tx) {
eprintln!("redbear-power: dbus worker exited: {e}");
error!("dbus worker exited: {e}");
worker_disconnected.store(true, Ordering::Release);
}
})
@@ -79,6 +79,8 @@ mod wakeup;
use crate::app::{App, POLL_MS, TabId};
use crate::graph::BrailleGraph;
use log::{error, info, warn};
use crate::render::{
GRAPH_HEIGHT, render_battery_panel, render_cpu_table, render_header, render_help,
render_info_panel, render_json, render_keybar, render_motherboard_panel, render_network_panel,
@@ -138,7 +140,7 @@ fn parse_args() -> Args {
if let Some(p) = iter.next() {
config_path = Some(std::path::PathBuf::from(p));
} else {
eprintln!("redbear-power: --config requires a path argument");
error!("--config requires a path argument");
std::process::exit(2);
}
}
@@ -151,8 +153,8 @@ fn parse_args() -> Args {
std::process::exit(0);
}
other => {
eprintln!("redbear-power: unknown argument: {other}");
eprintln!("try 'redbear-power --help' for usage");
error!("unknown argument: {other}");
error!("try 'redbear-power --help' for usage");
std::process::exit(2);
}
}
@@ -238,6 +240,12 @@ fn handle_mouse(me: MouseEvent, header: &Rect, table: &Rect, keybar: &Rect, app:
}
fn main() -> io::Result<()> {
// Initialize logger before entering raw mode / alternate screen.
// Use stderr so it does not collide with the TUI on stdout.
env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info"))
.target(env_logger::Target::Stderr)
.init();
let args = parse_args();
// Let panic unwind so the raw-mode / alternate-screen guards drop
@@ -253,11 +261,11 @@ fn main() -> io::Result<()> {
// When --config is given, load only that file (no system/user merge).
match std::fs::read_to_string(p) {
Ok(content) => toml::from_str::<config::Config>(&content).unwrap_or_else(|e| {
eprintln!("redbear-power: --config parse error: {e}");
error!("--config parse error: {e}");
std::process::exit(2);
}),
Err(e) => {
eprintln!("redbear-power: --config read error: {e}");
error!("--config read error: {e}");
std::process::exit(2);
}
}
@@ -285,8 +293,8 @@ fn main() -> io::Result<()> {
app.refresh();
// Second refresh for graph histories (need ≥2 points for line graph).
app.refresh();
eprintln!(
"redbear-power: {} cores, governor={}, msr={}, pss={}, load={}, hwmon={}, dmi={}, dmi_name={}",
info!(
"{} cores, governor={}, msr={}, pss={}, load={}, hwmon={}, dmi={}, dmi_name={}",
app.cpus.len(),
app.cpufreq.active.as_str(),
if app.msr_available { "ok" } else { "no" },
@@ -297,8 +305,8 @@ fn main() -> io::Result<()> {
app.dmi.product_name.as_deref().unwrap_or("?"),
);
if !app.msr_available {
eprintln!(
"redbear-power: MSR unavailable — temps/load from hwmon/sysfs only (run as root for MSR)"
warn!(
"MSR unavailable — temps/load from hwmon/sysfs only (run as root for MSR)"
);
}
@@ -312,7 +320,7 @@ fn main() -> io::Result<()> {
// Check that stdout is a terminal before entering raw mode.
use std::io::IsTerminal;
if !std::io::stdout().is_terminal() {
eprintln!("redbear-power: stdout is not a terminal; use --once for non-interactive mode");
error!("stdout is not a terminal; use --once for non-interactive mode");
std::process::exit(1);
}
@@ -358,12 +366,12 @@ fn main() -> io::Result<()> {
let dbus_server = if args.dbus {
match dbus::DbusServer::spawn() {
Ok(s) => {
eprintln!("redbear-power: dbus: org.redbear.Power registered on session bus");
info!("dbus: org.redbear.Power registered on session bus");
Some(s)
}
Err(e) => {
eprintln!(
"redbear-power: dbus: session bus unavailable ({e}); running without D-Bus"
warn!(
"dbus: session bus unavailable ({e}); running without D-Bus"
);
None
}
@@ -101,7 +101,7 @@ impl SessionState {
let path = Self::path();
match std::fs::read_to_string(&path) {
Ok(content) => toml::from_str::<SessionState>(&content).unwrap_or_else(|e| {
eprintln!("redbear-power: session {path:?} parse error: {e}; using defaults");
warn!("session {path:?} parse error: {e}; using defaults");
Self::default()
}),
Err(_) => Self::default(),
@@ -117,17 +117,17 @@ impl SessionState {
pub fn save(&self) {
let path = Self::path();
let Some(parent) = path.parent() else {
eprintln!("redbear-power: session path has no parent; cannot save");
warn!("session path has no parent; cannot save");
return;
};
if let Err(e) = std::fs::create_dir_all(parent) {
eprintln!("redbear-power: session dir {parent:?} create failed: {e}");
warn!("session dir {parent:?} create failed: {e}");
return;
}
let serialized = match toml::to_string(self) {
Ok(s) => s,
Err(e) => {
eprintln!("redbear-power: session serialize failed: {e}");
warn!("session serialize failed: {e}");
return;
}
};
@@ -137,11 +137,11 @@ impl SessionState {
let mut tmp = path.clone();
tmp.as_mut_os_string().push(".tmp");
if let Err(e) = std::fs::write(&tmp, serialized) {
eprintln!("redbear-power: session tmp write {tmp:?} failed: {e}");
warn!("session tmp write {tmp:?} failed: {e}");
return;
}
if let Err(e) = std::fs::rename(&tmp, &path) {
eprintln!("redbear-power: session rename to {path:?} failed: {e}");
warn!("session rename to {path:?} failed: {e}");
}
}
}
@@ -11,4 +11,6 @@ name = "redbear-session-launch"
path = "src/main.rs"
[dependencies]
log = { version = "0.4", features = ["std"] }
env_logger = "0.11"
libc = "0.2"
@@ -1,4 +1,5 @@
use std::{
use log::{error, info, warn};
collections::{BTreeMap, HashMap},
env,
ffi::CString,
@@ -399,9 +400,10 @@ fn run() -> Result<(), String> {
}
fn main() {
let _ = env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info")).try_init();
if let Err(err) = run() {
eprintln!("redbear-session-launch: {err}");
eprintln!("{}", usage());
log::error!("redbear-session-launch: {err}"));
log::error!("{}", usage()));
process::exit(1);
}
}
@@ -15,6 +15,8 @@ zbus = { version = "5", default-features = false, features = ["tokio"] }
tokio = { version = "1", default-features = false, features = ["rt", "rt-multi-thread", "macros", "net", "time", "sync"] }
serde = { version = "1", features = ["derive"] }
serde_json = "1"
log = "0.4"
env_logger = "0.11"
libc = "0.2"
libredox = { path = "../../../../../local/sources/libredox" }
redox-syscall = { path = "../../../../../local/sources/syscall", package = "redox_syscall" }
@@ -79,9 +79,9 @@ async fn watch_shutdown_edge(connection: Connection, runtime: SharedRuntime) {
)
.await
{
eprintln!("redbear-sessiond: PrepareForShutdown(before=true) emit failed: {err}");
log::error!("redbear-sessiond: PrepareForShutdown(before=true) emit failed: {err}");
}
eprintln!("redbear-sessiond: PrepareForShutdown(before=true) emitted");
log::info!("redbear-sessiond: PrepareForShutdown(before=true) emitted");
}
async fn watch_sleep_edge(connection: Connection, runtime: SharedRuntime) {
@@ -99,9 +99,9 @@ async fn watch_sleep_edge(connection: Connection, runtime: SharedRuntime) {
)
.await
{
eprintln!("redbear-sessiond: PrepareForSleep(before=true) emit failed: {err}");
log::error!("redbear-sessiond: PrepareForSleep(before=true) emit failed: {err}");
}
eprintln!("redbear-sessiond: PrepareForSleep(before=true) emitted");
log::info!("redbear-sessiond: PrepareForSleep(before=true) emitted");
let _ = tokio::task::spawn_blocking(wait_for_sleep_edge).await;
if let Ok(mut state) = runtime.write() {
@@ -117,9 +117,9 @@ async fn watch_sleep_edge(connection: Connection, runtime: SharedRuntime) {
)
.await
{
eprintln!("redbear-sessiond: PrepareForSleep(before=false) emit failed: {err}");
log::error!("redbear-sessiond: PrepareForSleep(before=false) emit failed: {err}");
}
eprintln!("redbear-sessiond: PrepareForSleep(before=false) emitted (resumed)");
log::info!("redbear-sessiond: PrepareForSleep(before=false) emitted (resumed)");
}
pub async fn watch_and_emit(connection: Connection, runtime: SharedRuntime) {
@@ -76,7 +76,7 @@ fn apply_message(
state,
} => {
let Ok(mut runtime) = runtime.write() else {
eprintln!("redbear-sessiond: runtime state is poisoned");
log::error!("redbear-sessiond: runtime state is poisoned");
return;
};
runtime.username = username;
@@ -88,7 +88,7 @@ fn apply_message(
}
ControlMessage::ResetSession { vt } => {
let Ok(mut runtime) = runtime.write() else {
eprintln!("redbear-sessiond: runtime state is poisoned");
log::error!("redbear-sessiond: runtime state is poisoned");
return;
};
runtime.username = String::from("root");
@@ -99,44 +99,44 @@ fn apply_message(
runtime.active = true;
}
ControlMessage::Shutdown => {
eprintln!("redbear-sessiond: shutdown requested via control socket");
log::info!("redbear-sessiond: shutdown requested via control socket");
let _ = shutdown_tx.send(true);
}
ControlMessage::SetInhibitDelay { usec } => {
let Ok(runtime) = runtime.read() else {
eprintln!("redbear-sessiond: runtime state is poisoned");
log::error!("redbear-sessiond: runtime state is poisoned");
return;
};
runtime.inhibit_delay_max_us.store(usec, Ordering::Relaxed);
eprintln!("redbear-sessiond: InhibitDelayMaxUSec set to {usec}");
log::info!("redbear-sessiond: InhibitDelayMaxUSec set to {usec}");
}
ControlMessage::SetLidSwitch { action } => {
let Ok(runtime) = runtime.read() else {
eprintln!("redbear-sessiond: runtime state is poisoned");
log::error!("redbear-sessiond: runtime state is poisoned");
return;
};
if let Ok(mut guard) = runtime.handle_lid_switch.write() {
*guard = action.clone();
eprintln!("redbear-sessiond: HandleLidSwitch set to '{action}'");
log::info!("redbear-sessiond: HandleLidSwitch set to '{action}'");
}
}
ControlMessage::SetPowerKey { action } => {
let Ok(runtime) = runtime.read() else {
eprintln!("redbear-sessiond: runtime state is poisoned");
log::error!("redbear-sessiond: runtime state is poisoned");
return;
};
if let Ok(mut guard) = runtime.handle_power_key.write() {
*guard = action.clone();
eprintln!("redbear-sessiond: HandlePowerKey set to '{action}'");
log::info!("redbear-sessiond: HandlePowerKey set to '{action}'");
}
}
ControlMessage::SetLastActivity { timestamp_us } => {
let Ok(runtime) = runtime.read() else {
eprintln!("redbear-sessiond: runtime state is poisoned");
log::error!("redbear-sessiond: runtime state is poisoned");
return;
};
runtime.last_activity_us.store(timestamp_us, Ordering::Relaxed);
eprintln!("redbear-sessiond: last activity timestamp set to {timestamp_us}");
log::info!("redbear-sessiond: last activity timestamp set to {timestamp_us}");
}
}
}
@@ -149,7 +149,7 @@ pub fn start_control_socket(
std::thread::spawn(move || {
if Path::new(CONTROL_SOCKET_PATH).exists() {
if let Err(err) = fs::remove_file(CONTROL_SOCKET_PATH) {
eprintln!("redbear-sessiond: failed to remove stale control socket: {err}");
log::error!("redbear-sessiond: failed to remove stale control socket: {err}");
return;
}
}
@@ -157,13 +157,13 @@ pub fn start_control_socket(
let listener = match UnixListener::bind(CONTROL_SOCKET_PATH) {
Ok(listener) => listener,
Err(err) => {
eprintln!("redbear-sessiond: failed to bind control socket: {err}");
log::error!("redbear-sessiond: failed to bind control socket: {err}");
return;
}
};
if let Err(err) = fs::set_permissions(CONTROL_SOCKET_PATH, fs::Permissions::from_mode(0o600)) {
eprintln!("redbear-sessiond: failed to chmod control socket: {err}");
log::error!("redbear-sessiond: failed to chmod control socket: {err}");
}
let shutdown_ref = Arc::clone(&shutdown_tx);
@@ -178,7 +178,7 @@ pub fn start_control_socket(
}
match serde_json::from_str::<ControlMessage>(line.trim()) {
Ok(message) => apply_message(&runtime, &shutdown_ref, message),
Err(err) => eprintln!("redbear-sessiond: invalid control message: {err}"),
Err(err) => log::warn!("redbear-sessiond: invalid control message: {err}"),
}
}
});
@@ -96,7 +96,7 @@ fn dbus_socket_candidates() -> Vec<String> {
async fn wait_for_dbus_socket() {
let candidates = dbus_socket_candidates();
eprintln!(
log::info!(
"redbear-sessiond: probing {} D-Bus socket candidate(s): {:?}",
candidates.len(),
candidates
@@ -108,20 +108,20 @@ async fn wait_for_dbus_socket() {
for tick in 0..30 {
for candidate in &candidates {
if tokio::net::UnixStream::connect(candidate).await.is_ok() {
eprintln!(
log::info!(
"redbear-sessiond: D-Bus socket reachable at {candidate} after {tick}s"
);
return;
}
}
if tick == 0 {
eprintln!("redbear-sessiond: still waiting for D-Bus socket (up to 30s)");
log::info!("redbear-sessiond: still waiting for D-Bus socket (up to 30s)");
} else if tick % 5 == 0 {
eprintln!("redbear-sessiond: still waiting for D-Bus socket ({tick}s elapsed)");
log::info!("redbear-sessiond: still waiting for D-Bus socket ({tick}s elapsed)");
}
tokio::time::sleep(Duration::from_secs(1)).await;
}
eprintln!(
log::info!(
"redbear-sessiond: timed out waiting for D-Bus socket, last tried: {:?}",
candidates
);
@@ -199,7 +199,7 @@ async fn run_daemon() -> Result<(), Box<dyn Error>> {
.await
{
Ok(connection) => {
eprintln!("redbear-sessiond: registered {BUS_NAME} on the system bus at {bus_addr}");
log::info!("redbear-sessiond: registered {BUS_NAME} on the system bus at {bus_addr}");
manager_ref.set_connection(connection.clone());
session.set_connection(connection.clone());
control::start_control_socket(runtime.clone(), shutdown_tx.clone());
@@ -214,7 +214,7 @@ async fn run_daemon() -> Result<(), Box<dyn Error>> {
match zbus::zvariant::OwnedObjectPath::try_from(SEAT_PATH.to_owned()) {
Ok(p) => p,
Err(_) => {
eprintln!(
log::info!(
"redbear-sessiond: SEAT_PATH constant is not a valid D-Bus path; skipping SeatRemoved"
);
drop(connection);
@@ -233,7 +233,7 @@ async fn run_daemon() -> Result<(), Box<dyn Error>> {
// (but harmless) boot noise; only report if it keeps failing.
if attempt < 3 {
if attempt >= 2 {
eprintln!(
log::info!(
"redbear-sessiond: attempt {attempt}/3 failed on {bus_addr} ({err}), retrying in 1s..."
);
}
@@ -315,19 +315,19 @@ fn main() {
let runtime = match RuntimeBuilder::new_multi_thread().enable_all().build() {
Ok(runtime) => runtime,
Err(err) => {
eprintln!("redbear-sessiond: failed to create tokio runtime: {err}");
log::error!("redbear-sessiond: failed to create tokio runtime: {err}");
process::exit(1);
}
};
if let Err(err) = runtime.block_on(run_daemon()) {
eprintln!("redbear-sessiond: fatal error: {err}");
log::error!("redbear-sessiond: fatal error: {err}");
process::exit(1);
}
}
Err(err) => {
eprintln!("redbear-sessiond: {err}");
eprintln!("{}", usage());
log::info!("redbear-sessiond: {err}");
log::info!("{}", usage());
process::exit(1);
}
}
@@ -116,7 +116,7 @@ impl LoginManager {
}
}
if !removed_fds.is_empty() {
eprintln!(
log::info!(
"redbear-sessiond: reaped {} inhibitor(s) for vanished bus name '{vanished_sender}'",
removed_fds.len()
);
@@ -140,7 +140,7 @@ impl LoginManager {
removed = runtime.inhibitors.len() < before;
}
if removed {
eprintln!(
log::info!(
"redbear-sessiond: reaped inhibitor {inhibitor_id} (caller FD closed)"
);
}
@@ -154,7 +154,7 @@ impl LoginManager {
let conn = match self.get_connection() {
Some(c) => c,
None => {
eprintln!(
log::info!(
"redbear-sessiond: inhibitor reaper has no connection; inhibitor lifecycle reaping disabled"
);
return;
@@ -164,7 +164,7 @@ impl LoginManager {
let proxy = match DBusProxy::new(&conn).await {
Ok(p) => p,
Err(err) => {
eprintln!(
log::info!(
"redbear-sessiond: inhibitor reaper failed to create DBus proxy: {err}"
);
return;
@@ -199,7 +199,7 @@ impl LoginManager {
self.reap_inhibitors_for_sender(sender);
}
Err(err) => {
eprintln!(
log::info!(
"redbear-sessiond: inhibitor reaper name_has_owner('{sender}') failed: {err}"
);
}
@@ -275,7 +275,7 @@ impl LoginManager {
});
}
eprintln!(
log::info!(
"redbear-sessiond: Inhibit(what={what}, who={who}, mode={mode}) granted as inhibitor #{inhibitor_id}"
);
@@ -294,7 +294,7 @@ impl LoginManager {
)
.await
{
eprintln!(
log::info!(
"redbear-sessiond: PrepareForShutdown(before={before}) emit failed: {err}"
);
}
@@ -313,7 +313,7 @@ impl LoginManager {
)
.await
{
eprintln!(
log::info!(
"redbear-sessiond: PrepareForSleep(before={before}) emit failed: {err}"
);
}
@@ -332,11 +332,11 @@ impl LoginManager {
)
.await
{
eprintln!(
log::info!(
"redbear-sessiond: SeatNew({id}, {seat_path}) emit failed: {err}"
);
} else {
eprintln!("redbear-sessiond: SeatNew emitted for {id} -> {seat_path}");
log::info!("redbear-sessiond: SeatNew emitted for {id} -> {seat_path}");
}
}
}
@@ -353,11 +353,11 @@ impl LoginManager {
)
.await
{
eprintln!(
log::info!(
"redbear-sessiond: SeatRemoved({id}, {seat_path}) emit failed: {err}"
);
} else {
eprintln!("redbear-sessiond: SeatRemoved emitted for {id} -> {seat_path}");
log::info!("redbear-sessiond: SeatRemoved emitted for {id} -> {seat_path}");
}
}
}
@@ -487,7 +487,7 @@ impl LoginManager {
}
async fn power_off(&self, _interactive: bool) -> fdo::Result<()> {
eprintln!("redbear-sessiond: PowerOff requested");
log::info!("redbear-sessiond: PowerOff requested");
if let Ok(mut runtime) = self.runtime.write() {
runtime.preparing_for_shutdown = true;
}
@@ -500,7 +500,7 @@ impl LoginManager {
if let Ok(mut runtime) = self.runtime.write() {
runtime.preparing_for_shutdown = false;
}
eprintln!("redbear-sessiond: PowerOff kstop write failed: {e}");
log::error!("redbear-sessiond: PowerOff kstop write failed: {e}");
return Err(fdo::Error::Failed(format!(
"cannot write to /scheme/sys/kstop for shutdown: {e}"
)));
@@ -510,7 +510,7 @@ impl LoginManager {
if let Ok(mut runtime) = self.runtime.write() {
runtime.preparing_for_shutdown = false;
}
eprintln!("redbear-sessiond: PowerOff kstop open failed: {e}");
log::error!("redbear-sessiond: PowerOff kstop open failed: {e}");
return Err(fdo::Error::Failed(format!(
"cannot open /scheme/sys/kstop for shutdown: {e}"
)));
@@ -522,7 +522,7 @@ impl LoginManager {
}
async fn reboot(&self, _interactive: bool) -> fdo::Result<()> {
eprintln!("redbear-sessiond: Reboot requested");
log::info!("redbear-sessiond: Reboot requested");
if let Ok(mut runtime) = self.runtime.write() {
runtime.preparing_for_shutdown = true;
}
@@ -535,7 +535,7 @@ impl LoginManager {
if let Ok(mut runtime) = self.runtime.write() {
runtime.preparing_for_shutdown = false;
}
eprintln!("redbear-sessiond: Reboot kstop write failed: {e}");
log::error!("redbear-sessiond: Reboot kstop write failed: {e}");
return Err(fdo::Error::Failed(format!(
"cannot write to /scheme/sys/kstop for reboot: {e}"
)));
@@ -545,7 +545,7 @@ impl LoginManager {
if let Ok(mut runtime) = self.runtime.write() {
runtime.preparing_for_shutdown = false;
}
eprintln!("redbear-sessiond: Reboot kstop open failed: {e}");
log::error!("redbear-sessiond: Reboot kstop open failed: {e}");
return Err(fdo::Error::Failed(format!(
"cannot open /scheme/sys/kstop for reboot: {e}"
)));
@@ -557,7 +557,7 @@ impl LoginManager {
}
async fn suspend(&self, _interactive: bool) -> fdo::Result<()> {
eprintln!("redbear-sessiond: Suspend requested — sending to kernel kstop");
log::info!("redbear-sessiond: Suspend requested — sending to kernel kstop");
if let Ok(mut runtime) = self.runtime.write() {
runtime.preparing_for_sleep = true;
}
@@ -570,7 +570,7 @@ impl LoginManager {
if let Ok(mut runtime) = self.runtime.write() {
runtime.preparing_for_sleep = false;
}
eprintln!("redbear-sessiond: Suspend kstop write failed: {e}");
log::error!("redbear-sessiond: Suspend kstop write failed: {e}");
return Err(fdo::Error::Failed(format!(
"cannot write to /scheme/sys/kstop for suspend: {e}"
)));
@@ -580,7 +580,7 @@ impl LoginManager {
if let Ok(mut runtime) = self.runtime.write() {
runtime.preparing_for_sleep = false;
}
eprintln!("redbear-sessiond: Suspend kstop open failed: {e}");
log::error!("redbear-sessiond: Suspend kstop open failed: {e}");
return Err(fdo::Error::Failed(format!(
"cannot open /scheme/sys/kstop for suspend: {e}"
)));
@@ -649,7 +649,7 @@ impl LoginManager {
}
runtime.active = true;
eprintln!("redbear-sessiond: ActivateSession({session_id})");
log::info!("redbear-sessiond: ActivateSession({session_id})");
Ok(())
}
@@ -663,7 +663,7 @@ impl LoginManager {
}
runtime.active = true;
eprintln!("redbear-sessiond: ActivateSessionOnSeat({session_id}, {seat_id})");
log::info!("redbear-sessiond: ActivateSessionOnSeat({session_id}, {seat_id})");
Ok(())
}
@@ -674,7 +674,7 @@ impl LoginManager {
}
runtime.locked_hint = true;
eprintln!("redbear-sessiond: LockSession({session_id})");
log::info!("redbear-sessiond: LockSession({session_id})");
Ok(())
}
@@ -685,7 +685,7 @@ impl LoginManager {
}
runtime.locked_hint = false;
eprintln!("redbear-sessiond: UnlockSession({session_id})");
log::info!("redbear-sessiond: UnlockSession({session_id})");
Ok(())
}
@@ -696,7 +696,7 @@ impl LoginManager {
runtime.session_id.clone()
};
eprintln!("redbear-sessiond: LockSessions() -> {session_id}");
log::info!("redbear-sessiond: LockSessions() -> {session_id}");
Ok(())
}
@@ -707,7 +707,7 @@ impl LoginManager {
runtime.session_id.clone()
};
eprintln!("redbear-sessiond: UnlockSessions() -> {session_id}");
log::info!("redbear-sessiond: UnlockSessions() -> {session_id}");
Ok(())
}
@@ -719,7 +719,7 @@ impl LoginManager {
runtime.state = String::from("closing");
runtime.active = false;
eprintln!("redbear-sessiond: TerminateSession({session_id})");
log::info!("redbear-sessiond: TerminateSession({session_id})");
Ok(())
}
@@ -731,7 +731,7 @@ impl LoginManager {
runtime.state = String::from("closing");
runtime.active = false;
eprintln!("redbear-sessiond: TerminateUser({uid})");
log::info!("redbear-sessiond: TerminateUser({uid})");
Ok(())
}
@@ -742,7 +742,7 @@ impl LoginManager {
}
let leader = runtime.leader;
eprintln!(
log::info!(
"redbear-sessiond: KillSession({session_id}, who={who}, signal={signal_number}) — sending to PID {leader}"
);
drop(runtime);
@@ -769,7 +769,7 @@ impl LoginManager {
}
let leader = runtime.leader;
eprintln!(
log::info!(
"redbear-sessiond: KillUser({uid}, signal={signal_number}) — sending to PID {leader}"
);
drop(runtime);
@@ -75,7 +75,7 @@ impl LoginSeat {
runtime.vt = vt;
runtime.active = true;
eprintln!("redbear-sessiond: SwitchTo requested for seat {} -> vt {vt}", self.id);
log::info!("redbear-sessiond: SwitchTo requested for seat {} -> vt {vt}", self.id);
Ok(())
}
@@ -95,7 +95,7 @@ impl LoginSession {
#[interface(name = "org.freedesktop.login1.Session")]
impl LoginSession {
fn activate(&self) -> fdo::Result<()> {
eprintln!("redbear-sessiond: Activate requested for session {}", self.runtime()?.session_id);
log::info!("redbear-sessiond: Activate requested for session {}", self.runtime()?.session_id);
Ok(())
}
@@ -109,7 +109,7 @@ impl LoginSession {
)));
}
*controlled = true;
eprintln!(
log::info!(
"redbear-sessiond: TakeControl requested for session {} (force={force})",
runtime.session_id
);
@@ -120,7 +120,7 @@ impl LoginSession {
let mut controlled = self.control_state()?;
*controlled = false;
self.taken_devices()?.clear();
eprintln!("redbear-sessiond: ReleaseControl requested for session {}", self.runtime()?.session_id);
log::info!("redbear-sessiond: ReleaseControl requested for session {}", self.runtime()?.session_id);
Ok(())
}
@@ -151,7 +151,7 @@ impl LoginSession {
taken_devices.insert((major, minor));
let owned_fd: StdOwnedFd = file.into();
eprintln!(
log::info!(
"redbear-sessiond: TakeDevice granted for session {} -> ({major}, {minor}) at {}",
runtime.session_id, path
);
@@ -193,12 +193,12 @@ impl LoginSession {
&(major, minor, device_kind.as_str()),
)
.await;
eprintln!(
log::info!(
"redbear-sessiond: PauseDevice signal emitted for ({major}, {minor}, {device_kind}) on TakeDevice({path_for_log})"
);
}
None => {
eprintln!(
log::info!(
"redbear-sessiond: skipping PauseDevice emission on TakeDevice — no D-Bus connection"
);
}
@@ -218,7 +218,7 @@ impl LoginSession {
runtime.session_id
)));
}
eprintln!(
log::info!(
"redbear-sessiond: ReleaseDevice requested for session {} -> ({major}, {minor})",
runtime.session_id
);
@@ -240,14 +240,14 @@ impl LoginSession {
Ok((path, file))
}) {
Ok((resume_path, resume_file)) => {
eprintln!(
log::info!(
"redbear-sessiond: re-opened ({major}, {minor}) at {resume_path} for ResumeDevice signal"
);
let owned: StdOwnedFd = resume_file.into();
Some(owned)
}
Err(err) => {
eprintln!(
log::info!(
"redbear-sessiond: could not re-open ({major}, {minor}) for ResumeDevice signal: {err}"
);
None
@@ -273,16 +273,16 @@ impl LoginSession {
)
.await;
match result {
Ok(()) => eprintln!(
Ok(()) => log::info!(
"redbear-sessiond: ResumeDevice signal emitted for ({major}, {minor}) on ReleaseDevice"
),
Err(err) => eprintln!(
Err(err) => log::info!(
"redbear-sessiond: failed to emit ResumeDevice signal for ({major}, {minor}): {err}"
),
}
}
None => {
eprintln!(
log::info!(
"redbear-sessiond: skipping ResumeDevice emission on ReleaseDevice — no D-Bus connection"
);
}
@@ -294,7 +294,7 @@ impl LoginSession {
}
fn pause_device_complete(&self, major: u32, minor: u32) -> fdo::Result<()> {
eprintln!(
log::info!(
"redbear-sessiond: PauseDeviceComplete received for session {} -> ({major}, {minor})",
self.runtime()?.session_id
);
@@ -309,7 +309,7 @@ impl LoginSession {
if let Ok(mut guard) = self.runtime.write() {
guard.idle_hint = idle;
}
eprintln!("redbear-sessiond: SetIdleHint({idle}) for session {session_id}");
log::info!("redbear-sessiond: SetIdleHint({idle}) for session {session_id}");
Ok(())
}
@@ -321,7 +321,7 @@ impl LoginSession {
if let Ok(mut guard) = self.runtime.write() {
guard.locked_hint = locked;
}
eprintln!("redbear-sessiond: SetLockedHint({locked}) for session {session_id}");
log::info!("redbear-sessiond: SetLockedHint({locked}) for session {session_id}");
Ok(())
}
@@ -333,7 +333,7 @@ impl LoginSession {
if let Ok(mut guard) = self.runtime.write() {
guard.session_type = session_type.to_owned();
}
eprintln!("redbear-sessiond: SetType({session_type}) for session {session_id}");
log::info!("redbear-sessiond: SetType({session_type}) for session {session_id}");
Ok(())
}
@@ -343,14 +343,14 @@ impl LoginSession {
drop(runtime);
self.runtime_write()?.state = String::from("closing");
eprintln!("redbear-sessiond: Terminate requested for session {session_id}");
log::info!("redbear-sessiond: Terminate requested for session {session_id}");
Ok(())
}
fn kill(&self, who: &str, signal_number: i32) -> fdo::Result<()> {
let leader = self.leader();
let sig = signal_number as u32;
eprintln!(
log::info!(
"redbear-sessiond: Kill session {} (who={who}, signal={signal_number}) → PID {leader}",
self.runtime()?.session_id
);
@@ -478,7 +478,7 @@ impl LoginSession {
minor: u32,
kind: String,
) -> zbus::Result<()> {
eprintln!("redbear-sessiond: PauseDevice signal emitted ({major}, {minor}, {kind})");
log::info!("redbear-sessiond: PauseDevice signal emitted ({major}, {minor}, {kind})");
Ok(())
}
@@ -489,19 +489,19 @@ impl LoginSession {
minor: u32,
fd: Fd<'_>,
) -> zbus::Result<()> {
eprintln!("redbear-sessiond: ResumeDevice signal emitted ({major}, {minor})");
log::info!("redbear-sessiond: ResumeDevice signal emitted ({major}, {minor})");
Ok(())
}
#[zbus(signal, name = "Lock")]
async fn lock(signal_emitter: &SignalEmitter<'_>) -> zbus::Result<()> {
eprintln!("redbear-sessiond: Lock signal emitted");
log::info!("redbear-sessiond: Lock signal emitted");
Ok(())
}
#[zbus(signal, name = "Unlock")]
async fn unlock(signal_emitter: &SignalEmitter<'_>) -> zbus::Result<()> {
eprintln!("redbear-sessiond: Unlock signal emitted");
log::info!("redbear-sessiond: Unlock signal emitted");
Ok(())
}
}
@@ -11,5 +11,7 @@ name = "redbear-statusnotifierwatcher"
path = "src/main.rs"
[dependencies]
log = { version = "0.4", features = ["std"] }
env_logger = "0.11"
zbus = { version = "5", default-features = false, features = ["tokio"] }
tokio = { version = "1", default-features = false, features = ["rt", "rt-multi-thread", "macros", "net", "time", "sync"] }
@@ -4,6 +4,7 @@ use std::pin::pin;
use std::sync::{Arc, Mutex};
use zbus::{
use log::{error, info, warn};
connection::Builder as ConnectionBuilder, export::futures_core::Stream, fdo, interface,
message::Header, object_server::SignalEmitter, proxy, zvariant::ObjectPath,
};
@@ -368,7 +369,7 @@ impl StatusNotifierWatcher {
item: &str,
) -> fdo::Result<()> {
if let Err(msg) = validate_input(item) {
eprintln!("statusnotifierwatcher: rejected item registration: {msg}");
log::error!("statusnotifierwatcher: rejected item registration: {msg}"));
return Err(fdo::Error::InvalidArgs(msg));
}
let owner = hdr
@@ -380,7 +381,7 @@ impl StatusNotifierWatcher {
let is_new = self.register_item(&owner, item);
if is_new {
eprintln!("statusnotifierwatcher: item registered: {item} (owner: {owner})");
log::info!("statusnotifierwatcher: item registered: {item} (owner: {owner})"));
let _ = Self::status_notifier_item_registered(&signal_emitter, item).await;
}
Ok(())
@@ -405,7 +406,7 @@ impl StatusNotifierWatcher {
let was_present = self.unregister_item(&owner, item);
if was_present {
eprintln!("statusnotifierwatcher: item unregistered: {item} (owner: {owner})");
log::error!("statusnotifierwatcher: item unregistered: {item} (owner: {owner})"));
let _ = Self::status_notifier_item_unregistered(&signal_emitter, item).await;
}
Ok(())
@@ -419,7 +420,7 @@ impl StatusNotifierWatcher {
host: &str,
) -> fdo::Result<()> {
if let Err(msg) = validate_input(host) {
eprintln!("statusnotifierwatcher: rejected host registration: {msg}");
log::error!("statusnotifierwatcher: rejected host registration: {msg}"));
return Err(fdo::Error::InvalidArgs(msg));
}
let owner = hdr
@@ -431,7 +432,7 @@ impl StatusNotifierWatcher {
let is_new = self.register_host(&owner, host);
if is_new {
eprintln!("statusnotifierwatcher: host registered: {host} (owner: {owner})");
log::info!("statusnotifierwatcher: host registered: {host} (owner: {owner})"));
let _ = Self::status_notifier_host_registered(&signal_emitter).await;
}
Ok(())
@@ -456,7 +457,7 @@ impl StatusNotifierWatcher {
let was_present = self.unregister_host(&owner, host);
if was_present {
eprintln!("statusnotifierwatcher: host unregistered: {host} (owner: {owner})");
log::error!("statusnotifierwatcher: host unregistered: {host} (owner: {owner})"));
}
Ok(())
}
@@ -534,32 +535,32 @@ async fn run_name_owner_changed_listener(
let proxy = match DBusDaemonProxy::new(&connection).await {
Ok(p) => p,
Err(e) => {
eprintln!("statusnotifierwatcher: failed to create DBus proxy: {e}");
log::error!("statusnotifierwatcher: failed to create DBus proxy: {e}"));
return;
}
};
let signals = match proxy.receive_name_owner_changed().await {
Ok(s) => s,
Err(e) => {
eprintln!("statusnotifierwatcher: failed to subscribe to NameOwnerChanged: {e}");
log::error!("statusnotifierwatcher: failed to subscribe to NameOwnerChanged: {e}"));
return;
}
};
let object_path: ObjectPath<'_> = match OBJECT_PATH.try_into() {
Ok(path) => path,
Err(e) => {
eprintln!("statusnotifierwatcher: invalid object path {OBJECT_PATH}: {e}");
log::error!("statusnotifierwatcher: invalid object path {OBJECT_PATH}: {e}"));
return;
}
};
let signal_emitter = match SignalEmitter::new(&connection, object_path) {
Ok(emitter) => emitter,
Err(e) => {
eprintln!("statusnotifierwatcher: failed to create signal emitter: {e}");
log::error!("statusnotifierwatcher: failed to create signal emitter: {e}"));
return;
}
};
eprintln!("statusnotifierwatcher: NameOwnerChanged listener active");
log::info!("statusnotifierwatcher: NameOwnerChanged listener active"));
// Consume the signal stream without pulling in futures-lite as a direct
// dependency: zbus re-exports futures_core::Stream, and std provides
// poll_fn + pin! for manual polling.
@@ -577,7 +578,7 @@ async fn run_name_owner_changed_listener(
if !purged.is_empty() {
emit_purge_unregistered_signals(&signal_emitter, &purged).await;
let removed = purged.items.len() + purged.hosts.len();
eprintln!(
log::error!();
"statusnotifierwatcher: purged {removed} entries for vanished owner {}",
args.old_owner
);
@@ -641,14 +642,14 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
.build()
.await?;
eprintln!("statusnotifierwatcher: {BUS_NAME} registered on session bus");
log::info!("statusnotifierwatcher: {BUS_NAME} registered on session bus"));
// Spawn NameOwnerChanged listener that prunes entries on owner loss.
tokio::spawn(run_name_owner_changed_listener(connection.clone(), watcher));
// Wait for shutdown signal
let _ = shutdown_rx.changed().await;
eprintln!("statusnotifierwatcher: shutdown signal received, exiting cleanly");
log::info!("statusnotifierwatcher: shutdown signal received, exiting cleanly"));
drop(connection);
Ok(())
}
@@ -15,6 +15,8 @@ name = "redbear-traceroute"
path = "src/main.rs"
[dependencies]
log = { version = "0.4", features = ["std"] }
env_logger = "0.11"
anyhow = "1"
[target.'cfg(target_os = "redox")'.dependencies]
@@ -1,5 +1,6 @@
use anyhow::{bail, Context, Result};
use redbear_traceroute::{
use log::{error, info, warn};
destination_port, format_reply_suffix, probe, resolve_destination, ProbeStatus,
};
use std::env;
@@ -143,8 +144,9 @@ fn run() -> Result<()> {
}
fn main() {
let _ = env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info")).try_init();
if let Err(err) = run() {
eprintln!("redbear-traceroute: {err}");
log::error!("redbear-traceroute: {err}"));
std::process::exit(1);
}
}
@@ -11,6 +11,8 @@ name = "redbear-udisks"
path = "src/main.rs"
[dependencies]
log = { version = "0.4", features = ["std"] }
env_logger = "0.11"
zbus = { version = "5", default-features = false, features = ["tokio"] }
tokio = { version = "1", default-features = false, features = ["rt", "rt-multi-thread", "macros", "net", "time", "sync"] }
serde = { version = "1", features = ["derive"] }
@@ -1,6 +1,7 @@
use std::{collections::{BTreeMap, HashMap}, sync::Arc};
use zbus::{
use log::{error, info};
interface,
object_server::SignalEmitter,
zvariant::{OwnedObjectPath, Value},
@@ -227,7 +228,7 @@ impl BlockDeviceInterface {
let state = self.block.mount_state.lock().map(|g| g.clone()).unwrap_or_default();
match crate::mount::mount(&self.block.device_path, &mountpoint, &state) {
Ok(mounted_at) => {
eprintln!(
log::error!();
"redbear-udisks: mounted {} at {mounted_at} (fs={})",
self.block.device_path,
kind.as_str()
@@ -250,7 +251,7 @@ impl BlockDeviceInterface {
let state = self.block.mount_state.lock().map(|g| g.clone()).unwrap_or_default();
crate::mount::unmount(&state)
.map_err(|err| zbus::fdo::Error::Failed(format!("unmount failed: {err}")))?;
eprintln!(
log::error!();
"redbear-udisks: unmounted {}",
self.block.device_path
);
@@ -3,6 +3,7 @@ mod inventory;
mod mount;
use std::{
use log::{error, info, warn};
env,
error::Error,
process,
@@ -44,7 +45,7 @@ async fn wait_for_dbus_socket() {
}
tokio::time::sleep(Duration::from_secs(1)).await;
}
eprintln!("redbear-udisks: timed out waiting for D-Bus socket at {socket_path}");
log::error!("redbear-udisks: timed out waiting for D-Bus socket at {socket_path}"));
}
fn parse_args() -> Result<Command, String> {
@@ -123,19 +124,19 @@ async fn run_daemon() -> Result<(), Box<dyn Error>> {
match builder.build().await {
Ok(connection) => {
eprintln!(
log::error!();
"redbear-udisks: registered {BUS_NAME} on the system bus ({} drives, {} blocks)",
inventory.drives().len(),
inventory.blocks().len(),
);
let _ = shutdown_rx.changed().await;
eprintln!("redbear-udisks: shutdown signal received, exiting cleanly");
log::info!("redbear-udisks: shutdown signal received, exiting cleanly"));
drop(connection);
return Ok(());
}
Err(err) => {
if attempt < 3 {
eprintln!(
log::error!();
"redbear-udisks: attempt {attempt}/3 failed ({err}), retrying in 1s..."
);
tokio::time::sleep(Duration::from_secs(1)).await;
@@ -152,27 +153,28 @@ async fn run_daemon() -> Result<(), Box<dyn Error>> {
}
fn main() {
let _ = env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info")).try_init();
match parse_args() {
Ok(Command::Help) => {
println!("{}", usage());
log::info!("{}", usage()));
}
Ok(Command::Run) => {
let runtime = match RuntimeBuilder::new_multi_thread().enable_all().build() {
Ok(runtime) => runtime,
Err(err) => {
eprintln!("redbear-udisks: failed to create tokio runtime: {err}");
log::error!("redbear-udisks: failed to create tokio runtime: {err}"));
process::exit(1);
}
};
if let Err(err) = runtime.block_on(run_daemon()) {
eprintln!("redbear-udisks: fatal error: {err}");
log::error!("redbear-udisks: fatal error: {err}"));
process::exit(1);
}
}
Err(err) => {
eprintln!("redbear-udisks: {err}");
eprintln!("{}", usage());
log::error!("redbear-udisks: {err}"));
log::error!("{}", usage()));
process::exit(1);
}
}
@@ -11,6 +11,8 @@ name = "redbear-upower"
path = "src/main.rs"
[dependencies]
log = { version = "0.4", features = ["std"] }
env_logger = "0.11"
zbus = { version = "5", default-features = false, features = ["tokio"] }
# Minimal tokio feature set. Avoids the unstable tokio::signal::unix
# backend on Redox (the `signal` feature pulls in libc::kill and a
@@ -1,4 +1,5 @@
use std::{
use log::{error, info, warn};
env,
error::Error,
fs,
@@ -136,7 +137,7 @@ async fn wait_for_dbus_socket() {
}
tokio::time::sleep(Duration::from_secs(1)).await;
}
eprintln!("redbear-upower: timed out waiting for D-Bus socket at {socket_path}");
log::error!("redbear-upower: timed out waiting for D-Bus socket at {socket_path}"));
}
fn parse_object_path(path: &str) -> Result<OwnedObjectPath, Box<dyn Error>> {
@@ -620,7 +621,7 @@ async fn run_daemon() -> Result<(), Box<dyn Error>> {
wait_for_dbus_socket().await;
let runtime = PowerRuntime::discover()?;
if !runtime.available() {
eprintln!(
log::error!();
"redbear-upower: /scheme/acpi/power unavailable; serving empty provisional UPower surface"
);
}
@@ -677,7 +678,7 @@ async fn run_daemon() -> Result<(), Box<dyn Error>> {
match builder.build().await {
Ok(connection) => {
eprintln!("redbear-upower: registered {BUS_NAME} on the system bus");
log::info!("redbear-upower: registered {BUS_NAME} on the system bus"));
let upower_path = parse_object_path(UPOWER_PATH)?;
let signal_emitter = SignalEmitter::new(&connection, upower_path)?;
@@ -692,22 +693,22 @@ async fn run_daemon() -> Result<(), Box<dyn Error>> {
tokio::select! {
result = shutdown_rx.changed() => {
if result.is_err() {
eprintln!("redbear-upower: signal handler exited unexpectedly");
log::info!("redbear-upower: signal handler exited unexpectedly"));
}
eprintln!("redbear-upower: shutdown signal received, exiting cleanly");
log::info!("redbear-upower: shutdown signal received, exiting cleanly"));
break;
}
_ = notify_interval.tick() => {
let drained = read_notifications();
if !drained.is_empty() {
eprintln!(
log::error!();
"redbear-upower: {} ACPI notification(s): {}",
drained.len(),
drained.join(", ")
);
let current_snapshot = runtime.snapshot();
if current_snapshot != last_snapshot {
eprintln!(
log::error!();
"redbear-upower: power state changed after notification, emitting Changed signal"
);
let _ = UPowerDaemon::changed(&signal_emitter).await;
@@ -718,7 +719,7 @@ async fn run_daemon() -> Result<(), Box<dyn Error>> {
_ = poll_interval.tick() => {
let current_snapshot = runtime.snapshot();
if current_snapshot != last_snapshot {
eprintln!(
log::error!();
"redbear-upower: power state changed, emitting Changed signal"
);
let _ = UPowerDaemon::changed(&signal_emitter).await;
@@ -733,7 +734,7 @@ async fn run_daemon() -> Result<(), Box<dyn Error>> {
}
Err(err) => {
if attempt < 3 {
eprintln!(
log::error!();
"redbear-upower: attempt {attempt}/3 failed ({err}), retrying in 1s..."
);
tokio::time::sleep(Duration::from_secs(1)).await;
@@ -750,27 +751,28 @@ async fn run_daemon() -> Result<(), Box<dyn Error>> {
}
fn main() {
let _ = env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info")).try_init();
match parse_args() {
Ok(Command::Help) => {
println!("{}", usage());
log::info!("{}", usage()));
}
Ok(Command::Run) => {
let runtime = match RuntimeBuilder::new_multi_thread().enable_all().build() {
Ok(runtime) => runtime,
Err(err) => {
eprintln!("redbear-upower: failed to create tokio runtime: {err}");
log::error!("redbear-upower: failed to create tokio runtime: {err}"));
process::exit(1);
}
};
if let Err(err) = runtime.block_on(run_daemon()) {
eprintln!("redbear-upower: fatal error: {err}");
log::error!("redbear-upower: fatal error: {err}"));
process::exit(1);
}
}
Err(err) => {
eprintln!("redbear-upower: {err}");
eprintln!("{}", usage());
log::error!("redbear-upower: {err}"));
log::error!("{}", usage()));
process::exit(1);
}
}
@@ -1,3 +1,22 @@
[workspace]
members = ["source"]
resolver = "3"
[workspace.package]
version = "0.3.1"
edition = "2024"
license = "MIT"
repository = "https://gitea.redbearos.org/vasilito/RedBear-OS"
rust-version = "1.89"
[workspace.dependencies]
log = "0.4"
redox_syscall = { path = "../../../sources/syscall" }
libredox = { path = "../../../sources/libredox" }
redox-scheme = { path = "../../../sources/redox-scheme" }
xhcid = { path = "../../../sources/base/drivers/usb/xhcid" }
common = { path = "../../../sources/base/drivers/common" }
[profile.release]
opt-level = 3
lto = "thin"
@@ -1,21 +1,21 @@
[package]
name = "redbear-usb-hotplugd"
version = "0.3.1"
description = "USB hotplug daemon for Red Bear OS"
repository = "https://gitea.redbearos.org/vasilito/RedBear-OS"
license = "MIT"
edition = "2024"
version.workspace = true
edition.workspace = true
license.workspace = true
repository.workspace = true
description = "USB device hotplug daemon"
[[bin]]
name = "redbear-usb-hotplugd"
path = "src/main.rs"
[dependencies]
log = "0.4"
redox_syscall = { path = "../../../../../local/sources/syscall" }
libredox = { path = "../../../../../local/sources/libredox", features = ["call", "std"] }
xhcid = { path = "../../../../../local/sources/base/drivers/usb/xhcid" }
common = { path = "../../../../../local/sources/base/drivers/common" }
log = { workspace = true }
redox_syscall = { workspace = true }
libredox = { workspace = true }
xhcid = { workspace = true }
common = { workspace = true }
[patch.crates-io]
redox_syscall = { path = "../../../../../local/sources/syscall" }
@@ -1,3 +1,22 @@
[workspace]
members = ["source"]
resolver = "3"
[workspace.package]
version = "0.3.1"
edition = "2024"
license = "MIT"
repository = "https://gitea.redbearos.org/vasilito/RedBear-OS"
rust-version = "1.89"
[workspace.dependencies]
log = "0.4"
redox_syscall = { path = "../../../sources/syscall" }
libredox = { path = "../../../sources/libredox" }
redox-scheme = { path = "../../../sources/redox-scheme" }
xhcid = { path = "../../../sources/base/drivers/usb/xhcid" }
common = { path = "../../../sources/base/drivers/common" }
[profile.release]
opt-level = 3
lto = "thin"
@@ -1,24 +1,24 @@
[package]
name = "redbear-usbaudiod"
version = "0.3.1"
description = "USB audio daemon for Red Bear OS"
repository = "https://gitea.redbearos.org/vasilito/RedBear-OS"
license = "MIT"
edition = "2024"
version.workspace = true
edition.workspace = true
license.workspace = true
repository.workspace = true
description = "USB Audio Class 1.0 driver daemon"
[[bin]]
name = "redbear-usbaudiod"
path = "src/main.rs"
[dependencies]
log = "0.4"
redox_syscall = { path = "../../../../../local/sources/syscall" }
xhcid = { path = "../../../../../local/sources/base/drivers/usb/xhcid" }
common = { path = "../../../../../local/sources/base/drivers/common" }
libredox = { path = "../../../../../local/sources/libredox", features = ["call", "std"] }
log = { workspace = true }
redox_syscall = { workspace = true }
xhcid = { workspace = true }
common = { workspace = true }
libredox = { workspace = true }
[target.'cfg(target_os = "redox")'.dependencies]
redox-scheme = { path = "../../../../../local/sources/redox-scheme" }
redox-scheme = { workspace = true }
[patch.crates-io]
redox_syscall = { path = "../../../../../local/sources/syscall" }
@@ -18,6 +18,7 @@ dbus-nm = ["dep:zbus"]
libc = "0.2"
libredox = { path = "../../../../../local/sources/libredox", features = ["call", "std"] }
log = { version = "0.4", features = ["std"] }
env_logger = "0.11"
redox-scheme = { path = "../../../../../local/sources/redox-scheme" }
syscall = { path = "../../../../../local/sources/syscall", package = "redox_syscall", features = ["std"] }
redox-driver-sys = { path = "../../../drivers/redox-driver-sys/source" }
@@ -12,18 +12,12 @@ use std::process;
use backend::{Backend, IntelBackend, NoDeviceBackend};
#[cfg(target_os = "redox")]
use dbus_nm::register_nm_interface;
use log::LevelFilter;
#[cfg(target_os = "redox")]
use log::{error, info};
use log::{LevelFilter, error, info, warn};
#[cfg(target_os = "redox")]
use redox_scheme::{scheme::SchemeSync, SignalBehavior, Socket};
#[cfg(target_os = "redox")]
use scheme::WifiCtlScheme;
fn init_logging(level: LevelFilter) {
log::set_max_level(level);
}
#[cfg(target_os = "redox")]
unsafe fn get_init_notify_fd() -> Option<RawFd> {
let Ok(value) = env::var("INIT_NOTIFY") else {
@@ -190,14 +184,7 @@ mod tests {
}
fn main() {
let log_level = match env::var("REDBEAR_WIFICTL_LOG").as_deref() {
Ok("debug") => LevelFilter::Debug,
Ok("trace") => LevelFilter::Trace,
Ok("warn") => LevelFilter::Warn,
Ok("error") => LevelFilter::Error,
_ => LevelFilter::Info,
};
init_logging(log_level);
env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info")).init();
let raw_args = env::args().skip(1).collect::<Vec<_>>();
#[cfg(target_os = "redox")]
@@ -226,7 +213,7 @@ fn main() {
return;
}
Err(err) => {
eprintln!("redbear-wifictl: prepare failed for {}: {}", iface, err);
error!("prepare failed for {}: {}", iface, err);
process::exit(1);
}
}
@@ -256,7 +243,7 @@ fn main() {
return;
}
Err(err) => {
eprintln!("redbear-wifictl: scan failed for {}: {}", iface, err);
error!("scan failed for {}: {}", iface, err);
process::exit(1);
}
}
@@ -271,10 +258,7 @@ fn main() {
return;
}
Err(err) => {
eprintln!(
"redbear-wifictl: transport probe failed for {}: {}",
iface, err
);
error!("transport probe failed for {}: {}", iface, err);
process::exit(1);
}
}
@@ -290,10 +274,7 @@ fn main() {
return;
}
Err(err) => {
eprintln!(
"redbear-wifictl: transport init failed for {}: {}",
iface, err
);
error!("transport init failed for {}: {}", iface, err);
process::exit(1);
}
}
@@ -309,10 +290,7 @@ fn main() {
return;
}
Err(err) => {
eprintln!(
"redbear-wifictl: activate-nic failed for {}: {}",
iface, err
);
error!("activate-nic failed for {}: {}", iface, err);
process::exit(1);
}
}
@@ -328,7 +306,7 @@ fn main() {
return;
}
Err(err) => {
eprintln!("redbear-wifictl: retry failed for {}: {}", iface, err);
error!("retry failed for {}: {}", iface, err);
process::exit(1);
}
}
@@ -340,21 +318,15 @@ fn main() {
let key = args.next().unwrap_or_default();
let mut backend = build_backend();
if let Err(err) = backend.prepare(&iface) {
eprintln!("redbear-wifictl: prepare failed for {}: {}", iface, err);
error!("prepare failed for {}: {}", iface, err);
process::exit(1);
}
if let Err(err) = backend.init_transport(&iface) {
eprintln!(
"redbear-wifictl: transport init failed for {}: {}",
iface, err
);
error!("transport init failed for {}: {}", iface, err);
process::exit(1);
}
if let Err(err) = backend.activate(&iface) {
eprintln!(
"redbear-wifictl: activate-nic failed for {}: {}",
iface, err
);
error!("activate-nic failed for {}: {}", iface, err);
process::exit(1);
}
let state = backend::InterfaceState {
@@ -373,7 +345,7 @@ fn main() {
return;
}
Err(err) => {
eprintln!("redbear-wifictl: connect failed for {}: {}", iface, err);
error!("connect failed for {}: {}", iface, err);
process::exit(1);
}
}
@@ -382,21 +354,15 @@ fn main() {
let iface = args.next().unwrap_or_else(|| "wlan0".to_string());
let mut backend = build_backend();
if let Err(err) = backend.prepare(&iface) {
eprintln!("redbear-wifictl: prepare failed for {}: {}", iface, err);
error!("prepare failed for {}: {}", iface, err);
process::exit(1);
}
if let Err(err) = backend.init_transport(&iface) {
eprintln!(
"redbear-wifictl: transport init failed for {}: {}",
iface, err
);
error!("transport init failed for {}: {}", iface, err);
process::exit(1);
}
if let Err(err) = backend.activate(&iface) {
eprintln!(
"redbear-wifictl: activate-nic failed for {}: {}",
iface, err
);
error!("activate-nic failed for {}: {}", iface, err);
process::exit(1);
}
match backend.disconnect(&iface) {
@@ -409,7 +375,7 @@ fn main() {
return;
}
Err(err) => {
eprintln!("redbear-wifictl: disconnect failed for {}: {}", iface, err);
error!("disconnect failed for {}: {}", iface, err);
process::exit(1);
}
}
@@ -419,7 +385,7 @@ fn main() {
#[cfg(not(target_os = "redox"))]
{
eprintln!("redbear-wifictl: daemon mode is only supported on Redox; use --probe on host");
error!("daemon mode is only supported on Redox; use --probe on host");
process::exit(1);
}
@@ -433,7 +399,7 @@ fn main() {
let socket = match Socket::create() {
Ok(s) => s,
Err(err) => {
error!("redbear-wifictl: failed to create scheme socket: {err}");
error!("failed to create scheme socket: {err}");
process::exit(1);
}
};
@@ -442,9 +408,9 @@ fn main() {
notify_scheme_ready(notify_fd, &socket, &mut scheme);
match libredox::call::setrens(0, 0) {
Ok(_) => info!("redbear-wifictl: registered scheme:wifictl"),
Ok(_) => info!("registered scheme:wifictl"),
Err(err) => {
error!("redbear-wifictl: failed to enter null namespace: {err}");
error!("failed to enter null namespace: {err}");
process::exit(1);
}
}
@@ -454,11 +420,11 @@ fn main() {
let request = match socket.next_request(SignalBehavior::Restart) {
Ok(Some(req)) => req,
Ok(None) => {
info!("redbear-wifictl: scheme socket closed, shutting down");
info!("scheme socket closed, shutting down");
break;
}
Err(err) => {
error!("redbear-wifictl: failed to read scheme request: {err}");
error!("failed to read scheme request: {err}");
exit_code = 1;
break;
}
@@ -467,7 +433,7 @@ fn main() {
redox_scheme::RequestKind::Call(request) => {
let response = request.handle_sync(&mut scheme, &mut state);
if let Err(err) = socket.write_response(response, SignalBehavior::Restart) {
error!("redbear-wifictl: failed to write response: {err}");
error!("failed to write response: {err}");
exit_code = 1;
break;
}
@@ -7,6 +7,8 @@ license = "MIT"
edition = "2024"
[dependencies]
log = "0.4"
env_logger = "0.11"
libc = "0.2"
[[bin]]
@@ -16,3 +18,6 @@ path = "src/main.rs"
[[bin]]
name = "redbear-compositor-check"
path = "src/bin/redbear-compositor-check.rs"
anyhow = "1"
thiserror = "2"
@@ -19,7 +19,7 @@ pub struct DisplayBackend {
impl DisplayBackend {
pub fn open_or_framebuffer() -> Self {
if let Some(drm) = drm_backend::DrmOutput::open() {
eprintln!(
log::info!(
"redbear-compositor: using DRM/KMS output {}x{}",
drm.width, drm.height
);
@@ -47,7 +47,7 @@ impl DisplayBackend {
let fb_phys_str = std::env::var("FRAMEBUFFER_ADDR").unwrap_or_else(|_| "0x80000000".into());
let fb_phys =
usize::from_str_radix(fb_phys_str.trim_start_matches("0x"), 16).unwrap_or(0x80000000);
eprintln!(
log::info!(
"redbear-compositor: fb {}x{} stride {} phys 0x{:X}",
width, height, stride, fb_phys
);
@@ -207,7 +207,7 @@ mod drm_backend {
impl DrmOutput {
pub fn open() -> Option<Self> {
let mut file = File::open("/scheme/drm/card0").ok()?;
eprintln!("redbear-compositor: opened /scheme/drm/card0");
log::info!("redbear-compositor: opened /scheme/drm/card0");
let mut resources_resp = vec![0u8; std::mem::size_of::<DrmResources>() + 32];
if drm_ioctl(&mut file, DRM_IOCTL_BASE, &[], &mut resources_resp).is_err() {
@@ -257,7 +257,7 @@ mod drm_backend {
};
let width = mode.hdisplay as u32;
let height = mode.vdisplay as u32;
eprintln!("redbear-compositor: DRM mode {}x{}", width, height);
log::info!("redbear-compositor: DRM mode {}x{}", width, height);
let mut crtc_id = 1u32;
if conn.encoder_id != 0 {
@@ -409,7 +409,7 @@ mod drm_backend {
return None;
}
eprintln!(
log::info!(
"redbear-compositor: DRM output {}x{} stride={} connector={} crtc={}",
width, height, stride, connector_id, crtc_id
);
@@ -435,7 +435,7 @@ mod drm_backend {
buf.extend_from_slice(&(DRM_IOCTL_MODE_PAGE_FLIP as u64).to_le_bytes());
buf.extend_from_slice(&fb_id.to_le_bytes());
if let Err(e) = (&self.drm_file).write_all(&buf) {
eprintln!("redbear-compositor: DRM page flip ioctl failed: {}", e);
log::error!("redbear-compositor: DRM page flip ioctl failed: {}", e);
}
self.current.store(next, Ordering::Relaxed);
}

Some files were not shown because too many files have changed in this diff Show More