diag(kernel): mirror userspace writes starting with PROCMGR to log

This commit is contained in:
2026-07-15 13:25:43 +09:00
parent 5a07dce55b
commit 9359e740bd
+20
View File
@@ -857,6 +857,26 @@ pub fn sys_read(fd: FileHandle, buf: UserSliceWo, token: &mut CleanLockToken) ->
Ok(bytes_read)
}
pub fn sys_write(fd: FileHandle, buf: UserSliceRo, token: &mut CleanLockToken) -> Result<usize> {
// Red Bear diagnostic (2026-07-15): procmgr (userspace process manager,
// scheme 18) has no serial-connected stdout, so its "PROCMGR ..."
// diagnostics written to fd 1 never reach the log. Mirror any userspace
// write whose payload begins with "PROCMGR" to the kernel log. This runs
// before fd validation, so it works even if procmgr's fd 1 is not a real
// sink. Cheap: only 7 bytes are peeked unless the marker matches.
if buf.len() >= 7 {
let mut marker = [0u8; 7];
if buf.copy_common_bytes_to_slice(&mut marker).is_ok() && &marker == b"PROCMGR" {
let mut line = [0u8; 256];
if let Ok(n) = buf.copy_common_bytes_to_slice(&mut line) {
error!(
"{}",
core::str::from_utf8(&line[..n])
.unwrap_or("<procmgr non-utf8>")
.trim_end_matches('\n')
);
}
}
}
let result = (|| {
let (bytes_written, desc_arc, desc) =
file_op_generic_ext(fd, token, |scheme, desc_arc, desc, token| {