]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
util-lib: move open_serialization_fd() to serialize.c
authorLennart Poettering <lennart@poettering.net>
Fri, 30 Nov 2018 20:39:12 +0000 (21:39 +0100)
committerLennart Poettering <lennart@poettering.net>
Sun, 2 Dec 2018 12:22:29 +0000 (13:22 +0100)
It definitely fits better there.

No code changes, just some rearranging.

src/basic/fileio.c
src/basic/fileio.h
src/shared/serialize.c
src/shared/serialize.h
src/test/test-fd-util.c

index 6ccbae02a9a30d7771eed6ab7f83aaa954fb9f50..549f98728347a25d59b5e3a0d91a2a25284eeb78 100644 (file)
@@ -9,7 +9,6 @@
 #include <stdio_ext.h>
 #include <stdlib.h>
 #include <string.h>
-#include <sys/mman.h>
 #include <sys/stat.h>
 #include <sys/types.h>
 #include <unistd.h>
@@ -25,7 +24,6 @@
 #include "missing.h"
 #include "parse-util.h"
 #include "path-util.h"
-#include "process-util.h"
 #include "stdio-util.h"
 #include "string-util.h"
 #include "strv.h"
@@ -1219,25 +1217,6 @@ int fputs_with_space(FILE *f, const char *s, const char *separator, bool *space)
         return fputs(s, f);
 }
 
-int open_serialization_fd(const char *ident) {
-        int fd;
-
-        fd = memfd_create(ident, MFD_CLOEXEC);
-        if (fd < 0) {
-                const char *path;
-
-                path = getpid_cached() == 1 ? "/run/systemd" : "/tmp";
-                fd = open_tmpfile_unlinkable(path, O_RDWR|O_CLOEXEC);
-                if (fd < 0)
-                        return fd;
-
-                log_debug("Serializing %s to %s.", ident, path);
-        } else
-                log_debug("Serializing %s to memfd.", ident);
-
-        return fd;
-}
-
 int read_nul_string(FILE *f, char **ret) {
         _cleanup_free_ char *x = NULL;
         size_t allocated = 0, n = 0;
index 8ca717f309891c9e0da661df7e826428ee29ea8b..874cdabd6bf71014bbea3f2c79aa2e3b644b4301 100644 (file)
@@ -71,8 +71,6 @@ int read_timestamp_file(const char *fn, usec_t *ret);
 
 int fputs_with_space(FILE *f, const char *s, const char *separator, bool *space);
 
-int open_serialization_fd(const char *ident);
-
 int read_nul_string(FILE *f, char **ret);
 
 int read_line(FILE *f, size_t limit, char **ret);
index eb1191b3bfa1227654286459d2616222248507e1..20d2e9fb044e3a895372b3c0b521b142b92197a8 100644 (file)
@@ -1,12 +1,16 @@
 /* SPDX-License-Identifier: LGPL-2.1+ */
 
+#include <sys/mman.h>
+
 #include "alloc-util.h"
 #include "env-util.h"
 #include "escape.h"
 #include "fileio.h"
 #include "parse-util.h"
+#include "process-util.h"
 #include "serialize.h"
 #include "strv.h"
+#include "tmpfile-util.h"
 
 int serialize_item(FILE *f, const char *key, const char *value) {
         assert(f);
@@ -188,3 +192,22 @@ int deserialize_environment(const char *value, char ***list) {
         unescaped = NULL; /* now part of 'list' */
         return 0;
 }
+
+int open_serialization_fd(const char *ident) {
+        int fd;
+
+        fd = memfd_create(ident, MFD_CLOEXEC);
+        if (fd < 0) {
+                const char *path;
+
+                path = getpid_cached() == 1 ? "/run/systemd" : "/tmp";
+                fd = open_tmpfile_unlinkable(path, O_RDWR|O_CLOEXEC);
+                if (fd < 0)
+                        return fd;
+
+                log_debug("Serializing %s to %s.", ident, path);
+        } else
+                log_debug("Serializing %s to memfd.", ident);
+
+        return fd;
+}
index a671524153b705994ddc15279424d2ffdec7670f..4cbd98bb34489a3c02bec798f7d18af86d4b6e24 100644 (file)
@@ -21,3 +21,5 @@ static inline int serialize_bool(FILE *f, const char *key, bool b) {
 int deserialize_usec(const char *value, usec_t *timestamp);
 int deserialize_dual_timestamp(const char *value, dual_timestamp *t);
 int deserialize_environment(const char *value, char ***environment);
+
+int open_serialization_fd(const char *ident);
index a9ecfb6bfe66fda8892fc1d0c0e1dbf6632967d7..7a0a2ad7d8b35fe1ca7bcc8489bf8b193e2f3896 100644 (file)
@@ -10,6 +10,7 @@
 #include "path-util.h"
 #include "process-util.h"
 #include "random-util.h"
+#include "serialize.h"
 #include "string-util.h"
 #include "tests.h"
 #include "tmpfile-util.h"