diff options
author | Daniel Mack <github@zonque.org> | 2015-07-24 12:04:30 +0200 |
---|---|---|
committer | Daniel Mack <github@zonque.org> | 2015-07-24 12:04:30 +0200 |
commit | 77b7f805099dbdd869b1846d30ffed56833941ff (patch) | |
tree | a2b3f1b5e2a650518b70856cc9809b415d7140d1 /src/journal/journal-file.c | |
parent | 7121b2152a69bc8e6ad9ea02804f92817468f8f1 (diff) | |
parent | e80acc51aeaf2d74cb4d6cecbcb6e18f74c22c05 (diff) |
Merge pull request #695 from poettering/journal-fixes
Journal fixes
Diffstat (limited to 'src/journal/journal-file.c')
-rw-r--r-- | src/journal/journal-file.c | 37 |
1 files changed, 26 insertions, 11 deletions
diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c index be6a5522fa..f7815b2796 100644 --- a/src/journal/journal-file.c +++ b/src/journal/journal-file.c @@ -656,13 +656,16 @@ static int journal_file_setup_field_hash_table(JournalFile *f) { return 0; } -static int journal_file_map_data_hash_table(JournalFile *f) { +int journal_file_map_data_hash_table(JournalFile *f) { uint64_t s, p; void *t; int r; assert(f); + if (f->data_hash_table) + return 0; + p = le64toh(f->header->data_hash_table_offset); s = le64toh(f->header->data_hash_table_size); @@ -678,13 +681,16 @@ static int journal_file_map_data_hash_table(JournalFile *f) { return 0; } -static int journal_file_map_field_hash_table(JournalFile *f) { +int journal_file_map_field_hash_table(JournalFile *f) { uint64_t s, p; void *t; int r; assert(f); + if (f->field_hash_table) + return 0; + p = le64toh(f->header->field_hash_table_offset); s = le64toh(f->header->field_hash_table_size); @@ -803,10 +809,18 @@ int journal_file_find_field_object_with_hash( assert(f); assert(field && size > 0); + /* If the field hash table is empty, we can't find anything */ + if (le64toh(f->header->field_hash_table_size) <= 0) + return 0; + + /* Map the field hash table, if it isn't mapped yet. */ + r = journal_file_map_field_hash_table(f); + if (r < 0) + return r; + osize = offsetof(Object, field.payload) + size; m = le64toh(f->header->field_hash_table_size) / sizeof(HashItem); - if (m <= 0) return -EBADMSG; @@ -866,6 +880,15 @@ int journal_file_find_data_object_with_hash( assert(f); assert(data || size == 0); + /* If there's no data hash table, then there's no entry. */ + if (le64toh(f->header->data_hash_table_size) <= 0) + return 0; + + /* Map the data hash table, if it isn't mapped yet. */ + r = journal_file_map_data_hash_table(f); + if (r < 0) + return r; + osize = offsetof(Object, data.payload) + size; m = le64toh(f->header->data_hash_table_size) / sizeof(HashItem); @@ -2731,14 +2754,6 @@ int journal_file_open( #endif } - r = journal_file_map_field_hash_table(f); - if (r < 0) - goto fail; - - r = journal_file_map_data_hash_table(f); - if (r < 0) - goto fail; - if (mmap_cache_got_sigbus(f->mmap, f->fd)) { r = -EIO; goto fail; |