summaryrefslogtreecommitdiff
path: root/src/journal-remote
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2022-03-24 14:04:40 +0100
committerLennart Poettering <lennart@poettering.net>2022-03-25 09:59:09 +0100
commit49615dbd8191e2b898496c5a90fdb35f92d4fdb9 (patch)
tree38d63d34e959aee2896594dadfb121033aea4cbd /src/journal-remote
parenta35420d85d42bc1c0c7b315ab161ff0e5026c46d (diff)
downloadsystemd-49615dbd8191e2b898496c5a90fdb35f92d4fdb9.tar.gz
journal-file: merge compress/seal bool args into a single flags param
Just some modernization/refactoring. No change in behaviour, just let's do how we do things these days: use flags param instead of list of bools.
Diffstat (limited to 'src/journal-remote')
-rw-r--r--src/journal-remote/fuzz-journal-remote.c2
-rw-r--r--src/journal-remote/journal-remote-main.c11
-rw-r--r--src/journal-remote/journal-remote-parse.c4
-rw-r--r--src/journal-remote/journal-remote-parse.h2
-rw-r--r--src/journal-remote/journal-remote-write.c13
-rw-r--r--src/journal-remote/journal-remote-write.h3
-rw-r--r--src/journal-remote/journal-remote.c25
-rw-r--r--src/journal-remote/journal-remote.h6
8 files changed, 35 insertions, 31 deletions
diff --git a/src/journal-remote/fuzz-journal-remote.c b/src/journal-remote/fuzz-journal-remote.c
index 1731b94bb8..9206b99406 100644
--- a/src/journal-remote/fuzz-journal-remote.c
+++ b/src/journal-remote/fuzz-journal-remote.c
@@ -43,7 +43,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
/* In */
- r = journal_remote_server_init(&s, name, JOURNAL_WRITE_SPLIT_NONE, false, false);
+ r = journal_remote_server_init(&s, name, JOURNAL_WRITE_SPLIT_NONE, 0);
if (r < 0) {
assert_se(IN_SET(r, -ENOMEM, -EMFILE, -ENFILE));
return r;
diff --git a/src/journal-remote/journal-remote-main.c b/src/journal-remote/journal-remote-main.c
index beb73f3572..7c3c9ff44a 100644
--- a/src/journal-remote/journal-remote-main.c
+++ b/src/journal-remote/journal-remote-main.c
@@ -223,9 +223,7 @@ static int process_http_upload(
finished = true;
for (;;) {
- r = process_source(source,
- journal_remote_server_global->compress,
- journal_remote_server_global->seal);
+ r = process_source(source, journal_remote_server_global->file_flags);
if (r == -EAGAIN)
break;
if (r < 0) {
@@ -599,7 +597,12 @@ static int create_remoteserver(
int r, n, fd;
- r = journal_remote_server_init(s, arg_output, arg_split_mode, arg_compress, arg_seal);
+ r = journal_remote_server_init(
+ s,
+ arg_output,
+ arg_split_mode,
+ (arg_compress ? JOURNAL_COMPRESS : 0) |
+ (arg_seal ? JOURNAL_SEAL : 0));
if (r < 0)
return r;
diff --git a/src/journal-remote/journal-remote-parse.c b/src/journal-remote/journal-remote-parse.c
index 2ece329251..f8d068d6fe 100644
--- a/src/journal-remote/journal-remote-parse.c
+++ b/src/journal-remote/journal-remote-parse.c
@@ -47,7 +47,7 @@ RemoteSource* source_new(int fd, bool passive_fd, char *name, Writer *writer) {
return source;
}
-int process_source(RemoteSource *source, bool compress, bool seal) {
+int process_source(RemoteSource *source, JournalFileFlags file_flags) {
int r;
assert(source);
@@ -72,7 +72,7 @@ int process_source(RemoteSource *source, bool compress, bool seal) {
&source->importer.iovw,
&source->importer.ts,
&source->importer.boot_id,
- compress, seal);
+ file_flags);
if (r == -EBADMSG) {
log_warning_errno(r, "Entry is invalid, ignoring.");
r = 0;
diff --git a/src/journal-remote/journal-remote-parse.h b/src/journal-remote/journal-remote-parse.h
index a5b51ad4d1..703035b1ec 100644
--- a/src/journal-remote/journal-remote-parse.h
+++ b/src/journal-remote/journal-remote-parse.h
@@ -17,4 +17,4 @@ typedef struct RemoteSource {
RemoteSource* source_new(int fd, bool passive_fd, char *name, Writer *writer);
void source_free(RemoteSource *source);
-int process_source(RemoteSource *source, bool compress, bool seal);
+int process_source(RemoteSource *source, JournalFileFlags file_flags);
diff --git a/src/journal-remote/journal-remote-write.c b/src/journal-remote/journal-remote-write.c
index 6477bfac2d..f4f3b64811 100644
--- a/src/journal-remote/journal-remote-write.c
+++ b/src/journal-remote/journal-remote-write.c
@@ -3,8 +3,10 @@
#include "alloc-util.h"
#include "journal-remote.h"
-static int do_rotate(ManagedJournalFile **f, MMapCache *m, bool compress, bool seal) {
- int r = managed_journal_file_rotate(f, m, compress, UINT64_MAX, seal, NULL);
+static int do_rotate(ManagedJournalFile **f, MMapCache *m, JournalFileFlags file_flags) {
+ int r;
+
+ r = managed_journal_file_rotate(f, m, file_flags, UINT64_MAX, NULL);
if (r < 0) {
if (*f)
log_error_errno(r, "Failed to rotate %s: %m", (*f)->file->path);
@@ -60,8 +62,7 @@ int writer_write(Writer *w,
const struct iovec_wrapper *iovw,
const dual_timestamp *ts,
const sd_id128_t *boot_id,
- bool compress,
- bool seal) {
+ JournalFileFlags file_flags) {
int r;
assert(w);
@@ -71,7 +72,7 @@ int writer_write(Writer *w,
if (journal_file_rotate_suggested(w->journal->file, 0, LOG_DEBUG)) {
log_info("%s: Journal header limits reached or header out-of-date, rotating",
w->journal->file->path);
- r = do_rotate(&w->journal, w->mmap, compress, seal);
+ r = do_rotate(&w->journal, w->mmap, file_flags);
if (r < 0)
return r;
}
@@ -87,7 +88,7 @@ int writer_write(Writer *w,
return r;
log_debug_errno(r, "%s: Write failed, rotating: %m", w->journal->file->path);
- r = do_rotate(&w->journal, w->mmap, compress, seal);
+ r = do_rotate(&w->journal, w->mmap, file_flags);
if (r < 0)
return r;
else
diff --git a/src/journal-remote/journal-remote-write.h b/src/journal-remote/journal-remote-write.h
index 0e375f3489..2079214e23 100644
--- a/src/journal-remote/journal-remote-write.h
+++ b/src/journal-remote/journal-remote-write.h
@@ -29,8 +29,7 @@ int writer_write(Writer *s,
const struct iovec_wrapper *iovw,
const dual_timestamp *ts,
const sd_id128_t *boot_id,
- bool compress,
- bool seal);
+ JournalFileFlags file_flags);
typedef enum JournalWriteSplitMode {
JOURNAL_WRITE_SPLIT_NONE,
diff --git a/src/journal-remote/journal-remote.c b/src/journal-remote/journal-remote.c
index 67a0205bee..d1f394b027 100644
--- a/src/journal-remote/journal-remote.c
+++ b/src/journal-remote/journal-remote.c
@@ -61,12 +61,17 @@ static int open_output(RemoteServer *s, Writer *w, const char* host) {
assert_not_reached();
}
- r = managed_journal_file_open_reliably(filename,
- O_RDWR|O_CREAT, 0640,
- s->compress, UINT64_MAX, s->seal,
- &w->metrics,
- w->mmap, NULL,
- NULL, &w->journal);
+ r = managed_journal_file_open_reliably(
+ filename,
+ O_RDWR|O_CREAT,
+ s->file_flags,
+ 0640,
+ UINT64_MAX,
+ &w->metrics,
+ w->mmap,
+ NULL,
+ NULL,
+ &w->journal);
if (r < 0)
return log_error_errno(r, "Failed to open output journal %s: %m", filename);
@@ -302,8 +307,7 @@ int journal_remote_server_init(
RemoteServer *s,
const char *output,
JournalWriteSplitMode split_mode,
- bool compress,
- bool seal) {
+ JournalFileFlags file_flags) {
int r;
@@ -313,8 +317,7 @@ int journal_remote_server_init(
journal_remote_server_global = s;
s->split_mode = split_mode;
- s->compress = compress;
- s->seal = seal;
+ s->file_flags = file_flags;
if (output)
s->output = output;
@@ -391,7 +394,7 @@ int journal_remote_handle_raw_source(
source = s->sources[fd];
assert(source->importer.fd == fd);
- r = process_source(source, s->compress, s->seal);
+ r = process_source(source, s->file_flags);
if (journal_importer_eof(&source->importer)) {
size_t remaining;
diff --git a/src/journal-remote/journal-remote.h b/src/journal-remote/journal-remote.h
index 45176e964d..facf1516e0 100644
--- a/src/journal-remote/journal-remote.h
+++ b/src/journal-remote/journal-remote.h
@@ -38,8 +38,7 @@ struct RemoteServer {
const char *output; /* either the output file or directory */
JournalWriteSplitMode split_mode;
- bool compress;
- bool seal;
+ JournalFileFlags file_flags;
bool check_trust;
};
extern RemoteServer *journal_remote_server_global;
@@ -48,8 +47,7 @@ int journal_remote_server_init(
RemoteServer *s,
const char *output,
JournalWriteSplitMode split_mode,
- bool compress,
- bool seal);
+ JournalFileFlags file_flags);
int journal_remote_get_writer(RemoteServer *s, const char *host, Writer **writer);