From 628e481c32c9fd47919e46216ee26e6c28226578 Mon Sep 17 00:00:00 2001 From: Vitaliy Filippov Date: Mon, 12 Jun 2023 02:39:27 +0300 Subject: [PATCH] Fill journal header to know checksum type & size when dumping journal with --all --- src/disk_tool_journal.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/disk_tool_journal.cpp b/src/disk_tool_journal.cpp index d997b0b8..bc14601a 100644 --- a/src/disk_tool_journal.cpp +++ b/src/disk_tool_journal.cpp @@ -55,6 +55,23 @@ int disk_tool_t::dump_journal() printf("offset %08lx:\n", journal_pos); else printf(",\"entries\":[\n"); + if (journal_pos == 0) + { + // Fill journal header to know checksum type & size + journal_entry *je = (journal_entry*)journal_buf; + if (je->magic == JOURNAL_MAGIC && je->type == JE_START && + (je->start.version == JOURNAL_VERSION_V1 || je->start.version == JOURNAL_VERSION_V2)) + { + memcpy(&je_start, je, sizeof(je_start)); + if (je_start.size == JE_START_V0_SIZE) + je_start.version = 0; + if (je_start.version < JOURNAL_VERSION_V2) + { + je_start.data_csum_type = 0; + je_start.csum_block_size = 0; + } + } + } first_entry = true; process_journal_block(journal_buf, [this](int num, journal_entry *je) { dump_journal_entry(num, je, json); }); if (json)