Unfortunately, to get a chronological list of boot IDs, we
need to search through the journal. sd_journal_enumerate_unique()
doesn't help us here, because order of returned values is undefined.
An initial search for the reference boot ID is performed. We then
start a search filtering by SD_MESSAGE_JOURNAL_START. This
message ID should come up in every journal and is therefore a good
start to reduce the amount of messages the lookup process has to
walk through to find the previous/next boot IDs.
Note that this or any other message ID could get rotated away,
so lookup is not guaranteed to be precise. This should only affect
old (and uninteresting) journal entries, though.
---
Changes in v3:
- do filter by MESSAGE_ID and simply declare the cases where we
skip boot IDs not a problem
- --this-boot not documented anymore
- usage of ":" instead of "^" to define relative IDs
- improved wording in the man page
- indentation fixes
Changes in v2:
- prevent unnecessary strdup by changing the argv value in place
- speed up the lookup by doing an initial search for the boot ID
TODO | 1 -
man/journalctl.xml | 58 +---
shell-completion/bash/journalctl | 8 +-
src/journal/journalctl.c | 186 ---
4 files changed, 228 insertions(+), 25 deletions(-)
diff --git a/TODO b/TODO
index ecc5748..2b2aafc 100644
--- a/TODO
+++ b/TODO
@@ -259,7 +259,6 @@ Features:
- journal-send.c, log.c: when the log socket is clogged, and we drop, count
this and write a message about this when it gets unclogged again.
- journal: find a way to allow dropping history early, based on priority,
other rules
- journal: When used on NFS, check payload hashes
- - Introduce journalctl -b to show journal messages of a previous boot
- journald: check whether it is OK if the client can still modify delivered
journal entries
- journal live copy, based on libneon (client) and libmicrohttpd (server)
- journald: add kernel cmdline option to disable ratelimiting for debug
purposes
diff --git a/man/journalctl.xml b/man/journalctl.xml
index d9ca0a6..6cbeb22 100644
--- a/man/journalctl.xml
+++ b/man/journalctl.xml
@@ -312,23 +312,55 @@
--b
---this-boot
-
-Show data only from
-current boot. This will add a match
-for _BOOT_ID= for
-the current boot ID of the
-kernel.
+-b
ID
+
--boot=ID
+
+Show messages from specified
+boot ID. This will
+add a match for
_BOOT_ID=.
+
+The argument is a 128 bit ID given in
+short or UUID form and optionally followed by
+:n which identifies the nth
+boot relative to the boot ID given to the left
+of :. Supplying a negative
+value will look for a past boot and a positive
+value for a future boot. The boot IDs are
+searched for in chronological order.
+
+If no number is provided after
+:, -1 is
+assumed. A value of 0 is valid and equivalent
to
+omitting :0. The boot ID may
+be omitted if : is provided,
+which will assume the current boot ID as the
+reference.
+
+For example, if
962e0810b0c44735a6a70e7132996502
+were the ID of the current boot, the following
+are all equivalent:
+
962e0810b0c44735a6a70e7132996502,
+
962e0810-b0c4-4735-a6a7-0e7132996502,
+:0,
+
962e0810b0c44735a6a70e7132996502:0,
+
962e0810-b0c4-4735-a6a7-0e7132996502:0.
+Additionally, if
04089164-6fb3-4826-a7d1-207b11a02169
+were the previous boot ID the following are
equivalent:
+
040891646fb34826a7d1207b11a02169,
+
04089164-6fb3-4826-a7d1-207b11a02169,
+:-1, :,
+
962e0810b0c44735a6a70e7132996502:-1,
+
962e0810-b0c4-4735-a6a7-0e7132996502:-1.
+