summaryrefslogtreecommitdiff
path: root/src/journal
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2012-08-07 00:51:17 +0200
committerLennart Poettering <lennart@poettering.net>2012-08-07 00:51:17 +0200
commitde2c390731e563db0ee383bfd0073fdbef643ca2 (patch)
treecce752f08048ae8ac7df59acdd51cd0ded585696 /src/journal
parentb3ac5f8cb98757416d8660023d6564a7c411f0a0 (diff)
journalctl: include corrupted files in output
If a journal file was rotated away because it was corrupted or dirty we should still show its contents via "journalctl".
Diffstat (limited to 'src/journal')
-rw-r--r--src/journal/sd-journal.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/journal/sd-journal.c b/src/journal/sd-journal.c
index fd0fb57338..33686ed2b2 100644
--- a/src/journal/sd-journal.c
+++ b/src/journal/sd-journal.c
@@ -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") ||
- (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);
@@ -1246,7 +1248,8 @@ static int add_directory(sd_journal *j, const char *prefix, const char *dirname)
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));
@@ -1324,7 +1327,8 @@ static int add_root_directory(sd_journal *j, const char *p) {
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));
@@ -1823,7 +1827,9 @@ static void process_inotify_event(sd_journal *j, struct inotify_event *e) {
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 */