1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
9 #include "sd-journal.h"
12 #include "journal-def.h"
13 #include "journal-file.h"
17 typedef struct Match Match
;
18 typedef struct Location Location
;
19 typedef struct Directory Directory
;
21 typedef enum MatchType
{
30 LIST_FIELDS(Match
, matches
);
32 /* For concrete matches */
35 uint64_t hash
; /* old-style jenkins hash. New-style siphash is different per file, hence won't be cached here */
38 LIST_HEAD(Match
, matches
);
64 unsigned last_seen_generation
;
74 OrderedHashmap
*files
;
75 IteratedCache
*files_cache
;
78 Location current_location
;
80 JournalFile
*current_file
;
81 uint64_t current_field
;
83 Match
*level0
, *level1
, *level2
;
88 unsigned current_invalidate_counter
, last_invalidate_counter
;
89 usec_t last_process_usec
;
92 /* Iterating through unique fields and their data values */
94 JournalFile
*unique_file
;
95 uint64_t unique_offset
;
97 /* Iterating through known fields */
98 JournalFile
*fields_file
;
99 uint64_t fields_offset
;
100 uint64_t fields_hash_table_index
;
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;
116 size_t data_threshold
;
118 Hashmap
*directories_by_path
;
119 Hashmap
*directories_by_wd
;
124 char *journal_make_match_string(sd_journal
*j
);
125 void journal_print_header(sd_journal
*j
);
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; )
130 /* All errors that we might encounter while extracting a field that are not real errors,
131 * but only mean that the field is too large or we don't support the compression. */
132 static inline bool JOURNAL_ERRNO_IS_UNAVAILABLE_FIELD(int r
) {
133 return IN_SET(abs(r
),
134 ENOBUFS
, /* Field or decompressed field too large */
135 E2BIG
, /* Field too large for pointer width */
136 EPROTONOSUPPORT
); /* Unsupported compression */