chiark / gitweb /
journalctl: include corrupted files in output
authorLennart Poettering <lennart@poettering.net>
Mon, 6 Aug 2012 22:51:17 +0000 (00:51 +0200)
committerLennart Poettering <lennart@poettering.net>
Mon, 6 Aug 2012 22:51:17 +0000 (00:51 +0200)
If a journal file was rotated away because it was corrupted or dirty we
should still show its contents via "journalctl".

TODO
src/journal/sd-journal.c

diff --git a/TODO b/TODO
index 6d99afe63ba2c4591f1c1d8896ac9c922020777f..8acf45edea7b7448a28ae7ffa2c21a3ebd4ced57 100644 (file)
--- a/TODO
+++ b/TODO
@@ -47,8 +47,6 @@ Bugfixes:
 
 Features:
 
 
 Features:
 
-* .journal~ files should be parsed too
-
 * allow services with no ExecStart= but with an ExecStop=
 
 * add proper journal support to "systemctl --user status ..."
 * allow services with no ExecStart= but with an ExecStop=
 
 * add proper journal support to "systemctl --user status ..."
index fd0fb57338b48179f89c6cd08827fed796042955..33686ed2b26529793f78b8f8d924bfff4abd9d25 100644 (file)
@@ -1098,7 +1098,9 @@ static int add_file(sd_journal *j, const char *prefix, const char *filename) {
 
         if ((j->flags & SD_JOURNAL_SYSTEM_ONLY) &&
             !(streq(filename, "system.journal") ||
 
         if ((j->flags & SD_JOURNAL_SYSTEM_ONLY) &&
             !(streq(filename, "system.journal") ||
-             (startswith(filename, "system@") && endswith(filename, ".journal"))))
+              streq(filename, "system.journal~") ||
+              (startswith(filename, "system@") &&
+               (endswith(filename, ".journal") || endswith(filename, ".journal~")))))
                 return 0;
 
         path = strjoin(prefix, "/", filename, NULL);
                 return 0;
 
         path = strjoin(prefix, "/", filename, NULL);
@@ -1246,7 +1248,8 @@ static int add_directory(sd_journal *j, const char *prefix, const char *dirname)
                 if (r != 0 || !de)
                         break;
 
                 if (r != 0 || !de)
                         break;
 
-                if (dirent_is_file_with_suffix(de, ".journal")) {
+                if (dirent_is_file_with_suffix(de, ".journal") ||
+                    dirent_is_file_with_suffix(de, ".journal~")) {
                         r = add_file(j, m->path, de->d_name);
                         if (r < 0)
                                 log_debug("Failed to add file %s/%s: %s", m->path, de->d_name, strerror(-r));
                         r = add_file(j, m->path, de->d_name);
                         if (r < 0)
                                 log_debug("Failed to add file %s/%s: %s", m->path, de->d_name, strerror(-r));
@@ -1324,7 +1327,8 @@ static int add_root_directory(sd_journal *j, const char *p) {
                 if (r != 0 || !de)
                         break;
 
                 if (r != 0 || !de)
                         break;
 
-                if (dirent_is_file_with_suffix(de, ".journal")) {
+                if (dirent_is_file_with_suffix(de, ".journal") ||
+                    dirent_is_file_with_suffix(de, ".journal~")) {
                         r = add_file(j, m->path, de->d_name);
                         if (r < 0)
                                 log_debug("Failed to add file %s/%s: %s", m->path, de->d_name, strerror(-r));
                         r = add_file(j, m->path, de->d_name);
                         if (r < 0)
                                 log_debug("Failed to add file %s/%s: %s", m->path, de->d_name, strerror(-r));
@@ -1823,7 +1827,9 @@ static void process_inotify_event(sd_journal *j, struct inotify_event *e) {
         if (d) {
                 sd_id128_t id;
 
         if (d) {
                 sd_id128_t id;
 
-                if (!(e->mask & IN_ISDIR) && e->len > 0 && endswith(e->name, ".journal")) {
+                if (!(e->mask & IN_ISDIR) && e->len > 0 &&
+                    (endswith(e->name, ".journal") ||
+                     endswith(e->name, ".journal~"))) {
 
                         /* Event for a journal file */
 
 
                         /* Event for a journal file */