chiark / gitweb /
journal: parse fsprg seed
[elogind.git] / src / journal / journal-file.c
index efa0910780d0fddf878067cb7d1c50e016521525..3bb1e90fb324b9f86b3a8c76c87cf641a480fa0e 100644 (file)
@@ -96,8 +96,12 @@ void journal_file_close(JournalFile *f) {
 #endif
 
 #ifdef HAVE_GCRYPT
-        if (f->fsprg_header)
-                munmap(f->fsprg_header, PAGE_ALIGN(f->fsprg_size));
+        if (f->fsprg_file)
+                munmap(f->fsprg_file, PAGE_ALIGN(f->fsprg_file_size));
+        else if (f->fsprg_state)
+                free(f->fsprg_state);
+
+        free(f->fsprg_seed);
 
         if (f->hmac)
                 gcry_md_close(f->hmac);
@@ -839,6 +843,9 @@ static int link_entry_into_array(JournalFile *f,
                 o->entry_array.next_entry_array_offset = htole64(q);
         }
 
+        if (JOURNAL_HEADER_CONTAINS(f->header, n_entry_arrays))
+                f->header->n_entry_arrays = htole64(le64toh(f->header->n_entry_arrays) + 1);
+
         *idx = htole64(hidx + 1);
 
         return 0;
@@ -2134,7 +2141,7 @@ int journal_file_open_reliably(
                 bool compress,
                 bool authenticate,
                 JournalMetrics *metrics,
-                MMapCache *mmap,
+                MMapCache *mmap_cache,
                 JournalFile *template,
                 JournalFile **ret) {
 
@@ -2142,7 +2149,8 @@ int journal_file_open_reliably(
         size_t l;
         char *p;
 
-        r = journal_file_open(fname, flags, mode, compress, authenticate, metrics, mmap, template, ret);
+        r = journal_file_open(fname, flags, mode, compress, authenticate,
+                              metrics, mmap_cache, template, ret);
         if (r != -EBADMSG && /* corrupted */
             r != -ENODATA && /* truncated */
             r != -EHOSTDOWN && /* other machine */
@@ -2176,7 +2184,8 @@ int journal_file_open_reliably(
 
         log_warning("File %s corrupted or uncleanly shut down, renaming and replacing.", fname);
 
-        return journal_file_open(fname, flags, mode, compress, authenticate, metrics, mmap, template, ret);
+        return journal_file_open(fname, flags, mode, compress, authenticate,
+                                 metrics, mmap_cache, template, ret);
 }