journalctl: show friendly info when using -b on runtime journal only
authorJan Synacek <jsynacek@redhat.com>
Mon, 1 Feb 2016 08:25:22 +0000 (09:25 +0100)
committerJan Synacek <jsynacek@redhat.com>
Mon, 1 Feb 2016 10:59:33 +0000 (11:59 +0100)
Make it clear that specifing boot when there is actually only one has no
effect. This cosmetic patch improves user experience a bit.

src/journal/journalctl.c

index db11421..69a2013 100644 (file)
@@ -2091,6 +2091,13 @@ int main(int argc, char *argv[]) {
                 assert_not_reached("Unknown action");
         }
 
+        if (arg_boot_offset != 0 &&
+            sd_journal_has_runtime_files(j) > 0 &&
+            sd_journal_has_persistent_files(j) == 0) {
+                log_info("Specifying boot ID has no effect, no persistent journal was found");
+                r = 0;
+                goto finish;
+        }
         /* add_boot() must be called first!
          * It may need to seek the journal to find parent boot IDs. */
         r = add_boot(j);