]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
util-lib: move more file I/O related calls into fileio.[ch]
authorLennart Poettering <lennart@poettering.net>
Mon, 26 Oct 2015 17:05:03 +0000 (18:05 +0100)
committerLennart Poettering <lennart@poettering.net>
Tue, 27 Oct 2015 12:25:55 +0000 (13:25 +0100)
51 files changed:
src/basic/calendarspec.c
src/basic/copy.c
src/basic/fileio.c
src/basic/fileio.h
src/basic/hostname-util.c
src/basic/time-util.c
src/basic/util.c
src/basic/util.h
src/boot/bootctl.c
src/core/cgroup.c
src/core/dbus-cgroup.c
src/core/dbus-manager.c
src/core/dbus-service.c
src/core/ima-setup.c
src/core/manager.c
src/cryptsetup/cryptsetup-generator.c
src/dbus1-generator/dbus1-generator.c
src/fstab-generator/fstab-generator.c
src/hwdb/hwdb.c
src/import/export-raw.c
src/import/export-tar.c
src/import/import-raw.c
src/import/import-tar.c
src/import/pull-dkr.c
src/import/pull-raw.c
src/import/pull-tar.c
src/journal/catalog.c
src/journal/coredumpctl.c
src/journal/journal-send.c
src/journal/journal-verify.c
src/journal/test-catalog.c
src/journal/test-compress.c
src/journal/test-mmap-cache.c
src/libsystemd-network/sd-lldp.c
src/libsystemd/sd-bus/bus-dump.c
src/libsystemd/sd-bus/bus-introspect.c
src/libsystemd/sd-bus/bus-match.c
src/libsystemd/sd-path/sd-path.c
src/libudev/libudev-monitor.c
src/login/logind-seat.c
src/modules-load/modules-load.c
src/network/networkd-manager.c
src/shared/ask-password-api.c
src/shared/clean-ipc.c
src/shared/machine-pool.c
src/test/test-async.c
src/test/test-fdset.c
src/test/test-terminal-util.c
src/test/test-tmpfiles.c
src/tmpfiles/tmpfiles.c
src/udev/udevadm-hwdb.c

index 50328e4187fda15ca64480deb13af7442a5189d6..62b03a913c61334b410ca8cdc3525ee284eb1906 100644 (file)
@@ -24,6 +24,7 @@
 
 #include "string-util.h"
 #include "calendarspec.h"
+#include "fileio.h"
 
 #define BITS_WEEKDAYS   127
 
index 9f274c4d51c89360007fe775e169a64063a15959..4b410a74e50bb4bb7a3d627e5b8294ff3b5a7304 100644 (file)
@@ -25,6 +25,7 @@
 #include "btrfs-util.h"
 #include "copy.h"
 #include "fd-util.h"
+#include "fileio.h"
 #include "io-util.h"
 #include "string-util.h"
 #include "strv.h"
index 5d33309ab2f80b0893303ab835fcf4bb975ffba3..b7e447f6b612db250b6f0ef88bc6b8fdda67d9c3 100644 (file)
@@ -25,6 +25,9 @@
 #include "escape.h"
 #include "fd-util.h"
 #include "fileio.h"
+#include "hexdecoct.h"
+#include "path-util.h"
+#include "random-util.h"
 #include "string-util.h"
 #include "strv.h"
 #include "utf8.h"
@@ -54,7 +57,7 @@ static int write_string_file_atomic(const char *fn, const char *line, bool enfor
         if (r < 0)
                 return r;
 
-        fchmod_umask(fileno(f), 0644);
+        (void) fchmod_umask(fileno(f), 0644);
 
         r = write_string_stream(f, line, enforce_newline);
         if (r >= 0) {
@@ -63,7 +66,7 @@ static int write_string_file_atomic(const char *fn, const char *line, bool enfor
         }
 
         if (r < 0)
-                unlink(p);
+                (void) unlink(p);
 
         return r;
 }
@@ -848,3 +851,298 @@ int get_proc_field(const char *filename, const char *pattern, const char *termin
         *field = f;
         return 0;
 }
+
+DIR *xopendirat(int fd, const char *name, int flags) {
+        int nfd;
+        DIR *d;
+
+        assert(!(flags & O_CREAT));
+
+        nfd = openat(fd, name, O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC|flags, 0);
+        if (nfd < 0)
+                return NULL;
+
+        d = fdopendir(nfd);
+        if (!d) {
+                safe_close(nfd);
+                return NULL;
+        }
+
+        return d;
+}
+
+static int search_and_fopen_internal(const char *path, const char *mode, const char *root, char **search, FILE **_f) {
+        char **i;
+
+        assert(path);
+        assert(mode);
+        assert(_f);
+
+        if (!path_strv_resolve_uniq(search, root))
+                return -ENOMEM;
+
+        STRV_FOREACH(i, search) {
+                _cleanup_free_ char *p = NULL;
+                FILE *f;
+
+                if (root)
+                        p = strjoin(root, *i, "/", path, NULL);
+                else
+                        p = strjoin(*i, "/", path, NULL);
+                if (!p)
+                        return -ENOMEM;
+
+                f = fopen(p, mode);
+                if (f) {
+                        *_f = f;
+                        return 0;
+                }
+
+                if (errno != ENOENT)
+                        return -errno;
+        }
+
+        return -ENOENT;
+}
+
+int search_and_fopen(const char *path, const char *mode, const char *root, const char **search, FILE **_f) {
+        _cleanup_strv_free_ char **copy = NULL;
+
+        assert(path);
+        assert(mode);
+        assert(_f);
+
+        if (path_is_absolute(path)) {
+                FILE *f;
+
+                f = fopen(path, mode);
+                if (f) {
+                        *_f = f;
+                        return 0;
+                }
+
+                return -errno;
+        }
+
+        copy = strv_copy((char**) search);
+        if (!copy)
+                return -ENOMEM;
+
+        return search_and_fopen_internal(path, mode, root, copy, _f);
+}
+
+int search_and_fopen_nulstr(const char *path, const char *mode, const char *root, const char *search, FILE **_f) {
+        _cleanup_strv_free_ char **s = NULL;
+
+        if (path_is_absolute(path)) {
+                FILE *f;
+
+                f = fopen(path, mode);
+                if (f) {
+                        *_f = f;
+                        return 0;
+                }
+
+                return -errno;
+        }
+
+        s = strv_split_nulstr(search);
+        if (!s)
+                return -ENOMEM;
+
+        return search_and_fopen_internal(path, mode, root, s, _f);
+}
+
+int fopen_temporary(const char *path, FILE **_f, char **_temp_path) {
+        FILE *f;
+        char *t;
+        int r, fd;
+
+        assert(path);
+        assert(_f);
+        assert(_temp_path);
+
+        r = tempfn_xxxxxx(path, NULL, &t);
+        if (r < 0)
+                return r;
+
+        fd = mkostemp_safe(t, O_WRONLY|O_CLOEXEC);
+        if (fd < 0) {
+                free(t);
+                return -errno;
+        }
+
+        f = fdopen(fd, "we");
+        if (!f) {
+                unlink_noerrno(t);
+                free(t);
+                safe_close(fd);
+                return -errno;
+        }
+
+        *_f = f;
+        *_temp_path = t;
+
+        return 0;
+}
+
+int fflush_and_check(FILE *f) {
+        assert(f);
+
+        errno = 0;
+        fflush(f);
+
+        if (ferror(f))
+                return errno ? -errno : -EIO;
+
+        return 0;
+}
+
+/* This is much like like mkostemp() but is subject to umask(). */
+int mkostemp_safe(char *pattern, int flags) {
+        _cleanup_umask_ mode_t u;
+        int fd;
+
+        assert(pattern);
+
+        u = umask(077);
+
+        fd = mkostemp(pattern, flags);
+        if (fd < 0)
+                return -errno;
+
+        return fd;
+}
+
+int open_tmpfile(const char *path, int flags) {
+        char *p;
+        int fd;
+
+        assert(path);
+
+#ifdef O_TMPFILE
+        /* Try O_TMPFILE first, if it is supported */
+        fd = open(path, flags|O_TMPFILE|O_EXCL, S_IRUSR|S_IWUSR);
+        if (fd >= 0)
+                return fd;
+#endif
+
+        /* Fall back to unguessable name + unlinking */
+        p = strjoina(path, "/systemd-tmp-XXXXXX");
+
+        fd = mkostemp_safe(p, flags);
+        if (fd < 0)
+                return fd;
+
+        unlink(p);
+        return fd;
+}
+
+int tempfn_xxxxxx(const char *p, const char *extra, char **ret) {
+        const char *fn;
+        char *t;
+
+        assert(p);
+        assert(ret);
+
+        /*
+         * Turns this:
+         *         /foo/bar/waldo
+         *
+         * Into this:
+         *         /foo/bar/.#<extra>waldoXXXXXX
+         */
+
+        fn = basename(p);
+        if (!filename_is_valid(fn))
+                return -EINVAL;
+
+        if (extra == NULL)
+                extra = "";
+
+        t = new(char, strlen(p) + 2 + strlen(extra) + 6 + 1);
+        if (!t)
+                return -ENOMEM;
+
+        strcpy(stpcpy(stpcpy(stpcpy(mempcpy(t, p, fn - p), ".#"), extra), fn), "XXXXXX");
+
+        *ret = path_kill_slashes(t);
+        return 0;
+}
+
+int tempfn_random(const char *p, const char *extra, char **ret) {
+        const char *fn;
+        char *t, *x;
+        uint64_t u;
+        unsigned i;
+
+        assert(p);
+        assert(ret);
+
+        /*
+         * Turns this:
+         *         /foo/bar/waldo
+         *
+         * Into this:
+         *         /foo/bar/.#<extra>waldobaa2a261115984a9
+         */
+
+        fn = basename(p);
+        if (!filename_is_valid(fn))
+                return -EINVAL;
+
+        if (!extra)
+                extra = "";
+
+        t = new(char, strlen(p) + 2 + strlen(extra) + 16 + 1);
+        if (!t)
+                return -ENOMEM;
+
+        x = stpcpy(stpcpy(stpcpy(mempcpy(t, p, fn - p), ".#"), extra), fn);
+
+        u = random_u64();
+        for (i = 0; i < 16; i++) {
+                *(x++) = hexchar(u & 0xF);
+                u >>= 4;
+        }
+
+        *x = 0;
+
+        *ret = path_kill_slashes(t);
+        return 0;
+}
+
+int tempfn_random_child(const char *p, const char *extra, char **ret) {
+        char *t, *x;
+        uint64_t u;
+        unsigned i;
+
+        assert(p);
+        assert(ret);
+
+        /* Turns this:
+         *         /foo/bar/waldo
+         * Into this:
+         *         /foo/bar/waldo/.#<extra>3c2b6219aa75d7d0
+         */
+
+        if (!extra)
+                extra = "";
+
+        t = new(char, strlen(p) + 3 + strlen(extra) + 16 + 1);
+        if (!t)
+                return -ENOMEM;
+
+        x = stpcpy(stpcpy(stpcpy(t, p), "/.#"), extra);
+
+        u = random_u64();
+        for (i = 0; i < 16; i++) {
+                *(x++) = hexchar(u & 0xF);
+                u >>= 4;
+        }
+
+        *x = 0;
+
+        *ret = path_kill_slashes(t);
+        return 0;
+}
index 4998d4d04232e31acaa7f4ef0a90fcd7a94df7c8..fa7f1923317d3fb9aed62c20b5a588f3c685190c 100644 (file)
   You should have received a copy of the GNU Lesser General Public License
   along with systemd; If not, see <http://www.gnu.org/licenses/>.
 ***/
+
+#include <dirent.h>
+#include <stdbool.h>
 #include <stddef.h>
 #include <stdio.h>
+#include <sys/types.h>
 
 #include "macro.h"
 
@@ -49,3 +53,27 @@ int write_env_file(const char *fname, char **l);
 int executable_is_script(const char *path, char **interpreter);
 
 int get_proc_field(const char *filename, const char *pattern, const char *terminator, char **field);
+
+DIR *xopendirat(int dirfd, const char *name, int flags);
+
+int search_and_fopen(const char *path, const char *mode, const char *root, const char **search, FILE **_f);
+int search_and_fopen_nulstr(const char *path, const char *mode, const char *root, const char *search, FILE **_f);
+
+#define FOREACH_LINE(line, f, on_error)                         \
+        for (;;)                                                \
+                if (!fgets(line, sizeof(line), f)) {            \
+                        if (ferror(f)) {                        \
+                                on_error;                       \
+                        }                                       \
+                        break;                                  \
+                } else
+
+int fflush_and_check(FILE *f);
+
+int fopen_temporary(const char *path, FILE **_f, char **_temp_path);
+int mkostemp_safe(char *pattern, int flags);
+int open_tmpfile(const char *path, int flags);
+
+int tempfn_xxxxxx(const char *p, const char *extra, char **ret);
+int tempfn_random(const char *p, const char *extra, char **ret);
+int tempfn_random_child(const char *p, const char *extra, char **ret);
index 7d058416e5bc6cda0451b8e7a31faeba2597d174..ea0528c6fcbd19dafbfcdd7d1b687151366c2199 100644 (file)
@@ -23,6 +23,7 @@
 #include <sys/utsname.h>
 
 #include "fd-util.h"
+#include "fileio.h"
 #include "hostname-util.h"
 #include "string-util.h"
 #include "util.h"
index b348ed4204d8f67bbcfc6b43c80708736af5686c..b7d92cbad884d9907315287a0094d44711cecf8d 100644 (file)
@@ -24,6 +24,7 @@
 #include <sys/timex.h>
 
 #include "fd-util.h"
+#include "fileio.h"
 #include "path-util.h"
 #include "string-util.h"
 #include "strv.h"
index f403dca10efb3d0b4b1ea3ba02cf14ab3ffc07b9..25ba59505df6e5bd3a951d22dbd80c101ede80d5 100644 (file)
@@ -636,25 +636,6 @@ int null_or_empty_fd(int fd) {
         return null_or_empty(&st);
 }
 
-DIR *xopendirat(int fd, const char *name, int flags) {
-        int nfd;
-        DIR *d;
-
-        assert(!(flags & O_CREAT));
-
-        nfd = openat(fd, name, O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC|flags, 0);
-        if (nfd < 0)
-                return NULL;
-
-        d = fdopendir(nfd);
-        if (!d) {
-                safe_close(nfd);
-                return NULL;
-        }
-
-        return d;
-}
-
 static char *tag_to_udev_node(const char *tagvalue, const char *by) {
         _cleanup_free_ char *t = NULL, *u = NULL;
         size_t enc_len;
@@ -864,39 +845,6 @@ bool plymouth_running(void) {
         return access("/run/plymouth/pid", F_OK) >= 0;
 }
 
-int fopen_temporary(const char *path, FILE **_f, char **_temp_path) {
-        FILE *f;
-        char *t;
-        int r, fd;
-
-        assert(path);
-        assert(_f);
-        assert(_temp_path);
-
-        r = tempfn_xxxxxx(path, NULL, &t);
-        if (r < 0)
-                return r;
-
-        fd = mkostemp_safe(t, O_WRONLY|O_CLOEXEC);
-        if (fd < 0) {
-                free(t);
-                return -errno;
-        }
-
-        f = fdopen(fd, "we");
-        if (!f) {
-                unlink_noerrno(t);
-                free(t);
-                safe_close(fd);
-                return -errno;
-        }
-
-        *_f = f;
-        *_temp_path = t;
-
-        return 0;
-}
-
 int symlink_atomic(const char *from, const char *to) {
         _cleanup_free_ char *t = NULL;
         int r;
@@ -1782,88 +1730,6 @@ int on_ac_power(void) {
         return found_online || !found_offline;
 }
 
-static int search_and_fopen_internal(const char *path, const char *mode, const char *root, char **search, FILE **_f) {
-        char **i;
-
-        assert(path);
-        assert(mode);
-        assert(_f);
-
-        if (!path_strv_resolve_uniq(search, root))
-                return -ENOMEM;
-
-        STRV_FOREACH(i, search) {
-                _cleanup_free_ char *p = NULL;
-                FILE *f;
-
-                if (root)
-                        p = strjoin(root, *i, "/", path, NULL);
-                else
-                        p = strjoin(*i, "/", path, NULL);
-                if (!p)
-                        return -ENOMEM;
-
-                f = fopen(p, mode);
-                if (f) {
-                        *_f = f;
-                        return 0;
-                }
-
-                if (errno != ENOENT)
-                        return -errno;
-        }
-
-        return -ENOENT;
-}
-
-int search_and_fopen(const char *path, const char *mode, const char *root, const char **search, FILE **_f) {
-        _cleanup_strv_free_ char **copy = NULL;
-
-        assert(path);
-        assert(mode);
-        assert(_f);
-
-        if (path_is_absolute(path)) {
-                FILE *f;
-
-                f = fopen(path, mode);
-                if (f) {
-                        *_f = f;
-                        return 0;
-                }
-
-                return -errno;
-        }
-
-        copy = strv_copy((char**) search);
-        if (!copy)
-                return -ENOMEM;
-
-        return search_and_fopen_internal(path, mode, root, copy, _f);
-}
-
-int search_and_fopen_nulstr(const char *path, const char *mode, const char *root, const char *search, FILE **_f) {
-        _cleanup_strv_free_ char **s = NULL;
-
-        if (path_is_absolute(path)) {
-                FILE *f;
-
-                f = fopen(path, mode);
-                if (f) {
-                        *_f = f;
-                        return 0;
-                }
-
-                return -errno;
-        }
-
-        s = strv_split_nulstr(search);
-        if (!s)
-                return -ENOMEM;
-
-        return search_and_fopen_internal(path, mode, root, s, _f);
-}
-
 void* greedy_realloc(void **p, size_t *allocated, size_t need, size_t size) {
         size_t a, newalloc;
         void *q;
@@ -2213,46 +2079,6 @@ int namespace_enter(int pidns_fd, int mntns_fd, int netns_fd, int userns_fd, int
         return reset_uid_gid();
 }
 
-/* This is much like like mkostemp() but is subject to umask(). */
-int mkostemp_safe(char *pattern, int flags) {
-        _cleanup_umask_ mode_t u;
-        int fd;
-
-        assert(pattern);
-
-        u = umask(077);
-
-        fd = mkostemp(pattern, flags);
-        if (fd < 0)
-                return -errno;
-
-        return fd;
-}
-
-int open_tmpfile(const char *path, int flags) {
-        char *p;
-        int fd;
-
-        assert(path);
-
-#ifdef O_TMPFILE
-        /* Try O_TMPFILE first, if it is supported */
-        fd = open(path, flags|O_TMPFILE|O_EXCL, S_IRUSR|S_IWUSR);
-        if (fd >= 0)
-                return fd;
-#endif
-
-        /* Fall back to unguessable name + unlinking */
-        p = strjoina(path, "/systemd-tmp-XXXXXX");
-
-        fd = mkostemp_safe(p, flags);
-        if (fd < 0)
-                return fd;
-
-        unlink(p);
-        return fd;
-}
-
 int fd_warn_permissions(const char *path, int fd) {
         struct stat st;
 
@@ -2599,127 +2425,6 @@ int bind_remount_recursive(const char *prefix, bool ro) {
         }
 }
 
-int fflush_and_check(FILE *f) {
-        assert(f);
-
-        errno = 0;
-        fflush(f);
-
-        if (ferror(f))
-                return errno ? -errno : -EIO;
-
-        return 0;
-}
-
-int tempfn_xxxxxx(const char *p, const char *extra, char **ret) {
-        const char *fn;
-        char *t;
-
-        assert(p);
-        assert(ret);
-
-        /*
-         * Turns this:
-         *         /foo/bar/waldo
-         *
-         * Into this:
-         *         /foo/bar/.#<extra>waldoXXXXXX
-         */
-
-        fn = basename(p);
-        if (!filename_is_valid(fn))
-                return -EINVAL;
-
-        if (extra == NULL)
-                extra = "";
-
-        t = new(char, strlen(p) + 2 + strlen(extra) + 6 + 1);
-        if (!t)
-                return -ENOMEM;
-
-        strcpy(stpcpy(stpcpy(stpcpy(mempcpy(t, p, fn - p), ".#"), extra), fn), "XXXXXX");
-
-        *ret = path_kill_slashes(t);
-        return 0;
-}
-
-int tempfn_random(const char *p, const char *extra, char **ret) {
-        const char *fn;
-        char *t, *x;
-        uint64_t u;
-        unsigned i;
-
-        assert(p);
-        assert(ret);
-
-        /*
-         * Turns this:
-         *         /foo/bar/waldo
-         *
-         * Into this:
-         *         /foo/bar/.#<extra>waldobaa2a261115984a9
-         */
-
-        fn = basename(p);
-        if (!filename_is_valid(fn))
-                return -EINVAL;
-
-        if (!extra)
-                extra = "";
-
-        t = new(char, strlen(p) + 2 + strlen(extra) + 16 + 1);
-        if (!t)
-                return -ENOMEM;
-
-        x = stpcpy(stpcpy(stpcpy(mempcpy(t, p, fn - p), ".#"), extra), fn);
-
-        u = random_u64();
-        for (i = 0; i < 16; i++) {
-                *(x++) = hexchar(u & 0xF);
-                u >>= 4;
-        }
-
-        *x = 0;
-
-        *ret = path_kill_slashes(t);
-        return 0;
-}
-
-int tempfn_random_child(const char *p, const char *extra, char **ret) {
-        char *t, *x;
-        uint64_t u;
-        unsigned i;
-
-        assert(p);
-        assert(ret);
-
-        /* Turns this:
-         *         /foo/bar/waldo
-         * Into this:
-         *         /foo/bar/waldo/.#<extra>3c2b6219aa75d7d0
-         */
-
-        if (!extra)
-                extra = "";
-
-        t = new(char, strlen(p) + 3 + strlen(extra) + 16 + 1);
-        if (!t)
-                return -ENOMEM;
-
-        x = stpcpy(stpcpy(stpcpy(t, p), "/.#"), extra);
-
-        u = random_u64();
-        for (i = 0; i < 16; i++) {
-                *(x++) = hexchar(u & 0xF);
-                u >>= 4;
-        }
-
-        *x = 0;
-
-        *ret = path_kill_slashes(t);
-        return 0;
-}
-
 int take_password_lock(const char *root) {
 
         struct flock flock = {
index ec95c53130de202605ffa9df7bf535c717292a10..9393140c727b9eb5e22bae6aea8161a03f28ba9d 100644 (file)
@@ -158,8 +158,6 @@ ssize_t string_table_lookup(const char * const *table, size_t len, const char *k
 
 bool fstype_is_network(const char *fstype);
 
-int fopen_temporary(const char *path, FILE **_f, char **_temp_path);
-
 bool is_device_path(const char *path);
 
 int dir_is_empty(const char *path);
@@ -201,8 +199,6 @@ bool null_or_empty(struct stat *st) _pure_;
 int null_or_empty_path(const char *fn);
 int null_or_empty_fd(int fd);
 
-DIR *xopendirat(int dirfd, const char *name, int flags);
-
 char *fstab_node_to_udev_node(const char *p);
 
 void execute_directories(const char* const* directories, usec_t timeout, char *argv[]);
@@ -349,18 +345,6 @@ const char *draw_special_char(DrawSpecialChar ch);
 
 int on_ac_power(void);
 
-int search_and_fopen(const char *path, const char *mode, const char *root, const char **search, FILE **_f);
-int search_and_fopen_nulstr(const char *path, const char *mode, const char *root, const char *search, FILE **_f);
-
-#define FOREACH_LINE(line, f, on_error)                         \
-        for (;;)                                                \
-                if (!fgets(line, sizeof(line), f)) {            \
-                        if (ferror(f)) {                        \
-                                on_error;                       \
-                        }                                       \
-                        break;                                  \
-                } else
-
 #define FOREACH_DIRENT(de, d, on_error)                                 \
         for (errno = 0, de = readdir(d);; errno = 0, de = readdir(d))   \
                 if (!de) {                                              \
@@ -521,9 +505,6 @@ int container_get_leader(const char *machine, pid_t *pid);
 int namespace_open(pid_t pid, int *pidns_fd, int *mntns_fd, int *netns_fd, int *userns_fd, int *root_fd);
 int namespace_enter(int pidns_fd, int mntns_fd, int netns_fd, int userns_fd, int root_fd);
 
-int mkostemp_safe(char *pattern, int flags);
-int open_tmpfile(const char *path, int flags);
-
 int fd_warn_permissions(const char *path, int fd);
 
 #ifndef PERSONALITY_INVALID
@@ -550,12 +531,6 @@ int umount_recursive(const char *target, int flags);
 
 int bind_remount_recursive(const char *prefix, bool ro);
 
-int fflush_and_check(FILE *f);
-
-int tempfn_xxxxxx(const char *p, const char *extra, char **ret);
-int tempfn_random(const char *p, const char *extra, char **ret);
-int tempfn_random_child(const char *p, const char *extra, char **ret);
-
 int take_password_lock(const char *root);
 
 int is_symlink(const char *path);
index a167f8086ca4d32b357dc0a08ba3ac84484c6d65..7e06abd3bf2b85abb769bbf7a1cd824281592c86 100644 (file)
@@ -40,6 +40,7 @@
 #include "blkid-util.h"
 #include "efivars.h"
 #include "fd-util.h"
+#include "fileio.h"
 #include "rm-rf.h"
 #include "string-util.h"
 #include "util.h"
index a33eaa8d421a4287994fac228c6b7a5af82a52b6..6ef0580fad08ee1e6af73c306e57fdf0ae4ffba0 100644 (file)
@@ -25,6 +25,7 @@
 #include "cgroup-util.h"
 #include "cgroup.h"
 #include "fd-util.h"
+#include "fileio.h"
 #include "parse-util.h"
 #include "path-util.h"
 #include "process-util.h"
index 6a43be873a8b2a298aa6bcad975d1dc7543f469e..f424909b46d3ba6b2224a631abb174e8e8e1a4f7 100644 (file)
@@ -24,6 +24,7 @@
 #include "cgroup.h"
 #include "dbus-cgroup.h"
 #include "fd-util.h"
+#include "fileio.h"
 #include "path-util.h"
 
 static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_cgroup_device_policy, cgroup_device_policy, CGroupDevicePolicy);
index 1ef259ec7aebd02c7c48f2c618b14b6ff3b45754..77a64dfd574452a91ad6b568f7d8eabd3d6ec5b2 100644 (file)
@@ -35,6 +35,7 @@
 #include "dbus.h"
 #include "env-util.h"
 #include "fd-util.h"
+#include "fileio.h"
 #include "formats-util.h"
 #include "install.h"
 #include "log.h"
index 22b8690c540df6c4ca30eb7b724870832781f808..91cdeb1f30b21bbff9778349ae15e797e3dc6cb8 100644 (file)
@@ -26,6 +26,7 @@
 #include "dbus-kill.h"
 #include "dbus-service.h"
 #include "fd-util.h"
+#include "fileio.h"
 #include "path-util.h"
 #include "service.h"
 #include "string-util.h"
index 0c0982b0b4cbc1c71627856bc4b988b6a36acba9..9572fa17d9cd61f3c53aacfd03ce4f0aca63d10c 100644 (file)
@@ -25,6 +25,7 @@
 #include <errno.h>
 
 #include "fd-util.h"
+#include "fileio.h"
 #include "ima-setup.h"
 #include "log.h"
 #include "util.h"
index 9ad8a136abb326c1bf3861e0af126e193949e3a2..589501519aff1cc0f955a72cb05be7893cc265fe 100644 (file)
@@ -54,6 +54,7 @@
 #include "escape.h"
 #include "exit-status.h"
 #include "fd-util.h"
+#include "fileio.h"
 #include "hashmap.h"
 #include "io-util.h"
 #include "locale-setup.h"
index 51a2c6dfd7b7332f6d1088f030119ea4b9b83a9e..768d59c8df238d0b5a41499ec2f606a25ba40922 100644 (file)
@@ -23,6 +23,7 @@
 
 #include "dropin.h"
 #include "fd-util.h"
+#include "fileio.h"
 #include "fstab-util.h"
 #include "generator.h"
 #include "hashmap.h"
index 8dd75f332409dcc31eb6bd8a4025398195b357f9..b9683a7ee19e5a2ac7b5bc7266f06d15a9f3273a 100644 (file)
@@ -24,6 +24,7 @@
 #include "cgroup-util.h"
 #include "conf-parser.h"
 #include "fd-util.h"
+#include "fileio.h"
 #include "mkdir.h"
 #include "special.h"
 #include "unit-name.h"
index 18baf6cc7d34392e46992cb8747524b32f1347ea..732b3d1704a3355ed5ed94d16ab2ba08466e6c36 100644 (file)
@@ -26,6 +26,7 @@
 #include <unistd.h>
 
 #include "fd-util.h"
+#include "fileio.h"
 #include "fstab-util.h"
 #include "generator.h"
 #include "log.h"
index 3b800e99d37f3a9085cd64a846f47231d1a197c4..b4118828a94f229c7293e824d113cc1efbe19c53 100644 (file)
@@ -23,6 +23,8 @@
 #include <string.h>
 
 #include "conf-files.h"
+#include "fd-util.h"
+#include "fileio.h"
 #include "hwdb-internal.h"
 #include "hwdb-util.h"
 #include "mkdir.h"
@@ -31,7 +33,6 @@
 #include "strv.h"
 #include "util.h"
 #include "verbs.h"
-#include "fd-util.h"
 
 /*
  * Generic udev properties, key/value database based on modalias strings.
index 24c0ec930999b7b161c6ce93fdd077eecc759738..85e781a3085c8633a31b62e5f6c10f18bf20017e 100644 (file)
@@ -29,6 +29,7 @@
 #include "copy.h"
 #include "export-raw.h"
 #include "fd-util.h"
+#include "fileio.h"
 #include "import-common.h"
 #include "ratelimit.h"
 #include "string-util.h"
index aa9b7f1a91b66302edd8d34c810c0a9c7fa90e3b..38e659a517ebadbb1cc3cab7345fc7230f610e4e 100644 (file)
@@ -24,6 +24,7 @@
 #include "btrfs-util.h"
 #include "export-tar.h"
 #include "fd-util.h"
+#include "fileio.h"
 #include "import-common.h"
 #include "process-util.h"
 #include "ratelimit.h"
index a34f30abfcf7d6244f6dd2957d34c7fec4a20abc..d94d8ab4ae64f21b9097f3e7a015ea3f1fdb185b 100644 (file)
@@ -27,6 +27,7 @@
 #include "btrfs-util.h"
 #include "copy.h"
 #include "fd-util.h"
+#include "fileio.h"
 #include "hostname-util.h"
 #include "import-common.h"
 #include "import-compress.h"
index 9aade0f4304ba192f95c1e83fc05bbd9855529d7..d88eae1973e69581af7e3b710d085520bf2248cc 100644 (file)
@@ -27,6 +27,7 @@
 #include "btrfs-util.h"
 #include "copy.h"
 #include "fd-util.h"
+#include "fileio.h"
 #include "hostname-util.h"
 #include "import-common.h"
 #include "import-compress.h"
index 448dbafa9f3564dc59c2aade7a50eb970d5873de..700462bfd2f3c45107c377d131905c854040e8d8 100644 (file)
@@ -28,6 +28,7 @@
 #include "btrfs-util.h"
 #include "curl-util.h"
 #include "fd-util.h"
+#include "fileio.h"
 #include "hostname-util.h"
 #include "import-common.h"
 #include "import-util.h"
index 848a4fcd4465c94eea56c0320c4050426c240765..4d0ac770aab55c8b7becb3638a75bec9d68c6072 100644 (file)
@@ -29,6 +29,7 @@
 #include "copy.h"
 #include "curl-util.h"
 #include "fd-util.h"
+#include "fileio.h"
 #include "hostname-util.h"
 #include "import-common.h"
 #include "import-util.h"
index 3540bbff4162358bc5b481f81bd8522ac97fd9ea..3e21d72157e90b8b47ac4307daa5db0e8e39bb1d 100644 (file)
@@ -28,6 +28,7 @@
 #include "copy.h"
 #include "curl-util.h"
 #include "fd-util.h"
+#include "fileio.h"
 #include "hostname-util.h"
 #include "import-common.h"
 #include "import-util.h"
index fe3975b7b8e689631c70d14973d3ee638199b5a4..72d2bedc2673a56e0633687634fad473091e0d7b 100644 (file)
@@ -32,6 +32,7 @@
 #include "catalog.h"
 #include "conf-files.h"
 #include "fd-util.h"
+#include "fileio.h"
 #include "hashmap.h"
 #include "log.h"
 #include "mkdir.h"
index fecccd4eb92b9b9c46feeb97c6c61701a3e7f910..07ca8dde0a5e4140d0130208c1c5030d80fff13e 100644 (file)
@@ -30,6 +30,7 @@
 
 #include "compress.h"
 #include "fd-util.h"
+#include "fileio.h"
 #include "journal-internal.h"
 #include "log.h"
 #include "macro.h"
index f388c30d2e4e4aa757adbe62df5cb1d6f703208e..dddd5703f445acf90921ea11fed692f1ee85146a 100644 (file)
@@ -32,6 +32,7 @@
 #include "sd-journal.h"
 
 #include "fd-util.h"
+#include "fileio.h"
 #include "io-util.h"
 #include "memfd-util.h"
 #include "socket-util.h"
index de4f73a471301469cfac60a911e9175196cf52b5..5d000aedbbc116ea1d74efa5853e592e26d3a07f 100644 (file)
@@ -26,6 +26,7 @@
 
 #include "compress.h"
 #include "fd-util.h"
+#include "fileio.h"
 #include "journal-authenticate.h"
 #include "journal-def.h"
 #include "journal-file.h"
index 72c1f60f023400bd7c5a6e62680ef9d69a67609b..c942df46a821c43a6c65811ed1d1bd55a1c6307c 100644 (file)
@@ -29,6 +29,7 @@
 
 #include "catalog.h"
 #include "fd-util.h"
+#include "fileio.h"
 #include "log.h"
 #include "macro.h"
 #include "string-util.h"
index e562fa19482510611d4adb87469a28211075fc7c..db4fa1555412b3c6e4c32dd27e04780195c552cf 100644 (file)
@@ -19,6 +19,7 @@
 
 #include "compress.h"
 #include "fd-util.h"
+#include "fileio.h"
 #include "macro.h"
 #include "random-util.h"
 #include "util.h"
index ac1239acc400a16f868e415b32a9ab208cc65013..fdd48e531c16be16b4f3782149f9b7f953910e9d 100644 (file)
   along with systemd; If not, see <http://www.gnu.org/licenses/>.
 ***/
 
+#include <fcntl.h>
 #include <stdlib.h>
 #include <sys/mman.h>
 #include <unistd.h>
-#include <fcntl.h>
 
 #include "fd-util.h"
+#include "fileio.h"
 #include "macro.h"
 #include "mmap-cache.h"
 #include "util.h"
index b2b85e56e817f2133354daf79e24dede82a1ccbe..bc06f483864e5a811e04ce0f576503f4d102cdf9 100644 (file)
@@ -25,6 +25,7 @@
 #include "sd-lldp.h"
 
 #include "fd-util.h"
+#include "fileio.h"
 #include "hashmap.h"
 #include "lldp-internal.h"
 #include "lldp-port.h"
index cd7fcc7c80b2d2029026868f34ea4519ce3901d8..9ddd059072b6aec6881227b6e9abad153c94a16d 100644 (file)
   along with systemd; If not, see <http://www.gnu.org/licenses/>.
 ***/
 
+#include "bus-dump.h"
 #include "bus-internal.h"
 #include "bus-message.h"
 #include "bus-type.h"
 #include "cap-list.h"
 #include "capability.h"
+#include "fileio.h"
 #include "formats-util.h"
 #include "macro.h"
 #include "string-util.h"
 #include "strv.h"
 #include "terminal-util.h"
 #include "util.h"
-#include "bus-dump.h"
 
 static char *indent(unsigned level, unsigned flags) {
         char *p;
index f5a8885332b470d2fba9d00fd0efefe1d05eb0f6..a90536bac9d0086d01c8b640f03fc7bbb9bd0e0f 100644 (file)
@@ -24,6 +24,7 @@
 #include "bus-protocol.h"
 #include "bus-signature.h"
 #include "fd-util.h"
+#include "fileio.h"
 #include "string-util.h"
 #include "util.h"
 
index fca3ebd394d978d7204e68ddbde332bce31bd7e2..6a37f22c1f7dd34b57bd031c612ab075fd1b68ab 100644 (file)
@@ -24,6 +24,7 @@
 #include "bus-message.h"
 #include "bus-util.h"
 #include "fd-util.h"
+#include "fileio.h"
 #include "hexdecoct.h"
 #include "string-util.h"
 #include "strv.h"
index 8e3eeb15d89f33bc8b61158f1ed4d352f31af5c5..c1d42e96e5733a50cc0e72f2c3ee272cf098718e 100644 (file)
@@ -21,6 +21,7 @@
 
 #include "architecture.h"
 #include "fd-util.h"
+#include "fileio.h"
 #include "missing.h"
 #include "path-util.h"
 #include "string-util.h"
index 5590aec2b75e2e2b651a4aff9e5e6f1ed698aefe..0059c09e77bb2bedab608d7646900d45898aafcc 100644 (file)
@@ -31,6 +31,7 @@
 #include "libudev.h"
 
 #include "fd-util.h"
+#include "fileio.h"
 #include "formats-util.h"
 #include "libudev-private.h"
 #include "missing.h"
index 2566894d0579aaf4abf0f1eb1c5f1b4885241939..2dcf8ddc62bae32c152b20c69a35484cecfaae5a 100644 (file)
@@ -27,6 +27,7 @@
 #include "sd-messages.h"
 
 #include "fd-util.h"
+#include "fileio.h"
 #include "formats-util.h"
 #include "logind-acl.h"
 #include "logind-seat.h"
index 34bd65cb11f56b903b26b1bf2bd050ad4bf60ff1..5627e63938af4ab859793302b42640ba2b88695a 100644 (file)
@@ -28,6 +28,7 @@
 
 #include "conf-files.h"
 #include "fd-util.h"
+#include "fileio.h"
 #include "log.h"
 #include "string-util.h"
 #include "strv.h"
index febfe2ff81fdfdc5e2a70ba6f89b52002056f6ed..af243c9a708ff806a237cf452d3051c39341de0f 100644 (file)
@@ -29,6 +29,7 @@
 #include "conf-parser.h"
 #include "def.h"
 #include "fd-util.h"
+#include "fileio.h"
 #include "libudev-private.h"
 #include "local-addresses.h"
 #include "netlink-util.h"
index 15203d21eae307929c65cd21ab49dcd277f1c12b..9e8025d615dc00c3d7ac317dea073878c21679c1 100644 (file)
@@ -34,6 +34,7 @@
 
 #include "ask-password-api.h"
 #include "fd-util.h"
+#include "fileio.h"
 #include "formats-util.h"
 #include "io-util.h"
 #include "missing.h"
index fe3187384fde841ad8eb527c3a057f29683ad5c0..2be1bc3fc0b3b829a182edb043db5dcbee30cd63 100644 (file)
@@ -30,6 +30,7 @@
 
 #include "clean-ipc.h"
 #include "fd-util.h"
+#include "fileio.h"
 #include "formats-util.h"
 #include "string-util.h"
 #include "strv.h"
index c576242b59917662b81886dc96ce8d074d5ba05a..6d726a687a4671fc14cc717df58b3e3c2f189765 100644 (file)
@@ -26,6 +26,7 @@
 
 #include "btrfs-util.h"
 #include "fd-util.h"
+#include "fileio.h"
 #include "lockfile-util.h"
 #include "machine-pool.h"
 #include "mkdir.h"
index abd36d693cd949108d57e0494d417f80cf1b3350..ada6d67c424b5605e476a1385269c5558571d48d 100644 (file)
@@ -20,8 +20,9 @@
 #include <unistd.h>
 
 #include "async.h"
-#include "util.h"
+#include "fileio.h"
 #include "macro.h"
+#include "util.h"
 
 static bool test_async = false;
 
index 96d5e3817700e0710990ec3205660c3af67099be..282aab12460b3156cf212b7ac1426b77add7b3d0 100644 (file)
@@ -22,6 +22,7 @@
 
 #include "fd-util.h"
 #include "fdset.h"
+#include "fileio.h"
 #include "macro.h"
 #include "util.h"
 
index a41de59719a28bc0e061467e60aeff8d3f23c7fd..e940b5a204ce229d00d63d559b9fd6fc0fc60651 100644 (file)
 #include <stdio.h>
 #include <stdbool.h>
 
-#include "terminal-util.h"
+#include "fd-util.h"
+#include "fileio.h"
+#include "log.h"
 #include "macro.h"
+#include "terminal-util.h"
 #include "util.h"
-#include "log.h"
-#include "fd-util.h"
 
 static void test_default_term_for_tty(void) {
         puts(default_term_for_tty("/dev/tty23"));
index 6aa9cc847386469341e28df385cad19875e87465..683fbe217ceea81e2a011846c89499224952e0f3 100644 (file)
@@ -25,6 +25,7 @@
 #include <unistd.h>
 
 #include "fd-util.h"
+#include "fileio.h"
 #include "formats-util.h"
 #include "string-util.h"
 #include "util.h"
index 57cca17e80730a2908ecbb835ff483189c3cc9d4..85a2d6c2f5e0b41d5c4d3fb2f6cca355c7cb9360 100644 (file)
@@ -45,6 +45,7 @@
 #include "copy.h"
 #include "escape.h"
 #include "fd-util.h"
+#include "fileio.h"
 #include "formats-util.h"
 #include "io-util.h"
 #include "label.h"
index f9509ad6406683cbc3ebdabdf7f49077fe2aa8ce..69aff7b57983bbef1d881e3f0008934e72d2b2ab 100644 (file)
@@ -23,6 +23,7 @@
 #include <string.h>
 
 #include "conf-files.h"
+#include "fileio.h"
 #include "hwdb-internal.h"
 #include "hwdb-util.h"
 #include "strbuf.h"