1 /* SPDX-License-Identifier: LGPL-2.1+ */
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
;
102 size_t fields_buffer_allocated
;
109 bool unique_file_lost
:1; /* File we were iterating over got
110 removed, and there were no more
111 files, so sd_j_enumerate_unique
112 will return a value equal to 0. */
113 bool fields_file_lost
:1;
114 bool has_runtime_files
:1;
115 bool has_persistent_files
:1;
117 size_t data_threshold
;
119 Hashmap
*directories_by_path
;
120 Hashmap
*directories_by_wd
;
125 char *journal_make_match_string(sd_journal
*j
);
126 void journal_print_header(sd_journal
*j
);
128 #define JOURNAL_FOREACH_DATA_RETVAL(j, data, l, retval) \
129 for (sd_journal_restart_data(j); ((retval) = sd_journal_enumerate_data((j), &(data), &(l))) > 0; )
131 /* All errors that we might encounter while extracting a field that are not real errors,
132 * but only mean that the field is too large or we don't support the compression. */
133 static inline bool JOURNAL_ERRNO_IS_UNAVAILABLE_FIELD(int r
) {
134 return IN_SET(abs(r
),
135 ENOBUFS
, /* Field or decompressed field too large */
136 E2BIG
, /* Field too large for pointer width */
137 EPROTONOSUPPORT
); /* Unsupported compression */