diff options
author | Lennart Poettering <lennart@poettering.net> | 2012-06-05 20:32:55 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2012-06-17 00:03:11 +0200 |
commit | 23b0b2b2647d3f0f3fd0219c877d6233b4585421 (patch) | |
tree | e8f47e76f9f327b1a43a27f25d2196bdc741d99e /src/journal/journal-file.c | |
parent | cdc564d27f71f82457e96e9b237564fc6e8e84c9 (diff) |
journal: replace arena offset by header size
Diffstat (limited to 'src/journal/journal-file.c')
-rw-r--r-- | src/journal/journal-file.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c index 1f82191d28..bbe00ab1ef 100644 --- a/src/journal/journal-file.c +++ b/src/journal/journal-file.c @@ -99,7 +99,7 @@ static int journal_file_init_header(JournalFile *f, JournalFile *template) { zero(h); memcpy(h.signature, signature, 8); - h.arena_offset = htole64(ALIGN64(sizeof(h))); + h.header_size = htole64(ALIGN64(sizeof(h))); r = sd_id128_randomize(&h.file_id); if (r < 0) @@ -161,7 +161,10 @@ static int journal_file_verify_header(JournalFile *f) { return -EPROTONOSUPPORT; #endif - if ((uint64_t) f->last_stat.st_size < (le64toh(f->header->arena_offset) + le64toh(f->header->arena_size))) + if (f->header->header_size != htole64(ALIGN64(sizeof(*(f->header))))) + return -EBADMSG; + + if ((uint64_t) f->last_stat.st_size < (le64toh(f->header->header_size) + le64toh(f->header->arena_size))) return -ENODATA; if (f->writable) { @@ -200,12 +203,12 @@ static int journal_file_allocate(JournalFile *f, uint64_t offset, uint64_t size) * ourselves */ old_size = - le64toh(f->header->arena_offset) + + le64toh(f->header->header_size) + le64toh(f->header->arena_size); new_size = PAGE_ALIGN(offset + size); - if (new_size < le64toh(f->header->arena_offset)) - new_size = le64toh(f->header->arena_offset); + if (new_size < le64toh(f->header->header_size)) + new_size = le64toh(f->header->header_size); if (new_size <= old_size) return 0; @@ -243,7 +246,7 @@ static int journal_file_allocate(JournalFile *f, uint64_t offset, uint64_t size) if (fstat(f->fd, &f->last_stat) < 0) return -errno; - f->header->arena_size = htole64(new_size - le64toh(f->header->arena_offset)); + f->header->arena_size = htole64(new_size - le64toh(f->header->header_size)); return 0; } @@ -457,7 +460,7 @@ static int journal_file_append_object(JournalFile *f, int type, uint64_t size, O p = le64toh(f->header->tail_object_offset); if (p == 0) - p = le64toh(f->header->arena_offset); + p = le64toh(f->header->header_size); else { r = journal_file_move_to_object(f, -1, p, &tail); if (r < 0) @@ -1665,7 +1668,7 @@ void journal_file_dump(JournalFile *f) { (unsigned long) le64toh(f->header->n_objects), (unsigned long) le64toh(f->header->n_entries)); - p = le64toh(f->header->arena_offset); + p = le64toh(f->header->header_size); while (p != 0) { r = journal_file_move_to_object(f, -1, p, &o); if (r < 0) |