]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/journal/journal-internal.h
Add SPDX license identifiers to source files under the LGPL
[thirdparty/systemd.git] / src / journal / journal-internal.h
CommitLineData
53e1b683 1/* SPDX-License-Identifier: LGPL-2.1+ */
c2f1db8f 2#pragma once
f39e126e
LP
3
4/***
5 This file is part of systemd.
6
7 Copyright 2011 Lennart Poettering
8
9 systemd is free software; you can redistribute it and/or modify it
5430f7f2
LP
10 under the terms of the GNU Lesser General Public License as published by
11 the Free Software Foundation; either version 2.1 of the License, or
f39e126e
LP
12 (at your option) any later version.
13
14 systemd is distributed in the hope that it will be useful, but
15 WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
5430f7f2 17 Lesser General Public License for more details.
f39e126e 18
5430f7f2 19 You should have received a copy of the GNU Lesser General Public License
f39e126e
LP
20 along with systemd; If not, see <http://www.gnu.org/licenses/>.
21***/
22
f39e126e
LP
23#include <inttypes.h>
24#include <stdbool.h>
71d35b6b 25#include <sys/types.h>
f39e126e 26
07630cea
LP
27#include "sd-id128.h"
28#include "sd-journal.h"
81527be1 29
07630cea 30#include "hashmap.h"
cbdca852 31#include "journal-def.h"
07630cea 32#include "journal-file.h"
f39e126e 33#include "list.h"
6fe391c5 34#include "set.h"
cbdca852 35
f39e126e 36typedef struct Match Match;
a963990f
LP
37typedef struct Location Location;
38typedef struct Directory Directory;
39
cbdca852
LP
40typedef enum MatchType {
41 MATCH_DISCRETE,
42 MATCH_OR_TERM,
43 MATCH_AND_TERM
44} MatchType;
f39e126e
LP
45
46struct Match {
cbdca852
LP
47 MatchType type;
48 Match *parent;
49 LIST_FIELDS(Match, matches);
50
51 /* For concrete matches */
f39e126e
LP
52 char *data;
53 size_t size;
4fd052ae 54 le64_t le_hash;
f39e126e 55
cbdca852
LP
56 /* For terms */
57 LIST_HEAD(Match, matches);
f39e126e
LP
58};
59
a963990f 60struct Location {
cbdca852 61 LocationType type;
f39e126e 62
68667801
ZJS
63 bool seqnum_set;
64 bool realtime_set;
65 bool monotonic_set;
66 bool xor_hash_set;
67
f39e126e
LP
68 uint64_t seqnum;
69 sd_id128_t seqnum_id;
f39e126e
LP
70
71 uint64_t realtime;
f39e126e
LP
72
73 uint64_t monotonic;
74 sd_id128_t boot_id;
f39e126e
LP
75
76 uint64_t xor_hash;
a963990f
LP
77};
78
79struct Directory {
80 char *path;
81 int wd;
82 bool is_root;
83};
f39e126e
LP
84
85struct sd_journal {
5d1ce257
LP
86 int toplevel_fd;
87
7827b1a1 88 char *path;
89739579 89 char *prefix;
7827b1a1 90
c1f906bd 91 OrderedHashmap *files;
16e9f408 92 MMapCache *mmap;
f39e126e
LP
93
94 Location current_location;
cbdca852 95
f39e126e
LP
96 JournalFile *current_file;
97 uint64_t current_field;
98
cd34b3c6 99 Match *level0, *level1, *level2;
a963990f 100
a65f06bb
ZJS
101 pid_t original_pid;
102
103 int inotify_fd;
a963990f 104 unsigned current_invalidate_counter, last_invalidate_counter;
a65f06bb 105 usec_t last_process_usec;
3c1668da 106
eb86030e 107 /* Iterating through unique fields and their data values */
3c1668da
LP
108 char *unique_field;
109 JournalFile *unique_file;
110 uint64_t unique_offset;
85210bff 111
eb86030e
LP
112 /* Iterating through known fields */
113 JournalFile *fields_file;
114 uint64_t fields_offset;
115 uint64_t fields_hash_table_index;
116 char *fields_buffer;
117 size_t fields_buffer_allocated;
118
a65f06bb
ZJS
119 int flags;
120
eb86030e
LP
121 bool on_network:1;
122 bool no_new_files:1;
5d1ce257 123 bool no_inotify:1;
eb86030e
LP
124 bool unique_file_lost:1; /* File we were iterating over got
125 removed, and there were no more
126 files, so sd_j_enumerate_unique
127 will return a value equal to 0. */
128 bool fields_file_lost:1;
39fd5b08
JS
129 bool has_runtime_files:1;
130 bool has_persistent_files:1;
93b73b06
LP
131
132 size_t data_threshold;
6fe391c5 133
a65f06bb
ZJS
134 Hashmap *directories_by_path;
135 Hashmap *directories_by_wd;
39c155ea 136
5768d259 137 Hashmap *errors;
f39e126e
LP
138};
139
cbdca852 140char *journal_make_match_string(sd_journal *j);
dca6219e 141void journal_print_header(sd_journal *j);
dfb33a97 142
a72b6353
ZJS
143#define JOURNAL_FOREACH_DATA_RETVAL(j, data, l, retval) \
144 for (sd_journal_restart_data(j); ((retval) = sd_journal_enumerate_data((j), &(data), &(l))) > 0; )