]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/journal/journal-def.h
add sparse support to detect endianness bug
[thirdparty/systemd.git] / src / journal / journal-def.h
CommitLineData
87d2c1ff
LP
1/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
2
3#ifndef foojournaldefhfoo
4#define foojournaldefhfoo
5
6/***
7 This file is part of systemd.
8
9 Copyright 2011 Lennart Poettering
10
11 systemd is free software; you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by
13 the Free Software Foundation; either version 2 of the License, or
14 (at your option) any later version.
15
16 systemd is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
20
21 You should have received a copy of the GNU General Public License
22 along with systemd; If not, see <http://www.gnu.org/licenses/>.
23***/
24
4fd052ae 25#include "sparse-endian.h"
87d2c1ff 26
81527be1
LP
27#include <systemd/sd-id128.h>
28
87d2c1ff 29#include "macro.h"
87d2c1ff
LP
30
31typedef struct Header Header;
32typedef struct ObjectHeader ObjectHeader;
33typedef union Object Object;
34typedef struct DataObject DataObject;
de190aef 35typedef struct FieldObject FieldObject;
87d2c1ff
LP
36typedef struct EntryObject EntryObject;
37typedef struct HashTableObject HashTableObject;
de190aef 38typedef struct EntryArrayObject EntryArrayObject;
87d2c1ff
LP
39typedef struct EntryItem EntryItem;
40typedef struct HashItem HashItem;
41
42/* Object types */
43enum {
44 OBJECT_UNUSED,
45 OBJECT_DATA,
de190aef 46 OBJECT_FIELD,
87d2c1ff 47 OBJECT_ENTRY,
de190aef
LP
48 OBJECT_DATA_HASH_TABLE,
49 OBJECT_FIELD_HASH_TABLE,
50 OBJECT_ENTRY_ARRAY,
51 _OBJECT_TYPE_MAX
87d2c1ff
LP
52};
53
807e17f0
LP
54/* Object flags */
55enum {
56 OBJECT_COMPRESSED = 1
57};
58
87d2c1ff
LP
59_packed_ struct ObjectHeader {
60 uint8_t type;
807e17f0
LP
61 uint8_t flags;
62 uint8_t reserved[6];
4fd052ae 63 le64_t size;
87d2c1ff
LP
64 uint8_t payload[];
65};
66
67_packed_ struct DataObject {
68 ObjectHeader object;
4fd052ae
FC
69 le64_t hash;
70 le64_t next_hash_offset;
71 le64_t next_field_offset;
72 le64_t entry_offset; /* the first array entry we store inline */
73 le64_t entry_array_offset;
74 le64_t n_entries;
de190aef
LP
75 uint8_t payload[];
76};
77
78_packed_ struct FieldObject {
79 ObjectHeader object;
4fd052ae
FC
80 le64_t hash;
81 le64_t next_hash_offset;
82 le64_t head_data_offset;
83 le64_t tail_data_offset;
87d2c1ff
LP
84 uint8_t payload[];
85};
86
87_packed_ struct EntryItem {
4fd052ae
FC
88 le64_t object_offset;
89 le64_t hash;
87d2c1ff
LP
90};
91
92_packed_ struct EntryObject {
93 ObjectHeader object;
4fd052ae
FC
94 le64_t seqnum;
95 le64_t realtime;
96 le64_t monotonic;
cec736d2 97 sd_id128_t boot_id;
4fd052ae 98 le64_t xor_hash;
87d2c1ff
LP
99 EntryItem items[];
100};
101
102_packed_ struct HashItem {
4fd052ae
FC
103 le64_t head_hash_offset;
104 le64_t tail_hash_offset;
87d2c1ff
LP
105};
106
107_packed_ struct HashTableObject {
108 ObjectHeader object;
de190aef 109 HashItem items[];
87d2c1ff
LP
110};
111
de190aef 112_packed_ struct EntryArrayObject {
87d2c1ff 113 ObjectHeader object;
4fd052ae
FC
114 le64_t next_entry_array_offset;
115 le64_t items[];
87d2c1ff
LP
116};
117
118union Object {
119 ObjectHeader object;
120 DataObject data;
de190aef 121 FieldObject field;
87d2c1ff
LP
122 EntryObject entry;
123 HashTableObject hash_table;
de190aef 124 EntryArrayObject entry_array;
87d2c1ff
LP
125};
126
127enum {
128 STATE_OFFLINE,
129 STATE_ONLINE,
130 STATE_ARCHIVED
131};
132
807e17f0
LP
133/* Header flags */
134enum {
135 HEADER_INCOMPATIBLE_COMPRESSED = 1
136};
137
87d2c1ff
LP
138_packed_ struct Header {
139 uint8_t signature[8]; /* "LPKSHHRH" */
140 uint32_t compatible_flags;
141 uint32_t incompatible_flags;
de190aef
LP
142 uint8_t state;
143 uint8_t reserved[7];
87d2c1ff
LP
144 sd_id128_t file_id;
145 sd_id128_t machine_id;
146 sd_id128_t boot_id;
cec736d2 147 sd_id128_t seqnum_id;
4fd052ae
FC
148 le64_t arena_offset;
149 le64_t arena_size;
150 le64_t data_hash_table_offset; /* for looking up data objects */
151 le64_t data_hash_table_size;
152 le64_t field_hash_table_offset; /* for looking up field objects */
153 le64_t field_hash_table_size;
154 le64_t tail_object_offset;
155 le64_t n_objects;
156 le64_t n_entries;
157 le64_t seqnum;
158 le64_t first_seqnum;
159 le64_t entry_array_offset;
160 le64_t head_entry_realtime;
161 le64_t tail_entry_realtime;
162 le64_t tail_entry_monotonic;
87d2c1ff
LP
163};
164
165#endif