dcavalca / rpms / systemd

Forked from rpms/systemd 3 months ago
Clone
803fb7
From 8290b73eeb8da4f8f0076f3bb7e23990af734de0 Mon Sep 17 00:00:00 2001
803fb7
From: Lennart Poettering <lennart@poettering.net>
803fb7
Date: Fri, 24 Jul 2015 02:10:32 +0200
803fb7
Subject: [PATCH] journalctl: properly detect empty journal files
803fb7
803fb7
When we encounter a journal file with exactly zero entries, print a nice
803fb7
message and exit, and don't print a weird error message.
803fb7
803fb7
Cherry-picked from: 02ab86c732576a71179ce12e97d44c289833236d
803fb7
Related: #1350232
803fb7
---
803fb7
 src/journal/journalctl.c | 6 ++++++
803fb7
 1 file changed, 6 insertions(+)
803fb7
803fb7
diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c
803fb7
index 6948ed689..904aae99e 100644
803fb7
--- a/src/journal/journalctl.c
803fb7
+++ b/src/journal/journalctl.c
803fb7
@@ -2141,6 +2141,12 @@ int main(int argc, char *argv[]) {
803fb7
                 return EXIT_FAILURE;
803fb7
         }
803fb7
 
803fb7
+        if (r == 0) {
803fb7
+                printf("-- No entries --\n");
803fb7
+                return EXIT_SUCCESS;
803fb7
+        }
803fb7
+
803fb7
+
803fb7
         if (!arg_follow)
803fb7
                 pager_open_if_enabled();
803fb7