]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/journal/journal-internal.h
journal: automatically rotate journal files if the data hash table is full > 75%
[thirdparty/systemd.git] / src / journal / journal-internal.h
1 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
2
3 #ifndef foojournalinternalhfoo
4 #define foojournalinternalhfoo
5
6 /***
7 This file is part of systemd.
8
9 Copyright 2011 Lennart Poettering
10
11 systemd is free software; you can redistribute it and/or modify it
12 under the terms of the GNU Lesser General Public License as published by
13 the Free Software Foundation; either version 2.1 of the License, or
14 (at your option) any later version.
15
16 systemd is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 Lesser General Public License for more details.
20
21 You should have received a copy of the GNU Lesser General Public License
22 along with systemd; If not, see <http://www.gnu.org/licenses/>.
23 ***/
24
25 #include <sys/types.h>
26 #include <inttypes.h>
27 #include <stdbool.h>
28
29 #include <systemd/sd-id128.h>
30
31 #include "journal-def.h"
32 #include "list.h"
33 #include "hashmap.h"
34 #include "journal-file.h"
35
36 typedef struct Match Match;
37 typedef struct Location Location;
38 typedef struct Directory Directory;
39
40 typedef enum MatchType {
41 MATCH_DISCRETE,
42 MATCH_OR_TERM,
43 MATCH_AND_TERM
44 } MatchType;
45
46 struct Match {
47 MatchType type;
48 Match *parent;
49 LIST_FIELDS(Match, matches);
50
51 /* For concrete matches */
52 char *data;
53 size_t size;
54 le64_t le_hash;
55
56 /* For terms */
57 LIST_HEAD(Match, matches);
58 };
59
60 typedef enum LocationType {
61 LOCATION_HEAD,
62 LOCATION_TAIL,
63 LOCATION_DISCRETE
64 } LocationType;
65
66 struct Location {
67 LocationType type;
68
69 uint64_t seqnum;
70 sd_id128_t seqnum_id;
71 bool seqnum_set;
72
73 uint64_t realtime;
74 bool realtime_set;
75
76 uint64_t monotonic;
77 sd_id128_t boot_id;
78 bool monotonic_set;
79
80 uint64_t xor_hash;
81 bool xor_hash_set;
82 };
83
84 struct Directory {
85 char *path;
86 int wd;
87 bool is_root;
88 };
89
90 struct sd_journal {
91 int flags;
92
93 Hashmap *files;
94
95 Location current_location;
96
97 JournalFile *current_file;
98 uint64_t current_field;
99
100 Hashmap *directories_by_path;
101 Hashmap *directories_by_wd;
102
103 int inotify_fd;
104
105 Match *level0, *level1;
106
107 unsigned current_invalidate_counter, last_invalidate_counter;
108 };
109
110 char *journal_make_match_string(sd_journal *j);
111 void journal_print_header(sd_journal *j);
112
113 #endif