X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fjournal%2Fsd-journal.c;h=41526b35bf8e485411095c7ba03ff9c962162f02;hb=16e9f408fa9a9626059bdd6c89dc175e06b9e976;hp=fd0fb57338b48179f89c6cd08827fed796042955;hpb=4a842cadb8d6b30fa9fdc8ff183633c14e02cf96;p=elogind.git diff --git a/src/journal/sd-journal.c b/src/journal/sd-journal.c index fd0fb5733..41526b35b 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); @@ -1116,7 +1118,7 @@ static int add_file(sd_journal *j, const char *prefix, const char *filename) { return 0; } - r = journal_file_open(path, O_RDONLY, 0, NULL, NULL, &f); + r = journal_file_open(path, O_RDONLY, 0, false, false, NULL, j->mmap, NULL, &f); free(path); if (r < 0) { @@ -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)); @@ -1435,6 +1439,17 @@ static sd_journal *journal_new(int flags, const char *path) { return NULL; } + /* One context for each type, plus the zeroth catchall + * context. One fd for each file plus one for each type, which + * is need when verifying things */ + j->mmap = mmap_cache_new(_OBJECT_TYPE_MAX, JOURNAL_FILES_MAX + _OBJECT_TYPE_MAX); + if (!j->mmap) { + hashmap_free(j->files); + hashmap_free(j->directories_by_path); + free(j->path); + free(j); + } + return j; } @@ -1523,6 +1538,9 @@ _public_ void sd_journal_close(sd_journal *j) { sd_journal_flush_matches(j); + if (j->mmap) + mmap_cache_unref(j->mmap); + free(j->path); free(j); } @@ -1823,7 +1841,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 */