]> git.proxmox.com Git - systemd.git/blame - src/journal/journal-def.h
Imported Upstream version 229
[systemd.git] / src / journal / journal-def.h
CommitLineData
663996b3
MS
1#pragma once
2
3/***
4 This file is part of systemd.
5
6 Copyright 2011 Lennart Poettering
7
8 systemd is free software; you can redistribute it and/or modify it
9 under the terms of the GNU Lesser General Public License as published by
10 the Free Software Foundation; either version 2.1 of the License, or
11 (at your option) any later version.
12
13 systemd is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Lesser General Public License for more details.
17
18 You should have received a copy of the GNU Lesser General Public License
19 along with systemd; If not, see <http://www.gnu.org/licenses/>.
20***/
21
db2df898 22#include "sd-id128.h"
663996b3
MS
23
24#include "macro.h"
db2df898 25#include "sparse-endian.h"
663996b3
MS
26
27/*
28 * If you change this file you probably should also change its documentation:
29 *
30 * http://www.freedesktop.org/wiki/Software/systemd/journal-files
31 *
32 */
33
34typedef struct Header Header;
35
36typedef struct ObjectHeader ObjectHeader;
37typedef union Object Object;
38
39typedef struct DataObject DataObject;
40typedef struct FieldObject FieldObject;
41typedef struct EntryObject EntryObject;
42typedef struct HashTableObject HashTableObject;
43typedef struct EntryArrayObject EntryArrayObject;
44typedef struct TagObject TagObject;
45
46typedef struct EntryItem EntryItem;
47typedef struct HashItem HashItem;
48
49typedef struct FSSHeader FSSHeader;
50
51/* Object types */
e735f4d4
MP
52typedef enum ObjectType {
53 OBJECT_UNUSED, /* also serves as "any type" or "additional context" */
663996b3
MS
54 OBJECT_DATA,
55 OBJECT_FIELD,
56 OBJECT_ENTRY,
57 OBJECT_DATA_HASH_TABLE,
58 OBJECT_FIELD_HASH_TABLE,
59 OBJECT_ENTRY_ARRAY,
60 OBJECT_TAG,
61 _OBJECT_TYPE_MAX
e735f4d4 62} ObjectType;
663996b3
MS
63
64/* Object flags */
65enum {
5eef597e
MP
66 OBJECT_COMPRESSED_XZ = 1 << 0,
67 OBJECT_COMPRESSED_LZ4 = 1 << 1,
68 _OBJECT_COMPRESSED_MAX
663996b3
MS
69};
70
5eef597e
MP
71#define OBJECT_COMPRESSION_MASK (OBJECT_COMPRESSED_XZ | OBJECT_COMPRESSED_LZ4)
72
663996b3
MS
73struct ObjectHeader {
74 uint8_t type;
75 uint8_t flags;
76 uint8_t reserved[6];
77 le64_t size;
78 uint8_t payload[];
79} _packed_;
80
81struct DataObject {
82 ObjectHeader object;
83 le64_t hash;
84 le64_t next_hash_offset;
85 le64_t next_field_offset;
86 le64_t entry_offset; /* the first array entry we store inline */
87 le64_t entry_array_offset;
88 le64_t n_entries;
89 uint8_t payload[];
90} _packed_;
91
92struct FieldObject {
93 ObjectHeader object;
94 le64_t hash;
95 le64_t next_hash_offset;
96 le64_t head_data_offset;
97 uint8_t payload[];
98} _packed_;
99
100struct EntryItem {
101 le64_t object_offset;
102 le64_t hash;
103} _packed_;
104
105struct EntryObject {
106 ObjectHeader object;
107 le64_t seqnum;
108 le64_t realtime;
109 le64_t monotonic;
110 sd_id128_t boot_id;
111 le64_t xor_hash;
112 EntryItem items[];
113} _packed_;
114
115struct HashItem {
116 le64_t head_hash_offset;
117 le64_t tail_hash_offset;
118} _packed_;
119
120struct HashTableObject {
121 ObjectHeader object;
122 HashItem items[];
123} _packed_;
124
125struct EntryArrayObject {
126 ObjectHeader object;
127 le64_t next_entry_array_offset;
128 le64_t items[];
129} _packed_;
130
131#define TAG_LENGTH (256/8)
132
133struct TagObject {
134 ObjectHeader object;
135 le64_t seqnum;
136 le64_t epoch;
137 uint8_t tag[TAG_LENGTH]; /* SHA-256 HMAC */
138} _packed_;
139
140union Object {
141 ObjectHeader object;
142 DataObject data;
143 FieldObject field;
144 EntryObject entry;
145 HashTableObject hash_table;
146 EntryArrayObject entry_array;
147 TagObject tag;
148};
149
150enum {
151 STATE_OFFLINE = 0,
152 STATE_ONLINE = 1,
153 STATE_ARCHIVED = 2,
154 _STATE_MAX
155};
156
157/* Header flags */
158enum {
5eef597e
MP
159 HEADER_INCOMPATIBLE_COMPRESSED_XZ = 1 << 0,
160 HEADER_INCOMPATIBLE_COMPRESSED_LZ4 = 1 << 1,
663996b3
MS
161};
162
5eef597e
MP
163#define HEADER_INCOMPATIBLE_ANY (HEADER_INCOMPATIBLE_COMPRESSED_XZ|HEADER_INCOMPATIBLE_COMPRESSED_LZ4)
164
165#if defined(HAVE_XZ) && defined(HAVE_LZ4)
166# define HEADER_INCOMPATIBLE_SUPPORTED HEADER_INCOMPATIBLE_ANY
167#elif defined(HAVE_XZ)
168# define HEADER_INCOMPATIBLE_SUPPORTED HEADER_INCOMPATIBLE_COMPRESSED_XZ
169#elif defined(HAVE_LZ4)
170# define HEADER_INCOMPATIBLE_SUPPORTED HEADER_INCOMPATIBLE_COMPRESSED_LZ4
171#else
172# define HEADER_INCOMPATIBLE_SUPPORTED 0
173#endif
174
663996b3
MS
175enum {
176 HEADER_COMPATIBLE_SEALED = 1
177};
178
5eef597e
MP
179#define HEADER_COMPATIBLE_ANY HEADER_COMPATIBLE_SEALED
180#ifdef HAVE_GCRYPT
181# define HEADER_COMPATIBLE_SUPPORTED HEADER_COMPATIBLE_SEALED
182#else
183# define HEADER_COMPATIBLE_SUPPORTED 0
184#endif
185
663996b3
MS
186#define HEADER_SIGNATURE ((char[]) { 'L', 'P', 'K', 'S', 'H', 'H', 'R', 'H' })
187
188struct Header {
189 uint8_t signature[8]; /* "LPKSHHRH" */
190 le32_t compatible_flags;
191 le32_t incompatible_flags;
192 uint8_t state;
193 uint8_t reserved[7];
194 sd_id128_t file_id;
195 sd_id128_t machine_id;
196 sd_id128_t boot_id; /* last writer */
197 sd_id128_t seqnum_id;
198 le64_t header_size;
199 le64_t arena_size;
200 le64_t data_hash_table_offset;
201 le64_t data_hash_table_size;
202 le64_t field_hash_table_offset;
203 le64_t field_hash_table_size;
204 le64_t tail_object_offset;
205 le64_t n_objects;
206 le64_t n_entries;
207 le64_t tail_entry_seqnum;
208 le64_t head_entry_seqnum;
209 le64_t entry_array_offset;
210 le64_t head_entry_realtime;
211 le64_t tail_entry_realtime;
212 le64_t tail_entry_monotonic;
213 /* Added in 187 */
214 le64_t n_data;
215 le64_t n_fields;
216 /* Added in 189 */
217 le64_t n_tags;
218 le64_t n_entry_arrays;
219
e3bff60a 220 /* Size: 240 */
663996b3
MS
221} _packed_;
222
223#define FSS_HEADER_SIGNATURE ((char[]) { 'K', 'S', 'H', 'H', 'R', 'H', 'L', 'P' })
224
225struct FSSHeader {
226 uint8_t signature[8]; /* "KSHHRHLP" */
227 le32_t compatible_flags;
228 le32_t incompatible_flags;
229 sd_id128_t machine_id;
230 sd_id128_t boot_id; /* last writer */
231 le64_t header_size;
232 le64_t start_usec;
233 le64_t interval_usec;
234 le16_t fsprg_secpar;
235 le16_t reserved[3];
236 le64_t fsprg_state_size;
237} _packed_;