chiark / gitweb /
0d865ae2a20ab46a5f3ceda3b65481f15329ef5f
[elogind.git] / src / journal / journal-def.h
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
25 #include <inttypes.h>
26
27 #include "macro.h"
28 #include "sd-id128.h"
29
30 typedef struct Header Header;
31 typedef struct ObjectHeader ObjectHeader;
32 typedef union Object Object;
33 typedef struct DataObject DataObject;
34 typedef struct EntryObject EntryObject;
35 typedef struct HashTableObject HashTableObject;
36 typedef struct BisectTableObject BisectTableObject;
37 typedef struct EntryItem EntryItem;
38 typedef struct HashItem HashItem;
39
40 /* Object types */
41 enum {
42         OBJECT_UNUSED,
43         OBJECT_DATA,
44         OBJECT_ENTRY,
45         OBJECT_HASH_TABLE,
46         OBJECT_BISECT_TABLE
47 };
48
49 _packed_ struct ObjectHeader {
50         uint8_t type;
51         uint8_t reserved[3];
52         uint64_t size;
53         uint8_t payload[];
54 };
55
56 _packed_ struct DataObject {
57         ObjectHeader object;
58         uint64_t hash;
59         uint64_t head_entry_offset;
60         uint64_t tail_entry_offset;
61         uint64_t prev_hash_offset;
62         uint64_t next_hash_offset;
63         uint8_t payload[];
64 };
65
66 _packed_ struct EntryItem {
67         uint64_t object_offset;
68         uint64_t prev_entry_offset;
69         uint64_t next_entry_offset;
70 };
71
72 _packed_ struct EntryObject {
73         ObjectHeader object;
74         uint64_t seqnum;
75         uint64_t realtime;
76         uint64_t monotonic;
77         uint64_t prev_entry_offset;
78         uint64_t next_entry_offset;
79         EntryItem items[];
80 };
81
82 _packed_ struct HashItem {
83         uint64_t head_hash_offset;
84         uint64_t tail_hash_offset;
85 };
86
87 _packed_ struct HashTableObject {
88         ObjectHeader object;
89         HashItem table[];
90 };
91
92 _packed_ struct BisectTableObject {
93         ObjectHeader object;
94         uint64_t table[];
95 };
96
97 union Object {
98         ObjectHeader object;
99         DataObject data;
100         EntryObject entry;
101         HashTableObject hash_table;
102         BisectTableObject bisect_table;
103 };
104
105 enum {
106         STATE_OFFLINE,
107         STATE_ONLINE,
108         STATE_ARCHIVED
109 };
110
111 _packed_ struct Header {
112         uint8_t signature[8]; /* "LPKSHHRH" */
113         uint32_t compatible_flags;
114         uint32_t incompatible_flags;
115         uint32_t state;
116         uint8_t reserved[4];
117         sd_id128_t file_id;
118         sd_id128_t machine_id;
119         sd_id128_t boot_id;
120         uint64_t arena_offset;
121         uint64_t arena_size;
122         uint64_t arena_max_size;
123         uint64_t arena_min_size;
124         uint64_t arena_keep_free;
125         uint64_t hash_table_offset;     /* for looking up data objects */
126         uint64_t hash_table_size;
127         uint64_t bisect_table_offset;   /* for looking up entry objects */
128         uint64_t bisect_table_size;
129         uint64_t head_object_offset;
130         uint64_t tail_object_offset;
131         uint64_t head_entry_offset;
132         uint64_t tail_entry_offset;
133         uint64_t last_bisect_offset;
134         uint64_t n_objects;
135         uint64_t seqnum_base;
136         uint64_t seqnum;
137 };
138
139 #endif