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