valeriyvdovin / rpms / systemd

Forked from rpms/systemd 4 years ago
Clone

Blame SOURCES/0348-journalctl-properly-detect-empty-journal-files.patch

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