From 07ccba45dc34e06cee96a40b3b381d6f9a14b42f Mon Sep 17 00:00:00 2001 From: Alexander Kanevskiy Date: Fri, 2 Oct 2026 12:59:14 +0300 Subject: [PATCH] lib: add record types to Crash Log filenames and use UTC time The extraction filename only carried the source and the time, so it gave no hint of what the Crash Log contains. Add the record types found in the Crash Log to `Metadata`, after the time: pmt:0000:03:00.0-20261002T122443.937Z-Punit+MCA.crashlog `CrashLog::from_regions` collects the types while it walks the regions. Each type is listed once, in the order it is first found, and Box records are skipped because they only wrap the real records. The EFI and Windows Event Log sources replace the whole `Metadata` after parsing, so they now carry the record types over. `Time::now()` now returns UTC instead of the local time zone, and the `Display` output ends with `Z`. Filenames from machines in different time zones sort and compare directly this way. This also lets `jiff` drop its `tz-system` and `tzdb-zoneinfo` features. The UEFI and Windows Event Log timestamps are unchanged, since the platform does not say which time zone they use. --- lib/Cargo.lock | 1 - lib/Cargo.toml | 6 +----- lib/src/crashlog.rs | 19 +++++++++++++++---- lib/src/metadata.rs | 33 ++++++++++++++++++++++++++++++++- lib/src/metadata/time.rs | 14 ++++---------- lib/src/source/acpi/efi.rs | 1 + lib/src/source/event_log/win.rs | 5 ++++- 7 files changed, 57 insertions(+), 22 deletions(-) diff --git a/lib/Cargo.lock b/lib/Cargo.lock index 379c2f7..b0a4d55 100644 --- a/lib/Cargo.lock +++ b/lib/Cargo.lock @@ -235,7 +235,6 @@ dependencies = [ "portable-atomic", "portable-atomic-util", "serde_core", - "windows-link", ] [[package]] diff --git a/lib/Cargo.toml b/lib/Cargo.toml index cf6bc36..24d5bcc 100644 --- a/lib/Cargo.toml +++ b/lib/Cargo.toml @@ -68,11 +68,7 @@ default-features = false [dependencies.jiff] version = "0.2" default-features = false -features = [ - "std", - "tz-system", - "tzdb-zoneinfo", -] +features = ["std"] optional = true [dependencies.serde] diff --git a/lib/src/crashlog.rs b/lib/src/crashlog.rs index c4f36b2..ae4f39e 100644 --- a/lib/src/crashlog.rs +++ b/lib/src/crashlog.rs @@ -6,6 +6,7 @@ use crate::bert::{Berr, Bert}; #[cfg(feature = "collateral_manager")] use crate::collateral::{CollateralManager, CollateralTree}; use crate::cper::{Cper, CperSectionBody}; +use crate::header::record_types; use crate::metadata::Metadata; use crate::node::Node; use crate::region::Region; @@ -27,8 +28,21 @@ impl CrashLog { pub(crate) fn from_regions(regions: Vec) -> Result { let mut queue = VecDeque::from(regions); let mut regions = Vec::new(); + let mut metadata = Metadata::default(); while let Some(region) = queue.pop_front() { + for record in region.records.iter() { + let is_box = record.header.version.record_type == record_types::BOX + || record.header.version.errata().type0_legacy_server_box; + + if !is_box + && let Ok(record_type) = record.header.record_type() + && !metadata.record_types.contains(&record_type) + { + metadata.record_types.push(record_type); + } + } + for child in region.get_children() { queue.push_back(child); } @@ -39,10 +53,7 @@ impl CrashLog { return Err(Error::InvalidCrashLog); } - Ok(CrashLog { - regions, - ..CrashLog::default() - }) + Ok(CrashLog { regions, metadata }) } /// Extracts the Crash Log records from [Berr]. diff --git a/lib/src/metadata.rs b/lib/src/metadata.rs index acadcbb..598a63a 100644 --- a/lib/src/metadata.rs +++ b/lib/src/metadata.rs @@ -24,8 +24,11 @@ pub struct Metadata { pub computer: Option, /// Name of the source where the Crash Log has been extracted from. pub source: Option, - /// Time of the extraction + /// Time of the extraction, expressed in UTC pub time: Option