X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;ds=sidebyside;f=src%2Fjournal%2Fjournal-file.h;h=21b0821b6b246fbb5cf98cb82a4cded6cc1f64b4;hb=b8e891e699e1336c5527f8203e4e8f67c9bbeb84;hp=f52ee8c538459fce23924c6ed4006cb463a0c0f2;hpb=fb0951b02ebf51a93acf12721d8857d31ce57ba3;p=elogind.git diff --git a/src/journal/journal-file.h b/src/journal/journal-file.h index f52ee8c53..21b0821b6 100644 --- a/src/journal/journal-file.h +++ b/src/journal/journal-file.h @@ -33,6 +33,7 @@ #include "journal-def.h" #include "util.h" #include "mmap-cache.h" +#include "hashmap.h" typedef struct JournalMetrics { uint64_t max_use; @@ -41,19 +42,28 @@ typedef struct JournalMetrics { uint64_t keep_free; } JournalMetrics; +typedef enum direction { + DIRECTION_UP, + DIRECTION_DOWN +} direction_t; + typedef struct JournalFile { int fd; - char *path; - struct stat last_stat; + mode_t mode; int flags; int prot; - bool writable; - bool compress; - bool seal; + bool writable:1; + bool compress:1; + bool seal:1; - bool tail_entry_monotonic_valid; + bool tail_entry_monotonic_valid:1; + + direction_t last_direction; + + char *path; + struct stat last_stat; Header *header; HashItem *data_hash_table; @@ -64,6 +74,8 @@ typedef struct JournalFile { JournalMetrics metrics; MMapCache *mmap; + Hashmap *chain_cache; + #ifdef HAVE_XZ void *compress_buffer; uint64_t compress_buffer_size; @@ -87,11 +99,6 @@ typedef struct JournalFile { #endif } JournalFile; -typedef enum direction { - DIRECTION_UP, - DIRECTION_DOWN -} direction_t; - int journal_file_open( const char *fname, int flags, @@ -103,6 +110,7 @@ int journal_file_open( JournalFile *template, JournalFile **ret); +int journal_file_set_offline(JournalFile *f); void journal_file_close(JournalFile *j); int journal_file_open_reliably( @@ -145,9 +153,9 @@ static inline bool VALID_EPOCH(uint64_t u) { int journal_file_move_to_object(JournalFile *f, int type, uint64_t offset, Object **ret); -uint64_t journal_file_entry_n_items(Object *o); -uint64_t journal_file_entry_array_n_items(Object *o); -uint64_t journal_file_hash_table_n_items(Object *o); +uint64_t journal_file_entry_n_items(Object *o) _pure_; +uint64_t journal_file_entry_array_n_items(Object *o) _pure_; +uint64_t journal_file_hash_table_n_items(Object *o) _pure_; int journal_file_append_object(JournalFile *f, int type, uint64_t size, Object **ret, uint64_t *offset); int journal_file_append_entry(JournalFile *f, const dual_timestamp *ts, const struct iovec iovec[], unsigned n_iovec, uint64_t *seqno, Object **ret, uint64_t *offset); @@ -155,6 +163,9 @@ int journal_file_append_entry(JournalFile *f, const dual_timestamp *ts, const st int journal_file_find_data_object(JournalFile *f, const void *data, uint64_t size, Object **ret, uint64_t *offset); int journal_file_find_data_object_with_hash(JournalFile *f, const void *data, uint64_t size, uint64_t hash, Object **ret, uint64_t *offset); +int journal_file_find_field_object(JournalFile *f, const void *field, uint64_t size, Object **ret, uint64_t *offset); +int journal_file_find_field_object_with_hash(JournalFile *f, const void *field, uint64_t size, uint64_t hash, Object **ret, uint64_t *offset); + int journal_file_next_entry(JournalFile *f, Object *o, uint64_t p, direction_t direction, Object **ret, uint64_t *offset); int journal_file_skip_entry(JournalFile *f, Object *o, uint64_t p, int64_t skip, Object **ret, uint64_t *offset);