X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fjournal%2Fjournal-file.c;h=038b437e1ff25642d357c81c5c86cabb02c549f9;hb=bf3d3e2bb7ae2d3854be57f28dd1403c8f7e4c3c;hp=b6de502da8a7e2a36fa8d0e06ce7cfcf52ba2109;hpb=d89c8fdf48c7bad5816b9f2e77e8361721f22517;p=elogind.git diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c index b6de502da..038b437e1 100644 --- a/src/journal/journal-file.c +++ b/src/journal/journal-file.c @@ -279,12 +279,6 @@ static int journal_file_verify_header(JournalFile *f) { !VALID64(le64toh(f->header->entry_array_offset))) return -ENODATA; - if (le64toh(f->header->data_hash_table_offset) < le64toh(f->header->header_size) || - le64toh(f->header->field_hash_table_offset) < le64toh(f->header->header_size) || - le64toh(f->header->tail_object_offset) < le64toh(f->header->header_size) || - le64toh(f->header->entry_array_offset) < le64toh(f->header->header_size)) - return -ENODATA; - if (f->writable) { uint8_t state; sd_id128_t machine_id; @@ -397,7 +391,7 @@ static int journal_file_move_to(JournalFile *f, int context, bool keep_always, u return -EADDRNOTAVAIL; } - return mmap_cache_get(f->mmap, f->fd, f->prot, context, keep_always, offset, size, &f->last_stat, ret); + return mmap_cache_get(f->mmap, f->fd, f->prot, context, keep_always, offset, size, &f->last_stat, ret, NULL); } static uint64_t minimum_header_size(Object *o) { @@ -431,7 +425,6 @@ int journal_file_move_to_object(JournalFile *f, int type, uint64_t offset, Objec if (!VALID64(offset)) return -EFAULT; - r = journal_file_move_to(f, type_to_context(type), false, offset, sizeof(ObjectHeader), &t); if (r < 0) return r; @@ -819,7 +812,9 @@ int journal_file_find_data_object_with_hash( goto next; if (o->object.flags & OBJECT_COMPRESSION_MASK) { - uint64_t l, rsize; +#if defined(HAVE_XZ) || defined(HAVE_LZ4) + uint64_t l; + size_t rsize; l = le64toh(o->object.size); if (l <= offsetof(Object, data.payload)) @@ -843,7 +838,9 @@ int journal_file_find_data_object_with_hash( return 1; } - +#else + return -EPROTONOSUPPORT; +#endif } else if (le64toh(o->object.size) == osize && memcmp(o->data.payload, data, size) == 0) { @@ -982,7 +979,7 @@ static int journal_file_append_data( #if defined(HAVE_XZ) || defined(HAVE_LZ4) if (f->compress_xz && size >= COMPRESSION_SIZE_THRESHOLD) { - uint64_t rsize; + size_t rsize; compression = compress_blob(data, size, o->data.payload, &rsize); @@ -990,7 +987,7 @@ static int journal_file_append_data( o->object.size = htole64(offsetof(Object, data.payload) + rsize); o->object.flags |= compression; - log_debug("Compressed data object %"PRIu64" -> %"PRIu64" using %s", + log_debug("Compressed data object %"PRIu64" -> %zu using %s", size, rsize, object_compressed_to_string(compression)); } } @@ -2476,7 +2473,7 @@ int journal_file_open( f->flags = flags; f->prot = prot_from_flags(flags); f->writable = (flags & O_ACCMODE) != O_RDONLY; -#if defined(HAVE_LZ) +#if defined(HAVE_LZ4) f->compress_lz4 = compress; #elif defined(HAVE_XZ) f->compress_xz = compress; @@ -2501,7 +2498,7 @@ int journal_file_open( goto fail; } - f->chain_cache = hashmap_new(uint64_hash_func, uint64_compare_func); + f->chain_cache = hashmap_new(&uint64_hash_ops); if (!f->chain_cache) { r = -ENOMEM; goto fail; @@ -2772,7 +2769,8 @@ int journal_file_copy_entry(JournalFile *from, JournalFile *to, Object *o, uint6 return -E2BIG; if (o->object.flags & OBJECT_COMPRESSION_MASK) { - uint64_t rsize; +#if defined(HAVE_XZ) || defined(HAVE_LZ4) + size_t rsize; r = decompress_blob(o->object.flags & OBJECT_COMPRESSION_MASK, o->data.payload, l, &from->compress_buffer, &from->compress_buffer_size, &rsize, 0); @@ -2781,6 +2779,9 @@ int journal_file_copy_entry(JournalFile *from, JournalFile *to, Object *o, uint6 data = from->compress_buffer; l = rsize; +#else + return -EPROTONOSUPPORT; +#endif } else data = o->data.payload;