]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/libsystemd/sd-hwdb/hwdb-internal.h
license: LGPL-2.1+ -> LGPL-2.1-or-later
[thirdparty/systemd.git] / src / libsystemd / sd-hwdb / hwdb-internal.h
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2 #pragma once
3
4 #include <stdint.h>
5
6 #include "sparse-endian.h"
7
8 #define HWDB_SIG { 'K', 'S', 'L', 'P', 'H', 'H', 'R', 'H' }
9
10 /* on-disk trie objects */
11 struct trie_header_f {
12 uint8_t signature[8];
13
14 /* version of tool which created the file */
15 le64_t tool_version;
16 le64_t file_size;
17
18 /* size of structures to allow them to grow */
19 le64_t header_size;
20 le64_t node_size;
21 le64_t child_entry_size;
22 le64_t value_entry_size;
23
24 /* offset of the root trie node */
25 le64_t nodes_root_off;
26
27 /* size of the nodes and string section */
28 le64_t nodes_len;
29 le64_t strings_len;
30 } _packed_;
31
32 struct trie_node_f {
33 /* prefix of lookup string, shared by all children */
34 le64_t prefix_off;
35 /* size of children entry array appended to the node */
36 uint8_t children_count;
37 uint8_t padding[7];
38 /* size of value entry array appended to the node */
39 le64_t values_count;
40 } _packed_;
41
42 /* array of child entries, follows directly the node record */
43 struct trie_child_entry_f {
44 /* index of the child node */
45 uint8_t c;
46 uint8_t padding[7];
47 /* offset of the child node */
48 le64_t child_off;
49 } _packed_;
50
51 /* array of value entries, follows directly the node record/child array */
52 struct trie_value_entry_f {
53 le64_t key_off;
54 le64_t value_off;
55 } _packed_;
56
57 /* v2 extends v1 with filename and line-number */
58 struct trie_value_entry2_f {
59 le64_t key_off;
60 le64_t value_off;
61 le64_t filename_off;
62 le32_t line_number;
63 le16_t file_priority;
64 le16_t padding;
65 } _packed_;