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