journal: count number of entry arrays in header

This commit is contained in:
Lennart Poettering 2012-08-16 20:51:24 +02:00
parent 45b51b6b71
commit 2dee23ebe0
3 changed files with 11 additions and 0 deletions

View File

@ -185,6 +185,7 @@ _packed_ struct Header {
le64_t n_fields;
/* Added in 189 */
le64_t n_tags;
le64_t n_entry_arrays;
};
#define FSPRG_HEADER_SIGNATURE ((char[]) { 'K', 'S', 'H', 'H', 'R', 'H', 'L', 'P' })

View File

@ -839,6 +839,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;

View File

@ -837,6 +837,13 @@ int journal_file_verify(JournalFile *f, const char *key) {
goto fail;
}
if (JOURNAL_HEADER_CONTAINS(f->header, n_entry_arrays) &&
n_entry_arrays != le64toh(f->header->n_entry_arrays)) {
log_error("Entry array number mismatch");
r = -EBADMSG;
goto fail;
}
if (n_data_hash_tables != 1) {
log_error("Missing data hash table");
r = -EBADMSG;