]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/journal/journal-internal.h
Merge pull request #15840 from Werkov/mkosi-opensuse
[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
e6fea306
LP
44 bool seqnum_set:1;
45 bool realtime_set:1;
46 bool monotonic_set:1;
47 bool xor_hash_set:1;
68667801 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;
456aa879 72 char *namespace;
7827b1a1 73
c1f906bd 74 OrderedHashmap *files;
5d4ba7f2 75 IteratedCache *files_cache;
16e9f408 76 MMapCache *mmap;
f39e126e
LP
77
78 Location current_location;
cbdca852 79
f39e126e
LP
80 JournalFile *current_file;
81 uint64_t current_field;
82
cd34b3c6 83 Match *level0, *level1, *level2;
a963990f 84
a65f06bb
ZJS
85 pid_t original_pid;
86
87 int inotify_fd;
a963990f 88 unsigned current_invalidate_counter, last_invalidate_counter;
a65f06bb 89 usec_t last_process_usec;
858749f7 90 unsigned generation;
3c1668da 91
eb86030e 92 /* Iterating through unique fields and their data values */
3c1668da
LP
93 char *unique_field;
94 JournalFile *unique_file;
95 uint64_t unique_offset;
85210bff 96
eb86030e
LP
97 /* Iterating through known fields */
98 JournalFile *fields_file;
99 uint64_t fields_offset;
100 uint64_t fields_hash_table_index;
101 char *fields_buffer;
102 size_t fields_buffer_allocated;
103
a65f06bb
ZJS
104 int flags;
105
eb86030e
LP
106 bool on_network:1;
107 bool no_new_files:1;
5d1ce257 108 bool no_inotify:1;
eb86030e
LP
109 bool unique_file_lost:1; /* File we were iterating over got
110 removed, and there were no more
111 files, so sd_j_enumerate_unique
112 will return a value equal to 0. */
113 bool fields_file_lost:1;
39fd5b08
JS
114 bool has_runtime_files:1;
115 bool has_persistent_files:1;
93b73b06
LP
116
117 size_t data_threshold;
6fe391c5 118
a65f06bb
ZJS
119 Hashmap *directories_by_path;
120 Hashmap *directories_by_wd;
39c155ea 121
5768d259 122 Hashmap *errors;
f39e126e
LP
123};
124
cbdca852 125char *journal_make_match_string(sd_journal *j);
dca6219e 126void journal_print_header(sd_journal *j);
dfb33a97 127
a72b6353
ZJS
128#define JOURNAL_FOREACH_DATA_RETVAL(j, data, l, retval) \
129 for (sd_journal_restart_data(j); ((retval) = sd_journal_enumerate_data((j), &(data), &(l))) > 0; )