1 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
6 This file is part of systemd.
8 Copyright 2011 Lennart Poettering
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.
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.
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/>.
24 #include "sparse-endian.h"
26 #include <systemd/sd-id128.h>
30 typedef struct Header Header;
32 typedef struct ObjectHeader ObjectHeader;
33 typedef union Object Object;
35 typedef struct DataObject DataObject;
36 typedef struct FieldObject FieldObject;
37 typedef struct EntryObject EntryObject;
38 typedef struct HashTableObject HashTableObject;
39 typedef struct EntryArrayObject EntryArrayObject;
40 typedef struct TagObject TagObject;
42 typedef struct EntryItem EntryItem;
43 typedef struct HashItem HashItem;
45 typedef struct FSSHeader FSSHeader;
50 OBJECT_DATA, /* !!! */
53 OBJECT_DATA_HASH_TABLE,
54 OBJECT_FIELD_HASH_TABLE,
55 OBJECT_ENTRY_ARRAY, /* !!! */
65 _packed_ struct ObjectHeader {
73 _packed_ struct DataObject {
76 le64_t next_hash_offset;
77 le64_t next_field_offset;
78 le64_t entry_offset; /* the first array entry we store inline */
79 le64_t entry_array_offset;
84 _packed_ struct FieldObject {
87 le64_t next_hash_offset;
88 le64_t head_data_offset;
92 _packed_ struct EntryItem {
97 _packed_ struct EntryObject {
107 _packed_ struct HashItem {
108 le64_t head_hash_offset;
109 le64_t tail_hash_offset;
112 _packed_ struct HashTableObject {
117 _packed_ struct EntryArrayObject {
119 le64_t next_entry_array_offset;
123 #define TAG_LENGTH (256/8)
125 _packed_ struct TagObject {
129 uint8_t tag[TAG_LENGTH]; /* SHA-256 HMAC */
137 HashTableObject hash_table;
138 EntryArrayObject entry_array;
151 HEADER_INCOMPATIBLE_COMPRESSED = 1
155 HEADER_COMPATIBLE_SEALED = 1
158 #define HEADER_SIGNATURE ((char[]) { 'L', 'P', 'K', 'S', 'H', 'H', 'R', 'H' })
160 _packed_ struct Header {
161 uint8_t signature[8]; /* "LPKSHHRH" */
162 le32_t compatible_flags;
163 le32_t incompatible_flags;
167 sd_id128_t machine_id;
168 sd_id128_t boot_id; /* last writer */
169 sd_id128_t seqnum_id;
172 le64_t data_hash_table_offset; /* for looking up data objects */
173 le64_t data_hash_table_size;
174 le64_t field_hash_table_offset; /* for looking up field objects */
175 le64_t field_hash_table_size;
176 le64_t tail_object_offset;
179 le64_t tail_entry_seqnum;
180 le64_t head_entry_seqnum;
181 le64_t entry_array_offset;
182 le64_t head_entry_realtime;
183 le64_t tail_entry_realtime;
184 le64_t tail_entry_monotonic;
190 le64_t n_entry_arrays;
195 #define FSS_HEADER_SIGNATURE ((char[]) { 'K', 'S', 'H', 'H', 'R', 'H', 'L', 'P' })
197 _packed_ struct FSSHeader {
198 uint8_t signature[8]; /* "KSHHRHLP" */
199 le32_t compatible_flags;
200 le32_t incompatible_flags;
201 sd_id128_t machine_id;
202 sd_id128_t boot_id; /* last writer */
205 le64_t interval_usec;
208 le64_t fsprg_state_size;