]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/libsystemd/sd-hwdb/hwdb-internal.h
hwdb: store file-name and file-number with properties
[thirdparty/systemd.git] / src / libsystemd / sd-hwdb / hwdb-internal.h
1 #pragma once
2
3 /***
4 This file is part of systemd.
5
6 Copyright 2012 Kay Sievers <kay@vrfy.org>
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
22 #include "sparse-endian.h"
23 #include "util.h"
24
25 #define HWDB_SIG { 'K', 'S', 'L', 'P', 'H', 'H', 'R', 'H' }
26
27 /* on-disk trie objects */
28 struct trie_header_f {
29 uint8_t signature[8];
30
31 /* version of tool which created the file */
32 le64_t tool_version;
33 le64_t file_size;
34
35 /* size of structures to allow them to grow */
36 le64_t header_size;
37 le64_t node_size;
38 le64_t child_entry_size;
39 le64_t value_entry_size;
40
41 /* offset of the root trie node */
42 le64_t nodes_root_off;
43
44 /* size of the nodes and string section */
45 le64_t nodes_len;
46 le64_t strings_len;
47 } _packed_;
48
49 struct trie_node_f {
50 /* prefix of lookup string, shared by all children */
51 le64_t prefix_off;
52 /* size of children entry array appended to the node */
53 uint8_t children_count;
54 uint8_t padding[7];
55 /* size of value entry array appended to the node */
56 le64_t values_count;
57 } _packed_;
58
59 /* array of child entries, follows directly the node record */
60 struct trie_child_entry_f {
61 /* index of the child node */
62 uint8_t c;
63 uint8_t padding[7];
64 /* offset of the child node */
65 le64_t child_off;
66 } _packed_;
67
68 /* array of value entries, follows directly the node record/child array */
69 struct trie_value_entry_f {
70 le64_t key_off;
71 le64_t value_off;
72 } _packed_;
73
74 /* v2 extends v1 with filename and line-number */
75 struct trie_value_entry2_f {
76 le64_t key_off;
77 le64_t value_off;
78 le64_t filename_off;
79 le64_t line_number;
80 } _packed_;