diff options
Diffstat (limited to 'src')
274 files changed, 971 insertions, 659 deletions
diff --git a/src/activate/activate.c b/src/activate/activate.c index adb43623cf..0e6ead310e 100644 --- a/src/activate/activate.c +++ b/src/activate/activate.c @@ -34,6 +34,7 @@ #include "socket-util.h" #include "string-util.h" #include "strv.h" +#include "fd-util.h" static char** arg_listen = NULL; static bool arg_accept = false; diff --git a/src/basic/async.c b/src/basic/async.c index 7725e6d7d3..c3135f0efe 100644 --- a/src/basic/async.c +++ b/src/basic/async.c @@ -23,6 +23,7 @@ #include <unistd.h> #include "async.h" +#include "fd-util.h" #include "log.h" #include "util.h" diff --git a/src/basic/audit.c b/src/basic/audit.c index 1f593aa813..af43ec8097 100644 --- a/src/basic/audit.c +++ b/src/basic/audit.c @@ -22,11 +22,12 @@ #include <errno.h> #include <stdio.h> -#include "macro.h" #include "audit.h" -#include "util.h" -#include "process-util.h" +#include "fd-util.h" #include "fileio.h" +#include "macro.h" +#include "process-util.h" +#include "util.h" int audit_session_from_pid(pid_t pid, uint32_t *id) { _cleanup_free_ char *s = NULL; diff --git a/src/basic/barrier.c b/src/basic/barrier.c index 436ba95989..2d55bab4ab 100644 --- a/src/basic/barrier.c +++ b/src/basic/barrier.c @@ -30,6 +30,7 @@ #include <unistd.h> #include "barrier.h" +#include "fd-util.h" #include "macro.h" #include "util.h" diff --git a/src/basic/btrfs-util.c b/src/basic/btrfs-util.c index df7b959c12..f799f8dcc2 100644 --- a/src/basic/btrfs-util.c +++ b/src/basic/btrfs-util.c @@ -27,7 +27,9 @@ #endif #include "btrfs-ctree.h" +#include "btrfs-util.h" #include "copy.h" +#include "fd-util.h" #include "fileio.h" #include "macro.h" #include "missing.h" @@ -36,7 +38,6 @@ #include "smack-util.h" #include "string-util.h" #include "util.h" -#include "btrfs-util.h" /* WARNING: Be careful with file system ioctls! When we get an fd, we * need to make sure it either refers to only a regular file or diff --git a/src/basic/capability.c b/src/basic/capability.c index 8dbe4da5bb..6f25b5dee9 100644 --- a/src/basic/capability.c +++ b/src/basic/capability.c @@ -19,18 +19,18 @@ along with systemd; If not, see <http://www.gnu.org/licenses/>. ***/ -#include <unistd.h> #include <errno.h> +#include <grp.h> #include <stdio.h> #include <sys/capability.h> #include <sys/prctl.h> -#include "grp.h" +#include <unistd.h> +#include "capability.h" +#include "fileio.h" +#include "log.h" #include "macro.h" #include "util.h" -#include "log.h" -#include "fileio.h" -#include "capability.h" int have_effective_cap(int value) { _cleanup_cap_free_ cap_t cap; diff --git a/src/basic/cgroup-util.c b/src/basic/cgroup-util.c index ce21ef73eb..958497543a 100644 --- a/src/basic/cgroup-util.c +++ b/src/basic/cgroup-util.c @@ -29,7 +29,9 @@ #include <sys/types.h> #include <unistd.h> +#include "cgroup-util.h" #include "extract-word.h" +#include "fd-util.h" #include "fileio.h" #include "formats-util.h" #include "login-util.h" @@ -42,7 +44,6 @@ #include "string-util.h" #include "unit-name.h" #include "util.h" -#include "cgroup-util.h" int cg_enumerate_processes(const char *controller, const char *path, FILE **_f) { _cleanup_free_ char *fs = NULL; diff --git a/src/basic/clock-util.c b/src/basic/clock-util.c index 03ec5725ae..00ee4c2796 100644 --- a/src/basic/clock-util.c +++ b/src/basic/clock-util.c @@ -26,10 +26,11 @@ #include <sys/ioctl.h> #include <sys/time.h> +#include "clock-util.h" +#include "fd-util.h" #include "macro.h" #include "string-util.h" #include "util.h" -#include "clock-util.h" int clock_get_hwclock(struct tm *tm) { _cleanup_close_ int fd = -1; diff --git a/src/basic/clock-util.h b/src/basic/clock-util.h index 8c2d235430..fef2d471a6 100644 --- a/src/basic/clock-util.h +++ b/src/basic/clock-util.h @@ -21,6 +21,7 @@ along with systemd; If not, see <http://www.gnu.org/licenses/>. ***/ +#include <time.h> int clock_is_localtime(void); int clock_set_timezone(int *min); diff --git a/src/basic/conf-files.c b/src/basic/conf-files.c index 0e44d1bbad..3af3fe392c 100644 --- a/src/basic/conf-files.c +++ b/src/basic/conf-files.c @@ -25,6 +25,8 @@ #include <stdlib.h> #include <string.h> +#include "conf-files.h" +#include "fd-util.h" #include "hashmap.h" #include "log.h" #include "macro.h" @@ -33,7 +35,6 @@ #include "string-util.h" #include "strv.h" #include "util.h" -#include "conf-files.h" static int files_add(Hashmap *h, const char *root, const char *path, const char *suffix) { _cleanup_closedir_ DIR *dir = NULL; diff --git a/src/basic/copy.c b/src/basic/copy.c index 7702d906c7..c15527df22 100644 --- a/src/basic/copy.c +++ b/src/basic/copy.c @@ -23,10 +23,11 @@ #include <sys/xattr.h> #include "btrfs-util.h" +#include "copy.h" +#include "fd-util.h" #include "string-util.h" #include "strv.h" #include "util.h" -#include "copy.h" #define COPY_BUFFER_SIZE (16*1024) diff --git a/src/basic/extract-word.c b/src/basic/extract-word.c index 52d2672390..f2b74802fa 100644 --- a/src/basic/extract-word.c +++ b/src/basic/extract-word.c @@ -22,7 +22,6 @@ #include "escape.h" #include "utf8.h" #include "util.h" - #include "extract-word.h" int extract_first_word(const char **p, char **ret, const char *separators, ExtractFlags flags) { diff --git a/src/basic/fd-util.c b/src/basic/fd-util.c new file mode 100644 index 0000000000..e54c104597 --- /dev/null +++ b/src/basic/fd-util.c @@ -0,0 +1,321 @@ +/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/ + +/*** + This file is part of systemd. + + Copyright 2010 Lennart Poettering + + systemd is free software; you can redistribute it and/or modify it + under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation; either version 2.1 of the License, or + (at your option) any later version. + + systemd is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + 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 "fd-util.h" +#include "util.h" + +int close_nointr(int fd) { + assert(fd >= 0); + + if (close(fd) >= 0) + return 0; + + /* + * Just ignore EINTR; a retry loop is the wrong thing to do on + * Linux. + * + * http://lkml.indiana.edu/hypermail/linux/kernel/0509.1/0877.html + * https://bugzilla.gnome.org/show_bug.cgi?id=682819 + * http://utcc.utoronto.ca/~cks/space/blog/unix/CloseEINTR + * https://sites.google.com/site/michaelsafyan/software-engineering/checkforeintrwheninvokingclosethinkagain + */ + if (errno == EINTR) + return 0; + + return -errno; +} + +int safe_close(int fd) { + + /* + * Like close_nointr() but cannot fail. Guarantees errno is + * unchanged. Is a NOP with negative fds passed, and returns + * -1, so that it can be used in this syntax: + * + * fd = safe_close(fd); + */ + + if (fd >= 0) { + PROTECT_ERRNO; + + /* The kernel might return pretty much any error code + * via close(), but the fd will be closed anyway. The + * only condition we want to check for here is whether + * the fd was invalid at all... */ + + assert_se(close_nointr(fd) != -EBADF); + } + + return -1; +} + +void safe_close_pair(int p[]) { + assert(p); + + if (p[0] == p[1]) { + /* Special case pairs which use the same fd in both + * directions... */ + p[0] = p[1] = safe_close(p[0]); + return; + } + + p[0] = safe_close(p[0]); + p[1] = safe_close(p[1]); +} + +void close_many(const int fds[], unsigned n_fd) { + unsigned i; + + assert(fds || n_fd <= 0); + + for (i = 0; i < n_fd; i++) + safe_close(fds[i]); +} + +int fclose_nointr(FILE *f) { + assert(f); + + /* Same as close_nointr(), but for fclose() */ + + if (fclose(f) == 0) + return 0; + + if (errno == EINTR) + return 0; + + return -errno; +} + +FILE* safe_fclose(FILE *f) { + + /* Same as safe_close(), but for fclose() */ + + if (f) { + PROTECT_ERRNO; + + assert_se(fclose_nointr(f) != EBADF); + } + + return NULL; +} + +DIR* safe_closedir(DIR *d) { + + if (d) { + PROTECT_ERRNO; + + assert_se(closedir(d) >= 0 || errno != EBADF); + } + + return NULL; +} + +int fd_nonblock(int fd, bool nonblock) { + int flags, nflags; + + assert(fd >= 0); + + flags = fcntl(fd, F_GETFL, 0); + if (flags < 0) + return -errno; + + if (nonblock) + nflags = flags | O_NONBLOCK; + else + nflags = flags & ~O_NONBLOCK; + + if (nflags == flags) + return 0; + + if (fcntl(fd, F_SETFL, nflags) < 0) + return -errno; + + return 0; +} + +int fd_cloexec(int fd, bool cloexec) { + int flags, nflags; + + assert(fd >= 0); + + flags = fcntl(fd, F_GETFD, 0); + if (flags < 0) + return -errno; + + if (cloexec) + nflags = flags | FD_CLOEXEC; + else + nflags = flags & ~FD_CLOEXEC; + + if (nflags == flags) + return 0; + + if (fcntl(fd, F_SETFD, nflags) < 0) + return -errno; + + return 0; +} + +_pure_ static bool fd_in_set(int fd, const int fdset[], unsigned n_fdset) { + unsigned i; + + assert(n_fdset == 0 || fdset); + + for (i = 0; i < n_fdset; i++) + if (fdset[i] == fd) + return true; + + return false; +} + +int close_all_fds(const int except[], unsigned n_except) { + _cleanup_closedir_ DIR *d = NULL; + struct dirent *de; + int r = 0; + + assert(n_except == 0 || except); + + d = opendir("/proc/self/fd"); + if (!d) { + int fd; + struct rlimit rl; + + /* When /proc isn't available (for example in chroots) + * the fallback is brute forcing through the fd + * table */ + + assert_se(getrlimit(RLIMIT_NOFILE, &rl) >= 0); + for (fd = 3; fd < (int) rl.rlim_max; fd ++) { + + if (fd_in_set(fd, except, n_except)) + continue; + + if (close_nointr(fd) < 0) + if (errno != EBADF && r == 0) + r = -errno; + } + + return r; + } + + while ((de = readdir(d))) { + int fd = -1; + + if (hidden_file(de->d_name)) + continue; + + if (safe_atoi(de->d_name, &fd) < 0) + /* Let's better ignore this, just in case */ + continue; + + if (fd < 3) + continue; + + if (fd == dirfd(d)) + continue; + + if (fd_in_set(fd, except, n_except)) + continue; + + if (close_nointr(fd) < 0) { + /* Valgrind has its own FD and doesn't want to have it closed */ + if (errno != EBADF && r == 0) + r = -errno; + } + } + + return r; +} + +int same_fd(int a, int b) { + struct stat sta, stb; + pid_t pid; + int r, fa, fb; + + assert(a >= 0); + assert(b >= 0); + + /* Compares two file descriptors. Note that semantics are + * quite different depending on whether we have kcmp() or we + * don't. If we have kcmp() this will only return true for + * dup()ed file descriptors, but not otherwise. If we don't + * have kcmp() this will also return true for two fds of the same + * file, created by separate open() calls. Since we use this + * call mostly for filtering out duplicates in the fd store + * this difference hopefully doesn't matter too much. */ + + if (a == b) + return true; + + /* Try to use kcmp() if we have it. */ + pid = getpid(); + r = kcmp(pid, pid, KCMP_FILE, a, b); + if (r == 0) + return true; + if (r > 0) + return false; + if (errno != ENOSYS) + return -errno; + + /* We don't have kcmp(), use fstat() instead. */ + if (fstat(a, &sta) < 0) + return -errno; + + if (fstat(b, &stb) < 0) + return -errno; + + if ((sta.st_mode & S_IFMT) != (stb.st_mode & S_IFMT)) + return false; + + /* We consider all device fds different, since two device fds + * might refer to quite different device contexts even though + * they share the same inode and backing dev_t. */ + + if (S_ISCHR(sta.st_mode) || S_ISBLK(sta.st_mode)) + return false; + + if (sta.st_dev != stb.st_dev || sta.st_ino != stb.st_ino) + return false; + + /* The fds refer to the same inode on disk, let's also check + * if they have the same fd flags. This is useful to + * distinguish the read and write side of a pipe created with + * pipe(). */ + fa = fcntl(a, F_GETFL); + if (fa < 0) + return -errno; + + fb = fcntl(b, F_GETFL); + if (fb < 0) + return -errno; + + return fa == fb; +} + +void cmsg_close_all(struct msghdr *mh) { + struct cmsghdr *cmsg; + + assert(mh); + + CMSG_FOREACH(cmsg, mh) + if (cmsg->cmsg_level == SOL_SOCKET && cmsg->cmsg_type == SCM_RIGHTS) + close_many((int*) CMSG_DATA(cmsg), (cmsg->cmsg_len - CMSG_LEN(0)) / sizeof(int)); +} diff --git a/src/basic/fd-util.h b/src/basic/fd-util.h new file mode 100644 index 0000000000..be00d881c3 --- /dev/null +++ b/src/basic/fd-util.h @@ -0,0 +1,69 @@ +/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/ + +#pragma once + +/*** + This file is part of systemd. + + Copyright 2010 Lennart Poettering + + systemd is free software; you can redistribute it and/or modify it + under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation; either version 2.1 of the License, or + (at your option) any later version. + + systemd is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + 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 <stdio.h> +#include <dirent.h> +#include <stdbool.h> +#include <sys/socket.h> + +#include "macro.h" + +int close_nointr(int fd); +int safe_close(int fd); +void safe_close_pair(int p[]); + +void close_many(const int fds[], unsigned n_fd); + +int fclose_nointr(FILE *f); +FILE* safe_fclose(FILE *f); +DIR* safe_closedir(DIR *f); + +static inline void closep(int *fd) { + safe_close(*fd); +} + +static inline void close_pairp(int (*p)[2]) { + safe_close_pair(*p); +} + +static inline void fclosep(FILE **f) { + safe_fclose(*f); +} + +DEFINE_TRIVIAL_CLEANUP_FUNC(FILE*, pclose); +DEFINE_TRIVIAL_CLEANUP_FUNC(DIR*, closedir); + +#define _cleanup_close_ _cleanup_(closep) +#define _cleanup_fclose_ _cleanup_(fclosep) +#define _cleanup_pclose_ _cleanup_(pclosep) +#define _cleanup_closedir_ _cleanup_(closedirp) +#define _cleanup_close_pair_ _cleanup_(close_pairp) + +int fd_nonblock(int fd, bool nonblock); +int fd_cloexec(int fd, bool cloexec); + +int close_all_fds(const int except[], unsigned n_except); + +int same_fd(int a, int b); + +void cmsg_close_all(struct msghdr *mh); diff --git a/src/basic/fdset.c b/src/basic/fdset.c index 2882f515b5..9669110828 100644 --- a/src/basic/fdset.c +++ b/src/basic/fdset.c @@ -25,10 +25,11 @@ #include "sd-daemon.h" +#include "fd-util.h" +#include "fdset.h" +#include "macro.h" #include "set.h" #include "util.h" -#include "macro.h" -#include "fdset.h" #define MAKE_SET(s) ((Set*) s) #define MAKE_FDSET(s) ((FDSet*) s) diff --git a/src/basic/fileio.c b/src/basic/fileio.c index f8ccf79221..5d33309ab2 100644 --- a/src/basic/fileio.c +++ b/src/basic/fileio.c @@ -23,11 +23,12 @@ #include "ctype.h" #include "escape.h" +#include "fd-util.h" +#include "fileio.h" #include "string-util.h" #include "strv.h" #include "utf8.h" #include "util.h" -#include "fileio.h" int write_string_stream(FILE *f, const char *line, bool enforce_newline) { diff --git a/src/basic/hostname-util.c b/src/basic/hostname-util.c index 8d10615682..7d058416e5 100644 --- a/src/basic/hostname-util.c +++ b/src/basic/hostname-util.c @@ -22,9 +22,10 @@ #include <ctype.h> #include <sys/utsname.h> +#include "fd-util.h" +#include "hostname-util.h" #include "string-util.h" #include "util.h" -#include "hostname-util.h" bool hostname_is_set(void) { struct utsname u; diff --git a/src/basic/locale-util.c b/src/basic/locale-util.c index a44daf8f5e..44e1628664 100644 --- a/src/basic/locale-util.c +++ b/src/basic/locale-util.c @@ -21,12 +21,13 @@ #include <sys/mman.h> +#include "fd-util.h" +#include "locale-util.h" #include "set.h" #include "string-util.h" #include "strv.h" #include "utf8.h" #include "util.h" -#include "locale-util.h" static int add_locales_from_archive(Set *locales) { /* Stolen from glibc... */ diff --git a/src/basic/lockfile-util.c b/src/basic/lockfile-util.c index f3ec6a3e52..e573dcb56f 100644 --- a/src/basic/lockfile-util.c +++ b/src/basic/lockfile-util.c @@ -27,9 +27,10 @@ #include <limits.h> #include <sys/file.h> -#include "util.h" -#include "lockfile-util.h" +#include "fd-util.h" #include "fileio.h" +#include "lockfile-util.h" +#include "util.h" int make_lock_file(const char *p, int operation, LockFile *ret) { _cleanup_close_ int fd = -1; diff --git a/src/basic/log.c b/src/basic/log.c index acc390b8d3..99dccb1f10 100644 --- a/src/basic/log.c +++ b/src/basic/log.c @@ -31,7 +31,9 @@ #include "sd-messages.h" +#include "fd-util.h" #include "formats-util.h" +#include "log.h" #include "macro.h" #include "missing.h" #include "process-util.h" @@ -40,7 +42,6 @@ #include "string-util.h" #include "terminal-util.h" #include "util.h" -#include "log.h" #define SNDBUF_SIZE (8*1024*1024) diff --git a/src/basic/memfd-util.c b/src/basic/memfd-util.c index 4dafd69daf..9d638b27f0 100644 --- a/src/basic/memfd-util.c +++ b/src/basic/memfd-util.c @@ -27,11 +27,12 @@ #include <sys/mman.h> #include <sys/prctl.h> +#include "fd-util.h" +#include "memfd-util.h" #include "missing.h" #include "string-util.h" #include "utf8.h" #include "util.h" -#include "memfd-util.h" int memfd_new(const char *name) { _cleanup_free_ char *g = NULL; diff --git a/src/basic/memfd-util.h b/src/basic/memfd-util.h index 3ed551fb37..2cb404ea81 100644 --- a/src/basic/memfd-util.h +++ b/src/basic/memfd-util.h @@ -21,7 +21,8 @@ along with systemd; If not, see <http://www.gnu.org/licenses/>. ***/ - +#include <sys/types.h> +#include <inttypes.h> int memfd_new(const char *name); int memfd_new_and_map(const char *name, size_t sz, void **p); diff --git a/src/basic/path-util.c b/src/basic/path-util.c index 31328807f4..7b01633f5f 100644 --- a/src/basic/path-util.c +++ b/src/basic/path-util.c @@ -27,14 +27,15 @@ #include <sys/statvfs.h> #include <unistd.h> +#include "fd-util.h" #include "fileio.h" #include "log.h" #include "macro.h" #include "missing.h" +#include "path-util.h" #include "string-util.h" #include "strv.h" #include "util.h" -#include "path-util.h" bool path_is_absolute(const char *p) { return p[0] == '/'; diff --git a/src/basic/process-util.c b/src/basic/process-util.c index bfde17a956..949bd1f64d 100644 --- a/src/basic/process-util.c +++ b/src/basic/process-util.c @@ -29,12 +29,13 @@ #include <unistd.h> #include "escape.h" +#include "fd-util.h" #include "fileio.h" #include "log.h" +#include "process-util.h" #include "signal-util.h" #include "string-util.h" #include "util.h" -#include "process-util.h" int get_process_state(pid_t pid) { const char *p; diff --git a/src/basic/random-util.c b/src/basic/random-util.c index b230044f50..e183165b9f 100644 --- a/src/basic/random-util.c +++ b/src/basic/random-util.c @@ -17,20 +17,21 @@ along with systemd; If not, see <http://www.gnu.org/licenses/>. ***/ -#include <stdint.h> #include <errno.h> -#include <sys/types.h> -#include <sys/stat.h> #include <fcntl.h> -#include <time.h> +#include <linux/random.h> +#include <stdint.h> #ifdef HAVE_SYS_AUXV_H #include <sys/auxv.h> #endif -#include <linux/random.h> +#include <sys/stat.h> +#include <sys/types.h> +#include <time.h> +#include "fd-util.h" +#include "missing.h" #include "random-util.h" #include "time-util.h" -#include "missing.h" #include "util.h" int dev_urandom(void *p, size_t n) { diff --git a/src/basic/rm-rf.c b/src/basic/rm-rf.c index 5a75090a6d..a5daa23f86 100644 --- a/src/basic/rm-rf.c +++ b/src/basic/rm-rf.c @@ -20,10 +20,11 @@ ***/ #include "btrfs-util.h" +#include "fd-util.h" #include "path-util.h" +#include "rm-rf.h" #include "string-util.h" #include "util.h" -#include "rm-rf.h" int rm_rf_children(int fd, RemoveFlags flags, struct stat *root_dev) { _cleanup_closedir_ DIR *d = NULL; diff --git a/src/basic/socket-label.c b/src/basic/socket-label.c index 937124cc02..4099ea6f9f 100644 --- a/src/basic/socket-label.c +++ b/src/basic/socket-label.c @@ -19,18 +19,19 @@ along with systemd; If not, see <http://www.gnu.org/licenses/>. ***/ -#include <string.h> -#include <unistd.h> #include <errno.h> -#include <sys/stat.h> #include <stddef.h> +#include <string.h> +#include <sys/stat.h> +#include <unistd.h> +#include "fd-util.h" #include "macro.h" -#include "util.h" -#include "mkdir.h" #include "missing.h" +#include "mkdir.h" #include "selinux-util.h" #include "socket-util.h" +#include "util.h" int socket_address_listen( const SocketAddress *a, diff --git a/src/basic/terminal-util.c b/src/basic/terminal-util.c index 4723653566..5949b99c95 100644 --- a/src/basic/terminal-util.c +++ b/src/basic/terminal-util.c @@ -31,13 +31,14 @@ #include <time.h> #include <unistd.h> +#include "fd-util.h" #include "fileio.h" #include "path-util.h" #include "process-util.h" #include "string-util.h" +#include "terminal-util.h" #include "time-util.h" #include "util.h" -#include "terminal-util.h" static volatile unsigned cached_columns = 0; static volatile unsigned cached_lines = 0; diff --git a/src/basic/time-util.c b/src/basic/time-util.c index a516d2807b..d117380d52 100644 --- a/src/basic/time-util.c +++ b/src/basic/time-util.c @@ -23,11 +23,12 @@ #include <sys/timerfd.h> #include <sys/timex.h> +#include "fd-util.h" #include "path-util.h" #include "string-util.h" #include "strv.h" -#include "util.h" #include "time-util.h" +#include "util.h" usec_t now(clockid_t clock_id) { struct timespec ts; diff --git a/src/basic/util.c b/src/basic/util.c index 233a6c2e35..05f34ea52c 100644 --- a/src/basic/util.c +++ b/src/basic/util.c @@ -79,6 +79,7 @@ #include "env-util.h" #include "escape.h" #include "exit-status.h" +#include "fd-util.h" #include "fileio.h" #include "formats-util.h" #include "gunicode.h" @@ -98,8 +99,8 @@ #include "strv.h" #include "terminal-util.h" #include "utf8.h" -#include "virt.h" #include "util.h" +#include "virt.h" /* Put this test here for a lack of better place */ assert_cc(EAGAIN == EWOULDBLOCK); @@ -121,98 +122,6 @@ size_t page_size(void) { return pgsz; } -int close_nointr(int fd) { - assert(fd >= 0); - - if (close(fd) >= 0) - return 0; - - /* - * Just ignore EINTR; a retry loop is the wrong thing to do on - * Linux. - * - * http://lkml.indiana.edu/hypermail/linux/kernel/0509.1/0877.html - * https://bugzilla.gnome.org/show_bug.cgi?id=682819 - * http://utcc.utoronto.ca/~cks/space/blog/unix/CloseEINTR - * https://sites.google.com/site/michaelsafyan/software-engineering/checkforeintrwheninvokingclosethinkagain - */ - if (errno == EINTR) - return 0; - - return -errno; -} - -int safe_close(int fd) { - - /* - * Like close_nointr() but cannot fail. Guarantees errno is - * unchanged. Is a NOP with negative fds passed, and returns - * -1, so that it can be used in this syntax: - * - * fd = safe_close(fd); - */ - - if (fd >= 0) { - PROTECT_ERRNO; - - /* The kernel might return pretty much any error code - * via close(), but the fd will be closed anyway. The - * only condition we want to check for here is whether - * the fd was invalid at all... */ - - assert_se(close_nointr(fd) != -EBADF); - } - - return -1; -} - -void close_many(const int fds[], unsigned n_fd) { - unsigned i; - - assert(fds || n_fd <= 0); - - for (i = 0; i < n_fd; i++) - safe_close(fds[i]); -} - -int fclose_nointr(FILE *f) { - assert(f); - - /* Same as close_nointr(), but for fclose() */ - - if (fclose(f) == 0) - return 0; - - if (errno == EINTR) - return 0; - - return -errno; -} - -FILE* safe_fclose(FILE *f) { - - /* Same as safe_close(), but for fclose() */ - - if (f) { - PROTECT_ERRNO; - - assert_se(fclose_nointr(f) != EBADF); - } - - return NULL; -} - -DIR* safe_closedir(DIR *d) { - - if (d) { - PROTECT_ERRNO; - - assert_se(closedir(d) >= 0 || errno != EBADF); - } - - return NULL; -} - int unlink_noerrno(const char *path) { PROTECT_ERRNO; int r; @@ -1304,123 +1213,6 @@ bool hidden_file(const char *filename) { return hidden_file_allow_backup(filename); } -int fd_nonblock(int fd, bool nonblock) { - int flags, nflags; - - assert(fd >= 0); - - flags = fcntl(fd, F_GETFL, 0); - if (flags < 0) - return -errno; - - if (nonblock) - nflags = flags | O_NONBLOCK; - else - nflags = flags & ~O_NONBLOCK; - - if (nflags == flags) - return 0; - - if (fcntl(fd, F_SETFL, nflags) < 0) - return -errno; - - return 0; -} - -int fd_cloexec(int fd, bool cloexec) { - int flags, nflags; - - assert(fd >= 0); - - flags = fcntl(fd, F_GETFD, 0); - if (flags < 0) - return -errno; - - if (cloexec) - nflags = flags | FD_CLOEXEC; - else - nflags = flags & ~FD_CLOEXEC; - - if (nflags == flags) - return 0; - - if (fcntl(fd, F_SETFD, nflags) < 0) - return -errno; - - return 0; -} - -_pure_ static bool fd_in_set(int fd, const int fdset[], unsigned n_fdset) { - unsigned i; - - assert(n_fdset == 0 || fdset); - - for (i = 0; i < n_fdset; i++) - if (fdset[i] == fd) - return true; - - return false; -} - -int close_all_fds(const int except[], unsigned n_except) { - _cleanup_closedir_ DIR *d = NULL; - struct dirent *de; - int r = 0; - - assert(n_except == 0 || except); - - d = opendir("/proc/self/fd"); - if (!d) { - int fd; - struct rlimit rl; - - /* When /proc isn't available (for example in chroots) - * the fallback is brute forcing through the fd - * table */ - - assert_se(getrlimit(RLIMIT_NOFILE, &rl) >= 0); - for (fd = 3; fd < (int) rl.rlim_max; fd ++) { - - if (fd_in_set(fd, except, n_except)) - continue; - - if (close_nointr(fd) < 0) - if (errno != EBADF && r == 0) - r = -errno; - } - - return r; - } - - while ((de = readdir(d))) { - int fd = -1; - - if (hidden_file(de->d_name)) - continue; - - if (safe_atoi(de->d_name, &fd) < 0) - /* Let's better ignore this, just in case */ - continue; - - if (fd < 3) - continue; - - if (fd == dirfd(d)) - continue; - - if (fd_in_set(fd, except, n_except)) - continue; - - if (close_nointr(fd) < 0) { - /* Valgrind has its own FD and doesn't want to have it closed */ - if (errno != EBADF && r == 0) - r = -errno; - } - } - - return r; -} - bool fstype_is_network(const char *fstype) { static const char table[] = "afs\0" @@ -1480,20 +1272,6 @@ int flush_fd(int fd) { } } -void safe_close_pair(int p[]) { - assert(p); - - if (p[0] == p[1]) { - /* Special case pairs which use the same fd in both - * directions... */ - p[0] = p[1] = safe_close(p[0]); - return; - } - - p[0] = safe_close(p[0]); - p[1] = safe_close(p[1]); -} - ssize_t loop_read(int fd, void *buf, size_t nbytes, bool do_poll) { uint8_t *p = buf; ssize_t n = 0; @@ -4804,71 +4582,6 @@ int fd_setcrtime(int fd, usec_t usec) { return 0; } -int same_fd(int a, int b) { - struct stat sta, stb; - pid_t pid; - int r, fa, fb; - - assert(a >= 0); - assert(b >= 0); - - /* Compares two file descriptors. Note that semantics are - * quite different depending on whether we have kcmp() or we - * don't. If we have kcmp() this will only return true for - * dup()ed file descriptors, but not otherwise. If we don't - * have kcmp() this will also return true for two fds of the same - * file, created by separate open() calls. Since we use this - * call mostly for filtering out duplicates in the fd store - * this difference hopefully doesn't matter too much. */ - - if (a == b) - return true; - - /* Try to use kcmp() if we have it. */ - pid = getpid(); - r = kcmp(pid, pid, KCMP_FILE, a, b); - if (r == 0) - return true; - if (r > 0) - return false; - if (errno != ENOSYS) - return -errno; - - /* We don't have kcmp(), use fstat() instead. */ - if (fstat(a, &sta) < 0) - return -errno; - - if (fstat(b, &stb) < 0) - return -errno; - - if ((sta.st_mode & S_IFMT) != (stb.st_mode & S_IFMT)) - return false; - - /* We consider all device fds different, since two device fds - * might refer to quite different device contexts even though - * they share the same inode and backing dev_t. */ - - if (S_ISCHR(sta.st_mode) || S_ISBLK(sta.st_mode)) - return false; - - if (sta.st_dev != stb.st_dev || sta.st_ino != stb.st_ino) - return false; - - /* The fds refer to the same inode on disk, let's also check - * if they have the same fd flags. This is useful to - * distinguish the read and write side of a pipe created with - * pipe(). */ - fa = fcntl(a, F_GETFL); - if (fa < 0) - return -errno; - - fb = fcntl(b, F_GETFL); - if (fb < 0) - return -errno; - - return fa == fb; -} - int chattr_fd(int fd, unsigned value, unsigned mask) { unsigned old_attr, new_attr; struct stat st; @@ -5075,16 +4788,6 @@ ssize_t string_table_lookup(const char * const *table, size_t len, const char *k return -1; } -void cmsg_close_all(struct msghdr *mh) { - struct cmsghdr *cmsg; - - assert(mh); - - CMSG_FOREACH(cmsg, mh) - if (cmsg->cmsg_level == SOL_SOCKET && cmsg->cmsg_type == SCM_RIGHTS) - close_many((int*) CMSG_DATA(cmsg), (cmsg->cmsg_len - CMSG_LEN(0)) / sizeof(int)); -} - int rename_noreplace(int olddirfd, const char *oldpath, int newdirfd, const char *newpath) { struct stat buf; int ret; diff --git a/src/basic/util.h b/src/basic/util.h index d1da9ce106..e50fd69664 100644 --- a/src/basic/util.h +++ b/src/basic/util.h @@ -87,16 +87,6 @@ static inline const char* one_zero(bool b) { return b ? "1" : "0"; } -int close_nointr(int fd); -int safe_close(int fd); -void safe_close_pair(int p[]); - -void close_many(const int fds[], unsigned n_fd); - -int fclose_nointr(FILE *f); -FILE* safe_fclose(FILE *f); -DIR* safe_closedir(DIR *f); - int parse_size(const char *t, uint64_t base, uint64_t *size); int parse_boolean(const char *v) _pure_; @@ -245,11 +235,6 @@ ssize_t string_table_lookup(const char * const *table, size_t len, const char *k } \ struct __useless_struct_to_allow_trailing_semicolon__ -int fd_nonblock(int fd, bool nonblock); -int fd_cloexec(int fd, bool cloexec); - -int close_all_fds(const int except[], unsigned n_except); - bool fstype_is_network(const char *fstype); int flush_fd(int fd); @@ -410,35 +395,16 @@ static inline void freep(void *p) { free(*(void**) p); } -static inline void closep(int *fd) { - safe_close(*fd); -} - static inline void umaskp(mode_t *u) { umask(*u); } -static inline void close_pairp(int (*p)[2]) { - safe_close_pair(*p); -} - -static inline void fclosep(FILE **f) { - safe_fclose(*f); -} - -DEFINE_TRIVIAL_CLEANUP_FUNC(FILE*, pclose); -DEFINE_TRIVIAL_CLEANUP_FUNC(DIR*, closedir); DEFINE_TRIVIAL_CLEANUP_FUNC(FILE*, endmntent); #define _cleanup_free_ _cleanup_(freep) -#define _cleanup_close_ _cleanup_(closep) #define _cleanup_umask_ _cleanup_(umaskp) #define _cleanup_globfree_ _cleanup_(globfree) -#define _cleanup_fclose_ _cleanup_(fclosep) -#define _cleanup_pclose_ _cleanup_(pclosep) -#define _cleanup_closedir_ _cleanup_(closedirp) #define _cleanup_endmntent_ _cleanup_(endmntentp) -#define _cleanup_close_pair_ _cleanup_(close_pairp) _malloc_ _alloc_(1, 2) static inline void *malloc_multiply(size_t a, size_t b) { if (_unlikely_(b != 0 && a > ((size_t) -1) / b)) @@ -747,8 +713,6 @@ int fd_getcrtime(int fd, usec_t *usec); int path_getcrtime(const char *p, usec_t *usec); int fd_getcrtime_at(int dirfd, const char *name, usec_t *usec, int flags); -int same_fd(int a, int b); - int chattr_fd(int fd, unsigned value, unsigned mask); int chattr_path(const char *p, unsigned value, unsigned mask); @@ -764,8 +728,6 @@ void sigkill_wait(pid_t *pid); int syslog_parse_priority(const char **p, int *priority, bool with_facility); -void cmsg_close_all(struct msghdr *mh); - int rename_noreplace(int olddirfd, const char *oldpath, int newdirfd, const char *newpath); int parse_mode(const char *s, mode_t *ret); diff --git a/src/binfmt/binfmt.c b/src/binfmt/binfmt.c index ca3f26a66f..b96695c353 100644 --- a/src/binfmt/binfmt.c +++ b/src/binfmt/binfmt.c @@ -28,6 +28,7 @@ #include <string.h> #include "conf-files.h" +#include "fd-util.h" #include "fileio.h" #include "log.h" #include "string-util.h" diff --git a/src/boot/bootctl.c b/src/boot/bootctl.c index 1016890768..a167f8086c 100644 --- a/src/boot/bootctl.c +++ b/src/boot/bootctl.c @@ -39,6 +39,7 @@ #include "blkid-util.h" #include "efivars.h" +#include "fd-util.h" #include "rm-rf.h" #include "string-util.h" #include "util.h" diff --git a/src/bootchart/bootchart.c b/src/bootchart/bootchart.c index 7842e0766d..a1699f8736 100644 --- a/src/bootchart/bootchart.c +++ b/src/bootchart/bootchart.c @@ -50,6 +50,7 @@ #include "bootchart.h" #include "conf-parser.h" +#include "fd-util.h" #include "fileio.h" #include "list.h" #include "macro.h" diff --git a/src/bootchart/store.c b/src/bootchart/store.c index f3f55781ad..6066e14288 100644 --- a/src/bootchart/store.c +++ b/src/bootchart/store.c @@ -33,12 +33,13 @@ #include "bootchart.h" #include "cgroup-util.h" +#include "fd-util.h" #include "fileio.h" +#include "store.h" #include "string-util.h" #include "strxcpyx.h" #include "time-util.h" #include "util.h" -#include "store.h" /* * Alloc a static 4k buffer for stdio - primarily used to increase diff --git a/src/bootchart/svg.c b/src/bootchart/svg.c index db5fc863b0..43eca90618 100644 --- a/src/bootchart/svg.c +++ b/src/bootchart/svg.c @@ -39,6 +39,7 @@ #include "bootchart.h" #include "list.h" #include "utf8.h" +#include "fd-util.h" #define time_to_graph(t) ((t) * arg_scale_x) #define ps_to_graph(n) ((n) * arg_scale_y) diff --git a/src/bus-proxyd/bus-proxyd.c b/src/bus-proxyd/bus-proxyd.c index e558578bd0..1bbf984a2e 100644 --- a/src/bus-proxyd/bus-proxyd.c +++ b/src/bus-proxyd/bus-proxyd.c @@ -37,6 +37,7 @@ #include "bus-xml-policy.h" #include "capability.h" #include "def.h" +#include "fd-util.h" #include "formats-util.h" #include "log.h" #include "proxy.h" diff --git a/src/bus-proxyd/proxy.c b/src/bus-proxyd/proxy.c index bc8516f5c6..ea2a01fdae 100644 --- a/src/bus-proxyd/proxy.c +++ b/src/bus-proxyd/proxy.c @@ -22,27 +22,29 @@ along with systemd; If not, see <http://www.gnu.org/licenses/>. ***/ -#include <sys/socket.h> -#include <sys/types.h> -#include <string.h> #include <errno.h> #include <poll.h> +#include <string.h> +#include <sys/socket.h> +#include <sys/types.h> -#include "log.h" -#include "util.h" -#include "sd-daemon.h" #include "sd-bus.h" +#include "sd-daemon.h" + +#include "bus-control.h" #include "bus-internal.h" #include "bus-message.h" #include "bus-util.h" -#include "strv.h" -#include "bus-control.h" -#include "set.h" #include "bus-xml-policy.h" #include "driver.h" +#include "fd-util.h" +#include "formats-util.h" +#include "log.h" #include "proxy.h" +#include "set.h" +#include "strv.h" #include "synthesize.h" -#include "formats-util.h" +#include "util.h" static int proxy_create_destination(Proxy *p, const char *destination, const char *local_sec, bool negotiate_fds) { _cleanup_bus_flush_close_unref_ sd_bus *b = NULL; diff --git a/src/cgtop/cgtop.c b/src/cgtop/cgtop.c index ad9cd2532f..3786dae2d9 100644 --- a/src/cgtop/cgtop.c +++ b/src/cgtop/cgtop.c @@ -33,6 +33,7 @@ #include "bus-error.h" #include "bus-util.h" #include "cgroup-util.h" +#include "fd-util.h" #include "fileio.h" #include "hashmap.h" #include "path-util.h" diff --git a/src/core/audit-fd.c b/src/core/audit-fd.c index 5a18e263a8..3ae46d8cfb 100644 --- a/src/core/audit-fd.c +++ b/src/core/audit-fd.c @@ -30,6 +30,7 @@ #include "log.h" #include "util.h" +#include "fd-util.h" static bool initialized = false; static int audit_fd; diff --git a/src/core/automount.c b/src/core/automount.c index 1995bb8b7d..c25038ca50 100644 --- a/src/core/automount.c +++ b/src/core/automount.c @@ -30,9 +30,11 @@ #include <unistd.h> #include "async.h" +#include "automount.h" #include "bus-error.h" #include "bus-util.h" #include "dbus-automount.h" +#include "fd-util.h" #include "formats-util.h" #include "label.h" #include "mkdir.h" @@ -43,7 +45,6 @@ #include "string-util.h" #include "unit-name.h" #include "unit.h" -#include "automount.h" static const UnitActiveState state_translation_table[_AUTOMOUNT_STATE_MAX] = { [AUTOMOUNT_DEAD] = UNIT_INACTIVE, diff --git a/src/core/busname.c b/src/core/busname.c index a7cb56dcbf..335a1fdc4c 100644 --- a/src/core/busname.c +++ b/src/core/busname.c @@ -25,14 +25,15 @@ #include "bus-kernel.h" #include "bus-policy.h" #include "bus-util.h" +#include "busname.h" #include "dbus-busname.h" +#include "fd-util.h" #include "formats-util.h" #include "kdbus.h" #include "service.h" #include "signal-util.h" #include "special.h" #include "string-util.h" -#include "busname.h" static const UnitActiveState state_translation_table[_BUSNAME_STATE_MAX] = { [BUSNAME_DEAD] = UNIT_INACTIVE, diff --git a/src/core/cgroup.c b/src/core/cgroup.c index 73e58f867c..2a2cf02774 100644 --- a/src/core/cgroup.c +++ b/src/core/cgroup.c @@ -23,11 +23,12 @@ #include <fnmatch.h> #include "cgroup-util.h" +#include "cgroup.h" +#include "fd-util.h" #include "path-util.h" #include "process-util.h" #include "special.h" #include "string-util.h" -#include "cgroup.h" #define CGROUP_CPU_QUOTA_PERIOD_USEC ((usec_t) 100 * USEC_PER_MSEC) diff --git a/src/core/dbus-cgroup.c b/src/core/dbus-cgroup.c index affb997304..6a43be873a 100644 --- a/src/core/dbus-cgroup.c +++ b/src/core/dbus-cgroup.c @@ -20,10 +20,11 @@ ***/ #include "bus-util.h" -#include "path-util.h" #include "cgroup-util.h" #include "cgroup.h" #include "dbus-cgroup.h" +#include "fd-util.h" +#include "path-util.h" static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_cgroup_device_policy, cgroup_device_policy, CGroupDevicePolicy); diff --git a/src/core/dbus-execute.c b/src/core/dbus-execute.c index b8da66c985..cfd89d0fa8 100644 --- a/src/core/dbus-execute.c +++ b/src/core/dbus-execute.c @@ -25,19 +25,20 @@ #include <seccomp.h> #endif +#include "af-list.h" #include "bus-util.h" -#include "missing.h" -#include "ioprio.h" -#include "strv.h" -#include "fileio.h" -#include "execute.h" #include "capability.h" +#include "dbus-execute.h" #include "env-util.h" -#include "af-list.h" +#include "execute.h" +#include "fd-util.h" +#include "fileio.h" +#include "ioprio.h" +#include "missing.h" #include "namespace.h" #include "path-util.h" +#include "strv.h" #include "utf8.h" -#include "dbus-execute.h" #ifdef HAVE_SECCOMP #include "seccomp-util.h" diff --git a/src/core/dbus-manager.c b/src/core/dbus-manager.c index 3cd4467efe..1ef259ec7a 100644 --- a/src/core/dbus-manager.c +++ b/src/core/dbus-manager.c @@ -29,10 +29,12 @@ #include "clock-util.h" #include "dbus-execute.h" #include "dbus-job.h" +#include "dbus-manager.h" #include "dbus-snapshot.h" #include "dbus-unit.h" #include "dbus.h" #include "env-util.h" +#include "fd-util.h" #include "formats-util.h" #include "install.h" #include "log.h" @@ -42,7 +44,6 @@ #include "strv.h" #include "virt.h" #include "watchdog.h" -#include "dbus-manager.h" static int property_get_version( sd_bus *bus, diff --git a/src/core/dbus-service.c b/src/core/dbus-service.c index 0062f1f7f0..22b8690c54 100644 --- a/src/core/dbus-service.c +++ b/src/core/dbus-service.c @@ -24,12 +24,13 @@ #include "dbus-cgroup.h" #include "dbus-execute.h" #include "dbus-kill.h" +#include "dbus-service.h" +#include "fd-util.h" #include "path-util.h" #include "service.h" #include "string-util.h" #include "strv.h" #include "unit.h" -#include "dbus-service.h" static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_type, service_type, ServiceType); static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_result, service_result, ServiceResult); diff --git a/src/core/dbus.c b/src/core/dbus.c index 5f27ec4952..37410a9870 100644 --- a/src/core/dbus.c +++ b/src/core/dbus.c @@ -35,6 +35,8 @@ #include "dbus-kill.h" #include "dbus-manager.h" #include "dbus-unit.h" +#include "dbus.h" +#include "fd-util.h" #include "log.h" #include "missing.h" #include "mkdir.h" @@ -43,7 +45,6 @@ #include "string-util.h" #include "strv.h" #include "strxcpyx.h" -#include "dbus.h" #define CONNECTIONS_MAX 4096 diff --git a/src/core/execute.c b/src/core/execute.c index a99e636d86..83ae3f6253 100644 --- a/src/core/execute.c +++ b/src/core/execute.c @@ -53,6 +53,9 @@ #include "sd-messages.h" #include "af-list.h" +#ifdef HAVE_APPARMOR +#include "apparmor-util.h" +#endif #include "async.h" #include "barrier.h" #include "bus-endpoint.h" @@ -61,7 +64,9 @@ #include "def.h" #include "env-util.h" #include "errno-list.h" +#include "execute.h" #include "exit-status.h" +#include "fd-util.h" #include "fileio.h" #include "formats-util.h" #include "ioprio.h" @@ -73,6 +78,9 @@ #include "path-util.h" #include "process-util.h" #include "rm-rf.h" +#ifdef HAVE_SECCOMP +#include "seccomp-util.h" +#endif #include "securebits.h" #include "selinux-util.h" #include "signal-util.h" @@ -84,16 +92,6 @@ #include "util.h" #include "utmp-wtmp.h" -#ifdef HAVE_APPARMOR -#include "apparmor-util.h" -#endif - -#ifdef HAVE_SECCOMP -#include "seccomp-util.h" -#endif - -#include "execute.h" - #define IDLE_TIMEOUT_USEC (5*USEC_PER_SEC) #define IDLE_TIMEOUT2_USEC (1*USEC_PER_SEC) diff --git a/src/core/ima-setup.c b/src/core/ima-setup.c index 42a3e97459..0c0982b0b4 100644 --- a/src/core/ima-setup.c +++ b/src/core/ima-setup.c @@ -24,9 +24,10 @@ #include <unistd.h> #include <errno.h> +#include "fd-util.h" #include "ima-setup.h" -#include "util.h" #include "log.h" +#include "util.h" #define IMA_SECFS_DIR "/sys/kernel/security/ima" #define IMA_SECFS_POLICY IMA_SECFS_DIR "/policy" diff --git a/src/core/killall.c b/src/core/killall.c index 6857b0bbf9..cb11987166 100644 --- a/src/core/killall.c +++ b/src/core/killall.c @@ -24,13 +24,14 @@ #include <sys/wait.h> #include <unistd.h> +#include "fd-util.h" #include "formats-util.h" +#include "killall.h" #include "process-util.h" #include "set.h" #include "string-util.h" #include "terminal-util.h" #include "util.h" -#include "killall.h" #define TIMEOUT_USEC (10 * USEC_PER_SEC) diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c index 3212ed24d2..31fdc48823 100644 --- a/src/core/load-fragment.c +++ b/src/core/load-fragment.c @@ -43,7 +43,9 @@ #include "env-util.h" #include "errno-list.h" #include "escape.h" +#include "fd-util.h" #include "ioprio.h" +#include "load-fragment.h" #include "log.h" #include "missing.h" #include "path-util.h" @@ -58,7 +60,6 @@ #include "unit-printf.h" #include "unit.h" #include "utf8.h" -#include "load-fragment.h" int config_parse_warn_compat( const char *unit, diff --git a/src/core/machine-id-setup.c b/src/core/machine-id-setup.c index caa5f3717a..f59bf56c73 100644 --- a/src/core/machine-id-setup.c +++ b/src/core/machine-id-setup.c @@ -29,8 +29,10 @@ #include "sd-id128.h" +#include "fd-util.h" #include "fileio.h" #include "log.h" +#include "machine-id-setup.h" #include "macro.h" #include "mkdir.h" #include "path-util.h" @@ -38,7 +40,6 @@ #include "string-util.h" #include "util.h" #include "virt.h" -#include "machine-id-setup.h" static int shorten_uuid(char destination[34], const char source[36]) { unsigned i, j; diff --git a/src/core/main.c b/src/core/main.c index 87b3af92bc..68ec730406 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -51,6 +51,7 @@ #include "dbus-manager.h" #include "def.h" #include "env-util.h" +#include "fd-util.h" #include "fdset.h" #include "fileio.h" #include "formats-util.h" diff --git a/src/core/manager.c b/src/core/manager.c index 2d30340828..400c66977b 100644 --- a/src/core/manager.c +++ b/src/core/manager.c @@ -53,10 +53,12 @@ #include "env-util.h" #include "escape.h" #include "exit-status.h" +#include "fd-util.h" #include "hashmap.h" #include "locale-setup.h" #include "log.h" #include "macro.h" +#include "manager.h" #include "missing.h" #include "mkdir.h" #include "path-lookup.h" @@ -75,7 +77,6 @@ #include "util.h" #include "virt.h" #include "watchdog.h" -#include "manager.h" /* Initial delay and the interval for printing status messages about running jobs */ #define JOBS_IN_PROGRESS_WAIT_USEC (5*USEC_PER_SEC) diff --git a/src/core/namespace.c b/src/core/namespace.c index 6806fc27e6..470f384056 100644 --- a/src/core/namespace.c +++ b/src/core/namespace.c @@ -29,15 +29,16 @@ #include <linux/fs.h> #include "dev-setup.h" +#include "fd-util.h" #include "loopback-setup.h" #include "missing.h" #include "mkdir.h" +#include "namespace.h" #include "path-util.h" #include "selinux-util.h" #include "string-util.h" #include "strv.h" #include "util.h" -#include "namespace.h" typedef enum MountMode { /* This is ordered by priority! */ diff --git a/src/core/path.c b/src/core/path.c index 4d276a79db..11054d8c78 100644 --- a/src/core/path.c +++ b/src/core/path.c @@ -27,13 +27,14 @@ #include "bus-error.h" #include "bus-util.h" #include "dbus-path.h" +#include "fd-util.h" #include "macro.h" #include "mkdir.h" +#include "path.h" #include "special.h" #include "string-util.h" #include "unit-name.h" #include "unit.h" -#include "path.h" static const UnitActiveState state_translation_table[_PATH_STATE_MAX] = { [PATH_DEAD] = UNIT_INACTIVE, diff --git a/src/core/service.c b/src/core/service.c index 042ce5d54d..abcbd4954f 100644 --- a/src/core/service.c +++ b/src/core/service.c @@ -32,6 +32,7 @@ #include "env-util.h" #include "escape.h" #include "exit-status.h" +#include "fd-util.h" #include "fileio.h" #include "formats-util.h" #include "load-dropin.h" @@ -40,6 +41,7 @@ #include "manager.h" #include "path-util.h" #include "process-util.h" +#include "service.h" #include "signal-util.h" #include "special.h" #include "string-util.h" @@ -49,7 +51,6 @@ #include "unit.h" #include "utf8.h" #include "util.h" -#include "service.h" static const UnitActiveState state_translation_table[_SERVICE_STATE_MAX] = { [SERVICE_DEAD] = UNIT_INACTIVE, diff --git a/src/core/smack-setup.c b/src/core/smack-setup.c index fb04e1135d..34df392184 100644 --- a/src/core/smack-setup.c +++ b/src/core/smack-setup.c @@ -28,12 +28,13 @@ #include <stdlib.h> #include <string.h> +#include "fd-util.h" #include "fileio.h" #include "log.h" #include "macro.h" +#include "smack-setup.h" #include "string-util.h" #include "util.h" -#include "smack-setup.h" #ifdef HAVE_SMACK diff --git a/src/core/socket.c b/src/core/socket.c index cfa17b3325..e2085dac1c 100644 --- a/src/core/socket.c +++ b/src/core/socket.c @@ -37,6 +37,7 @@ #include "dbus-socket.h" #include "def.h" #include "exit-status.h" +#include "fd-util.h" #include "formats-util.h" #include "label.h" #include "log.h" @@ -108,11 +109,9 @@ static void socket_unwatch_control_pid(Socket *s) { } static void socket_cleanup_fd_list(SocketPort *p) { - int k = p->n_auxiliary_fds; - - while (k--) - safe_close(p->auxiliary_fds[k]); + assert(p); + close_many(p->auxiliary_fds, p->n_auxiliary_fds); p->auxiliary_fds = mfree(p->auxiliary_fds); p->n_auxiliary_fds = 0; } diff --git a/src/core/swap.c b/src/core/swap.c index eeb53d0632..d864c7b304 100644 --- a/src/core/swap.c +++ b/src/core/swap.c @@ -29,16 +29,17 @@ #include "dbus-swap.h" #include "escape.h" #include "exit-status.h" +#include "fd-util.h" #include "formats-util.h" #include "fstab-util.h" #include "path-util.h" #include "special.h" #include "string-util.h" +#include "swap.h" #include "udev-util.h" #include "unit-name.h" #include "unit.h" #include "virt.h" -#include "swap.h" static const UnitActiveState state_translation_table[_SWAP_STATE_MAX] = { [SWAP_DEAD] = UNIT_INACTIVE, diff --git a/src/core/umount.c b/src/core/umount.c index ec887760a1..0e61bcaebb 100644 --- a/src/core/umount.c +++ b/src/core/umount.c @@ -30,14 +30,15 @@ #include "libudev.h" #include "escape.h" +#include "fd-util.h" #include "list.h" #include "mount-setup.h" #include "path-util.h" #include "string-util.h" #include "udev-util.h" +#include "umount.h" #include "util.h" #include "virt.h" -#include "umount.h" typedef struct MountPoint { char *path; diff --git a/src/cryptsetup/cryptsetup-generator.c b/src/cryptsetup/cryptsetup-generator.c index fde508ac25..78adcf18d6 100644 --- a/src/cryptsetup/cryptsetup-generator.c +++ b/src/cryptsetup/cryptsetup-generator.c @@ -22,6 +22,7 @@ #include <errno.h> #include "dropin.h" +#include "fd-util.h" #include "fstab-util.h" #include "generator.h" #include "hashmap.h" diff --git a/src/dbus1-generator/dbus1-generator.c b/src/dbus1-generator/dbus1-generator.c index 7bbec5467e..8dd75f3324 100644 --- a/src/dbus1-generator/dbus1-generator.c +++ b/src/dbus1-generator/dbus1-generator.c @@ -19,14 +19,15 @@ along with systemd; If not, see <http://www.gnu.org/licenses/>. ***/ -#include "util.h" +#include "bus-internal.h" +#include "bus-util.h" +#include "cgroup-util.h" #include "conf-parser.h" -#include "special.h" +#include "fd-util.h" #include "mkdir.h" -#include "bus-util.h" -#include "bus-internal.h" +#include "special.h" #include "unit-name.h" -#include "cgroup-util.h" +#include "util.h" static const char *arg_dest_late = "/tmp", *arg_dest = "/tmp"; diff --git a/src/delta/delta.c b/src/delta/delta.c index fbb6ab564b..5dbd526b9b 100644 --- a/src/delta/delta.c +++ b/src/delta/delta.c @@ -26,6 +26,7 @@ #include <sys/prctl.h> #include <unistd.h> +#include "fd-util.h" #include "hashmap.h" #include "log.h" #include "pager.h" diff --git a/src/firstboot/firstboot.c b/src/firstboot/firstboot.c index f6b9c095bf..5aa247b2ae 100644 --- a/src/firstboot/firstboot.c +++ b/src/firstboot/firstboot.c @@ -36,6 +36,7 @@ #include "terminal-util.h" #include "time-util.h" #include "string-util.h" +#include "fd-util.h" static char *arg_root = NULL; static char *arg_locale = NULL; /* $LANG */ diff --git a/src/fsck/fsck.c b/src/fsck/fsck.c index 72a6940849..9c49557787 100644 --- a/src/fsck/fsck.c +++ b/src/fsck/fsck.c @@ -32,16 +32,17 @@ #include "sd-bus.h" #include "sd-device.h" -#include "util.h" -#include "process-util.h" -#include "signal-util.h" -#include "special.h" -#include "bus-util.h" -#include "bus-error.h" #include "bus-common-errors.h" +#include "bus-error.h" +#include "bus-util.h" #include "device-util.h" +#include "fd-util.h" #include "path-util.h" +#include "process-util.h" +#include "signal-util.h" #include "socket-util.h" +#include "special.h" +#include "util.h" /* exit codes as defined in fsck(8) */ enum { diff --git a/src/fstab-generator/fstab-generator.c b/src/fstab-generator/fstab-generator.c index de2962d600..0a3917b7ba 100644 --- a/src/fstab-generator/fstab-generator.c +++ b/src/fstab-generator/fstab-generator.c @@ -25,6 +25,7 @@ #include <string.h> #include <unistd.h> +#include "fd-util.h" #include "fstab-util.h" #include "generator.h" #include "log.h" diff --git a/src/getty-generator/getty-generator.c b/src/getty-generator/getty-generator.c index eff9ee236f..0997cc5fae 100644 --- a/src/getty-generator/getty-generator.c +++ b/src/getty-generator/getty-generator.c @@ -24,6 +24,7 @@ #include <string.h> #include <unistd.h> +#include "fd-util.h" #include "fileio.h" #include "log.h" #include "mkdir.h" diff --git a/src/gpt-auto-generator/gpt-auto-generator.c b/src/gpt-auto-generator/gpt-auto-generator.c index 3e8c745238..ba97c98d6f 100644 --- a/src/gpt-auto-generator/gpt-auto-generator.c +++ b/src/gpt-auto-generator/gpt-auto-generator.c @@ -30,6 +30,7 @@ #include "blkid-util.h" #include "btrfs-util.h" #include "efivars.h" +#include "fd-util.h" #include "fileio.h" #include "fstab-util.h" #include "generator.h" diff --git a/src/hwdb/hwdb.c b/src/hwdb/hwdb.c index f60ed4b28b..3b800e99d3 100644 --- a/src/hwdb/hwdb.c +++ b/src/hwdb/hwdb.c @@ -31,6 +31,7 @@ #include "strv.h" #include "util.h" #include "verbs.h" +#include "fd-util.h" /* * Generic udev properties, key/value database based on modalias strings. diff --git a/src/import/curl-util.c b/src/import/curl-util.c index 422d517529..455fa1e07d 100644 --- a/src/import/curl-util.c +++ b/src/import/curl-util.c @@ -19,8 +19,9 @@ along with systemd; If not, see <http://www.gnu.org/licenses/>. ***/ -#include "string-util.h" #include "curl-util.h" +#include "fd-util.h" +#include "string-util.h" static void curl_glue_check_finished(CurlGlue *g) { CURLMsg *msg; diff --git a/src/import/export-raw.c b/src/import/export-raw.c index dc4db481ca..24c0ec9309 100644 --- a/src/import/export-raw.c +++ b/src/import/export-raw.c @@ -28,6 +28,7 @@ #include "btrfs-util.h" #include "copy.h" #include "export-raw.h" +#include "fd-util.h" #include "import-common.h" #include "ratelimit.h" #include "string-util.h" diff --git a/src/import/export-tar.c b/src/import/export-tar.c index 93f2fdbd44..aa9b7f1a91 100644 --- a/src/import/export-tar.c +++ b/src/import/export-tar.c @@ -22,12 +22,13 @@ #include "sd-daemon.h" #include "btrfs-util.h" +#include "export-tar.h" +#include "fd-util.h" #include "import-common.h" #include "process-util.h" #include "ratelimit.h" #include "string-util.h" #include "util.h" -#include "export-tar.h" #define COPY_BUFFER_SIZE (16*1024) diff --git a/src/import/export.c b/src/import/export.c index 89e23899b1..1ecd1e4e10 100644 --- a/src/import/export.c +++ b/src/import/export.c @@ -26,6 +26,7 @@ #include "event-util.h" #include "export-raw.h" #include "export-tar.h" +#include "fd-util.h" #include "hostname-util.h" #include "import-util.h" #include "machine-image.h" diff --git a/src/import/import-common.c b/src/import/import-common.c index 9b86dbfa79..d96a000f81 100644 --- a/src/import/import-common.c +++ b/src/import/import-common.c @@ -26,9 +26,10 @@ #include "btrfs-util.h" #include "capability.h" +#include "fd-util.h" +#include "import-common.h" #include "signal-util.h" #include "util.h" -#include "import-common.h" int import_make_read_only_fd(int fd) { int r; diff --git a/src/import/import-raw.c b/src/import/import-raw.c index b13e80584d..f8fc6c108a 100644 --- a/src/import/import-raw.c +++ b/src/import/import-raw.c @@ -26,9 +26,11 @@ #include "btrfs-util.h" #include "copy.h" +#include "fd-util.h" #include "hostname-util.h" #include "import-common.h" #include "import-compress.h" +#include "import-raw.h" #include "machine-pool.h" #include "mkdir.h" #include "path-util.h" @@ -37,7 +39,6 @@ #include "rm-rf.h" #include "string-util.h" #include "util.h" -#include "import-raw.h" struct RawImport { sd_event *event; diff --git a/src/import/import-tar.c b/src/import/import-tar.c index 0145dcb452..bc0cd9f5ba 100644 --- a/src/import/import-tar.c +++ b/src/import/import-tar.c @@ -26,9 +26,11 @@ #include "btrfs-util.h" #include "copy.h" +#include "fd-util.h" #include "hostname-util.h" #include "import-common.h" #include "import-compress.h" +#include "import-tar.h" #include "machine-pool.h" #include "mkdir.h" #include "path-util.h" @@ -38,7 +40,6 @@ #include "rm-rf.h" #include "string-util.h" #include "util.h" -#include "import-tar.h" struct TarImport { sd_event *event; diff --git a/src/import/import.c b/src/import/import.c index bc0bc78924..e50ded9219 100644 --- a/src/import/import.c +++ b/src/import/import.c @@ -24,6 +24,7 @@ #include "sd-event.h" #include "event-util.h" +#include "fd-util.h" #include "hostname-util.h" #include "import-raw.h" #include "import-tar.h" diff --git a/src/import/importd.c b/src/import/importd.c index a29e9d4bd5..b712cedcc6 100644 --- a/src/import/importd.c +++ b/src/import/importd.c @@ -22,20 +22,22 @@ #include <sys/prctl.h> #include "sd-bus.h" -#include "util.h" -#include "strv.h" -#include "bus-util.h" + #include "bus-common-errors.h" -#include "socket-util.h" -#include "mkdir.h" +#include "bus-util.h" #include "def.h" -#include "missing.h" +#include "fd-util.h" +#include "hostname-util.h" +#include "import-util.h" #include "machine-pool.h" +#include "missing.h" +#include "mkdir.h" #include "path-util.h" -#include "import-util.h" #include "process-util.h" #include "signal-util.h" -#include "hostname-util.h" +#include "socket-util.h" +#include "strv.h" +#include "util.h" typedef struct Transfer Transfer; typedef struct Manager Manager; diff --git a/src/import/pull-common.c b/src/import/pull-common.c index a79cc5825b..e98554b60c 100644 --- a/src/import/pull-common.c +++ b/src/import/pull-common.c @@ -25,7 +25,9 @@ #include "capability.h" #include "copy.h" #include "escape.h" +#include "fd-util.h" #include "process-util.h" +#include "pull-common.h" #include "pull-job.h" #include "rm-rf.h" #include "signal-util.h" @@ -33,7 +35,6 @@ #include "string-util.h" #include "strv.h" #include "util.h" -#include "pull-common.h" #define FILENAME_ESCAPE "/.#\"\'" #define HASH_URL_THRESHOLD_LENGTH (_POSIX_PATH_MAX - 16) diff --git a/src/import/pull-dkr.c b/src/import/pull-dkr.c index ea31d11641..1cd9e7b0bd 100644 --- a/src/import/pull-dkr.c +++ b/src/import/pull-dkr.c @@ -27,6 +27,7 @@ #include "aufs-util.h" #include "btrfs-util.h" #include "curl-util.h" +#include "fd-util.h" #include "hostname-util.h" #include "import-common.h" #include "import-util.h" diff --git a/src/import/pull-job.c b/src/import/pull-job.c index f8b597c9c3..7a0fb54bbe 100644 --- a/src/import/pull-job.c +++ b/src/import/pull-job.c @@ -21,10 +21,11 @@ #include <sys/xattr.h> +#include "fd-util.h" #include "machine-pool.h" +#include "pull-job.h" #include "string-util.h" #include "strv.h" -#include "pull-job.h" PullJob* pull_job_unref(PullJob *j) { if (!j) diff --git a/src/import/pull-raw.c b/src/import/pull-raw.c index a8b2c24507..848a4fcd44 100644 --- a/src/import/pull-raw.c +++ b/src/import/pull-raw.c @@ -28,6 +28,7 @@ #include "btrfs-util.h" #include "copy.h" #include "curl-util.h" +#include "fd-util.h" #include "hostname-util.h" #include "import-common.h" #include "import-util.h" @@ -36,13 +37,13 @@ #include "path-util.h" #include "pull-common.h" #include "pull-job.h" +#include "pull-raw.h" #include "qcow2-util.h" #include "rm-rf.h" #include "string-util.h" #include "strv.h" #include "utf8.h" #include "util.h" -#include "pull-raw.h" typedef enum RawProgress { RAW_DOWNLOADING, diff --git a/src/import/pull-tar.c b/src/import/pull-tar.c index fb4d5bf512..3540bbff41 100644 --- a/src/import/pull-tar.c +++ b/src/import/pull-tar.c @@ -27,6 +27,7 @@ #include "btrfs-util.h" #include "copy.h" #include "curl-util.h" +#include "fd-util.h" #include "hostname-util.h" #include "import-common.h" #include "import-util.h" @@ -36,12 +37,12 @@ #include "process-util.h" #include "pull-common.h" #include "pull-job.h" +#include "pull-tar.h" #include "rm-rf.h" #include "string-util.h" #include "strv.h" #include "utf8.h" #include "util.h" -#include "pull-tar.h" typedef enum TarProgress { TAR_DOWNLOADING, diff --git a/src/import/test-qcow2.c b/src/import/test-qcow2.c index 9a6c3e8b35..4b60079619 100644 --- a/src/import/test-qcow2.c +++ b/src/import/test-qcow2.c @@ -19,10 +19,10 @@ along with systemd; If not, see <http://www.gnu.org/licenses/>. ***/ +#include "fd-util.h" #include "log.h" -#include "util.h" - #include "qcow2-util.h" +#include "util.h" int main(int argc, char *argv[]) { _cleanup_close_ int sfd = -1, dfd = -1; diff --git a/src/initctl/initctl.c b/src/initctl/initctl.c index 2d5f7501e7..2b374c0288 100644 --- a/src/initctl/initctl.c +++ b/src/initctl/initctl.c @@ -25,18 +25,19 @@ #include <sys/epoll.h> #include <ctype.h> -#include "sd-daemon.h" #include "sd-bus.h" +#include "sd-daemon.h" -#include "util.h" -#include "log.h" -#include "list.h" -#include "initreq.h" -#include "special.h" -#include "bus-util.h" #include "bus-error.h" +#include "bus-util.h" #include "def.h" +#include "fd-util.h" #include "formats-util.h" +#include "initreq.h" +#include "list.h" +#include "log.h" +#include "special.h" +#include "util.h" #define SERVER_FD_MAX 16 #define TIMEOUT_MSEC ((int) (DEFAULT_EXIT_USEC/USEC_PER_MSEC)) diff --git a/src/journal-remote/journal-gatewayd.c b/src/journal-remote/journal-gatewayd.c index b839e5979b..92ef723aff 100644 --- a/src/journal-remote/journal-gatewayd.c +++ b/src/journal-remote/journal-gatewayd.c @@ -19,21 +19,22 @@ along with systemd; If not, see <http://www.gnu.org/licenses/>. ***/ -#include <stdlib.h> -#include <string.h> -#include <unistd.h> #include <fcntl.h> #include <getopt.h> -#include <microhttpd.h> #ifdef HAVE_GNUTLS #include <gnutls/gnutls.h> #endif +#include <microhttpd.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> -#include "sd-journal.h" -#include "sd-daemon.h" #include "sd-bus.h" +#include "sd-daemon.h" +#include "sd-journal.h" #include "bus-util.h" +#include "fd-util.h" #include "fileio.h" #include "hostname-util.h" #include "log.h" diff --git a/src/journal-remote/journal-remote-parse.c b/src/journal-remote/journal-remote-parse.c index e9bca39a20..bb299e378c 100644 --- a/src/journal-remote/journal-remote-parse.c +++ b/src/journal-remote/journal-remote-parse.c @@ -19,9 +19,10 @@ along with systemd; If not, see <http://www.gnu.org/licenses/>. ***/ +#include "fd-util.h" +#include "journal-remote-parse.h" #include "journald-native.h" #include "string-util.h" -#include "journal-remote-parse.h" #define LINE_CHUNK 8*1024u diff --git a/src/journal-remote/journal-remote.c b/src/journal-remote/journal-remote.c index 27385d9b94..de207f8d24 100644 --- a/src/journal-remote/journal-remote.c +++ b/src/journal-remote/journal-remote.c @@ -37,16 +37,17 @@ #include "conf-parser.h" #include "escape.h" +#include "fd-util.h" #include "fileio.h" #include "journal-file.h" #include "journal-remote-write.h" +#include "journal-remote.h" #include "journald-native.h" #include "macro.h" #include "signal-util.h" #include "socket-util.h" #include "string-util.h" #include "strv.h" -#include "journal-remote.h" #define REMOTE_JOURNAL_PATH "/var/log/journal/remote" diff --git a/src/journal-remote/journal-upload.c b/src/journal-remote/journal-upload.c index 471a8cad49..a945a9971a 100644 --- a/src/journal-remote/journal-upload.c +++ b/src/journal-remote/journal-upload.c @@ -28,15 +28,16 @@ #include "sd-daemon.h" #include "conf-parser.h" +#include "fd-util.h" #include "fileio.h" #include "formats-util.h" +#include "journal-upload.h" #include "log.h" #include "mkdir.h" #include "sigbus.h" #include "signal-util.h" #include "string-util.h" #include "util.h" -#include "journal-upload.h" #define PRIV_KEY_FILE CERTIFICATE_ROOT "/private/journal-upload.pem" #define CERT_FILE CERTIFICATE_ROOT "/certs/journal-upload.pem" diff --git a/src/journal/cat.c b/src/journal/cat.c index 7074552a15..ff1887604a 100644 --- a/src/journal/cat.c +++ b/src/journal/cat.c @@ -28,6 +28,7 @@ #include "sd-journal.h" +#include "fd-util.h" #include "string-util.h" #include "util.h" diff --git a/src/journal/catalog.c b/src/journal/catalog.c index 32b851aea3..d5bc17b4b6 100644 --- a/src/journal/catalog.c +++ b/src/journal/catalog.c @@ -31,6 +31,7 @@ #include "catalog.h" #include "conf-files.h" +#include "fd-util.h" #include "hashmap.h" #include "log.h" #include "mkdir.h" diff --git a/src/journal/compress.c b/src/journal/compress.c index 46a5410482..6c5078c110 100644 --- a/src/journal/compress.c +++ b/src/journal/compress.c @@ -25,20 +25,21 @@ #include <unistd.h> #ifdef HAVE_XZ -# include <lzma.h> +#include <lzma.h> #endif #ifdef HAVE_LZ4 -# include <lz4.h> -# include <lz4frame.h> +#include <lz4.h> +#include <lz4frame.h> #endif +#include "compress.h" +#include "fd-util.h" #include "journal-def.h" #include "macro.h" #include "sparse-endian.h" #include "string-util.h" #include "util.h" -#include "compress.h" #ifdef HAVE_LZ4 DEFINE_TRIVIAL_CLEANUP_FUNC(LZ4F_compressionContext_t, LZ4F_freeCompressionContext); diff --git a/src/journal/coredump-vacuum.c b/src/journal/coredump-vacuum.c index ba9994ac47..92259fd5ef 100644 --- a/src/journal/coredump-vacuum.c +++ b/src/journal/coredump-vacuum.c @@ -21,12 +21,13 @@ #include <sys/statvfs.h> +#include "coredump-vacuum.h" +#include "fd-util.h" #include "hashmap.h" #include "macro.h" #include "string-util.h" #include "time-util.h" #include "util.h" -#include "coredump-vacuum.h" #define DEFAULT_MAX_USE_LOWER (uint64_t) (1ULL*1024ULL*1024ULL) /* 1 MiB */ #define DEFAULT_MAX_USE_UPPER (uint64_t) (4ULL*1024ULL*1024ULL*1024ULL) /* 4 GiB */ diff --git a/src/journal/coredump.c b/src/journal/coredump.c index 5c1badd66d..3b87eb5355 100644 --- a/src/journal/coredump.c +++ b/src/journal/coredump.c @@ -41,6 +41,7 @@ #include "copy.h" #include "coredump-vacuum.h" #include "escape.h" +#include "fd-util.h" #include "fileio.h" #include "journald-native.h" #include "log.h" diff --git a/src/journal/coredumpctl.c b/src/journal/coredumpctl.c index 80f692e044..a497a4781b 100644 --- a/src/journal/coredumpctl.c +++ b/src/journal/coredumpctl.c @@ -29,6 +29,7 @@ #include "sd-journal.h" #include "compress.h" +#include "fd-util.h" #include "journal-internal.h" #include "log.h" #include "macro.h" diff --git a/src/journal/journal-authenticate.c b/src/journal/journal-authenticate.c index cdc80e2d26..dc51a5ab2f 100644 --- a/src/journal/journal-authenticate.c +++ b/src/journal/journal-authenticate.c @@ -22,10 +22,11 @@ #include <fcntl.h> #include <sys/mman.h> +#include "fd-util.h" +#include "fsprg.h" +#include "journal-authenticate.h" #include "journal-def.h" #include "journal-file.h" -#include "journal-authenticate.h" -#include "fsprg.h" static uint64_t journal_file_tag_seqnum(JournalFile *f) { uint64_t r; diff --git a/src/journal/journal-def.h b/src/journal/journal-def.h index 39c9dd0dbf..c003ac05dd 100644 --- a/src/journal/journal-def.h +++ b/src/journal/journal-def.h @@ -21,11 +21,10 @@ along with systemd; If not, see <http://www.gnu.org/licenses/>. ***/ -#include "sparse-endian.h" - -#include "systemd/sd-id128.h" +#include "sd-id128.h" #include "macro.h" +#include "sparse-endian.h" /* * If you change this file you probably should also change its documentation: diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c index f0962faeb5..6256c8133c 100644 --- a/src/journal/journal-file.c +++ b/src/journal/journal-file.c @@ -30,12 +30,13 @@ #include "btrfs-util.h" #include "compress.h" +#include "fd-util.h" #include "journal-authenticate.h" #include "journal-def.h" +#include "journal-file.h" #include "lookup3.h" #include "random-util.h" #include "string-util.h" -#include "journal-file.h" #define DEFAULT_DATA_HASH_TABLE_SIZE (2047ULL*sizeof(HashItem)) #define DEFAULT_FIELD_HASH_TABLE_SIZE (333ULL*sizeof(HashItem)) diff --git a/src/journal/journal-qrcode.h b/src/journal/journal-qrcode.h index 3ff6a3ad4a..7d14e8754b 100644 --- a/src/journal/journal-qrcode.h +++ b/src/journal/journal-qrcode.h @@ -21,8 +21,9 @@ along with systemd; If not, see <http://www.gnu.org/licenses/>. ***/ +#include <inttypes.h> #include <stdio.h> -#include "systemd/sd-id128.h" +#include "sd-id128.h" int print_qr_code(FILE *f, const void *seed, size_t seed_size, uint64_t start, uint64_t interval, const char *hn, sd_id128_t machine); diff --git a/src/journal/journal-send.c b/src/journal/journal-send.c index 79ef5b13d2..d42f8262a5 100644 --- a/src/journal/journal-send.c +++ b/src/journal/journal-send.c @@ -31,6 +31,7 @@ #include "sd-journal.h" +#include "fd-util.h" #include "memfd-util.h" #include "socket-util.h" #include "string-util.h" diff --git a/src/journal/journal-vacuum.c b/src/journal/journal-vacuum.c index 692b875fae..dca5bf5000 100644 --- a/src/journal/journal-vacuum.c +++ b/src/journal/journal-vacuum.c @@ -25,13 +25,13 @@ #include "sd-id128.h" +#include "fd-util.h" #include "journal-def.h" #include "journal-file.h" +#include "journal-vacuum.h" #include "string-util.h" #include "util.h" -#include "journal-vacuum.h" - struct vacuum_info { uint64_t usage; char *filename; diff --git a/src/journal/journal-verify.c b/src/journal/journal-verify.c index 4f1d125bb9..de4f73a471 100644 --- a/src/journal/journal-verify.c +++ b/src/journal/journal-verify.c @@ -24,15 +24,16 @@ #include <fcntl.h> #include <stddef.h> -#include "util.h" -#include "macro.h" +#include "compress.h" +#include "fd-util.h" +#include "journal-authenticate.h" #include "journal-def.h" #include "journal-file.h" -#include "journal-authenticate.h" #include "journal-verify.h" #include "lookup3.h" -#include "compress.h" +#include "macro.h" #include "terminal-util.h" +#include "util.h" static void draw_progress(uint64_t p, usec_t *last_usec) { unsigned n, i, j, k; diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c index 1307bd5630..dbb05e0527 100644 --- a/src/journal/journalctl.c +++ b/src/journal/journalctl.c @@ -42,6 +42,7 @@ #include "bus-error.h" #include "bus-util.h" #include "catalog.h" +#include "fd-util.h" #include "fileio.h" #include "fsprg.h" #include "hostname-util.h" diff --git a/src/journal/journald-audit.c b/src/journal/journald-audit.c index 58778a697a..4c102fd530 100644 --- a/src/journal/journald-audit.c +++ b/src/journal/journald-audit.c @@ -20,9 +20,10 @@ ***/ #include "audit-type.h" +#include "fd-util.h" +#include "journald-audit.h" #include "missing.h" #include "string-util.h" -#include "journald-audit.h" typedef struct MapField { const char *audit_field; diff --git a/src/journal/journald-console.c b/src/journal/journald-console.c index 307bdc3949..5f3eb05275 100644 --- a/src/journal/journald-console.c +++ b/src/journal/journald-console.c @@ -29,6 +29,7 @@ #include "formats-util.h" #include "process-util.h" #include "terminal-util.h" +#include "fd-util.h" static bool prefix_timestamp(void) { diff --git a/src/journal/journald-kmsg.c b/src/journal/journald-kmsg.c index a8be704716..5a05632e56 100644 --- a/src/journal/journald-kmsg.c +++ b/src/journal/journald-kmsg.c @@ -29,12 +29,13 @@ #include "sd-messages.h" #include "escape.h" +#include "fd-util.h" #include "formats-util.h" +#include "journald-kmsg.h" #include "journald-server.h" #include "journald-syslog.h" #include "process-util.h" #include "string-util.h" -#include "journald-kmsg.h" void server_forward_kmsg( Server *s, diff --git a/src/journal/journald-native.c b/src/journal/journald-native.c index 7a514b2848..7d4aac687e 100644 --- a/src/journal/journald-native.c +++ b/src/journal/journald-native.c @@ -24,8 +24,10 @@ #include <sys/mman.h> #include <unistd.h> +#include "fd-util.h" #include "journald-console.h" #include "journald-kmsg.h" +#include "journald-native.h" #include "journald-server.h" #include "journald-syslog.h" #include "journald-wall.h" @@ -34,7 +36,6 @@ #include "selinux-util.h" #include "socket-util.h" #include "string-util.h" -#include "journald-native.h" bool valid_user_field(const char *p, size_t l, bool allow_protected) { const char *a; diff --git a/src/journal/journald-server.c b/src/journal/journald-server.c index 2dfd309310..012970bad3 100644 --- a/src/journal/journald-server.c +++ b/src/journal/journald-server.c @@ -36,6 +36,7 @@ #include "acl-util.h" #include "cgroup-util.h" #include "conf-parser.h" +#include "fd-util.h" #include "formats-util.h" #include "hashmap.h" #include "hostname-util.h" @@ -47,6 +48,7 @@ #include "journald-kmsg.h" #include "journald-native.h" #include "journald-rate-limit.h" +#include "journald-server.h" #include "journald-stream.h" #include "journald-syslog.h" #include "missing.h" @@ -57,7 +59,6 @@ #include "signal-util.h" #include "socket-util.h" #include "string-util.h" -#include "journald-server.h" #define USER_JOURNALS_MAX 1024 diff --git a/src/journal/journald-stream.c b/src/journal/journald-stream.c index e06be6267f..0dd511519c 100644 --- a/src/journal/journald-stream.c +++ b/src/journal/journald-stream.c @@ -30,17 +30,18 @@ #include "sd-event.h" #include "escape.h" +#include "fd-util.h" #include "fileio.h" #include "journald-console.h" #include "journald-kmsg.h" #include "journald-server.h" +#include "journald-stream.h" #include "journald-syslog.h" #include "journald-wall.h" #include "mkdir.h" #include "selinux-util.h" #include "socket-util.h" #include "string-util.h" -#include "journald-stream.h" #define STDOUT_STREAMS_MAX 4096 diff --git a/src/journal/journald-syslog.c b/src/journal/journald-syslog.c index fc69cd7d9e..7e9ba12560 100644 --- a/src/journal/journald-syslog.c +++ b/src/journal/journald-syslog.c @@ -25,16 +25,17 @@ #include "sd-messages.h" +#include "fd-util.h" #include "formats-util.h" #include "journald-console.h" #include "journald-kmsg.h" #include "journald-server.h" +#include "journald-syslog.h" #include "journald-wall.h" #include "process-util.h" #include "selinux-util.h" #include "socket-util.h" #include "string-util.h" -#include "journald-syslog.h" /* Warn once every 30s if we missed syslog message */ #define WARN_FORWARD_SYSLOG_MISSED_USEC (30 * USEC_PER_SEC) diff --git a/src/journal/sd-journal.c b/src/journal/sd-journal.c index 442e352ae2..d39c0a900c 100644 --- a/src/journal/sd-journal.c +++ b/src/journal/sd-journal.c @@ -29,9 +29,9 @@ #include <unistd.h> #include "sd-journal.h" - #include "catalog.h" #include "compress.h" +#include "fd-util.h" #include "fileio.h" #include "formats-util.h" #include "hashmap.h" diff --git a/src/journal/stacktrace.c b/src/journal/stacktrace.c index c4ba9e3890..e32550d644 100644 --- a/src/journal/stacktrace.c +++ b/src/journal/stacktrace.c @@ -22,11 +22,12 @@ #include <dwarf.h> #include <elfutils/libdwfl.h> +#include "fd-util.h" #include "formats-util.h" #include "macro.h" +#include "stacktrace.h" #include "string-util.h" #include "util.h" -#include "stacktrace.h" #define FRAMES_MAX 64 #define THREADS_MAX 64 diff --git a/src/journal/test-catalog.c b/src/journal/test-catalog.c index 222d6cc72a..72c1f60f02 100644 --- a/src/journal/test-catalog.c +++ b/src/journal/test-catalog.c @@ -27,11 +27,12 @@ #include "sd-messages.h" -#include "util.h" +#include "catalog.h" +#include "fd-util.h" #include "log.h" #include "macro.h" -#include "catalog.h" #include "string-util.h" +#include "util.h" static const char *catalog_dirs[] = { CATALOG_DIR, diff --git a/src/journal/test-compress.c b/src/journal/test-compress.c index e51b12407f..e562fa1948 100644 --- a/src/journal/test-compress.c +++ b/src/journal/test-compress.c @@ -18,9 +18,10 @@ ***/ #include "compress.h" -#include "util.h" +#include "fd-util.h" #include "macro.h" #include "random-util.h" +#include "util.h" #ifdef HAVE_XZ # define XZ_OK 0 diff --git a/src/journal/test-journal-init.c b/src/journal/test-journal-init.c index e6599f366d..717b703d19 100644 --- a/src/journal/test-journal-init.c +++ b/src/journal/test-journal-init.c @@ -19,11 +19,11 @@ along with systemd; If not, see <http://www.gnu.org/licenses/>. ***/ -#include "systemd/sd-journal.h" +#include "sd-journal.h" #include "log.h" -#include "util.h" #include "rm-rf.h" +#include "util.h" int main(int argc, char *argv[]) { sd_journal *j; diff --git a/src/journal/test-journal-send.c b/src/journal/test-journal-send.c index 81ca47ed8d..694376670d 100644 --- a/src/journal/test-journal-send.c +++ b/src/journal/test-journal-send.c @@ -19,10 +19,11 @@ along with systemd; If not, see <http://www.gnu.org/licenses/>. ***/ -#include "systemd/sd-journal.h" #include <stdlib.h> #include <unistd.h> +#include "sd-journal.h" + #include "log.h" int main(int argc, char *argv[]) { diff --git a/src/journal/test-journal-verify.c b/src/journal/test-journal-verify.c index d89123dc64..887a83efe1 100644 --- a/src/journal/test-journal-verify.c +++ b/src/journal/test-journal-verify.c @@ -23,12 +23,13 @@ #include <unistd.h> #include <fcntl.h> -#include "util.h" -#include "log.h" -#include "rm-rf.h" +#include "fd-util.h" #include "journal-file.h" #include "journal-verify.h" +#include "log.h" +#include "rm-rf.h" #include "terminal-util.h" +#include "util.h" #define N_ENTRIES 6000 #define RANDOM_RANGE 77 diff --git a/src/journal/test-mmap-cache.c b/src/journal/test-mmap-cache.c index 3258b22702..ac1239acc4 100644 --- a/src/journal/test-mmap-cache.c +++ b/src/journal/test-mmap-cache.c @@ -24,9 +24,10 @@ #include <unistd.h> #include <fcntl.h> +#include "fd-util.h" #include "macro.h" -#include "util.h" #include "mmap-cache.h" +#include "util.h" int main(int argc, char *argv[]) { int x, y, z, r; diff --git a/src/libsystemd-network/arp-util.c b/src/libsystemd-network/arp-util.c index 2f5b9b3731..4660c7ea09 100644 --- a/src/libsystemd-network/arp-util.c +++ b/src/libsystemd-network/arp-util.c @@ -21,8 +21,9 @@ #include <linux/filter.h> #include <arpa/inet.h> -#include "util.h" #include "arp-util.h" +#include "fd-util.h" +#include "util.h" int arp_network_bind_raw_socket(int ifindex, be32_t address, const struct ether_addr *eth_mac) { struct sock_filter filter[] = { diff --git a/src/libsystemd-network/dhcp-network.c b/src/libsystemd-network/dhcp-network.c index 7f10838de1..fac25e0fa2 100644 --- a/src/libsystemd-network/dhcp-network.c +++ b/src/libsystemd-network/dhcp-network.c @@ -18,18 +18,18 @@ ***/ #include <errno.h> -#include <sys/socket.h> -#include <string.h> -#include <linux/if_packet.h> -#include <linux/if_infiniband.h> #include <net/ethernet.h> #include <net/if_arp.h> #include <stdio.h> +#include <string.h> +#include <sys/socket.h> #include <linux/filter.h> - -#include "socket-util.h" +#include <linux/if_infiniband.h> +#include <linux/if_packet.h> #include "dhcp-internal.h" +#include "fd-util.h" +#include "socket-util.h" static int _bind_raw_socket(int ifindex, union sockaddr_union *link, uint32_t xid, const uint8_t *mac_addr, diff --git a/src/libsystemd-network/dhcp6-network.c b/src/libsystemd-network/dhcp6-network.c index ccb8363e77..318ee9c4b4 100644 --- a/src/libsystemd-network/dhcp6-network.c +++ b/src/libsystemd-network/dhcp6-network.c @@ -18,19 +18,19 @@ ***/ #include <errno.h> -#include <sys/types.h> -#include <sys/socket.h> -#include <string.h> -#include <linux/if_packet.h> +#include <netinet/in.h> +#include <netinet/ip6.h> #include <stdio.h> +#include <string.h> +#include <sys/socket.h> +#include <sys/types.h> #include <unistd.h> -#include <netinet/ip6.h> -#include <netinet/in.h> - -#include "socket-util.h" +#include <linux/if_packet.h> #include "dhcp6-internal.h" #include "dhcp6-protocol.h" +#include "fd-util.h" +#include "socket-util.h" int dhcp6_network_bind_udp_socket(int index, struct in6_addr *local_address) { struct in6_pktinfo pktinfo = { diff --git a/src/libsystemd-network/icmp6-util.c b/src/libsystemd-network/icmp6-util.c index 140429b1e9..91308bf6c3 100644 --- a/src/libsystemd-network/icmp6-util.c +++ b/src/libsystemd-network/icmp6-util.c @@ -18,19 +18,19 @@ ***/ #include <errno.h> -#include <sys/types.h> -#include <sys/socket.h> -#include <string.h> -#include <linux/if_packet.h> -#include <stdio.h> -#include <unistd.h> -#include <netinet/ip6.h> #include <netinet/icmp6.h> #include <netinet/in.h> +#include <netinet/ip6.h> +#include <stdio.h> +#include <string.h> +#include <sys/socket.h> +#include <sys/types.h> +#include <unistd.h> +#include <linux/if_packet.h> -#include "socket-util.h" - +#include "fd-util.h" #include "icmp6-util.h" +#include "socket-util.h" #define IN6ADDR_ALL_ROUTERS_MULTICAST_INIT \ { { { 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ diff --git a/src/libsystemd-network/lldp-network.c b/src/libsystemd-network/lldp-network.c index 12a6599ff1..f483cd9c8e 100644 --- a/src/libsystemd-network/lldp-network.c +++ b/src/libsystemd-network/lldp-network.c @@ -23,10 +23,11 @@ #include <linux/filter.h> #include <linux/if_ether.h> -#include "socket-util.h" -#include "lldp-tlv.h" -#include "lldp-network.h" +#include "fd-util.h" #include "lldp-internal.h" +#include "lldp-network.h" +#include "lldp-tlv.h" +#include "socket-util.h" int lldp_network_bind_raw_socket(int ifindex) { typedef struct LLDPFrame { diff --git a/src/libsystemd-network/sd-dhcp-lease.c b/src/libsystemd-network/sd-dhcp-lease.c index bc01b5b535..d982936a28 100644 --- a/src/libsystemd-network/sd-dhcp-lease.c +++ b/src/libsystemd-network/sd-dhcp-lease.c @@ -29,6 +29,7 @@ #include "dhcp-lease-internal.h" #include "dhcp-protocol.h" #include "dns-domain.h" +#include "fd-util.h" #include "fileio.h" #include "hostname-util.h" #include "in-addr-util.h" diff --git a/src/libsystemd-network/sd-dhcp-server.c b/src/libsystemd-network/sd-dhcp-server.c index 52f7579c5e..a2a8c16fc8 100644 --- a/src/libsystemd-network/sd-dhcp-server.c +++ b/src/libsystemd-network/sd-dhcp-server.c @@ -26,6 +26,7 @@ #include "dhcp-internal.h" #include "dhcp-server-internal.h" +#include "fd-util.h" #include "in-addr-util.h" #include "siphash24.h" #include "string-util.h" diff --git a/src/libsystemd-network/sd-dhcp6-client.c b/src/libsystemd-network/sd-dhcp6-client.c index d4d4b771d9..ade1b470d4 100644 --- a/src/libsystemd-network/sd-dhcp6-client.c +++ b/src/libsystemd-network/sd-dhcp6-client.c @@ -30,6 +30,7 @@ #include "dhcp6-internal.h" #include "dhcp6-lease-internal.h" #include "dhcp6-protocol.h" +#include "fd-util.h" #include "network-internal.h" #include "random-util.h" #include "util.h" diff --git a/src/libsystemd-network/sd-ipv4acd.c b/src/libsystemd-network/sd-ipv4acd.c index d2ad5f75a4..3053724ea2 100644 --- a/src/libsystemd-network/sd-ipv4acd.c +++ b/src/libsystemd-network/sd-ipv4acd.c @@ -28,6 +28,7 @@ #include "arp-util.h" #include "event-util.h" +#include "fd-util.h" #include "in-addr-util.h" #include "list.h" #include "random-util.h" diff --git a/src/libsystemd-network/sd-lldp.c b/src/libsystemd-network/sd-lldp.c index b73673c55c..b2b85e56e8 100644 --- a/src/libsystemd-network/sd-lldp.c +++ b/src/libsystemd-network/sd-lldp.c @@ -24,6 +24,7 @@ #include "sd-lldp.h" +#include "fd-util.h" #include "hashmap.h" #include "lldp-internal.h" #include "lldp-port.h" diff --git a/src/libsystemd-network/sd-pppoe.c b/src/libsystemd-network/sd-pppoe.c index 7456b3218a..03a88973bf 100644 --- a/src/libsystemd-network/sd-pppoe.c +++ b/src/libsystemd-network/sd-pppoe.c @@ -25,13 +25,14 @@ #include <netinet/in.h> #include <sys/ioctl.h> #include <linux/if_pppox.h> -#include <linux/ppp-ioctl.h> #include <linux/ppp_defs.h> +#include <linux/ppp-ioctl.h> #include "sd-pppoe.h" #include "async.h" #include "event-util.h" +#include "fd-util.h" #include "random-util.h" #include "socket-util.h" #include "sparse-endian.h" diff --git a/src/libsystemd-network/test-dhcp-client.c b/src/libsystemd-network/test-dhcp-client.c index 41c817e3d3..40a85eb25e 100644 --- a/src/libsystemd-network/test-dhcp-client.c +++ b/src/libsystemd-network/test-dhcp-client.c @@ -32,6 +32,7 @@ #include "dhcp-protocol.h" #include "event-util.h" #include "util.h" +#include "fd-util.h" static uint8_t mac_addr[] = {'A', 'B', 'C', '1', '2', '3'}; diff --git a/src/libsystemd-network/test-dhcp6-client.c b/src/libsystemd-network/test-dhcp6-client.c index 4872567894..17ed6d58f3 100644 --- a/src/libsystemd-network/test-dhcp6-client.c +++ b/src/libsystemd-network/test-dhcp6-client.c @@ -33,6 +33,7 @@ #include "dhcp6-lease-internal.h" #include "dhcp6-protocol.h" #include "event-util.h" +#include "fd-util.h" #include "macro.h" #include "socket-util.h" #include "virt.h" diff --git a/src/libsystemd-network/test-ipv4ll.c b/src/libsystemd-network/test-ipv4ll.c index 3958a98a36..6f416c51e4 100644 --- a/src/libsystemd-network/test-ipv4ll.c +++ b/src/libsystemd-network/test-ipv4ll.c @@ -30,6 +30,7 @@ #include "arp-util.h" #include "event-util.h" +#include "fd-util.h" #include "socket-util.h" #include "util.h" diff --git a/src/libsystemd-network/test-lldp.c b/src/libsystemd-network/test-lldp.c index 4e84caa4b0..109462662f 100644 --- a/src/libsystemd-network/test-lldp.c +++ b/src/libsystemd-network/test-lldp.c @@ -29,6 +29,7 @@ #include "sd-lldp.h" #include "event-util.h" +#include "fd-util.h" #include "lldp-network.h" #include "lldp-tlv.h" #include "lldp.h" diff --git a/src/libsystemd/sd-bus/bus-container.c b/src/libsystemd/sd-bus/bus-container.c index 435ec92d6f..589a90bbff 100644 --- a/src/libsystemd/sd-bus/bus-container.c +++ b/src/libsystemd/sd-bus/bus-container.c @@ -22,11 +22,12 @@ #include <unistd.h> #include <fcntl.h> -#include "util.h" -#include "process-util.h" +#include "bus-container.h" #include "bus-internal.h" #include "bus-socket.h" -#include "bus-container.h" +#include "fd-util.h" +#include "process-util.h" +#include "util.h" int bus_container_connect_socket(sd_bus *b) { _cleanup_close_pair_ int pair[2] = { -1, -1 }; diff --git a/src/libsystemd/sd-bus/bus-creds.c b/src/libsystemd/sd-bus/bus-creds.c index 92978da09c..d7bff784b8 100644 --- a/src/libsystemd/sd-bus/bus-creds.c +++ b/src/libsystemd/sd-bus/bus-creds.c @@ -29,6 +29,7 @@ #include "bus-util.h" #include "capability.h" #include "cgroup-util.h" +#include "fd-util.h" #include "fileio.h" #include "formats-util.h" #include "process-util.h" diff --git a/src/libsystemd/sd-bus/bus-introspect.c b/src/libsystemd/sd-bus/bus-introspect.c index 7ad5474439..f5a8885332 100644 --- a/src/libsystemd/sd-bus/bus-introspect.c +++ b/src/libsystemd/sd-bus/bus-introspect.c @@ -20,11 +20,12 @@ ***/ #include "bus-internal.h" +#include "bus-introspect.h" #include "bus-protocol.h" #include "bus-signature.h" +#include "fd-util.h" #include "string-util.h" #include "util.h" -#include "bus-introspect.h" int introspect_begin(struct introspect *i, bool trusted) { assert(i); diff --git a/src/libsystemd/sd-bus/bus-kernel.c b/src/libsystemd/sd-bus/bus-kernel.c index 32246cbf59..f311e86d44 100644 --- a/src/libsystemd/sd-bus/bus-kernel.c +++ b/src/libsystemd/sd-bus/bus-kernel.c @@ -36,17 +36,18 @@ #include "bus-bloom.h" #include "bus-internal.h" +#include "bus-kernel.h" #include "bus-label.h" #include "bus-message.h" #include "bus-util.h" #include "capability.h" +#include "fd-util.h" #include "fileio.h" #include "formats-util.h" #include "memfd-util.h" #include "string-util.h" #include "strv.h" #include "util.h" -#include "bus-kernel.h" #define UNIQUE_NAME_MAX (3+DECIMAL_STR_MAX(uint64_t)) diff --git a/src/libsystemd/sd-bus/bus-match.c b/src/libsystemd/sd-bus/bus-match.c index efab756ef4..58b19fbdc7 100644 --- a/src/libsystemd/sd-bus/bus-match.c +++ b/src/libsystemd/sd-bus/bus-match.c @@ -20,11 +20,12 @@ ***/ #include "bus-internal.h" +#include "bus-match.h" #include "bus-message.h" #include "bus-util.h" +#include "fd-util.h" #include "string-util.h" #include "strv.h" -#include "bus-match.h" /* Example: * diff --git a/src/libsystemd/sd-bus/bus-message.c b/src/libsystemd/sd-bus/bus-message.c index 0e35b3a358..447e25db8a 100644 --- a/src/libsystemd/sd-bus/bus-message.c +++ b/src/libsystemd/sd-bus/bus-message.c @@ -27,16 +27,17 @@ #include "bus-gvariant.h" #include "bus-internal.h" +#include "bus-message.h" #include "bus-signature.h" #include "bus-type.h" #include "bus-util.h" +#include "fd-util.h" #include "memfd-util.h" #include "string-util.h" #include "strv.h" #include "time-util.h" #include "utf8.h" #include "util.h" -#include "bus-message.h" static int message_append_basic(sd_bus_message *m, char type, const void *p, const void **stored); diff --git a/src/libsystemd/sd-bus/bus-socket.c b/src/libsystemd/sd-bus/bus-socket.c index e4994b491f..3273d9b0c2 100644 --- a/src/libsystemd/sd-bus/bus-socket.c +++ b/src/libsystemd/sd-bus/bus-socket.c @@ -29,6 +29,8 @@ #include "bus-internal.h" #include "bus-message.h" +#include "bus-socket.h" +#include "fd-util.h" #include "formats-util.h" #include "macro.h" #include "missing.h" @@ -36,7 +38,6 @@ #include "string-util.h" #include "utf8.h" #include "util.h" -#include "bus-socket.h" #define SNDBUF_SIZE (8*1024*1024) diff --git a/src/libsystemd/sd-bus/bus-track.c b/src/libsystemd/sd-bus/bus-track.c index e43891be25..0911156e19 100644 --- a/src/libsystemd/sd-bus/bus-track.c +++ b/src/libsystemd/sd-bus/bus-track.c @@ -20,9 +20,10 @@ ***/ #include "sd-bus.h" -#include "bus-util.h" + #include "bus-internal.h" #include "bus-track.h" +#include "bus-util.h" struct sd_bus_track { unsigned n_ref; diff --git a/src/libsystemd/sd-bus/busctl.c b/src/libsystemd/sd-bus/busctl.c index 04c6b1e8ef..b55e81ce97 100644 --- a/src/libsystemd/sd-bus/busctl.c +++ b/src/libsystemd/sd-bus/busctl.c @@ -30,6 +30,7 @@ #include "bus-util.h" #include "busctl-introspect.h" #include "escape.h" +#include "fd-util.h" #include "log.h" #include "pager.h" #include "path-util.h" diff --git a/src/libsystemd/sd-bus/sd-bus.c b/src/libsystemd/sd-bus/sd-bus.c index 2fb483171e..7b91c2583d 100644 --- a/src/libsystemd/sd-bus/sd-bus.c +++ b/src/libsystemd/sd-bus/sd-bus.c @@ -44,6 +44,7 @@ #include "bus-util.h" #include "cgroup-util.h" #include "def.h" +#include "fd-util.h" #include "hostname-util.h" #include "macro.h" #include "missing.h" diff --git a/src/libsystemd/sd-bus/test-bus-benchmark.c b/src/libsystemd/sd-bus/test-bus-benchmark.c index 4c7c58f57e..549c88cd2d 100644 --- a/src/libsystemd/sd-bus/test-bus-benchmark.c +++ b/src/libsystemd/sd-bus/test-bus-benchmark.c @@ -27,6 +27,7 @@ #include "bus-kernel.h" #include "bus-util.h" #include "def.h" +#include "fd-util.h" #include "time-util.h" #include "util.h" diff --git a/src/libsystemd/sd-bus/test-bus-chat.c b/src/libsystemd/sd-bus/test-bus-chat.c index c6a81a1894..e9e5e4a8e3 100644 --- a/src/libsystemd/sd-bus/test-bus-chat.c +++ b/src/libsystemd/sd-bus/test-bus-chat.c @@ -34,6 +34,7 @@ #include "log.h" #include "macro.h" #include "util.h" +#include "fd-util.h" static int match_callback(sd_bus_message *m, void *userdata, sd_bus_error *ret_error) { log_info("Match triggered! interface=%s member=%s", strna(sd_bus_message_get_interface(m)), strna(sd_bus_message_get_member(m))); diff --git a/src/libsystemd/sd-bus/test-bus-kernel-bloom.c b/src/libsystemd/sd-bus/test-bus-kernel-bloom.c index 02ccbd7260..ff7f9cdafa 100644 --- a/src/libsystemd/sd-bus/test-bus-kernel-bloom.c +++ b/src/libsystemd/sd-bus/test-bus-kernel-bloom.c @@ -23,6 +23,7 @@ #include "bus-kernel.h" #include "bus-util.h" +#include "fd-util.h" #include "log.h" #include "util.h" diff --git a/src/libsystemd/sd-bus/test-bus-kernel.c b/src/libsystemd/sd-bus/test-bus-kernel.c index 436bc017a4..7d05953cd0 100644 --- a/src/libsystemd/sd-bus/test-bus-kernel.c +++ b/src/libsystemd/sd-bus/test-bus-kernel.c @@ -26,6 +26,7 @@ #include "bus-dump.h" #include "bus-kernel.h" #include "bus-util.h" +#include "fd-util.h" #include "log.h" #include "util.h" diff --git a/src/libsystemd/sd-bus/test-bus-marshal.c b/src/libsystemd/sd-bus/test-bus-marshal.c index b54d931c1c..c0daa451ec 100644 --- a/src/libsystemd/sd-bus/test-bus-marshal.c +++ b/src/libsystemd/sd-bus/test-bus-marshal.c @@ -36,6 +36,7 @@ #include "bus-label.h" #include "bus-message.h" #include "bus-util.h" +#include "fd-util.h" #include "log.h" #include "util.h" diff --git a/src/libsystemd/sd-bus/test-bus-zero-copy.c b/src/libsystemd/sd-bus/test-bus-zero-copy.c index 42c95240d4..1be0dbcd82 100644 --- a/src/libsystemd/sd-bus/test-bus-zero-copy.c +++ b/src/libsystemd/sd-bus/test-bus-zero-copy.c @@ -30,6 +30,7 @@ #include "memfd-util.h" #include "string-util.h" #include "util.h" +#include "fd-util.h" #define FIRST_ARRAY 17 #define SECOND_ARRAY 33 diff --git a/src/libsystemd/sd-daemon/sd-daemon.c b/src/libsystemd/sd-daemon/sd-daemon.c index bae37e8034..85c73722df 100644 --- a/src/libsystemd/sd-daemon/sd-daemon.c +++ b/src/libsystemd/sd-daemon/sd-daemon.c @@ -35,6 +35,7 @@ #include "sd-daemon.h" +#include "fd-util.h" #include "path-util.h" #include "socket-util.h" #include "strv.h" diff --git a/src/libsystemd/sd-device/device-enumerator.c b/src/libsystemd/sd-device/device-enumerator.c index 9379209a58..c98053220c 100644 --- a/src/libsystemd/sd-device/device-enumerator.c +++ b/src/libsystemd/sd-device/device-enumerator.c @@ -22,6 +22,7 @@ #include "device-enumerator-private.h" #include "device-util.h" +#include "fd-util.h" #include "prioq.h" #include "set.h" #include "string-util.h" diff --git a/src/libsystemd/sd-device/device-private.c b/src/libsystemd/sd-device/device-private.c index f6263121b6..bcabf9468d 100644 --- a/src/libsystemd/sd-device/device-private.c +++ b/src/libsystemd/sd-device/device-private.c @@ -27,6 +27,7 @@ #include "device-internal.h" #include "device-private.h" #include "device-util.h" +#include "fd-util.h" #include "fileio.h" #include "hashmap.h" #include "macro.h" diff --git a/src/libsystemd/sd-device/sd-device.c b/src/libsystemd/sd-device/sd-device.c index ca42b4318e..593dda52f2 100644 --- a/src/libsystemd/sd-device/sd-device.c +++ b/src/libsystemd/sd-device/sd-device.c @@ -27,6 +27,7 @@ #include "device-internal.h" #include "device-private.h" #include "device-util.h" +#include "fd-util.h" #include "fileio.h" #include "hashmap.h" #include "macro.h" diff --git a/src/libsystemd/sd-event/sd-event.c b/src/libsystemd/sd-event/sd-event.c index cab35e185e..b3f8881714 100644 --- a/src/libsystemd/sd-event/sd-event.c +++ b/src/libsystemd/sd-event/sd-event.c @@ -27,6 +27,7 @@ #include "sd-event.h" #include "sd-id128.h" +#include "fd-util.h" #include "hashmap.h" #include "list.h" #include "macro.h" diff --git a/src/libsystemd/sd-event/test-event.c b/src/libsystemd/sd-event/test-event.c index c092e56b7a..c1a3b49483 100644 --- a/src/libsystemd/sd-event/test-event.c +++ b/src/libsystemd/sd-event/test-event.c @@ -20,10 +20,12 @@ ***/ #include "sd-event.h" + +#include "fd-util.h" #include "log.h" -#include "util.h" #include "macro.h" #include "signal-util.h" +#include "util.h" static int prepare_handler(sd_event_source *s, void *userdata) { log_info("preparing %c", PTR_TO_INT(userdata)); diff --git a/src/libsystemd/sd-hwdb/sd-hwdb.c b/src/libsystemd/sd-hwdb/sd-hwdb.c index 4932c19199..9304fd376e 100644 --- a/src/libsystemd/sd-hwdb/sd-hwdb.c +++ b/src/libsystemd/sd-hwdb/sd-hwdb.c @@ -29,6 +29,7 @@ #include "sd-hwdb.h" +#include "fd-util.h" #include "hashmap.h" #include "hwdb-internal.h" #include "hwdb-util.h" diff --git a/src/libsystemd/sd-id128/sd-id128.c b/src/libsystemd/sd-id128/sd-id128.c index a6dbc413ac..ef89fd2572 100644 --- a/src/libsystemd/sd-id128/sd-id128.c +++ b/src/libsystemd/sd-id128/sd-id128.c @@ -28,6 +28,7 @@ #include "macro.h" #include "random-util.h" #include "util.h" +#include "fd-util.h" _public_ char *sd_id128_to_string(sd_id128_t id, char s[SD_ID128_STRING_MAX]) { unsigned n; diff --git a/src/libsystemd/sd-login/sd-login.c b/src/libsystemd/sd-login/sd-login.c index 28f935aa66..399918f834 100644 --- a/src/libsystemd/sd-login/sd-login.c +++ b/src/libsystemd/sd-login/sd-login.c @@ -29,6 +29,7 @@ #include "cgroup-util.h" #include "escape.h" +#include "fd-util.h" #include "fileio.h" #include "formats-util.h" #include "hostname-util.h" diff --git a/src/libsystemd/sd-login/test-login.c b/src/libsystemd/sd-login/test-login.c index 014323321e..46aa73b38a 100644 --- a/src/libsystemd/sd-login/test-login.c +++ b/src/libsystemd/sd-login/test-login.c @@ -24,6 +24,7 @@ #include "sd-login.h" +#include "fd-util.h" #include "formats-util.h" #include "string-util.h" #include "strv.h" diff --git a/src/libsystemd/sd-netlink/sd-netlink.c b/src/libsystemd/sd-netlink/sd-netlink.c index 2adc4499b6..57c5db1231 100644 --- a/src/libsystemd/sd-netlink/sd-netlink.c +++ b/src/libsystemd/sd-netlink/sd-netlink.c @@ -24,6 +24,7 @@ #include "sd-netlink.h" +#include "fd-util.h" #include "hashmap.h" #include "macro.h" #include "missing.h" diff --git a/src/libsystemd/sd-network/network-util.c b/src/libsystemd/sd-network/network-util.c index 48958e8a9f..8070ff07c4 100644 --- a/src/libsystemd/sd-network/network-util.c +++ b/src/libsystemd/sd-network/network-util.c @@ -19,8 +19,9 @@ along with systemd; If not, see <http://www.gnu.org/licenses/>. ***/ -#include "strv.h" +#include "fd-util.h" #include "network-util.h" +#include "strv.h" bool network_is_online(void) { _cleanup_free_ char *state = NULL; diff --git a/src/libsystemd/sd-network/sd-network.c b/src/libsystemd/sd-network/sd-network.c index d330712aaf..ad1227264c 100644 --- a/src/libsystemd/sd-network/sd-network.c +++ b/src/libsystemd/sd-network/sd-network.c @@ -32,6 +32,7 @@ #include "string-util.h" #include "strv.h" #include "util.h" +#include "fd-util.h" _public_ int sd_network_get_operational_state(char **state) { _cleanup_free_ char *s = NULL; diff --git a/src/libsystemd/sd-path/sd-path.c b/src/libsystemd/sd-path/sd-path.c index 927b6f8b2d..2467c126ae 100644 --- a/src/libsystemd/sd-path/sd-path.c +++ b/src/libsystemd/sd-path/sd-path.c @@ -20,6 +20,7 @@ #include "sd-path.h" #include "architecture.h" +#include "fd-util.h" #include "missing.h" #include "path-util.h" #include "string-util.h" diff --git a/src/libsystemd/sd-resolve/sd-resolve.c b/src/libsystemd/sd-resolve/sd-resolve.c index 024ad9ead1..38e2dc0fdd 100644 --- a/src/libsystemd/sd-resolve/sd-resolve.c +++ b/src/libsystemd/sd-resolve/sd-resolve.c @@ -33,6 +33,7 @@ #include "sd-resolve.h" +#include "fd-util.h" #include "list.h" #include "missing.h" #include "resolve-util.h" diff --git a/src/libudev/libudev-monitor.c b/src/libudev/libudev-monitor.c index 00472fedc9..5590aec2b7 100644 --- a/src/libudev/libudev-monitor.c +++ b/src/libudev/libudev-monitor.c @@ -30,6 +30,7 @@ #include "libudev.h" +#include "fd-util.h" #include "formats-util.h" #include "libudev-private.h" #include "missing.h" diff --git a/src/libudev/libudev-queue.c b/src/libudev/libudev-queue.c index 11e15d13e6..4d1a0adbf2 100644 --- a/src/libudev/libudev-queue.c +++ b/src/libudev/libudev-queue.c @@ -24,6 +24,7 @@ #include <errno.h> #include <sys/inotify.h> +#include "fd-util.h" #include "libudev-private.h" /** diff --git a/src/libudev/libudev.c b/src/libudev/libudev.c index 00605d0126..afadfe6993 100644 --- a/src/libudev/libudev.c +++ b/src/libudev/libudev.c @@ -26,6 +26,7 @@ #include "libudev.h" +#include "fd-util.h" #include "libudev-private.h" #include "missing.h" #include "string-util.h" diff --git a/src/locale/localectl.c b/src/locale/localectl.c index 880a1794aa..4a339dcfd4 100644 --- a/src/locale/localectl.c +++ b/src/locale/localectl.c @@ -32,6 +32,7 @@ #include "bus-error.h" #include "bus-util.h" #include "def.h" +#include "fd-util.h" #include "fileio.h" #include "locale-util.h" #include "pager.h" diff --git a/src/locale/localed.c b/src/locale/localed.c index e3eef4a610..73e25f0642 100644 --- a/src/locale/localed.c +++ b/src/locale/localed.c @@ -24,6 +24,10 @@ #include <string.h> #include <unistd.h> +#ifdef HAVE_XKBCOMMON +#include <xkbcommon/xkbcommon.h> +#endif + #include "sd-bus.h" #include "util.h" @@ -39,10 +43,7 @@ #include "event-util.h" #include "locale-util.h" #include "selinux-util.h" - -#ifdef HAVE_XKBCOMMON -#include <xkbcommon/xkbcommon.h> -#endif +#include "fd-util.h" enum { /* We don't list LC_ALL here on purpose. People should be diff --git a/src/login/inhibit.c b/src/login/inhibit.c index e671341b42..5ff0957aed 100644 --- a/src/login/inhibit.c +++ b/src/login/inhibit.c @@ -29,6 +29,7 @@ #include "bus-error.h" #include "bus-util.h" +#include "fd-util.h" #include "formats-util.h" #include "process-util.h" #include "signal-util.h" diff --git a/src/login/logind-acl.c b/src/login/logind-acl.c index 1acdc5aa22..4d7bda3ee0 100644 --- a/src/login/logind-acl.c +++ b/src/login/logind-acl.c @@ -24,12 +24,13 @@ #include "acl-util.h" #include "escape.h" +#include "fd-util.h" #include "formats-util.h" +#include "logind-acl.h" #include "set.h" #include "string-util.h" #include "udev-util.h" #include "util.h" -#include "logind-acl.h" static int flush_acl(acl_t acl) { acl_entry_t i; diff --git a/src/login/logind-button.c b/src/login/logind-button.c index caa844e601..b98035be21 100644 --- a/src/login/logind-button.c +++ b/src/login/logind-button.c @@ -28,9 +28,10 @@ #include "sd-messages.h" +#include "fd-util.h" +#include "logind-button.h" #include "string-util.h" #include "util.h" -#include "logind-button.h" Button* button_new(Manager *m, const char *name) { Button *b; diff --git a/src/login/logind-core.c b/src/login/logind-core.c index 6c05c11dbd..3b6e982e9f 100644 --- a/src/login/logind-core.c +++ b/src/login/logind-core.c @@ -25,13 +25,14 @@ #include <pwd.h> #include <linux/vt.h> -#include "strv.h" -#include "cgroup-util.h" -#include "bus-util.h" #include "bus-error.h" -#include "udev-util.h" +#include "bus-util.h" +#include "cgroup-util.h" +#include "fd-util.h" #include "logind.h" +#include "strv.h" #include "terminal-util.h" +#include "udev-util.h" int manager_add_device(Manager *m, const char *sysfs, bool master, Device **_device) { Device *d; diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c index 66807b3894..1677785467 100644 --- a/src/login/logind-dbus.c +++ b/src/login/logind-dbus.c @@ -32,6 +32,7 @@ #include "bus-util.h" #include "efivars.h" #include "escape.h" +#include "fd-util.h" #include "fileio-label.h" #include "formats-util.h" #include "logind.h" diff --git a/src/login/logind-inhibit.c b/src/login/logind-inhibit.c index 5b247f48d6..ec34535f83 100644 --- a/src/login/logind-inhibit.c +++ b/src/login/logind-inhibit.c @@ -25,12 +25,13 @@ #include <unistd.h> #include "escape.h" +#include "fd-util.h" #include "fileio.h" #include "formats-util.h" +#include "logind-inhibit.h" #include "mkdir.h" #include "string-util.h" #include "util.h" -#include "logind-inhibit.h" Inhibitor* inhibitor_new(Manager *m, const char* id) { Inhibitor *i; diff --git a/src/login/logind-seat.c b/src/login/logind-seat.c index 757993a953..dad552d5f2 100644 --- a/src/login/logind-seat.c +++ b/src/login/logind-seat.c @@ -26,13 +26,14 @@ #include "sd-messages.h" +#include "fd-util.h" #include "formats-util.h" #include "logind-acl.h" +#include "logind-seat.h" #include "mkdir.h" #include "string-util.h" #include "terminal-util.h" #include "util.h" -#include "logind-seat.h" Seat *seat_new(Manager *m, const char *id) { Seat *s; diff --git a/src/login/logind-session-dbus.c b/src/login/logind-session-dbus.c index e6b4ccd7c6..fe398a5eb6 100644 --- a/src/login/logind-session-dbus.c +++ b/src/login/logind-session-dbus.c @@ -22,15 +22,15 @@ #include <errno.h> #include <string.h> -#include "util.h" -#include "strv.h" -#include "bus-util.h" #include "bus-common-errors.h" #include "bus-label.h" - -#include "logind.h" -#include "logind-session.h" +#include "bus-util.h" +#include "fd-util.h" #include "logind-session-device.h" +#include "logind-session.h" +#include "logind.h" +#include "strv.h" +#include "util.h" static int property_get_user( sd_bus *bus, diff --git a/src/login/logind-session-device.c b/src/login/logind-session-device.c index d4d9052d10..3a0bb720f9 100644 --- a/src/login/logind-session-device.c +++ b/src/login/logind-session-device.c @@ -27,10 +27,11 @@ #include "libudev.h" -#include "util.h" -#include "missing.h" #include "bus-util.h" +#include "fd-util.h" #include "logind-session-device.h" +#include "missing.h" +#include "util.h" enum SessionDeviceNotifications { SESSION_DEVICE_RESUME, diff --git a/src/login/logind-session.c b/src/login/logind-session.c index e35b5e71a1..ead79ad327 100644 --- a/src/login/logind-session.c +++ b/src/login/logind-session.c @@ -34,13 +34,14 @@ #include "bus-error.h" #include "bus-util.h" #include "escape.h" +#include "fd-util.h" #include "fileio.h" #include "formats-util.h" +#include "logind-session.h" #include "mkdir.h" #include "path-util.h" #include "terminal-util.h" #include "util.h" -#include "logind-session.h" #define RELEASE_USEC (20*USEC_PER_SEC) diff --git a/src/login/logind-user.c b/src/login/logind-user.c index ecfbf2c5cc..80328068cd 100644 --- a/src/login/logind-user.c +++ b/src/login/logind-user.c @@ -29,10 +29,12 @@ #include "clean-ipc.h" #include "conf-parser.h" #include "escape.h" +#include "fd-util.h" #include "fileio.h" #include "formats-util.h" #include "hashmap.h" #include "label.h" +#include "logind-user.h" #include "mkdir.h" #include "path-util.h" #include "rm-rf.h" @@ -40,7 +42,6 @@ #include "special.h" #include "unit-name.h" #include "util.h" -#include "logind-user.h" User* user_new(Manager *m, uid_t uid, gid_t gid, const char *name) { User *u; diff --git a/src/login/logind.c b/src/login/logind.c index 6ce7e1fd78..02c87ca58e 100644 --- a/src/login/logind.c +++ b/src/login/logind.c @@ -30,11 +30,12 @@ #include "bus-error.h" #include "bus-util.h" #include "conf-parser.h" +#include "fd-util.h" #include "formats-util.h" +#include "logind.h" #include "signal-util.h" #include "strv.h" #include "udev-util.h" -#include "logind.h" static void manager_free(Manager *m); diff --git a/src/login/pam_systemd.c b/src/login/pam_systemd.c index 63c31a6f62..dbd055a79a 100644 --- a/src/login/pam_systemd.c +++ b/src/login/pam_systemd.c @@ -35,6 +35,7 @@ #include "bus-error.h" #include "bus-util.h" #include "def.h" +#include "fd-util.h" #include "fileio.h" #include "formats-util.h" #include "hostname-util.h" diff --git a/src/login/test-inhibit.c b/src/login/test-inhibit.c index f231e54cde..d0727ff7c7 100644 --- a/src/login/test-inhibit.c +++ b/src/login/test-inhibit.c @@ -24,6 +24,7 @@ #include "sd-bus.h" #include "bus-util.h" +#include "fd-util.h" #include "macro.h" #include "util.h" diff --git a/src/machine/machine-dbus.c b/src/machine/machine-dbus.c index 6e41e92962..c17a98e90f 100644 --- a/src/machine/machine-dbus.c +++ b/src/machine/machine-dbus.c @@ -29,22 +29,23 @@ #include <libgen.h> #undef basename -#include "bus-util.h" -#include "bus-label.h" -#include "strv.h" #include "bus-common-errors.h" +#include "bus-internal.h" +#include "bus-label.h" +#include "bus-util.h" #include "copy.h" +#include "env-util.h" +#include "fd-util.h" #include "fileio.h" +#include "formats-util.h" #include "in-addr-util.h" #include "local-addresses.h" -#include "path-util.h" -#include "mkdir.h" -#include "bus-internal.h" -#include "machine.h" #include "machine-dbus.h" -#include "formats-util.h" +#include "machine.h" +#include "mkdir.h" +#include "path-util.h" #include "process-util.h" -#include "env-util.h" +#include "strv.h" #include "terminal-util.h" static int property_get_id( diff --git a/src/machine/machine.c b/src/machine/machine.c index e27d0af169..e41f8add98 100644 --- a/src/machine/machine.c +++ b/src/machine/machine.c @@ -28,16 +28,17 @@ #include "bus-error.h" #include "bus-util.h" #include "escape.h" +#include "fd-util.h" #include "fileio.h" #include "formats-util.h" #include "hashmap.h" #include "machine-dbus.h" +#include "machine.h" #include "mkdir.h" #include "special.h" #include "terminal-util.h" #include "unit-name.h" #include "util.h" -#include "machine.h" Machine* machine_new(Manager *manager, MachineClass class, const char *name) { Machine *m; diff --git a/src/machine/machinectl.c b/src/machine/machinectl.c index f44f4edc0a..23cc74ab54 100644 --- a/src/machine/machinectl.c +++ b/src/machine/machinectl.c @@ -40,6 +40,7 @@ #include "copy.h" #include "env-util.h" #include "event-util.h" +#include "fd-util.h" #include "hostname-util.h" #include "import-util.h" #include "log.h" diff --git a/src/machine/machined-dbus.c b/src/machine/machined-dbus.c index 6e4c72e8a9..b5ce6cdca2 100644 --- a/src/machine/machined-dbus.c +++ b/src/machine/machined-dbus.c @@ -24,21 +24,23 @@ #include <unistd.h> #include "sd-id128.h" -#include "strv.h" -#include "path-util.h" -#include "unit-name.h" -#include "bus-util.h" + +#include "btrfs-util.h" #include "bus-common-errors.h" +#include "bus-util.h" #include "cgroup-util.h" -#include "btrfs-util.h" +#include "fd-util.h" #include "formats-util.h" -#include "process-util.h" #include "hostname-util.h" +#include "image-dbus.h" +#include "machine-dbus.h" #include "machine-image.h" #include "machine-pool.h" -#include "image-dbus.h" #include "machined.h" -#include "machine-dbus.h" +#include "path-util.h" +#include "process-util.h" +#include "strv.h" +#include "unit-name.h" static int property_get_pool_path( sd_bus *bus, diff --git a/src/machine/machined.c b/src/machine/machined.c index df3cc9972a..fe229c88a8 100644 --- a/src/machine/machined.c +++ b/src/machine/machined.c @@ -24,15 +24,17 @@ #include <unistd.h> #include "sd-daemon.h" -#include "cgroup-util.h" -#include "bus-util.h" + #include "bus-error.h" -#include "label.h" +#include "bus-util.h" +#include "cgroup-util.h" +#include "fd-util.h" #include "formats-util.h" -#include "signal-util.h" #include "hostname-util.h" +#include "label.h" #include "machine-image.h" #include "machined.h" +#include "signal-util.h" Manager *manager_new(void) { Manager *m; diff --git a/src/modules-load/modules-load.c b/src/modules-load/modules-load.c index 4a58ce1082..34bd65cb11 100644 --- a/src/modules-load/modules-load.c +++ b/src/modules-load/modules-load.c @@ -27,6 +27,7 @@ #include <sys/stat.h> #include "conf-files.h" +#include "fd-util.h" #include "log.h" #include "string-util.h" #include "strv.h" diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c index 09f4bd7029..1144c82c17 100644 --- a/src/network/networkd-link.c +++ b/src/network/networkd-link.c @@ -25,18 +25,18 @@ #include "bus-util.h" #include "dhcp-lease-internal.h" +#include "fd-util.h" #include "fileio.h" #include "netlink-util.h" #include "network-internal.h" +#include "networkd-link.h" +#include "networkd-netdev.h" #include "set.h" #include "socket-util.h" #include "udev-util.h" #include "util.h" #include "virt.h" -#include "networkd-link.h" -#include "networkd-netdev.h" - bool link_dhcp6_enabled(Link *link) { if (link->flags & IFF_LOOPBACK) return false; diff --git a/src/network/networkd-manager.c b/src/network/networkd-manager.c index 23d3aac694..febfe2ff81 100644 --- a/src/network/networkd-manager.c +++ b/src/network/networkd-manager.c @@ -28,6 +28,7 @@ #include "bus-util.h" #include "conf-parser.h" #include "def.h" +#include "fd-util.h" #include "libudev-private.h" #include "local-addresses.h" #include "netlink-util.h" diff --git a/src/network/networkd-netdev-tuntap.c b/src/network/networkd-netdev-tuntap.c index 6a808b6205..3096c4f72a 100644 --- a/src/network/networkd-netdev-tuntap.c +++ b/src/network/networkd-netdev-tuntap.c @@ -24,6 +24,7 @@ #include <linux/if_tun.h> #include "networkd-netdev-tuntap.h" +#include "fd-util.h" #define TUN_DEV "/dev/net/tun" diff --git a/src/network/networkd-netdev.c b/src/network/networkd-netdev.c index d9ccc19d3d..bd1129a09b 100644 --- a/src/network/networkd-netdev.c +++ b/src/network/networkd-netdev.c @@ -23,13 +23,14 @@ #include "conf-files.h" #include "conf-parser.h" +#include "fd-util.h" #include "list.h" #include "netlink-util.h" #include "network-internal.h" +#include "networkd-netdev.h" #include "networkd.h" #include "siphash24.h" #include "string-util.h" -#include "networkd-netdev.h" const NetDevVTable * const netdev_vtable[_NETDEV_KIND_MAX] = { diff --git a/src/network/networkd-network.c b/src/network/networkd-network.c index 9f9a6911e3..150fd052c2 100644 --- a/src/network/networkd-network.c +++ b/src/network/networkd-network.c @@ -25,12 +25,13 @@ #include "conf-files.h" #include "conf-parser.h" #include "dns-domain.h" +#include "fd-util.h" #include "hostname-util.h" #include "network-internal.h" +#include "networkd-network.h" #include "networkd.h" #include "string-util.h" #include "util.h" -#include "networkd-network.h" static int network_load_one(Manager *manager, const char *filename) { _cleanup_network_free_ Network *network = NULL; diff --git a/src/nspawn/nspawn-cgroup.c b/src/nspawn/nspawn-cgroup.c index 9e1f58f730..4e86ed13cb 100644 --- a/src/nspawn/nspawn-cgroup.c +++ b/src/nspawn/nspawn-cgroup.c @@ -22,12 +22,13 @@ #include <sys/mount.h> #include "cgroup-util.h" +#include "fd-util.h" #include "fileio.h" #include "mkdir.h" +#include "nspawn-cgroup.h" #include "string-util.h" #include "strv.h" #include "util.h" -#include "nspawn-cgroup.h" int chown_cgroup(pid_t pid, uid_t uid_shift) { _cleanup_free_ char *path = NULL, *fs = NULL; diff --git a/src/nspawn/nspawn-expose-ports.c b/src/nspawn/nspawn-expose-ports.c index 1081a38c58..df9fbe185b 100644 --- a/src/nspawn/nspawn-expose-ports.c +++ b/src/nspawn/nspawn-expose-ports.c @@ -21,13 +21,14 @@ #include "sd-netlink.h" +#include "fd-util.h" #include "firewall-util.h" #include "in-addr-util.h" #include "local-addresses.h" #include "netlink-util.h" +#include "nspawn-expose-ports.h" #include "string-util.h" #include "util.h" -#include "nspawn-expose-ports.h" int expose_port_parse(ExposePort **l, const char *s) { diff --git a/src/nspawn/nspawn-setuid.c b/src/nspawn/nspawn-setuid.c index b6d18574e8..2a1dfd83a9 100644 --- a/src/nspawn/nspawn-setuid.c +++ b/src/nspawn/nspawn-setuid.c @@ -23,12 +23,13 @@ #include <sys/types.h> #include <unistd.h> +#include "fd-util.h" #include "mkdir.h" +#include "nspawn-setuid.h" #include "process-util.h" #include "signal-util.h" #include "string-util.h" #include "util.h" -#include "nspawn-setuid.h" static int spawn_getent(const char *database, const char *key, pid_t *rpid) { int pipe_fds[2]; diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c index 8ef6cfd731..f95842d252 100644 --- a/src/nspawn/nspawn.c +++ b/src/nspawn/nspawn.c @@ -57,6 +57,7 @@ #include "dev-setup.h" #include "env-util.h" #include "event-util.h" +#include "fd-util.h" #include "fdset.h" #include "fileio.h" #include "formats-util.h" diff --git a/src/random-seed/random-seed.c b/src/random-seed/random-seed.c index a21a0fb916..42841480c5 100644 --- a/src/random-seed/random-seed.c +++ b/src/random-seed/random-seed.c @@ -25,6 +25,7 @@ #include <sys/stat.h> #include <unistd.h> +#include "fd-util.h" #include "log.h" #include "mkdir.h" #include "string-util.h" diff --git a/src/reply-password/reply-password.c b/src/reply-password/reply-password.c index 61deafe728..166ab470ed 100644 --- a/src/reply-password/reply-password.c +++ b/src/reply-password/reply-password.c @@ -25,6 +25,7 @@ #include <sys/socket.h> #include <sys/un.h> +#include "fd-util.h" #include "log.h" #include "macro.h" #include "string-util.h" diff --git a/src/resolve/resolved-dns-scope.c b/src/resolve/resolved-dns-scope.c index 9e6f595a1b..7c63c63b63 100644 --- a/src/resolve/resolved-dns-scope.c +++ b/src/resolve/resolved-dns-scope.c @@ -21,15 +21,16 @@ #include <netinet/tcp.h> -#include "missing.h" -#include "strv.h" -#include "socket-util.h" #include "af-list.h" -#include "random-util.h" -#include "hostname-util.h" #include "dns-domain.h" -#include "resolved-llmnr.h" +#include "fd-util.h" +#include "hostname-util.h" +#include "missing.h" +#include "random-util.h" #include "resolved-dns-scope.h" +#include "resolved-llmnr.h" +#include "socket-util.h" +#include "strv.h" #define MULTICAST_RATELIMIT_INTERVAL_USEC (1*USEC_PER_SEC) #define MULTICAST_RATELIMIT_BURST 1000 diff --git a/src/resolve/resolved-dns-stream.c b/src/resolve/resolved-dns-stream.c index 7f47e7223a..b2eebe09a2 100644 --- a/src/resolve/resolved-dns-stream.c +++ b/src/resolve/resolved-dns-stream.c @@ -21,6 +21,7 @@ #include <netinet/tcp.h> +#include "fd-util.h" #include "missing.h" #include "resolved-dns-stream.h" diff --git a/src/resolve/resolved-dns-transaction.c b/src/resolve/resolved-dns-transaction.c index b30473dd7e..84472ca1bc 100644 --- a/src/resolve/resolved-dns-transaction.c +++ b/src/resolve/resolved-dns-transaction.c @@ -21,10 +21,11 @@ #include "af-list.h" -#include "resolved-llmnr.h" -#include "resolved-dns-transaction.h" -#include "random-util.h" #include "dns-domain.h" +#include "fd-util.h" +#include "random-util.h" +#include "resolved-dns-transaction.h" +#include "resolved-llmnr.h" DnsTransaction* dns_transaction_free(DnsTransaction *t) { DnsQuery *q; diff --git a/src/resolve/resolved-llmnr.c b/src/resolve/resolved-llmnr.c index 8afaf8db6e..5c3a4a00c3 100644 --- a/src/resolve/resolved-llmnr.c +++ b/src/resolve/resolved-llmnr.c @@ -22,8 +22,9 @@ #include <resolv.h> #include <netinet/in.h> -#include "resolved-manager.h" +#include "fd-util.h" #include "resolved-llmnr.h" +#include "resolved-manager.h" void manager_llmnr_stop(Manager *m) { assert(m); diff --git a/src/resolve/resolved-manager.c b/src/resolve/resolved-manager.c index b410e40308..65476fa38b 100644 --- a/src/resolve/resolved-manager.c +++ b/src/resolve/resolved-manager.c @@ -26,6 +26,7 @@ #include "af-list.h" #include "dns-domain.h" +#include "fd-util.h" #include "fileio-label.h" #include "hostname-util.h" #include "netlink-util.h" diff --git a/src/rfkill/rfkill.c b/src/rfkill/rfkill.c index ece778b8ef..df8fc0690d 100644 --- a/src/rfkill/rfkill.c +++ b/src/rfkill/rfkill.c @@ -26,6 +26,7 @@ #include "sd-daemon.h" #include "escape.h" +#include "fd-util.h" #include "fileio.h" #include "mkdir.h" #include "string-util.h" diff --git a/src/run/run.c b/src/run/run.c index 25ef04a7d2..6d3e739882 100644 --- a/src/run/run.c +++ b/src/run/run.c @@ -30,6 +30,7 @@ #include "calendarspec.h" #include "env-util.h" #include "event-util.h" +#include "fd-util.h" #include "formats-util.h" #include "path-util.h" #include "ptyfwd.h" diff --git a/src/shared/acpi-fpdt.c b/src/shared/acpi-fpdt.c index 64e50401b9..b3d2f96885 100644 --- a/src/shared/acpi-fpdt.c +++ b/src/shared/acpi-fpdt.c @@ -19,16 +19,17 @@ along with systemd; If not, see <http://www.gnu.org/licenses/>. ***/ -#include <stdio.h> +#include <fcntl.h> #include <stdint.h> +#include <stdio.h> #include <string.h> #include <unistd.h> -#include <fcntl.h> -#include <util.h> -#include <fileio.h> -#include <time-util.h> -#include <acpi-fpdt.h> +#include "acpi-fpdt.h" +#include "fd-util.h" +#include "fileio.h" +#include "time-util.h" +#include "util.h" struct acpi_table_header { char signature[4]; diff --git a/src/shared/ask-password-api.c b/src/shared/ask-password-api.c index 4bf87576f2..baa6f159f8 100644 --- a/src/shared/ask-password-api.c +++ b/src/shared/ask-password-api.c @@ -32,6 +32,8 @@ #include <termios.h> #include <unistd.h> +#include "ask-password-api.h" +#include "fd-util.h" #include "formats-util.h" #include "missing.h" #include "mkdir.h" @@ -42,7 +44,6 @@ #include "strv.h" #include "terminal-util.h" #include "util.h" -#include "ask-password-api.h" #define KEYRING_TIMEOUT_USEC ((5 * USEC_PER_MINUTE) / 2) diff --git a/src/shared/base-filesystem.c b/src/shared/base-filesystem.c index f2796c6d64..751dfdec45 100644 --- a/src/shared/base-filesystem.c +++ b/src/shared/base-filesystem.c @@ -29,6 +29,7 @@ #include "string-util.h" #include "util.h" #include "base-filesystem.h" +#include "fd-util.h" typedef struct BaseFilesystem { const char *dir; diff --git a/src/shared/bus-util.c b/src/shared/bus-util.c index bc77884751..e0a8ecc7fd 100644 --- a/src/shared/bus-util.c +++ b/src/shared/bus-util.c @@ -29,10 +29,12 @@ #include "bus-internal.h" #include "bus-label.h" #include "bus-message.h" +#include "bus-util.h" #include "cgroup-util.h" #include "def.h" #include "env-util.h" #include "escape.h" +#include "fd-util.h" #include "macro.h" #include "missing.h" #include "path-util.h" @@ -43,7 +45,6 @@ #include "unit-name.h" #include "utf8.h" #include "util.h" -#include "bus-util.h" static int name_owner_change_callback(sd_bus_message *m, void *userdata, sd_bus_error *ret_error) { sd_event *e = userdata; diff --git a/src/shared/cgroup-show.c b/src/shared/cgroup-show.c index 57b7aeb228..395e41930c 100644 --- a/src/shared/cgroup-show.c +++ b/src/shared/cgroup-show.c @@ -24,7 +24,9 @@ #include <stdio.h> #include <string.h> +#include "cgroup-show.h" #include "cgroup-util.h" +#include "fd-util.h" #include "formats-util.h" #include "macro.h" #include "path-util.h" @@ -32,7 +34,6 @@ #include "string-util.h" #include "terminal-util.h" #include "util.h" -#include "cgroup-show.h" static int compare(const void *a, const void *b) { const pid_t *p = a, *q = b; diff --git a/src/shared/clean-ipc.c b/src/shared/clean-ipc.c index baf4bc0b87..fe3187384f 100644 --- a/src/shared/clean-ipc.c +++ b/src/shared/clean-ipc.c @@ -28,11 +28,12 @@ #include <sys/shm.h> #include <sys/stat.h> +#include "clean-ipc.h" +#include "fd-util.h" #include "formats-util.h" #include "string-util.h" #include "strv.h" #include "util.h" -#include "clean-ipc.h" static int clean_sysvipc_shm(uid_t delete_uid) { _cleanup_fclose_ FILE *f = NULL; diff --git a/src/shared/condition.c b/src/shared/condition.c index 2556436542..b8915dab8a 100644 --- a/src/shared/condition.c +++ b/src/shared/condition.c @@ -31,7 +31,9 @@ #include "architecture.h" #include "audit.h" #include "cap-list.h" +#include "condition.h" #include "extract-word.h" +#include "fd-util.h" #include "hostname-util.h" #include "ima-util.h" #include "path-util.h" @@ -40,7 +42,6 @@ #include "string-util.h" #include "util.h" #include "virt.h" -#include "condition.h" Condition* condition_new(ConditionType type, const char *parameter, bool trigger, bool negate) { Condition *c; diff --git a/src/shared/conf-parser.c b/src/shared/conf-parser.c index 3f2e34c2e3..1b47c0ab52 100644 --- a/src/shared/conf-parser.c +++ b/src/shared/conf-parser.c @@ -36,6 +36,7 @@ #include "utf8.h" #include "util.h" #include "conf-parser.h" +#include "fd-util.h" int config_item_table_lookup( const void *table, diff --git a/src/shared/dropin.c b/src/shared/dropin.c index 52ea8086fe..1836e91acd 100644 --- a/src/shared/dropin.c +++ b/src/shared/dropin.c @@ -20,13 +20,14 @@ ***/ #include "conf-files.h" +#include "dropin.h" #include "escape.h" +#include "fd-util.h" #include "fileio-label.h" #include "mkdir.h" #include "string-util.h" #include "strv.h" #include "util.h" -#include "dropin.h" int drop_in_file(const char *dir, const char *unit, unsigned level, const char *name, char **_p, char **_q) { diff --git a/src/shared/efivars.c b/src/shared/efivars.c index f087c2a566..b482603bce 100644 --- a/src/shared/efivars.c +++ b/src/shared/efivars.c @@ -23,10 +23,11 @@ #include <string.h> #include <fcntl.h> -#include "util.h" +#include "efivars.h" +#include "fd-util.h" #include "utf8.h" +#include "util.h" #include "virt.h" -#include "efivars.h" #ifdef ENABLE_EFI diff --git a/src/shared/generator.c b/src/shared/generator.c index b52b9623fa..0a8e282949 100644 --- a/src/shared/generator.c +++ b/src/shared/generator.c @@ -23,15 +23,16 @@ #include "dropin.h" #include "escape.h" +#include "fd-util.h" #include "fileio.h" #include "fstab-util.h" +#include "generator.h" #include "mkdir.h" #include "path-util.h" #include "special.h" #include "string-util.h" #include "unit-name.h" #include "util.h" -#include "generator.h" static int write_fsck_sysroot_service(const char *dir, const char *what) { _cleanup_free_ char *device = NULL, *escaped = NULL; diff --git a/src/shared/install.c b/src/shared/install.c index 5368623b74..9b72f76662 100644 --- a/src/shared/install.c +++ b/src/shared/install.c @@ -39,6 +39,7 @@ #include "unit-name.h" #include "util.h" #include "install.h" +#include "fd-util.h" typedef struct { OrderedHashmap *will_install; diff --git a/src/shared/logs-show.c b/src/shared/logs-show.c index cb4a0d2172..6f5b83d08d 100644 --- a/src/shared/logs-show.c +++ b/src/shared/logs-show.c @@ -25,17 +25,18 @@ #include <sys/socket.h> #include <time.h> +#include "fd-util.h" #include "formats-util.h" #include "hashmap.h" #include "hostname-util.h" #include "journal-internal.h" #include "log.h" +#include "logs-show.h" #include "process-util.h" #include "string-util.h" #include "terminal-util.h" #include "utf8.h" #include "util.h" -#include "logs-show.h" /* up to three lines (each up to 100 characters) or 300 characters, whichever is less */ #define PRINT_LINE_THRESHOLD 3 diff --git a/src/shared/machine-image.c b/src/shared/machine-image.c index 8261d87091..415d939fc6 100644 --- a/src/shared/machine-image.c +++ b/src/shared/machine-image.c @@ -25,13 +25,14 @@ #include "btrfs-util.h" #include "copy.h" +#include "fd-util.h" +#include "machine-image.h" #include "mkdir.h" #include "path-util.h" #include "rm-rf.h" #include "string-util.h" #include "strv.h" #include "utf8.h" -#include "machine-image.h" static const char image_search_path[] = "/var/lib/machines\0" diff --git a/src/shared/machine-pool.c b/src/shared/machine-pool.c index 597680ef5f..a2cb5fc5a0 100644 --- a/src/shared/machine-pool.c +++ b/src/shared/machine-pool.c @@ -25,14 +25,15 @@ #include <sys/vfs.h> #include "btrfs-util.h" +#include "fd-util.h" #include "lockfile-util.h" +#include "machine-pool.h" #include "mkdir.h" #include "path-util.h" #include "process-util.h" #include "signal-util.h" #include "string-util.h" #include "util.h" -#include "machine-pool.h" #define VAR_LIB_MACHINES_SIZE_START (1024UL*1024UL*500UL) #define VAR_LIB_MACHINES_FREE_MIN (1024UL*1024UL*750UL) diff --git a/src/shared/pager.c b/src/shared/pager.c index b82b526309..7029d6b2e2 100644 --- a/src/shared/pager.c +++ b/src/shared/pager.c @@ -26,13 +26,14 @@ #include <unistd.h> #include "copy.h" +#include "fd-util.h" #include "macro.h" +#include "pager.h" #include "process-util.h" #include "signal-util.h" #include "string-util.h" #include "terminal-util.h" #include "util.h" -#include "pager.h" static pid_t pager_pid = 0; diff --git a/src/shared/ptyfwd.c b/src/shared/ptyfwd.c index 7749f20540..e5e0f37adf 100644 --- a/src/shared/ptyfwd.c +++ b/src/shared/ptyfwd.c @@ -24,8 +24,9 @@ #include <limits.h> #include <termios.h> -#include "util.h" +#include "fd-util.h" #include "ptyfwd.h" +#include "util.h" struct PTYForward { sd_event *event; diff --git a/src/shared/sleep-config.c b/src/shared/sleep-config.c index e69300b1db..b5cb9508bf 100644 --- a/src/shared/sleep-config.c +++ b/src/shared/sleep-config.c @@ -22,12 +22,13 @@ #include <stdio.h> #include "conf-parser.h" +#include "fd-util.h" #include "fileio.h" #include "log.h" +#include "sleep-config.h" #include "string-util.h" #include "strv.h" #include "util.h" -#include "sleep-config.h" #define USE(x, y) do{ (x) = (y); (y) = NULL; } while(0) diff --git a/src/shared/spawn-polkit-agent.c b/src/shared/spawn-polkit-agent.c index 4db249e1ca..472cdecf20 100644 --- a/src/shared/spawn-polkit-agent.c +++ b/src/shared/spawn-polkit-agent.c @@ -29,6 +29,7 @@ #include "util.h" #include "process-util.h" #include "spawn-polkit-agent.h" +#include "fd-util.h" #ifdef ENABLE_POLKIT static pid_t agent_pid = 0; diff --git a/src/shared/switch-root.c b/src/shared/switch-root.c index 205a2e1449..60d7043fda 100644 --- a/src/shared/switch-root.c +++ b/src/shared/switch-root.c @@ -28,13 +28,14 @@ #include <unistd.h> #include "base-filesystem.h" +#include "fd-util.h" #include "missing.h" #include "mkdir.h" #include "path-util.h" #include "rm-rf.h" #include "string-util.h" -#include "util.h" #include "switch-root.h" +#include "util.h" int switch_root(const char *new_root, const char *oldroot, bool detach_oldroot, unsigned long mountflags) { diff --git a/src/shared/utmp-wtmp.c b/src/shared/utmp-wtmp.c index 235f10d1a6..93e6313360 100644 --- a/src/shared/utmp-wtmp.c +++ b/src/shared/utmp-wtmp.c @@ -27,6 +27,7 @@ #include <unistd.h> #include <utmpx.h> +#include "fd-util.h" #include "hostname-util.h" #include "macro.h" #include "path-util.h" diff --git a/src/shared/watchdog.c b/src/shared/watchdog.c index 9d39beb340..d58f9873d5 100644 --- a/src/shared/watchdog.c +++ b/src/shared/watchdog.c @@ -27,6 +27,7 @@ #include "watchdog.h" #include "log.h" +#include "fd-util.h" static int watchdog_fd = -1; static usec_t watchdog_timeout = USEC_INFINITY; diff --git a/src/sleep/sleep.c b/src/sleep/sleep.c index b92b77c381..95de369817 100644 --- a/src/sleep/sleep.c +++ b/src/sleep/sleep.c @@ -27,6 +27,7 @@ #include "sd-messages.h" #include "def.h" +#include "fd-util.h" #include "fileio.h" #include "log.h" #include "sleep-config.h" diff --git a/src/socket-proxy/socket-proxyd.c b/src/socket-proxy/socket-proxyd.c index 521dbb2840..e82fb06417 100644 --- a/src/socket-proxy/socket-proxyd.c +++ b/src/socket-proxy/socket-proxyd.c @@ -34,6 +34,7 @@ #include "sd-event.h" #include "sd-resolve.h" +#include "fd-util.h" #include "log.h" #include "path-util.h" #include "set.h" diff --git a/src/sysctl/sysctl.c b/src/sysctl/sysctl.c index e247264a83..5e15dfba53 100644 --- a/src/sysctl/sysctl.c +++ b/src/sysctl/sysctl.c @@ -28,6 +28,7 @@ #include <string.h> #include "conf-files.h" +#include "fd-util.h" #include "fileio.h" #include "hashmap.h" #include "log.h" diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c index dbf9f600c0..213c3c30a0 100644 --- a/src/systemctl/systemctl.c +++ b/src/systemctl/systemctl.c @@ -48,6 +48,7 @@ #include "efivars.h" #include "env-util.h" #include "exit-status.h" +#include "fd-util.h" #include "fileio.h" #include "formats-util.h" #include "hostname-util.h" diff --git a/src/sysusers/sysusers.c b/src/sysusers/sysusers.c index 4c88f28e28..547bd1b344 100644 --- a/src/sysusers/sysusers.c +++ b/src/sysusers/sysusers.c @@ -40,6 +40,7 @@ #include "uid-range.h" #include "utf8.h" #include "util.h" +#include "fd-util.h" typedef enum ItemType { ADD_USER = 'u', diff --git a/src/sysv-generator/sysv-generator.c b/src/sysv-generator/sysv-generator.c index 4d1ecaff40..3374456973 100644 --- a/src/sysv-generator/sysv-generator.c +++ b/src/sysv-generator/sysv-generator.c @@ -25,6 +25,7 @@ #include <stdio.h> #include <unistd.h> +#include "fd-util.h" #include "hashmap.h" #include "install.h" #include "log.h" diff --git a/src/test/test-btrfs.c b/src/test/test-btrfs.c index b772e31963..afe3ff8fc2 100644 --- a/src/test/test-btrfs.c +++ b/src/test/test-btrfs.c @@ -21,11 +21,12 @@ #include <fcntl.h> -#include "log.h" -#include "fileio.h" -#include "util.h" #include "btrfs-util.h" +#include "fd-util.h" +#include "fileio.h" +#include "log.h" #include "string-util.h" +#include "util.h" int main(int argc, char *argv[]) { BtrfsQuotaInfo quota; diff --git a/src/test/test-capability.c b/src/test/test-capability.c index f47452ce72..09d7e61e92 100644 --- a/src/test/test-capability.c +++ b/src/test/test-capability.c @@ -17,20 +17,22 @@ along with systemd; If not, see <http://www.gnu.org/licenses/>. ***/ -#include <sys/wait.h> -#include <sys/capability.h> -#include <sys/socket.h> #include <netinet/in.h> #include <pwd.h> +#include <sys/capability.h> +#include <sys/socket.h> +#include <sys/wait.h> #include <unistd.h> #include "capability.h" -#include "util.h" +#include "fd-util.h" #include "macro.h" +#include "util.h" static uid_t test_uid = -1; static gid_t test_gid = -1; -// We keep CAP_DAC_OVERRIDE to avoid errors with gcov when doing test coverage + +/* We keep CAP_DAC_OVERRIDE to avoid errors with gcov when doing test coverage */ static uint64_t test_flags = 1ULL << CAP_DAC_OVERRIDE; static void fork_test(void (*test_func)(void)) { diff --git a/src/test/test-cgroup-util.c b/src/test/test-cgroup-util.c index 267dda651d..7bf59a0aa2 100644 --- a/src/test/test-cgroup-util.c +++ b/src/test/test-cgroup-util.c @@ -19,12 +19,13 @@ along with systemd; If not, see <http://www.gnu.org/licenses/>. ***/ -#include "util.h" #include "cgroup-util.h" -#include "test-helper.h" +#include "fd-util.h" #include "formats-util.h" #include "process-util.h" #include "string-util.h" +#include "test-helper.h" +#include "util.h" static void check_p_d_u(const char *path, int code, const char *result) { _cleanup_free_ char *unit = NULL; diff --git a/src/test/test-copy.c b/src/test/test-copy.c index 000d407db1..1bd50edca2 100644 --- a/src/test/test-copy.c +++ b/src/test/test-copy.c @@ -20,6 +20,7 @@ #include <unistd.h> #include "copy.h" +#include "fd-util.h" #include "fileio.h" #include "macro.h" #include "mkdir.h" diff --git a/src/test/test-fdset.c b/src/test/test-fdset.c index 242c5d9dc2..96d5e38177 100644 --- a/src/test/test-fdset.c +++ b/src/test/test-fdset.c @@ -20,9 +20,10 @@ #include <fcntl.h> #include <unistd.h> +#include "fd-util.h" #include "fdset.h" -#include "util.h" #include "macro.h" +#include "util.h" static void test_fdset_new_fill(void) { int fd = -1; diff --git a/src/test/test-fileio.c b/src/test/test-fileio.c index a72e84bc66..a40f013491 100644 --- a/src/test/test-fileio.c +++ b/src/test/test-fileio.c @@ -23,14 +23,15 @@ #include <fcntl.h> #include <unistd.h> -#include "util.h" -#include "process-util.h" -#include "fileio.h" -#include "strv.h" -#include "env-util.h" -#include "def.h" #include "ctype.h" +#include "def.h" +#include "env-util.h" +#include "fd-util.h" +#include "fileio.h" +#include "process-util.h" #include "string-util.h" +#include "strv.h" +#include "util.h" static void test_parse_env_file(void) { char t[] = "/tmp/test-fileio-in-XXXXXX", diff --git a/src/test/test-namespace.c b/src/test/test-namespace.c index de11443c7a..a060a7ba6f 100644 --- a/src/test/test-namespace.c +++ b/src/test/test-namespace.c @@ -21,6 +21,7 @@ #include <sys/socket.h> +#include "fd-util.h" #include "namespace.h" #include "process-util.h" #include "string-util.h" diff --git a/src/test/test-path-util.c b/src/test/test-path-util.c index 2977487c88..89129c9894 100644 --- a/src/test/test-path-util.c +++ b/src/test/test-path-util.c @@ -23,6 +23,7 @@ #include <sys/mount.h> #include <unistd.h> +#include "fd-util.h" #include "macro.h" #include "path-util.h" #include "rm-rf.h" diff --git a/src/test/test-path.c b/src/test/test-path.c index 19796bd6cb..e9e0bfd41d 100644 --- a/src/test/test-path.c +++ b/src/test/test-path.c @@ -28,6 +28,7 @@ #include "strv.h" #include "unit.h" #include "util.h" +#include "fd-util.h" typedef void (*test_function_t)(Manager *m); diff --git a/src/test/test-sigbus.c b/src/test/test-sigbus.c index f5bae65bef..b3ccc7509d 100644 --- a/src/test/test-sigbus.c +++ b/src/test/test-sigbus.c @@ -21,8 +21,9 @@ #include <sys/mman.h> -#include "util.h" +#include "fd-util.h" #include "sigbus.h" +#include "util.h" int main(int argc, char *argv[]) { _cleanup_close_ int fd = -1; diff --git a/src/test/test-socket-util.c b/src/test/test-socket-util.c index ba1c7e6877..4a2d952c86 100644 --- a/src/test/test-socket-util.c +++ b/src/test/test-socket-util.c @@ -18,6 +18,7 @@ ***/ #include "async.h" +#include "fd-util.h" #include "in-addr-util.h" #include "log.h" #include "macro.h" diff --git a/src/test/test-terminal-util.c b/src/test/test-terminal-util.c index d81fdb9923..a41de59719 100644 --- a/src/test/test-terminal-util.c +++ b/src/test/test-terminal-util.c @@ -25,6 +25,7 @@ #include "macro.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")); diff --git a/src/test/test-tmpfiles.c b/src/test/test-tmpfiles.c index ab255c7c83..6aa9cc8473 100644 --- a/src/test/test-tmpfiles.c +++ b/src/test/test-tmpfiles.c @@ -24,6 +24,7 @@ #include <stdlib.h> #include <unistd.h> +#include "fd-util.h" #include "formats-util.h" #include "string-util.h" #include "util.h" diff --git a/src/test/test-unit-file.c b/src/test/test-unit-file.c index e4573956a5..226453d06e 100644 --- a/src/test/test-unit-file.c +++ b/src/test/test-unit-file.c @@ -26,6 +26,7 @@ #include <string.h> #include <unistd.h> +#include "fd-util.h" #include "fileio.h" #include "hashmap.h" #include "hostname-util.h" diff --git a/src/test/test-util.c b/src/test/test-util.c index 49a30601bc..ddfcdd857b 100644 --- a/src/test/test-util.c +++ b/src/test/test-util.c @@ -44,6 +44,7 @@ #include "strv.h" #include "util.h" #include "virt.h" +#include "fd-util.h" static void test_streq_ptr(void) { assert_se(streq_ptr(NULL, NULL)); diff --git a/src/timesync/timesyncd-manager.c b/src/timesync/timesyncd-manager.c index 2964aa7652..d44cf0a80b 100644 --- a/src/timesync/timesyncd-manager.c +++ b/src/timesync/timesyncd-manager.c @@ -33,6 +33,7 @@ #include "sd-daemon.h" +#include "fd-util.h" #include "list.h" #include "log.h" #include "missing.h" @@ -44,8 +45,8 @@ #include "strv.h" #include "time-util.h" #include "timesyncd-conf.h" -#include "util.h" #include "timesyncd-manager.h" +#include "util.h" #ifndef ADJ_SETOFFSET #define ADJ_SETOFFSET 0x0100 /* add 'time' to current time */ diff --git a/src/timesync/timesyncd.c b/src/timesync/timesyncd.c index 722b349b81..7755a6d89f 100644 --- a/src/timesync/timesyncd.c +++ b/src/timesync/timesyncd.c @@ -19,15 +19,16 @@ along with systemd; If not, see <http://www.gnu.org/licenses/>. ***/ -#include "sd-event.h" #include "sd-daemon.h" +#include "sd-event.h" + #include "capability.h" #include "clock-util.h" +#include "fd-util.h" #include "network-util.h" #include "signal-util.h" - -#include "timesyncd-manager.h" #include "timesyncd-conf.h" +#include "timesyncd-manager.h" static int load_clock_timestamp(uid_t uid, gid_t gid) { _cleanup_close_ int fd = -1; diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c index d81382528f..e574e5ac26 100644 --- a/src/tmpfiles/tmpfiles.c +++ b/src/tmpfiles/tmpfiles.c @@ -44,6 +44,7 @@ #include "conf-files.h" #include "copy.h" #include "escape.h" +#include "fd-util.h" #include "formats-util.h" #include "label.h" #include "log.h" diff --git a/src/tty-ask-password-agent/tty-ask-password-agent.c b/src/tty-ask-password-agent/tty-ask-password-agent.c index d9b6cb3524..30f7f42a09 100644 --- a/src/tty-ask-password-agent/tty-ask-password-agent.c +++ b/src/tty-ask-password-agent/tty-ask-password-agent.c @@ -35,6 +35,7 @@ #include "ask-password-api.h" #include "conf-parser.h" #include "def.h" +#include "fd-util.h" #include "mkdir.h" #include "path-util.h" #include "process-util.h" diff --git a/src/udev/ata_id/ata_id.c b/src/udev/ata_id/ata_id.c index 7acd7b4e92..1e414664ce 100644 --- a/src/udev/ata_id/ata_id.c +++ b/src/udev/ata_id/ata_id.c @@ -39,6 +39,7 @@ #include "libudev.h" +#include "fd-util.h" #include "libudev-private.h" #include "log.h" #include "udev-util.h" diff --git a/src/udev/net/link-config.c b/src/udev/net/link-config.c index c308f898ea..e9577930e3 100644 --- a/src/udev/net/link-config.c +++ b/src/udev/net/link-config.c @@ -27,6 +27,7 @@ #include "conf-files.h" #include "conf-parser.h" #include "ethtool-util.h" +#include "fd-util.h" #include "libudev-private.h" #include "link-config.h" #include "log.h" diff --git a/src/udev/scsi_id/scsi_id.c b/src/udev/scsi_id/scsi_id.c index cbf9478e72..4655691642 100644 --- a/src/udev/scsi_id/scsi_id.c +++ b/src/udev/scsi_id/scsi_id.c @@ -31,6 +31,7 @@ #include "libudev.h" +#include "fd-util.h" #include "libudev-private.h" #include "scsi_id.h" #include "string-util.h" diff --git a/src/udev/udev-builtin-blkid.c b/src/udev/udev-builtin-blkid.c index 004ddb023f..0976525eb3 100644 --- a/src/udev/udev-builtin-blkid.c +++ b/src/udev/udev-builtin-blkid.c @@ -30,6 +30,7 @@ #include "sd-id128.h" #include "efivars.h" +#include "fd-util.h" #include "gpt.h" #include "string-util.h" #include "udev.h" diff --git a/src/udev/udev-builtin-btrfs.c b/src/udev/udev-builtin-btrfs.c index ce1a0c3882..cfaa463804 100644 --- a/src/udev/udev-builtin-btrfs.c +++ b/src/udev/udev-builtin-btrfs.c @@ -25,6 +25,7 @@ #include <linux/btrfs.h> #endif +#include "fd-util.h" #include "missing.h" #include "string-util.h" #include "udev.h" diff --git a/src/udev/udev-builtin-input_id.c b/src/udev/udev-builtin-input_id.c index f36f719a94..fddafbd4dc 100644 --- a/src/udev/udev-builtin-input_id.c +++ b/src/udev/udev-builtin-input_id.c @@ -30,6 +30,7 @@ #include <linux/limits.h> #include <linux/input.h> +#include "fd-util.h" #include "string-util.h" #include "udev.h" #include "util.h" diff --git a/src/udev/udev-builtin-keyboard.c b/src/udev/udev-builtin-keyboard.c index ce534ae0f9..5e97bdd614 100644 --- a/src/udev/udev-builtin-keyboard.c +++ b/src/udev/udev-builtin-keyboard.c @@ -23,6 +23,7 @@ #include <sys/ioctl.h> #include <linux/input.h> +#include "fd-util.h" #include "string-util.h" #include "udev.h" diff --git a/src/udev/udev-builtin-net_id.c b/src/udev/udev-builtin-net_id.c index bb721d6f0d..ef9c398e59 100644 --- a/src/udev/udev-builtin-net_id.c +++ b/src/udev/udev-builtin-net_id.c @@ -98,6 +98,7 @@ #include <unistd.h> #include <linux/pci_regs.h> +#include "fd-util.h" #include "fileio.h" #include "string-util.h" #include "udev.h" diff --git a/src/udev/udev-builtin-usb_id.c b/src/udev/udev-builtin-usb_id.c index c7d47891a7..cb531bd168 100644 --- a/src/udev/udev-builtin-usb_id.c +++ b/src/udev/udev-builtin-usb_id.c @@ -29,6 +29,7 @@ #include <string.h> #include <unistd.h> +#include "fd-util.h" #include "string-util.h" #include "udev.h" diff --git a/src/udev/udev-ctrl.c b/src/udev/udev-ctrl.c index 56277f551f..937fc4ecd8 100644 --- a/src/udev/udev-ctrl.c +++ b/src/udev/udev-ctrl.c @@ -18,8 +18,9 @@ #include <sys/socket.h> #include <sys/un.h> -#include "socket-util.h" +#include "fd-util.h" #include "formats-util.h" +#include "socket-util.h" #include "udev.h" /* wire protocol magic must match */ diff --git a/src/udev/udev-event.c b/src/udev/udev-event.c index 49a45811a6..bf122f85c7 100644 --- a/src/udev/udev-event.c +++ b/src/udev/udev-event.c @@ -31,6 +31,7 @@ #include <unistd.h> #include "event-util.h" +#include "fd-util.h" #include "formats-util.h" #include "netlink-util.h" #include "process-util.h" diff --git a/src/udev/udev-rules.c b/src/udev/udev-rules.c index c8abac7fef..f99d1a86c9 100644 --- a/src/udev/udev-rules.c +++ b/src/udev/udev-rules.c @@ -31,6 +31,7 @@ #include "conf-files.h" #include "escape.h" +#include "fd-util.h" #include "path-util.h" #include "strbuf.h" #include "string-util.h" diff --git a/src/udev/udevadm-info.c b/src/udev/udevadm-info.c index 911818eb00..7182668f23 100644 --- a/src/udev/udevadm-info.c +++ b/src/udev/udevadm-info.c @@ -26,6 +26,7 @@ #include <sys/stat.h> #include <unistd.h> +#include "fd-util.h" #include "string-util.h" #include "udev-util.h" #include "udev.h" diff --git a/src/udev/udevadm-monitor.c b/src/udev/udevadm-monitor.c index 5e93955186..30aa53feb2 100644 --- a/src/udev/udevadm-monitor.c +++ b/src/udev/udevadm-monitor.c @@ -25,9 +25,10 @@ #include <sys/time.h> #include <sys/epoll.h> -#include "udev.h" -#include "udev-util.h" +#include "fd-util.h" #include "formats-util.h" +#include "udev-util.h" +#include "udev.h" static bool udev_exit; diff --git a/src/udev/udevd.c b/src/udev/udevd.c index a3f0298ae7..a548f9ba49 100644 --- a/src/udev/udevd.c +++ b/src/udev/udevd.c @@ -47,6 +47,7 @@ #include "cpu-set-util.h" #include "dev-setup.h" #include "event-util.h" +#include "fd-util.h" #include "fileio.h" #include "formats-util.h" #include "hashmap.h" diff --git a/src/udev/v4l_id/v4l_id.c b/src/udev/v4l_id/v4l_id.c index 5c57db44c1..607d78a019 100644 --- a/src/udev/v4l_id/v4l_id.c +++ b/src/udev/v4l_id/v4l_id.c @@ -26,6 +26,7 @@ #include <sys/ioctl.h> #include <linux/videodev2.h> +#include "fd-util.h" #include "util.h" int main(int argc, char *argv[]) { diff --git a/src/update-done/update-done.c b/src/update-done/update-done.c index 01bbde8455..4f67145b36 100644 --- a/src/update-done/update-done.c +++ b/src/update-done/update-done.c @@ -19,8 +19,9 @@ along with systemd; If not, see <http://www.gnu.org/licenses/>. ***/ -#include "util.h" +#include "fd-util.h" #include "selinux-util.h" +#include "util.h" #define MESSAGE \ "This file was created by systemd-update-done. Its only \n" \ diff --git a/src/vconsole/vconsole-setup.c b/src/vconsole/vconsole-setup.c index b0c61cddc5..a06f61dd6f 100644 --- a/src/vconsole/vconsole-setup.c +++ b/src/vconsole/vconsole-setup.c @@ -31,6 +31,7 @@ #include <sys/ioctl.h> #include <unistd.h> +#include "fd-util.h" #include "fileio.h" #include "log.h" #include "process-util.h" |