chiark / gitweb /
journald: log when we fail to forward messages to syslog
[elogind.git] / src / journal / journal-file.h
index 9d437ae791062207cc61be150cdc5bccbd000089..5b1530e7a7ae4119bc6c08140035bc41e6f3448c 100644 (file)
@@ -51,7 +51,7 @@ typedef struct JournalFile {
         int prot;
         bool writable;
         bool compress;
-        bool authenticate;
+        bool seal;
 
         bool tail_entry_monotonic_valid;
 
@@ -73,17 +73,17 @@ typedef struct JournalFile {
         gcry_md_hd_t hmac;
         bool hmac_running;
 
-        FSPRGHeader *fsprg_file;
-        size_t fsprg_file_size;
+        FSSHeader *fss_file;
+        size_t fss_file_size;
+
+        uint64_t fss_start_usec;
+        uint64_t fss_interval_usec;
 
         void *fsprg_state;
         size_t fsprg_state_size;
 
         void *fsprg_seed;
         size_t fsprg_seed_size;
-
-        uint64_t fsprg_start_usec;
-        uint64_t fsprg_interval_usec;
 #endif
 } JournalFile;
 
@@ -97,7 +97,7 @@ int journal_file_open(
                 int flags,
                 mode_t mode,
                 bool compress,
-                bool authenticate,
+                bool seal,
                 JournalMetrics *metrics,
                 MMapCache *mmap_cache,
                 JournalFile *template,
@@ -110,21 +110,44 @@ int journal_file_open_reliably(
                 int flags,
                 mode_t mode,
                 bool compress,
-                bool authenticate,
+                bool seal,
                 JournalMetrics *metrics,
                 MMapCache *mmap_cache,
                 JournalFile *template,
                 JournalFile **ret);
 
 #define ALIGN64(x) (((x) + 7ULL) & ~7ULL)
+#define VALID64(x) (((x) & 7ULL) == 0ULL)
+
+static inline bool VALID_REALTIME(uint64_t u) {
+        /* This considers timestamps until the year 3112 valid. That should be plenty room... */
+        return u > 0 && u < (1ULL << 55);
+}
+
+static inline bool VALID_MONOTONIC(uint64_t u) {
+        /* This considers timestamps until 1142 years of runtime valid. */
+        return u < (1ULL << 55);
+}
+
+static inline bool VALID_EPOCH(uint64_t u) {
+        /* This allows changing the key for 1142 years, every usec. */
+        return u < (1ULL << 55);
+}
 
 #define JOURNAL_HEADER_CONTAINS(h, field) \
         (le64toh((h)->header_size) >= offsetof(Header, field) + sizeof((h)->field))
 
+#define JOURNAL_HEADER_SEALED(h) \
+        (!!(le32toh((h)->compatible_flags) & HEADER_COMPATIBLE_SEALED))
+
+#define JOURNAL_HEADER_COMPRESSED(h) \
+        (!!(le32toh((h)->incompatible_flags) & HEADER_INCOMPATIBLE_COMPRESSED))
+
 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);
 
 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);
@@ -152,7 +175,7 @@ int journal_file_copy_entry(JournalFile *from, JournalFile *to, Object *o, uint6
 void journal_file_dump(JournalFile *f);
 void journal_file_print_header(JournalFile *f);
 
-int journal_file_rotate(JournalFile **f, bool compress, bool authenticate);
+int journal_file_rotate(JournalFile **f, bool compress, bool seal);
 
 void journal_file_post_change(JournalFile *f);