chiark / gitweb /
journal: link up documentation with the file structure header
[elogind.git] / src / journal / journal-def.h
index 53f1e22cf07c6c03a13c4d652eb0240a30e79a65..351eec77c551fe35a1c2f86a4659dd5a677f89ad 100644 (file)
@@ -1,7 +1,6 @@
 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
 
-#ifndef foojournaldefhfoo
-#define foojournaldefhfoo
+#pragma once
 
 /***
   This file is part of systemd.
 
 #include "macro.h"
 
+/*
+ * If you change this file you probably should also change its documentation:
+ *
+ * http://www.freedesktop.org/wiki/Software/systemd/journal-files
+ *
+ */
+
 typedef struct Header Header;
+
 typedef struct ObjectHeader ObjectHeader;
 typedef union Object Object;
+
 typedef struct DataObject DataObject;
 typedef struct FieldObject FieldObject;
 typedef struct EntryObject EntryObject;
 typedef struct HashTableObject HashTableObject;
 typedef struct EntryArrayObject EntryArrayObject;
+typedef struct TagObject TagObject;
+
 typedef struct EntryItem EntryItem;
 typedef struct HashItem HashItem;
 
+typedef struct FSSHeader FSSHeader;
+
 /* Object types */
 enum {
         OBJECT_UNUSED,
@@ -48,6 +60,7 @@ enum {
         OBJECT_DATA_HASH_TABLE,
         OBJECT_FIELD_HASH_TABLE,
         OBJECT_ENTRY_ARRAY,
+        OBJECT_TAG,
         _OBJECT_TYPE_MAX
 };
 
@@ -80,7 +93,6 @@ _packed_ struct FieldObject {
         le64_t hash;
         le64_t next_hash_offset;
         le64_t head_data_offset;
-        le64_t tail_data_offset;
         uint8_t payload[];
 };
 
@@ -115,6 +127,15 @@ _packed_ struct EntryArrayObject {
         le64_t items[];
 };
 
+#define TAG_LENGTH (256/8)
+
+_packed_ struct TagObject {
+        ObjectHeader object;
+        uint64_t seqnum;
+        uint64_t epoch;
+        uint8_t tag[TAG_LENGTH]; /* SHA-256 HMAC */
+};
+
 union Object {
         ObjectHeader object;
         DataObject data;
@@ -122,12 +143,14 @@ union Object {
         EntryObject entry;
         HashTableObject hash_table;
         EntryArrayObject entry_array;
+        TagObject tag;
 };
 
 enum {
-        STATE_OFFLINE,
-        STATE_ONLINE,
-        STATE_ARCHIVED
+        STATE_OFFLINE = 0,
+        STATE_ONLINE = 1,
+        STATE_ARCHIVED = 2,
+        _STATE_MAX
 };
 
 /* Header flags */
@@ -135,31 +158,59 @@ enum {
         HEADER_INCOMPATIBLE_COMPRESSED = 1
 };
 
+enum {
+        HEADER_COMPATIBLE_SEALED = 1
+};
+
+#define HEADER_SIGNATURE ((char[]) { 'L', 'P', 'K', 'S', 'H', 'H', 'R', 'H' })
+
 _packed_ struct Header {
         uint8_t signature[8]; /* "LPKSHHRH" */
-        uint32_t compatible_flags;
-        uint32_t incompatible_flags;
+        le32_t compatible_flags;
+        le32_t incompatible_flags;
         uint8_t state;
         uint8_t reserved[7];
         sd_id128_t file_id;
         sd_id128_t machine_id;
-        sd_id128_t boot_id;
+        sd_id128_t boot_id;    /* last writer */
         sd_id128_t seqnum_id;
         le64_t header_size;
         le64_t arena_size;
-        le64_t data_hash_table_offset;     /* for looking up data objects */
+        le64_t data_hash_table_offset;
         le64_t data_hash_table_size;
-        le64_t field_hash_table_offset;     /* for looking up field objects */
+        le64_t field_hash_table_offset;
         le64_t field_hash_table_size;
         le64_t tail_object_offset;
         le64_t n_objects;
         le64_t n_entries;
-        le64_t seqnum;
-        le64_t first_seqnum;
+        le64_t tail_entry_seqnum;
+        le64_t head_entry_seqnum;
         le64_t entry_array_offset;
         le64_t head_entry_realtime;
         le64_t tail_entry_realtime;
         le64_t tail_entry_monotonic;
+        /* Added in 187 */
+        le64_t n_data;
+        le64_t n_fields;
+        /* Added in 189 */
+        le64_t n_tags;
+        le64_t n_entry_arrays;
+
+        /* Size: 224 */
 };
 
-#endif
+#define FSS_HEADER_SIGNATURE ((char[]) { 'K', 'S', 'H', 'H', 'R', 'H', 'L', 'P' })
+
+_packed_ struct FSSHeader {
+        uint8_t signature[8]; /* "KSHHRHLP" */
+        le32_t compatible_flags;
+        le32_t incompatible_flags;
+        sd_id128_t machine_id;
+        sd_id128_t boot_id;    /* last writer */
+        le64_t header_size;
+        le64_t start_usec;
+        le64_t interval_usec;
+        le16_t fsprg_secpar;
+        le16_t reserved[3];
+        le64_t fsprg_state_size;
+};