From 4f5e1723410513da418fbbae03c23b1b2cc4db82 Mon Sep 17 00:00:00 2001 From: Armin Widegreen Date: Thu, 11 Jan 2018 12:42:56 +0100 Subject: [PATCH] journal: Fix journal dumping for json, cat and export output Incorporating the fix from d00f1d57 into other output formats of journalctl. If journal files are corrupted, e.g. not cleanly closed, some journal entries can not be read by output options other than 'short' (default). If such entries has been identified, they will now just be skipped. --- src/shared/logs-show.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/shared/logs-show.c b/src/shared/logs-show.c index a861be7..8a1b266 100644 --- a/src/shared/logs-show.c +++ b/src/shared/logs-show.c @@ -661,6 +661,10 @@ static int output_export( fputc('\n', f); } + if (r == -EBADMSG) { + log_debug_errno(r, "Skipping message we can't read: %m"); + return 0; + } if (r < 0) return r; @@ -824,6 +828,11 @@ static int output_json( } } + if (r == -EBADMSG) { + log_debug_errno(r, "Skipping message we can't read: %m"); + return 0; + } + if (r < 0) return r; @@ -964,6 +973,10 @@ static int output_cat( sd_journal_set_data_threshold(j, 0); r = sd_journal_get_data(j, "MESSAGE", &data, &l); + if (r == -EBADMSG) { + log_debug_errno(r, "Skipping message we can't read: %m"); + return 0; + } if (r < 0) { /* An entry without MESSAGE=? */ if (r == -ENOENT) -- 2.7.4