]> git.ipfire.org Git - thirdparty/systemd.git/commit
journalctl: find boot ID more gracefully in corrupted journal
authorYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 27 Sep 2023 21:04:53 +0000 (06:04 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 2 Oct 2023 01:59:33 +0000 (10:59 +0900)
commit185e201690bd1fff63f99239b2ee7585557445bf
tree4bac3f5e468bad2d23eb2e76d1501bc1f56703b9
parentb503c766898387f872c93300f64b6bdcf44c439f
journalctl: find boot ID more gracefully in corrupted journal

In discover_next_boot(), first we find a new boot ID based on the value
stored in the entry object. Then, find the tail (or head when we are going
upwards) entry of the boot based on the _BOOT_ID= field data.

If boot IDs of an entry in the entry object and _BOOT_ID field data
are inconsistent, which may happen on corrupted journal, then previously
discover_next_boot() failed with -ENODATA.

This makes the function check if the two boot IDs in each entry are
consistent, and skip the entry if not.

Fixes the failure of `journalctl -b -1` for 'truncated' journal:
https://github.com/systemd/systemd/pull/29334#issuecomment-1736567951
src/shared/logs-show.c
test/units/testsuite-04.journal.sh