]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/journal/journal-internal.h
tree-wide: remove Lennart's copyright lines
[thirdparty/systemd.git] / src / journal / journal-internal.h
CommitLineData
53e1b683 1/* SPDX-License-Identifier: LGPL-2.1+ */
c2f1db8f 2#pragma once
f39e126e 3
f39e126e
LP
4#include <inttypes.h>
5#include <stdbool.h>
71d35b6b 6#include <sys/types.h>
f39e126e 7
07630cea
LP
8#include "sd-id128.h"
9#include "sd-journal.h"
81527be1 10
07630cea 11#include "hashmap.h"
cbdca852 12#include "journal-def.h"
07630cea 13#include "journal-file.h"
f39e126e 14#include "list.h"
6fe391c5 15#include "set.h"
cbdca852 16
f39e126e 17typedef struct Match Match;
a963990f
LP
18typedef struct Location Location;
19typedef struct Directory Directory;
20
cbdca852
LP
21typedef enum MatchType {
22 MATCH_DISCRETE,
23 MATCH_OR_TERM,
24 MATCH_AND_TERM
25} MatchType;
f39e126e
LP
26
27struct Match {
cbdca852
LP
28 MatchType type;
29 Match *parent;
30 LIST_FIELDS(Match, matches);
31
32 /* For concrete matches */
f39e126e
LP
33 char *data;
34 size_t size;
4fd052ae 35 le64_t le_hash;
f39e126e 36
cbdca852
LP
37 /* For terms */
38 LIST_HEAD(Match, matches);
f39e126e
LP
39};
40
a963990f 41struct Location {
cbdca852 42 LocationType type;
f39e126e 43
68667801
ZJS
44 bool seqnum_set;
45 bool realtime_set;
46 bool monotonic_set;
47 bool xor_hash_set;
48
f39e126e
LP
49 uint64_t seqnum;
50 sd_id128_t seqnum_id;
f39e126e
LP
51
52 uint64_t realtime;
f39e126e
LP
53
54 uint64_t monotonic;
55 sd_id128_t boot_id;
f39e126e
LP
56
57 uint64_t xor_hash;
a963990f
LP
58};
59
60struct Directory {
61 char *path;
62 int wd;
63 bool is_root;
858749f7 64 unsigned last_seen_generation;
a963990f 65};
f39e126e
LP
66
67struct sd_journal {
5d1ce257
LP
68 int toplevel_fd;
69
7827b1a1 70 char *path;
89739579 71 char *prefix;
7827b1a1 72
c1f906bd 73 OrderedHashmap *files;
5d4ba7f2 74 IteratedCache *files_cache;
16e9f408 75 MMapCache *mmap;
f39e126e
LP
76
77 Location current_location;
cbdca852 78
f39e126e
LP
79 JournalFile *current_file;
80 uint64_t current_field;
81
cd34b3c6 82 Match *level0, *level1, *level2;
a963990f 83
a65f06bb
ZJS
84 pid_t original_pid;
85
86 int inotify_fd;
a963990f 87 unsigned current_invalidate_counter, last_invalidate_counter;
a65f06bb 88 usec_t last_process_usec;
858749f7 89 unsigned generation;
3c1668da 90
eb86030e 91 /* Iterating through unique fields and their data values */
3c1668da
LP
92 char *unique_field;
93 JournalFile *unique_file;
94 uint64_t unique_offset;
85210bff 95
eb86030e
LP
96 /* Iterating through known fields */
97 JournalFile *fields_file;
98 uint64_t fields_offset;
99 uint64_t fields_hash_table_index;
100 char *fields_buffer;
101 size_t fields_buffer_allocated;
102
a65f06bb
ZJS
103 int flags;
104
eb86030e
LP
105 bool on_network:1;
106 bool no_new_files:1;
5d1ce257 107 bool no_inotify:1;
eb86030e
LP
108 bool unique_file_lost:1; /* File we were iterating over got
109 removed, and there were no more
110 files, so sd_j_enumerate_unique
111 will return a value equal to 0. */
112 bool fields_file_lost:1;
39fd5b08
JS
113 bool has_runtime_files:1;
114 bool has_persistent_files:1;
93b73b06
LP
115
116 size_t data_threshold;
6fe391c5 117
a65f06bb
ZJS
118 Hashmap *directories_by_path;
119 Hashmap *directories_by_wd;
39c155ea 120
5768d259 121 Hashmap *errors;
f39e126e
LP
122};
123
cbdca852 124char *journal_make_match_string(sd_journal *j);
dca6219e 125void journal_print_header(sd_journal *j);
dfb33a97 126
a72b6353
ZJS
127#define JOURNAL_FOREACH_DATA_RETVAL(j, data, l, retval) \
128 for (sd_journal_restart_data(j); ((retval) = sd_journal_enumerate_data((j), &(data), &(l))) > 0; )