]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/journal/journal-internal.h
journal: by default do not decompress dat objects larger than 64K
[thirdparty/systemd.git] / src / journal / journal-internal.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 <sys/types.h>
25 #include <inttypes.h>
26 #include <stdbool.h>
27
28 #include <systemd/sd-id128.h>
29
30 #include "journal-def.h"
31 #include "list.h"
32 #include "hashmap.h"
33 #include "journal-file.h"
34
35 typedef struct Match Match;
36 typedef struct Location Location;
37 typedef struct Directory Directory;
38
39 typedef enum MatchType {
40 MATCH_DISCRETE,
41 MATCH_OR_TERM,
42 MATCH_AND_TERM
43 } MatchType;
44
45 struct Match {
46 MatchType type;
47 Match *parent;
48 LIST_FIELDS(Match, matches);
49
50 /* For concrete matches */
51 char *data;
52 size_t size;
53 le64_t le_hash;
54
55 /* For terms */
56 LIST_HEAD(Match, matches);
57 };
58
59 typedef enum LocationType {
60 /* The first and last entries, resp. */
61 LOCATION_HEAD,
62 LOCATION_TAIL,
63
64 /* We already read the entry we currently point to, and the
65 * next one to read should probably not be this one again. */
66 LOCATION_DISCRETE,
67
68 /* We should seek to the precise location specified, and
69 * return it, as we haven't read it yet. */
70 LOCATION_SEEK
71 } LocationType;
72
73 struct Location {
74 LocationType type;
75
76 uint64_t seqnum;
77 sd_id128_t seqnum_id;
78 bool seqnum_set;
79
80 uint64_t realtime;
81 bool realtime_set;
82
83 uint64_t monotonic;
84 sd_id128_t boot_id;
85 bool monotonic_set;
86
87 uint64_t xor_hash;
88 bool xor_hash_set;
89 };
90
91 struct Directory {
92 char *path;
93 int wd;
94 bool is_root;
95 };
96
97 struct sd_journal {
98 int flags;
99
100 char *path;
101
102 Hashmap *files;
103 MMapCache *mmap;
104
105 Location current_location;
106
107 JournalFile *current_file;
108 uint64_t current_field;
109
110 Hashmap *directories_by_path;
111 Hashmap *directories_by_wd;
112
113 int inotify_fd;
114
115 Match *level0, *level1;
116
117 unsigned current_invalidate_counter, last_invalidate_counter;
118
119 char *unique_field;
120 JournalFile *unique_file;
121 uint64_t unique_offset;
122
123 bool on_network;
124
125 size_t data_threshold;
126 };
127
128 char *journal_make_match_string(sd_journal *j);
129 void journal_print_header(sd_journal *j);