+/* SPDX-License-Identifier: LGPL-2.1+ */
/***
This file is part of systemd.
#include "dirent-util.h"
#include "fd-util.h"
#include "fileio.h"
-#include "formats-util.h"
+#include "format-util.h"
#include "fs-util.h"
#include "hashmap.h"
#include "hostname-util.h"
/* We don't support people creating a journal object and
* keeping it around over a fork(). Let's complain. */
- return j->original_pid != getpid();
+ return j->original_pid != getpid_cached();
}
static int journal_put_error(sd_journal *j, int r, const char *path) {
static void init_location(Location *l, LocationType type, JournalFile *f, Object *o) {
assert(l);
- assert(type == LOCATION_DISCRETE || type == LOCATION_SEEK);
+ assert(IN_SET(type, LOCATION_DISCRETE, LOCATION_SEEK));
assert(f);
assert(o->object.type == OBJECT_ENTRY);
return mfree(p);
if (p) {
- k = strjoin(p, m->type == MATCH_OR_TERM ? " OR " : " AND ", t, NULL);
+ k = strjoin(p, m->type == MATCH_OR_TERM ? " OR " : " AND ", t);
free(p);
free(t);
}
if (enclose) {
- r = strjoin("(", p, ")", NULL);
+ r = strjoin("(", p, ")");
free(p);
return r;
}
assert(f);
assert(l);
assert(f->location_type == LOCATION_SEEK);
- assert(l->type == LOCATION_DISCRETE || l->type == LOCATION_SEEK);
+ assert(IN_SET(l->type, LOCATION_DISCRETE, LOCATION_SEEK));
if (l->monotonic_set &&
sd_id128_equal(f->current_boot_id, l->boot_id) &&
if (skip == 0) {
/* If this is not a discrete skip, then at least
* resolve the current location */
- if (j->current_location.type != LOCATION_DISCRETE)
- return real_journal_next(j, direction);
+ if (j->current_location.type != LOCATION_DISCRETE) {
+ r = real_journal_next(j, direction);
+ if (r < 0)
+ return r;
+ }
return 0;
}
* and reenumerates directory contents */
if (dirname)
- path = strjoin(prefix, "/", dirname, NULL);
+ path = strjoin(prefix, "/", dirname);
else
path = strdup(prefix);
if (!path) {
NULSTR_FOREACH(p, search_paths)
(void) add_root_directory(j, p, true);
+ if (!(j->flags & SD_JOURNAL_LOCAL_ONLY))
+ (void) add_root_directory(j, "/var/log/journal/remote", true);
+
return 0;
}
if (!j)
return NULL;
- j->original_pid = getpid();
+ j->original_pid = getpid_cached();
j->toplevel_fd = -1;
j->inotify_fd = -1;
j->flags = flags;
compression = o->object.flags & OBJECT_COMPRESSION_MASK;
if (compression) {
-#if defined(HAVE_XZ) || defined(HAVE_LZ4)
+#if HAVE_XZ || HAVE_LZ4
r = decompress_startswith(compression,
o->data.payload, l,
&f->compress_buffer, &f->compress_buffer_size,
compression = o->object.flags & OBJECT_COMPRESSION_MASK;
if (compression) {
-#if defined(HAVE_XZ) || defined(HAVE_LZ4)
+#if HAVE_XZ || HAVE_LZ4
size_t rsize;
int r;
assert_return(!journal_pid_changed(j), -ECHILD);
j->last_process_usec = now(CLOCK_MONOTONIC);
+ j->last_invalidate_counter = j->current_invalidate_counter;
for (;;) {
union inotify_event_buffer buffer;
l = read(j->inotify_fd, &buffer, sizeof(buffer));
if (l < 0) {
- if (errno == EAGAIN || errno == EINTR)
+ if (IN_SET(errno, EAGAIN, EINTR))
return got_something ? determine_change(j) : SD_JOURNAL_NOP;
return -errno;