]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/journal-remote/journal-remote.c
tree-wide: use -EBADF for fd initialization
[thirdparty/systemd.git] / src / journal-remote / journal-remote.c
index 9fd6a23076c2a3bfb20023c3151ee3a780cb6ee7..a670468884133d3d2db09c119c51d512954c9f11 100644 (file)
 
 #include "af-list.h"
 #include "alloc-util.h"
-#include "def.h"
+#include "constants.h"
 #include "errno-util.h"
 #include "escape.h"
 #include "fd-util.h"
-#include "journal-file.h"
 #include "journal-remote-write.h"
 #include "journal-remote.h"
 #include "journald-native.h"
 #include "macro.h"
+#include "managed-journal-file.h"
 #include "parse-util.h"
 #include "process-util.h"
 #include "socket-util.h"
@@ -61,16 +61,21 @@ static int open_output(RemoteServer *s, Writer *w, const char* host) {
                 assert_not_reached();
         }
 
-        r = 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);
 
-        log_debug("Opened output file %s", w->journal->path);
+        log_debug("Opened output file %s", w->journal->file->path);
         return 0;
 }
 
@@ -99,7 +104,7 @@ int journal_remote_get_writer(RemoteServer *s, const char *host, Writer **writer
         const void *key;
         int r;
 
-        switch(s->split_mode) {
+        switch (s->split_mode) {
         case JOURNAL_WRITE_SPLIT_NONE:
                 key = "one and only";
                 break;
@@ -289,7 +294,7 @@ int journal_remote_add_raw_socket(RemoteServer *s, int fd) {
         if (r < 0)
                 return r;
 
-        fd_ = -1;
+        fd_ = -EBADF;
         s->active++;
         return 0;
 }
@@ -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;
 
@@ -480,7 +483,7 @@ static int accept_connection(
                 SocketAddress *addr,
                 char **hostname) {
 
-        _cleanup_close_ int fd2 = -1;
+        _cleanup_close_ int fd2 = -EBADF;
         int r;
 
         log_debug("Accepting new %s connection on fd:%d", type, fd);
@@ -492,7 +495,7 @@ static int accept_connection(
                 return log_error_errno(errno, "accept() on fd:%d failed: %m", fd);
         }
 
-        switch(socket_address_family(addr)) {
+        switch (socket_address_family(addr)) {
         case AF_INET:
         case AF_INET6: {
                 _cleanup_free_ char *a = NULL;