From: Armin Widegreen Date: Thu, 11 Jan 2018 11:42:56 +0000 (+0100) Subject: journal: Fix journal dumping for json, cat and export output X-Git-Tag: v237~60 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4f5e1723410513da418fbbae03c23b1b2cc4db82;p=thirdparty%2Fsystemd.git 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. --- diff --git a/src/shared/logs-show.c b/src/shared/logs-show.c index a861be7b324..8a1b26629a2 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)