]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/journal/journal-internal.h
Revert "Revert "sysctl: Enable ping(8) inside rootless Podman containers""
[thirdparty/systemd.git] / src / journal / journal-internal.h
1 /* SPDX-License-Identifier: LGPL-2.1+ */
2 #pragma once
3
4 #include <inttypes.h>
5 #include <stdbool.h>
6 #include <sys/types.h>
7
8 #include "sd-id128.h"
9 #include "sd-journal.h"
10
11 #include "hashmap.h"
12 #include "journal-def.h"
13 #include "journal-file.h"
14 #include "list.h"
15 #include "set.h"
16
17 typedef struct Match Match;
18 typedef struct Location Location;
19 typedef struct Directory Directory;
20
21 typedef enum MatchType {
22 MATCH_DISCRETE,
23 MATCH_OR_TERM,
24 MATCH_AND_TERM
25 } MatchType;
26
27 struct Match {
28 MatchType type;
29 Match *parent;
30 LIST_FIELDS(Match, matches);
31
32 /* For concrete matches */
33 char *data;
34 size_t size;
35 le64_t le_hash;
36
37 /* For terms */
38 LIST_HEAD(Match, matches);
39 };
40
41 struct Location {
42 LocationType type;
43
44 bool seqnum_set;
45 bool realtime_set;
46 bool monotonic_set;
47 bool xor_hash_set;
48
49 uint64_t seqnum;
50 sd_id128_t seqnum_id;
51
52 uint64_t realtime;
53
54 uint64_t monotonic;
55 sd_id128_t boot_id;
56
57 uint64_t xor_hash;
58 };
59
60 struct Directory {
61 char *path;
62 int wd;
63 bool is_root;
64 unsigned last_seen_generation;
65 };
66
67 struct sd_journal {
68 int toplevel_fd;
69
70 char *path;
71 char *prefix;
72
73 OrderedHashmap *files;
74 IteratedCache *files_cache;
75 MMapCache *mmap;
76
77 Location current_location;
78
79 JournalFile *current_file;
80 uint64_t current_field;
81
82 Match *level0, *level1, *level2;
83
84 pid_t original_pid;
85
86 int inotify_fd;
87 unsigned current_invalidate_counter, last_invalidate_counter;
88 usec_t last_process_usec;
89 unsigned generation;
90
91 /* Iterating through unique fields and their data values */
92 char *unique_field;
93 JournalFile *unique_file;
94 uint64_t unique_offset;
95
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
103 int flags;
104
105 bool on_network:1;
106 bool no_new_files:1;
107 bool no_inotify:1;
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;
113 bool has_runtime_files:1;
114 bool has_persistent_files:1;
115
116 size_t data_threshold;
117
118 Hashmap *directories_by_path;
119 Hashmap *directories_by_wd;
120
121 Hashmap *errors;
122 };
123
124 char *journal_make_match_string(sd_journal *j);
125 void journal_print_header(sd_journal *j);
126
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; )