]>
Commit | Line | Data |
---|---|---|
f39e126e LP |
1 | /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/ |
2 | ||
c2f1db8f | 3 | #pragma once |
f39e126e LP |
4 | |
5 | /*** | |
6 | This file is part of systemd. | |
7 | ||
8 | Copyright 2011 Lennart Poettering | |
9 | ||
10 | systemd is free software; you can redistribute it and/or modify it | |
5430f7f2 LP |
11 | under the terms of the GNU Lesser General Public License as published by |
12 | the Free Software Foundation; either version 2.1 of the License, or | |
f39e126e LP |
13 | (at your option) any later version. |
14 | ||
15 | systemd is distributed in the hope that it will be useful, but | |
16 | WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
5430f7f2 | 18 | Lesser General Public License for more details. |
f39e126e | 19 | |
5430f7f2 | 20 | You should have received a copy of the GNU Lesser General Public License |
f39e126e LP |
21 | along with systemd; If not, see <http://www.gnu.org/licenses/>. |
22 | ***/ | |
23 | ||
f39e126e LP |
24 | #include <inttypes.h> |
25 | #include <stdbool.h> | |
71d35b6b | 26 | #include <sys/types.h> |
f39e126e | 27 | |
07630cea LP |
28 | #include "sd-id128.h" |
29 | #include "sd-journal.h" | |
81527be1 | 30 | |
07630cea | 31 | #include "hashmap.h" |
cbdca852 | 32 | #include "journal-def.h" |
07630cea | 33 | #include "journal-file.h" |
f39e126e | 34 | #include "list.h" |
6fe391c5 | 35 | #include "set.h" |
cbdca852 | 36 | |
f39e126e | 37 | typedef struct Match Match; |
a963990f LP |
38 | typedef struct Location Location; |
39 | typedef struct Directory Directory; | |
40 | ||
cbdca852 LP |
41 | typedef enum MatchType { |
42 | MATCH_DISCRETE, | |
43 | MATCH_OR_TERM, | |
44 | MATCH_AND_TERM | |
45 | } MatchType; | |
f39e126e LP |
46 | |
47 | struct Match { | |
cbdca852 LP |
48 | MatchType type; |
49 | Match *parent; | |
50 | LIST_FIELDS(Match, matches); | |
51 | ||
52 | /* For concrete matches */ | |
f39e126e LP |
53 | char *data; |
54 | size_t size; | |
4fd052ae | 55 | le64_t le_hash; |
f39e126e | 56 | |
cbdca852 LP |
57 | /* For terms */ |
58 | LIST_HEAD(Match, matches); | |
f39e126e LP |
59 | }; |
60 | ||
a963990f | 61 | struct Location { |
cbdca852 | 62 | LocationType type; |
f39e126e | 63 | |
68667801 ZJS |
64 | bool seqnum_set; |
65 | bool realtime_set; | |
66 | bool monotonic_set; | |
67 | bool xor_hash_set; | |
68 | ||
f39e126e LP |
69 | uint64_t seqnum; |
70 | sd_id128_t seqnum_id; | |
f39e126e LP |
71 | |
72 | uint64_t realtime; | |
f39e126e LP |
73 | |
74 | uint64_t monotonic; | |
75 | sd_id128_t boot_id; | |
f39e126e LP |
76 | |
77 | uint64_t xor_hash; | |
a963990f LP |
78 | }; |
79 | ||
80 | struct Directory { | |
81 | char *path; | |
82 | int wd; | |
83 | bool is_root; | |
84 | }; | |
f39e126e LP |
85 | |
86 | struct sd_journal { | |
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 LP |
105 | |
106 | char *unique_field; | |
107 | JournalFile *unique_file; | |
108 | uint64_t unique_offset; | |
85210bff | 109 | |
a65f06bb ZJS |
110 | int flags; |
111 | ||
85210bff | 112 | bool on_network; |
5302ebe1 | 113 | bool no_new_files; |
360af4cf ZJS |
114 | bool unique_file_lost; /* File we were iterating over got |
115 | removed, and there were no more | |
116 | files, so sd_j_enumerate_unique | |
117 | will return a value equal to 0. */ | |
93b73b06 LP |
118 | |
119 | size_t data_threshold; | |
6fe391c5 | 120 | |
a65f06bb ZJS |
121 | Hashmap *directories_by_path; |
122 | Hashmap *directories_by_wd; | |
39c155ea | 123 | |
5768d259 | 124 | Hashmap *errors; |
f39e126e LP |
125 | }; |
126 | ||
cbdca852 | 127 | char *journal_make_match_string(sd_journal *j); |
dca6219e | 128 | void journal_print_header(sd_journal *j); |
dfb33a97 | 129 | |
a72b6353 ZJS |
130 | #define JOURNAL_FOREACH_DATA_RETVAL(j, data, l, retval) \ |
131 | for (sd_journal_restart_data(j); ((retval) = sd_journal_enumerate_data((j), &(data), &(l))) > 0; ) |