journalctl: properly detect empty journal files
authorLennart Poettering <lennart@poettering.net>
Fri, 24 Jul 2015 00:10:32 +0000 (02:10 +0200)
committerLennart Poettering <lennart@poettering.net>
Fri, 24 Jul 2015 00:10:32 +0000 (02:10 +0200)
When we encounter a journal file with exactly zero entries, print a nice
message and exit, and don't print a weird error message.

src/journal/journalctl.c

index 2d6ecfb..073cc77 100644 (file)
@@ -2066,6 +2066,10 @@ int main(int argc, char *argv[]) {
                 log_error_errno(r, "Failed to iterate through journal: %m");
                 goto finish;
         }
+        if (r == 0) {
+                printf("-- No entries --\n");
+                goto finish;
+        }
 
         if (!arg_follow)
                 pager_open_if_enabled();