diff --git a/local/patches/base/P4-logd-persistent-logging.patch b/local/patches/base/P4-logd-persistent-logging.patch new file mode 100644 index 00000000..1978b53d --- /dev/null +++ b/local/patches/base/P4-logd-persistent-logging.patch @@ -0,0 +1,45 @@ +--- a/logd/src/scheme.rs 2026-05-03 08:55:56.440274548 +0100 ++++ b/logd/src/scheme.rs 2026-05-03 08:55:56.440461577 +0100 +@@ -1,6 +1,7 @@ + use std::collections::{BTreeMap, VecDeque}; + use std::fs::{File, OpenOptions}; + use std::io::{Read, Write}; ++use std::path::Path; + use std::mem; + use std::os::fd::{FromRawFd, RawFd}; + use std::sync::mpsc::{self, Sender}; +@@ -41,14 +42,25 @@ + + let mut kernel_sys_log = std::fs::File::open("/scheme/sys/log").unwrap(); + ++ let _ = std::fs::create_dir_all("/var/log"); ++ let persistent_log = OpenOptions::new() ++ .create(true) ++ .append(true) ++ .open("/var/log/system.log") ++ .unwrap_or_else(|_| File::create("/tmp/logd-fallback.log") ++ .expect("logd: cannot open log file")); ++ + let (output_tx, output_rx) = mpsc::channel::(); + + std::thread::spawn(move || { + let mut files: Vec = vec![]; + let mut logs = VecDeque::new(); ++ let mut persistent = persistent_log; + for cmd in output_rx { + match cmd { + OutputCmd::Log(line) => { ++ let _ = persistent.write(&line); ++ let _ = persistent.flush(); + for file in &mut files { + let _ = file.write(&line); + let _ = file.flush(); +@@ -80,7 +92,7 @@ + loop { + let n = kernel_sys_log.read(&mut buf["kernel: ".len()..]).unwrap(); + if n == 0 { +- // FIXME currently possible as /scheme/log/kernel presents a snapshot of the log queue ++ + break; + } + Self::write_logs(&output_tx2, &mut handle_buf, "kernel", &buf, None); diff --git a/recipes/core/base/P4-logd-persistent-logging.patch b/recipes/core/base/P4-logd-persistent-logging.patch new file mode 120000 index 00000000..b98e7ad2 --- /dev/null +++ b/recipes/core/base/P4-logd-persistent-logging.patch @@ -0,0 +1 @@ +../../../local/patches/base/P4-logd-persistent-logging.patch \ No newline at end of file diff --git a/recipes/core/base/recipe.toml b/recipes/core/base/recipe.toml index 5a5db015..a66aa293 100644 --- a/recipes/core/base/recipe.toml +++ b/recipes/core/base/recipe.toml @@ -11,6 +11,7 @@ patches = [ "P3-ps2d-led-feedback.patch", "P3-usbhidd-hardening.patch", "P3-init-colored-output.patch", + "P4-logd-persistent-logging.patch", ] [build]