From dea7b6b043f0cd9e34ee719b9b612c3a4776387e Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 23 Oct 2015 18:20:54 +0200 Subject: util-lib: rework extract_first_word_and_warn() a bit - Really warn in all error cases, not just some. We need to make sure that all errors are logged to not confuse the user. - Explicitly check for EINVAL error code before claiming anything about invalid escapes, could be ENOMEM after all. --- src/core/load-fragment.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'src/core') diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c index a361de2a4a..0500e2ba33 100644 --- a/src/core/load-fragment.c +++ b/src/core/load-fragment.c @@ -522,9 +522,7 @@ int config_parse_exec( assert(e); e += ltype; - rvalue += strspn(rvalue, WHITESPACE); - p = rvalue; if (isempty(rvalue)) { /* An empty assignment resets the list */ @@ -532,14 +530,15 @@ int config_parse_exec( return 0; } + p = rvalue; do { - int i; + _cleanup_free_ char *path = NULL, *firstword = NULL; + bool separate_argv0 = false, ignore = false; + _cleanup_free_ ExecCommand *nce = NULL; _cleanup_strv_free_ char **n = NULL; size_t nlen = 0, nbufsize = 0; - _cleanup_free_ ExecCommand *nce = NULL; - _cleanup_free_ char *path = NULL, *firstword = NULL; char *f; - bool separate_argv0 = false, ignore = false; + int i; semicolon = false; -- cgit v1.2.3-54-g00ecf From 4f5dd3943bef8a04be7e3b838b822bb9a7ad6cb3 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 23 Oct 2015 18:52:53 +0200 Subject: util: split out escaping code into escape.[ch] This really deserves its own file, given how much code this is now. --- Makefile.am | 2 + src/backlight/backlight.c | 7 +- src/basic/escape.c | 480 ++++++++++++++++++++++++++++++++++++ src/basic/escape.h | 48 ++++ src/basic/extract-word.c | 1 + src/basic/fileio.c | 5 +- src/basic/process-util.c | 17 +- src/basic/strv.c | 1 + src/basic/util.c | 458 +--------------------------------- src/basic/util.h | 23 -- src/core/job.c | 19 +- src/core/load-fragment.c | 1 + src/core/manager.c | 1 + src/core/mount.c | 26 +- src/core/service.c | 35 +-- src/core/swap.c | 19 +- src/core/umount.c | 11 +- src/core/unit.c | 41 +-- src/cryptsetup/cryptsetup.c | 11 +- src/import/pull-common.c | 13 +- src/journal-remote/journal-remote.c | 3 +- src/journal/coredump.c | 28 ++- src/journal/journald-kmsg.c | 13 +- src/journal/journald-stream.c | 16 +- src/libsystemd/sd-bus/busctl.c | 1 + src/libsystemd/sd-login/sd-login.c | 15 +- src/login/logind-acl.c | 7 +- src/login/logind-dbus.c | 28 ++- src/login/logind-inhibit.c | 7 +- src/login/logind-session.c | 16 +- src/login/logind-user.c | 27 +- src/machine/machine.c | 3 +- src/nspawn/nspawn-mount.c | 15 +- src/rfkill/rfkill.c | 1 + src/shared/bus-util.c | 3 +- src/shared/dropin.c | 11 +- src/shared/generator.c | 13 +- src/test/test-util.c | 1 + src/tmpfiles/tmpfiles.c | 1 + src/udev/udev-rules.c | 28 ++- 40 files changed, 777 insertions(+), 679 deletions(-) create mode 100644 src/basic/escape.c create mode 100644 src/basic/escape.h (limited to 'src/core') diff --git a/Makefile.am b/Makefile.am index 06bd5d4d9b..db96d51aa4 100644 --- a/Makefile.am +++ b/Makefile.am @@ -783,6 +783,8 @@ libbasic_la_SOURCES = \ src/basic/util.h \ src/basic/extract-word.c \ src/basic/extract-word.h \ + src/basic/escape.c \ + src/basic/escape.h \ src/basic/cpu-set-util.c \ src/basic/cpu-set-util.h \ src/basic/lockfile-util.c \ diff --git a/src/backlight/backlight.c b/src/backlight/backlight.c index c8961de946..84ce842cae 100644 --- a/src/backlight/backlight.c +++ b/src/backlight/backlight.c @@ -19,12 +19,13 @@ along with systemd; If not, see . ***/ -#include "util.h" -#include "mkdir.h" +#include "def.h" +#include "escape.h" #include "fileio.h" #include "libudev.h" +#include "mkdir.h" #include "udev-util.h" -#include "def.h" +#include "util.h" static struct udev_device *find_pci_or_platform_parent(struct udev_device *device) { struct udev_device *parent; diff --git a/src/basic/escape.c b/src/basic/escape.c new file mode 100644 index 0000000000..cf05ce10ef --- /dev/null +++ b/src/basic/escape.c @@ -0,0 +1,480 @@ +/*-*- 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 . +***/ + +#include "utf8.h" +#include "util.h" + +#include "escape.h" + +size_t cescape_char(char c, char *buf) { + char * buf_old = buf; + + switch (c) { + + case '\a': + *(buf++) = '\\'; + *(buf++) = 'a'; + break; + case '\b': + *(buf++) = '\\'; + *(buf++) = 'b'; + break; + case '\f': + *(buf++) = '\\'; + *(buf++) = 'f'; + break; + case '\n': + *(buf++) = '\\'; + *(buf++) = 'n'; + break; + case '\r': + *(buf++) = '\\'; + *(buf++) = 'r'; + break; + case '\t': + *(buf++) = '\\'; + *(buf++) = 't'; + break; + case '\v': + *(buf++) = '\\'; + *(buf++) = 'v'; + break; + case '\\': + *(buf++) = '\\'; + *(buf++) = '\\'; + break; + case '"': + *(buf++) = '\\'; + *(buf++) = '"'; + break; + case '\'': + *(buf++) = '\\'; + *(buf++) = '\''; + break; + + default: + /* For special chars we prefer octal over + * hexadecimal encoding, simply because glib's + * g_strescape() does the same */ + if ((c < ' ') || (c >= 127)) { + *(buf++) = '\\'; + *(buf++) = octchar((unsigned char) c >> 6); + *(buf++) = octchar((unsigned char) c >> 3); + *(buf++) = octchar((unsigned char) c); + } else + *(buf++) = c; + break; + } + + return buf - buf_old; +} + +char *cescape(const char *s) { + char *r, *t; + const char *f; + + assert(s); + + /* Does C style string escaping. May be reversed with + * cunescape(). */ + + r = new(char, strlen(s)*4 + 1); + if (!r) + return NULL; + + for (f = s, t = r; *f; f++) + t += cescape_char(*f, t); + + *t = 0; + + return r; +} + +int cunescape_one(const char *p, size_t length, char *ret, uint32_t *ret_unicode) { + int r = 1; + + assert(p); + assert(*p); + assert(ret); + + /* Unescapes C style. Returns the unescaped character in ret, + * unless we encountered a \u sequence in which case the full + * unicode character is returned in ret_unicode, instead. */ + + if (length != (size_t) -1 && length < 1) + return -EINVAL; + + switch (p[0]) { + + case 'a': + *ret = '\a'; + break; + case 'b': + *ret = '\b'; + break; + case 'f': + *ret = '\f'; + break; + case 'n': + *ret = '\n'; + break; + case 'r': + *ret = '\r'; + break; + case 't': + *ret = '\t'; + break; + case 'v': + *ret = '\v'; + break; + case '\\': + *ret = '\\'; + break; + case '"': + *ret = '"'; + break; + case '\'': + *ret = '\''; + break; + + case 's': + /* This is an extension of the XDG syntax files */ + *ret = ' '; + break; + + case 'x': { + /* hexadecimal encoding */ + int a, b; + + if (length != (size_t) -1 && length < 3) + return -EINVAL; + + a = unhexchar(p[1]); + if (a < 0) + return -EINVAL; + + b = unhexchar(p[2]); + if (b < 0) + return -EINVAL; + + /* Don't allow NUL bytes */ + if (a == 0 && b == 0) + return -EINVAL; + + *ret = (char) ((a << 4U) | b); + r = 3; + break; + } + + case 'u': { + /* C++11 style 16bit unicode */ + + int a[4]; + unsigned i; + uint32_t c; + + if (length != (size_t) -1 && length < 5) + return -EINVAL; + + for (i = 0; i < 4; i++) { + a[i] = unhexchar(p[1 + i]); + if (a[i] < 0) + return a[i]; + } + + c = ((uint32_t) a[0] << 12U) | ((uint32_t) a[1] << 8U) | ((uint32_t) a[2] << 4U) | (uint32_t) a[3]; + + /* Don't allow 0 chars */ + if (c == 0) + return -EINVAL; + + if (c < 128) + *ret = c; + else { + if (!ret_unicode) + return -EINVAL; + + *ret = 0; + *ret_unicode = c; + } + + r = 5; + break; + } + + case 'U': { + /* C++11 style 32bit unicode */ + + int a[8]; + unsigned i; + uint32_t c; + + if (length != (size_t) -1 && length < 9) + return -EINVAL; + + for (i = 0; i < 8; i++) { + a[i] = unhexchar(p[1 + i]); + if (a[i] < 0) + return a[i]; + } + + c = ((uint32_t) a[0] << 28U) | ((uint32_t) a[1] << 24U) | ((uint32_t) a[2] << 20U) | ((uint32_t) a[3] << 16U) | + ((uint32_t) a[4] << 12U) | ((uint32_t) a[5] << 8U) | ((uint32_t) a[6] << 4U) | (uint32_t) a[7]; + + /* Don't allow 0 chars */ + if (c == 0) + return -EINVAL; + + /* Don't allow invalid code points */ + if (!unichar_is_valid(c)) + return -EINVAL; + + if (c < 128) + *ret = c; + else { + if (!ret_unicode) + return -EINVAL; + + *ret = 0; + *ret_unicode = c; + } + + r = 9; + break; + } + + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': { + /* octal encoding */ + int a, b, c; + uint32_t m; + + if (length != (size_t) -1 && length < 3) + return -EINVAL; + + a = unoctchar(p[0]); + if (a < 0) + return -EINVAL; + + b = unoctchar(p[1]); + if (b < 0) + return -EINVAL; + + c = unoctchar(p[2]); + if (c < 0) + return -EINVAL; + + /* don't allow NUL bytes */ + if (a == 0 && b == 0 && c == 0) + return -EINVAL; + + /* Don't allow bytes above 255 */ + m = ((uint32_t) a << 6U) | ((uint32_t) b << 3U) | (uint32_t) c; + if (m > 255) + return -EINVAL; + + *ret = m; + r = 3; + break; + } + + default: + return -EINVAL; + } + + return r; +} + +int cunescape_length_with_prefix(const char *s, size_t length, const char *prefix, UnescapeFlags flags, char **ret) { + char *r, *t; + const char *f; + size_t pl; + + assert(s); + assert(ret); + + /* Undoes C style string escaping, and optionally prefixes it. */ + + pl = prefix ? strlen(prefix) : 0; + + r = new(char, pl+length+1); + if (!r) + return -ENOMEM; + + if (prefix) + memcpy(r, prefix, pl); + + for (f = s, t = r + pl; f < s + length; f++) { + size_t remaining; + uint32_t u; + char c; + int k; + + remaining = s + length - f; + assert(remaining > 0); + + if (*f != '\\') { + /* A literal literal, copy verbatim */ + *(t++) = *f; + continue; + } + + if (remaining == 1) { + if (flags & UNESCAPE_RELAX) { + /* A trailing backslash, copy verbatim */ + *(t++) = *f; + continue; + } + + free(r); + return -EINVAL; + } + + k = cunescape_one(f + 1, remaining - 1, &c, &u); + if (k < 0) { + if (flags & UNESCAPE_RELAX) { + /* Invalid escape code, let's take it literal then */ + *(t++) = '\\'; + continue; + } + + free(r); + return k; + } + + if (c != 0) + /* Non-Unicode? Let's encode this directly */ + *(t++) = c; + else + /* Unicode? Then let's encode this in UTF-8 */ + t += utf8_encode_unichar(t, u); + + f += k; + } + + *t = 0; + + *ret = r; + return t - r; +} + +int cunescape_length(const char *s, size_t length, UnescapeFlags flags, char **ret) { + return cunescape_length_with_prefix(s, length, NULL, flags, ret); +} + +int cunescape(const char *s, UnescapeFlags flags, char **ret) { + return cunescape_length(s, strlen(s), flags, ret); +} + +char *xescape(const char *s, const char *bad) { + char *r, *t; + const char *f; + + /* Escapes all chars in bad, in addition to \ and all special + * chars, in \xFF style escaping. May be reversed with + * cunescape(). */ + + r = new(char, strlen(s) * 4 + 1); + if (!r) + return NULL; + + for (f = s, t = r; *f; f++) { + + if ((*f < ' ') || (*f >= 127) || + (*f == '\\') || strchr(bad, *f)) { + *(t++) = '\\'; + *(t++) = 'x'; + *(t++) = hexchar(*f >> 4); + *(t++) = hexchar(*f); + } else + *(t++) = *f; + } + + *t = 0; + + return r; +} + +static char *strcpy_backslash_escaped(char *t, const char *s, const char *bad) { + assert(bad); + + for (; *s; s++) { + if (*s == '\\' || strchr(bad, *s)) + *(t++) = '\\'; + + *(t++) = *s; + } + + return t; +} + +char *shell_escape(const char *s, const char *bad) { + char *r, *t; + + r = new(char, strlen(s)*2+1); + if (!r) + return NULL; + + t = strcpy_backslash_escaped(r, s, bad); + *t = 0; + + return r; +} + +char *shell_maybe_quote(const char *s) { + const char *p; + char *r, *t; + + assert(s); + + /* Encloses a string in double quotes if necessary to make it + * OK as shell string. */ + + for (p = s; *p; p++) + if (*p <= ' ' || + *p >= 127 || + strchr(SHELL_NEED_QUOTES, *p)) + break; + + if (!*p) + return strdup(s); + + r = new(char, 1+strlen(s)*2+1+1); + if (!r) + return NULL; + + t = r; + *(t++) = '"'; + t = mempcpy(t, s, p - s); + + t = strcpy_backslash_escaped(t, p, SHELL_NEED_ESCAPE); + + *(t++)= '"'; + *t = 0; + + return r; +} diff --git a/src/basic/escape.h b/src/basic/escape.h new file mode 100644 index 0000000000..85ba909081 --- /dev/null +++ b/src/basic/escape.h @@ -0,0 +1,48 @@ +/*-*- 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 . +***/ + +#include +#include + +/* What characters are special in the shell? */ +/* must be escaped outside and inside double-quotes */ +#define SHELL_NEED_ESCAPE "\"\\`$" +/* can be escaped or double-quoted */ +#define SHELL_NEED_QUOTES SHELL_NEED_ESCAPE GLOB_CHARS "'()<>|&;" + +typedef enum UnescapeFlags { + UNESCAPE_RELAX = 1, +} UnescapeFlags; + +char *cescape(const char *s); +size_t cescape_char(char c, char *buf); + +int cunescape(const char *s, UnescapeFlags flags, char **ret); +int cunescape_length(const char *s, size_t length, UnescapeFlags flags, char **ret); +int cunescape_length_with_prefix(const char *s, size_t length, const char *prefix, UnescapeFlags flags, char **ret); +int cunescape_one(const char *p, size_t length, char *ret, uint32_t *ret_unicode); + +char *xescape(const char *s, const char *bad); + +char *shell_escape(const char *s, const char *bad); +char *shell_maybe_quote(const char *s); diff --git a/src/basic/extract-word.c b/src/basic/extract-word.c index 5e74f1832b..52d2672390 100644 --- a/src/basic/extract-word.c +++ b/src/basic/extract-word.c @@ -19,6 +19,7 @@ along with systemd; If not, see . ***/ +#include "escape.h" #include "utf8.h" #include "util.h" diff --git a/src/basic/fileio.c b/src/basic/fileio.c index 13a85e1158..65a6a6558b 100644 --- a/src/basic/fileio.c +++ b/src/basic/fileio.c @@ -21,10 +21,11 @@ #include -#include "util.h" +#include "ctype.h" +#include "escape.h" #include "strv.h" #include "utf8.h" -#include "ctype.h" +#include "util.h" #include "fileio.h" int write_string_stream(FILE *f, const char *line, bool enforce_newline) { diff --git a/src/basic/process-util.c b/src/basic/process-util.c index d8a94a4572..3199efeafd 100644 --- a/src/basic/process-util.c +++ b/src/basic/process-util.c @@ -17,21 +17,22 @@ along with systemd; If not, see . ***/ -#include -#include -#include -#include #include +#include #include -#include -#include #include -#include +#include +#include +#include +#include +#include +#include +#include "escape.h" #include "fileio.h" -#include "util.h" #include "log.h" #include "signal-util.h" +#include "util.h" #include "process-util.h" int get_process_state(pid_t pid) { diff --git a/src/basic/strv.c b/src/basic/strv.c index 501d022cb9..446d4a5631 100644 --- a/src/basic/strv.c +++ b/src/basic/strv.c @@ -24,6 +24,7 @@ #include #include +#include "escape.h" #include "util.h" #include "strv.h" diff --git a/src/basic/util.c b/src/basic/util.c index 641e0b4d89..d6488f8fd6 100644 --- a/src/basic/util.c +++ b/src/basic/util.c @@ -77,6 +77,7 @@ #include "def.h" #include "device-nodes.h" #include "env-util.h" +#include "escape.h" #include "exit-status.h" #include "fileio.h" #include "formats-util.h" @@ -96,8 +97,8 @@ #include "strv.h" #include "terminal-util.h" #include "utf8.h" -#include "util.h" #include "virt.h" +#include "util.h" /* Put this test here for a lack of better place */ assert_cc(EAGAIN == EWOULDBLOCK); @@ -214,69 +215,6 @@ char* first_word(const char *s, const char *word) { return (char*) p; } -size_t cescape_char(char c, char *buf) { - char * buf_old = buf; - - switch (c) { - - case '\a': - *(buf++) = '\\'; - *(buf++) = 'a'; - break; - case '\b': - *(buf++) = '\\'; - *(buf++) = 'b'; - break; - case '\f': - *(buf++) = '\\'; - *(buf++) = 'f'; - break; - case '\n': - *(buf++) = '\\'; - *(buf++) = 'n'; - break; - case '\r': - *(buf++) = '\\'; - *(buf++) = 'r'; - break; - case '\t': - *(buf++) = '\\'; - *(buf++) = 't'; - break; - case '\v': - *(buf++) = '\\'; - *(buf++) = 'v'; - break; - case '\\': - *(buf++) = '\\'; - *(buf++) = '\\'; - break; - case '"': - *(buf++) = '\\'; - *(buf++) = '"'; - break; - case '\'': - *(buf++) = '\\'; - *(buf++) = '\''; - break; - - default: - /* For special chars we prefer octal over - * hexadecimal encoding, simply because glib's - * g_strescape() does the same */ - if ((c < ' ') || (c >= 127)) { - *(buf++) = '\\'; - *(buf++) = octchar((unsigned char) c >> 6); - *(buf++) = octchar((unsigned char) c >> 3); - *(buf++) = octchar((unsigned char) c); - } else - *(buf++) = c; - break; - } - - return buf - buf_old; -} - int close_nointr(int fd) { assert(fd >= 0); @@ -1566,338 +1504,6 @@ int undecchar(char c) { return -EINVAL; } -char *cescape(const char *s) { - char *r, *t; - const char *f; - - assert(s); - - /* Does C style string escaping. May be reversed with - * cunescape(). */ - - r = new(char, strlen(s)*4 + 1); - if (!r) - return NULL; - - for (f = s, t = r; *f; f++) - t += cescape_char(*f, t); - - *t = 0; - - return r; -} - -int cunescape_one(const char *p, size_t length, char *ret, uint32_t *ret_unicode) { - int r = 1; - - assert(p); - assert(*p); - assert(ret); - - /* Unescapes C style. Returns the unescaped character in ret, - * unless we encountered a \u sequence in which case the full - * unicode character is returned in ret_unicode, instead. */ - - if (length != (size_t) -1 && length < 1) - return -EINVAL; - - switch (p[0]) { - - case 'a': - *ret = '\a'; - break; - case 'b': - *ret = '\b'; - break; - case 'f': - *ret = '\f'; - break; - case 'n': - *ret = '\n'; - break; - case 'r': - *ret = '\r'; - break; - case 't': - *ret = '\t'; - break; - case 'v': - *ret = '\v'; - break; - case '\\': - *ret = '\\'; - break; - case '"': - *ret = '"'; - break; - case '\'': - *ret = '\''; - break; - - case 's': - /* This is an extension of the XDG syntax files */ - *ret = ' '; - break; - - case 'x': { - /* hexadecimal encoding */ - int a, b; - - if (length != (size_t) -1 && length < 3) - return -EINVAL; - - a = unhexchar(p[1]); - if (a < 0) - return -EINVAL; - - b = unhexchar(p[2]); - if (b < 0) - return -EINVAL; - - /* Don't allow NUL bytes */ - if (a == 0 && b == 0) - return -EINVAL; - - *ret = (char) ((a << 4U) | b); - r = 3; - break; - } - - case 'u': { - /* C++11 style 16bit unicode */ - - int a[4]; - unsigned i; - uint32_t c; - - if (length != (size_t) -1 && length < 5) - return -EINVAL; - - for (i = 0; i < 4; i++) { - a[i] = unhexchar(p[1 + i]); - if (a[i] < 0) - return a[i]; - } - - c = ((uint32_t) a[0] << 12U) | ((uint32_t) a[1] << 8U) | ((uint32_t) a[2] << 4U) | (uint32_t) a[3]; - - /* Don't allow 0 chars */ - if (c == 0) - return -EINVAL; - - if (c < 128) - *ret = c; - else { - if (!ret_unicode) - return -EINVAL; - - *ret = 0; - *ret_unicode = c; - } - - r = 5; - break; - } - - case 'U': { - /* C++11 style 32bit unicode */ - - int a[8]; - unsigned i; - uint32_t c; - - if (length != (size_t) -1 && length < 9) - return -EINVAL; - - for (i = 0; i < 8; i++) { - a[i] = unhexchar(p[1 + i]); - if (a[i] < 0) - return a[i]; - } - - c = ((uint32_t) a[0] << 28U) | ((uint32_t) a[1] << 24U) | ((uint32_t) a[2] << 20U) | ((uint32_t) a[3] << 16U) | - ((uint32_t) a[4] << 12U) | ((uint32_t) a[5] << 8U) | ((uint32_t) a[6] << 4U) | (uint32_t) a[7]; - - /* Don't allow 0 chars */ - if (c == 0) - return -EINVAL; - - /* Don't allow invalid code points */ - if (!unichar_is_valid(c)) - return -EINVAL; - - if (c < 128) - *ret = c; - else { - if (!ret_unicode) - return -EINVAL; - - *ret = 0; - *ret_unicode = c; - } - - r = 9; - break; - } - - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': { - /* octal encoding */ - int a, b, c; - uint32_t m; - - if (length != (size_t) -1 && length < 3) - return -EINVAL; - - a = unoctchar(p[0]); - if (a < 0) - return -EINVAL; - - b = unoctchar(p[1]); - if (b < 0) - return -EINVAL; - - c = unoctchar(p[2]); - if (c < 0) - return -EINVAL; - - /* don't allow NUL bytes */ - if (a == 0 && b == 0 && c == 0) - return -EINVAL; - - /* Don't allow bytes above 255 */ - m = ((uint32_t) a << 6U) | ((uint32_t) b << 3U) | (uint32_t) c; - if (m > 255) - return -EINVAL; - - *ret = m; - r = 3; - break; - } - - default: - return -EINVAL; - } - - return r; -} - -int cunescape_length_with_prefix(const char *s, size_t length, const char *prefix, UnescapeFlags flags, char **ret) { - char *r, *t; - const char *f; - size_t pl; - - assert(s); - assert(ret); - - /* Undoes C style string escaping, and optionally prefixes it. */ - - pl = prefix ? strlen(prefix) : 0; - - r = new(char, pl+length+1); - if (!r) - return -ENOMEM; - - if (prefix) - memcpy(r, prefix, pl); - - for (f = s, t = r + pl; f < s + length; f++) { - size_t remaining; - uint32_t u; - char c; - int k; - - remaining = s + length - f; - assert(remaining > 0); - - if (*f != '\\') { - /* A literal literal, copy verbatim */ - *(t++) = *f; - continue; - } - - if (remaining == 1) { - if (flags & UNESCAPE_RELAX) { - /* A trailing backslash, copy verbatim */ - *(t++) = *f; - continue; - } - - free(r); - return -EINVAL; - } - - k = cunescape_one(f + 1, remaining - 1, &c, &u); - if (k < 0) { - if (flags & UNESCAPE_RELAX) { - /* Invalid escape code, let's take it literal then */ - *(t++) = '\\'; - continue; - } - - free(r); - return k; - } - - if (c != 0) - /* Non-Unicode? Let's encode this directly */ - *(t++) = c; - else - /* Unicode? Then let's encode this in UTF-8 */ - t += utf8_encode_unichar(t, u); - - f += k; - } - - *t = 0; - - *ret = r; - return t - r; -} - -int cunescape_length(const char *s, size_t length, UnescapeFlags flags, char **ret) { - return cunescape_length_with_prefix(s, length, NULL, flags, ret); -} - -int cunescape(const char *s, UnescapeFlags flags, char **ret) { - return cunescape_length(s, strlen(s), flags, ret); -} - -char *xescape(const char *s, const char *bad) { - char *r, *t; - const char *f; - - /* Escapes all chars in bad, in addition to \ and all special - * chars, in \xFF style escaping. May be reversed with - * cunescape(). */ - - r = new(char, strlen(s) * 4 + 1); - if (!r) - return NULL; - - for (f = s, t = r; *f; f++) { - - if ((*f < ' ') || (*f >= 127) || - (*f == '\\') || strchr(bad, *f)) { - *(t++) = '\\'; - *(t++) = 'x'; - *(t++) = hexchar(*f >> 4); - *(t++) = hexchar(*f); - } else - *(t++) = *f; - } - - *t = 0; - - return r; -} - char *ascii_strlower(char *t) { char *p; @@ -6242,66 +5848,6 @@ int rename_noreplace(int olddirfd, const char *oldpath, int newdirfd, const char return 0; } -static char *strcpy_backslash_escaped(char *t, const char *s, const char *bad) { - assert(bad); - - for (; *s; s++) { - if (*s == '\\' || strchr(bad, *s)) - *(t++) = '\\'; - - *(t++) = *s; - } - - return t; -} - -char *shell_escape(const char *s, const char *bad) { - char *r, *t; - - r = new(char, strlen(s)*2+1); - if (!r) - return NULL; - - t = strcpy_backslash_escaped(r, s, bad); - *t = 0; - - return r; -} - -char *shell_maybe_quote(const char *s) { - const char *p; - char *r, *t; - - assert(s); - - /* Encloses a string in double quotes if necessary to make it - * OK as shell string. */ - - for (p = s; *p; p++) - if (*p <= ' ' || - *p >= 127 || - strchr(SHELL_NEED_QUOTES, *p)) - break; - - if (!*p) - return strdup(s); - - r = new(char, 1+strlen(s)*2+1+1); - if (!r) - return NULL; - - t = r; - *(t++) = '"'; - t = mempcpy(t, s, p - s); - - t = strcpy_backslash_escaped(t, p, SHELL_NEED_ESCAPE); - - *(t++)= '"'; - *t = 0; - - return r; -} - int parse_mode(const char *s, mode_t *ret) { char *x; long l; diff --git a/src/basic/util.h b/src/basic/util.h index 132e6f862b..6674111145 100644 --- a/src/basic/util.h +++ b/src/basic/util.h @@ -53,12 +53,6 @@ #define COMMENTS "#;" #define GLOB_CHARS "*?[" -/* What characters are special in the shell? */ -/* must be escaped outside and inside double-quotes */ -#define SHELL_NEED_ESCAPE "\"\\`$" -/* can be escaped or double-quoted */ -#define SHELL_NEED_QUOTES SHELL_NEED_ESCAPE GLOB_CHARS "'()<>|&;" - #define FORMAT_BYTES_MAX 8 size_t page_size(void) _pure_; @@ -260,20 +254,6 @@ int unbase32hexchar(char c) _const_; char base64char(int x) _const_; int unbase64char(char c) _const_; -char *cescape(const char *s); -size_t cescape_char(char c, char *buf); - -typedef enum UnescapeFlags { - UNESCAPE_RELAX = 1, -} UnescapeFlags; - -int cunescape(const char *s, UnescapeFlags flags, char **ret); -int cunescape_length(const char *s, size_t length, UnescapeFlags flags, char **ret); -int cunescape_length_with_prefix(const char *s, size_t length, const char *prefix, UnescapeFlags flags, char **ret); -int cunescape_one(const char *p, size_t length, char *ret, uint32_t *ret_unicode); - -char *xescape(const char *s, const char *bad); - char *ascii_strlower(char *path); bool dirent_is_file(const struct dirent *de) _pure_; @@ -924,9 +904,6 @@ void cmsg_close_all(struct msghdr *mh); int rename_noreplace(int olddirfd, const char *oldpath, int newdirfd, const char *newpath); -char *shell_escape(const char *s, const char *bad); -char *shell_maybe_quote(const char *s); - int parse_mode(const char *s, mode_t *ret); int mount_move_root(const char *path); diff --git a/src/core/job.c b/src/core/job.c index 558d8d2d52..13a4e44ec7 100644 --- a/src/core/job.c +++ b/src/core/job.c @@ -23,17 +23,20 @@ #include "sd-id128.h" #include "sd-messages.h" -#include "set.h" -#include "unit.h" -#include "macro.h" -#include "strv.h" -#include "log.h" -#include "dbus-job.h" -#include "special.h" + #include "async.h" -#include "virt.h" +#include "dbus-job.h" #include "dbus.h" +#include "escape.h" +#include "log.h" +#include "macro.h" +#include "set.h" +#include "special.h" +#include "strv.h" #include "terminal-util.h" +#include "unit.h" +#include "virt.h" +#include "job.h" Job* job_new_raw(Unit *unit) { Job *j; diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c index 0500e2ba33..ae85da25ac 100644 --- a/src/core/load-fragment.c +++ b/src/core/load-fragment.c @@ -42,6 +42,7 @@ #include "cpu-set-util.h" #include "env-util.h" #include "errno-list.h" +#include "escape.h" #include "ioprio.h" #include "log.h" #include "missing.h" diff --git a/src/core/manager.c b/src/core/manager.c index 6ae836148d..d1955a9701 100644 --- a/src/core/manager.c +++ b/src/core/manager.c @@ -51,6 +51,7 @@ #include "dbus-unit.h" #include "dbus.h" #include "env-util.h" +#include "escape.h" #include "exit-status.h" #include "hashmap.h" #include "locale-setup.h" diff --git a/src/core/mount.c b/src/core/mount.c index 0d1a9b9de7..d6da99ecb9 100644 --- a/src/core/mount.c +++ b/src/core/mount.c @@ -20,26 +20,28 @@ ***/ #include +#include #include #include -#include -#include "manager.h" -#include "unit.h" -#include "mount.h" -#include "log.h" #include "sd-messages.h" -#include "strv.h" -#include "mkdir.h" -#include "path-util.h" -#include "mount-setup.h" -#include "unit-name.h" + #include "dbus-mount.h" -#include "special.h" +#include "escape.h" #include "exit-status.h" -#include "fstab-util.h" #include "formats-util.h" +#include "fstab-util.h" +#include "log.h" +#include "manager.h" +#include "mkdir.h" +#include "mount-setup.h" +#include "mount.h" +#include "path-util.h" #include "smack-util.h" +#include "special.h" +#include "strv.h" +#include "unit-name.h" +#include "unit.h" #define RETRY_UMOUNT_MAX 32 diff --git a/src/core/service.c b/src/core/service.c index c77d4dc796..29be0928d3 100644 --- a/src/core/service.c +++ b/src/core/service.c @@ -24,30 +24,31 @@ #include #include "async.h" -#include "manager.h" -#include "unit.h" -#include "service.h" -#include "load-fragment.h" -#include "load-dropin.h" -#include "log.h" -#include "strv.h" -#include "unit-name.h" -#include "unit-printf.h" +#include "bus-error.h" +#include "bus-kernel.h" +#include "bus-util.h" #include "dbus-service.h" -#include "special.h" -#include "exit-status.h" #include "def.h" -#include "path-util.h" -#include "util.h" -#include "utf8.h" #include "env-util.h" +#include "escape.h" +#include "exit-status.h" #include "fileio.h" -#include "bus-error.h" -#include "bus-util.h" -#include "bus-kernel.h" #include "formats-util.h" +#include "load-dropin.h" +#include "load-fragment.h" +#include "log.h" +#include "manager.h" +#include "path-util.h" #include "process-util.h" #include "signal-util.h" +#include "special.h" +#include "strv.h" +#include "unit-name.h" +#include "unit-printf.h" +#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/swap.c b/src/core/swap.c index f42d151075..82ca58cd7a 100644 --- a/src/core/swap.c +++ b/src/core/swap.c @@ -20,22 +20,23 @@ ***/ #include -#include +#include #include #include -#include +#include -#include "unit.h" -#include "swap.h" -#include "unit-name.h" #include "dbus-swap.h" -#include "special.h" +#include "escape.h" #include "exit-status.h" +#include "formats-util.h" +#include "fstab-util.h" #include "path-util.h" -#include "virt.h" +#include "special.h" #include "udev-util.h" -#include "fstab-util.h" -#include "formats-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 22dbe67259..38d004ece3 100644 --- a/src/core/umount.c +++ b/src/core/umount.c @@ -21,20 +21,21 @@ #include #include +#include +#include #include #include #include -#include -#include +#include "escape.h" +#include "libudev.h" #include "list.h" #include "mount-setup.h" -#include "umount.h" #include "path-util.h" +#include "udev-util.h" #include "util.h" #include "virt.h" -#include "libudev.h" -#include "udev-util.h" +#include "umount.h" typedef struct MountPoint { char *path; diff --git a/src/core/unit.c b/src/core/unit.c index e3ab74b8fa..841c1ac018 100644 --- a/src/core/unit.c +++ b/src/core/unit.c @@ -20,36 +20,39 @@ ***/ #include -#include #include -#include +#include #include +#include #include "sd-id128.h" #include "sd-messages.h" -#include "set.h" -#include "macro.h" -#include "strv.h" -#include "path-util.h" -#include "log.h" + +#include "bus-common-errors.h" +#include "bus-util.h" #include "cgroup-util.h" -#include "missing.h" -#include "mkdir.h" +#include "dbus-unit.h" +#include "dbus.h" +#include "dropin.h" +#include "escape.h" +#include "execute.h" #include "fileio-label.h" #include "formats-util.h" +#include "load-dropin.h" +#include "load-fragment.h" +#include "log.h" +#include "macro.h" +#include "missing.h" +#include "mkdir.h" +#include "path-util.h" #include "process-util.h" -#include "virt.h" -#include "bus-common-errors.h" -#include "bus-util.h" -#include "dropin.h" -#include "unit-name.h" +#include "set.h" #include "special.h" +#include "strv.h" +#include "unit-name.h" +#include "virt.h" + #include "unit.h" -#include "load-fragment.h" -#include "load-dropin.h" -#include "dbus.h" -#include "dbus-unit.h" -#include "execute.h" const UnitVTable * const unit_vtable[_UNIT_TYPE_MAX] = { [UNIT_SERVICE] = &service_vtable, diff --git a/src/cryptsetup/cryptsetup.c b/src/cryptsetup/cryptsetup.c index ecc1273eec..4b5f24ff2e 100644 --- a/src/cryptsetup/cryptsetup.c +++ b/src/cryptsetup/cryptsetup.c @@ -23,17 +23,18 @@ #include #include #include - #include +#include "sd-device.h" + +#include "ask-password-api.h" +#include "device-util.h" +#include "escape.h" #include "fileio.h" #include "log.h" -#include "util.h" #include "path-util.h" #include "strv.h" -#include "ask-password-api.h" -#include "sd-device.h" -#include "device-util.h" +#include "util.h" static const char *arg_type = NULL; /* CRYPT_LUKS1, CRYPT_TCRYPT or CRYPT_PLAIN */ static char *arg_cipher = NULL; diff --git a/src/import/pull-common.c b/src/import/pull-common.c index edebb91556..94d4438912 100644 --- a/src/import/pull-common.c +++ b/src/import/pull-common.c @@ -21,17 +21,18 @@ #include -#include "util.h" -#include "strv.h" -#include "copy.h" -#include "rm-rf.h" #include "btrfs-util.h" #include "capability.h" -#include "pull-job.h" -#include "pull-common.h" +#include "copy.h" +#include "escape.h" #include "process-util.h" +#include "pull-job.h" +#include "rm-rf.h" #include "signal-util.h" #include "siphash24.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/journal-remote/journal-remote.c b/src/journal-remote/journal-remote.c index c920ef7626..0fcd987664 100644 --- a/src/journal-remote/journal-remote.c +++ b/src/journal-remote/journal-remote.c @@ -36,14 +36,15 @@ #include "sd-daemon.h" #include "conf-parser.h" +#include "escape.h" #include "fileio.h" #include "journal-file.h" +#include "journal-remote-write.h" #include "journald-native.h" #include "macro.h" #include "signal-util.h" #include "socket-util.h" #include "strv.h" -#include "journal-remote-write.h" #include "journal-remote.h" #define REMOTE_JOURNAL_PATH "/var/log/journal/remote" diff --git a/src/journal/coredump.c b/src/journal/coredump.c index e1e66b9826..e20a73c159 100644 --- a/src/journal/coredump.c +++ b/src/journal/coredump.c @@ -20,10 +20,10 @@ ***/ #include -#include #include #include #include +#include #ifdef HAVE_ELFUTILS # include @@ -32,23 +32,25 @@ #include "sd-journal.h" #include "sd-login.h" -#include "log.h" -#include "util.h" -#include "fileio.h" -#include "strv.h" -#include "macro.h" -#include "mkdir.h" -#include "special.h" + +#include "acl-util.h" +#include "capability.h" #include "cgroup-util.h" +#include "compress.h" #include "conf-parser.h" #include "copy.h" -#include "stacktrace.h" -#include "compress.h" -#include "acl-util.h" -#include "capability.h" -#include "journald-native.h" #include "coredump-vacuum.h" +#include "escape.h" +#include "fileio.h" +#include "journald-native.h" +#include "log.h" +#include "macro.h" +#include "mkdir.h" #include "process-util.h" +#include "special.h" +#include "stacktrace.h" +#include "strv.h" +#include "util.h" /* The maximum size up to which we process coredumps */ #define PROCESS_SIZE_MAX ((uint64_t) (2LLU*1024LLU*1024LLU*1024LLU)) diff --git a/src/journal/journald-kmsg.c b/src/journal/journald-kmsg.c index 51fe3aa50a..9ed368b586 100644 --- a/src/journal/journald-kmsg.c +++ b/src/journal/journald-kmsg.c @@ -19,20 +19,21 @@ along with systemd; If not, see . ***/ -#include -#include #include +#include #include #include +#include -#include "systemd/sd-messages.h" -#include +#include "libudev.h" +#include "sd-messages.h" +#include "escape.h" +#include "formats-util.h" #include "journald-server.h" -#include "journald-kmsg.h" #include "journald-syslog.h" -#include "formats-util.h" #include "process-util.h" +#include "journald-kmsg.h" void server_forward_kmsg( Server *s, diff --git a/src/journal/journald-stream.c b/src/journal/journald-stream.c index cbdaa3b888..0c4b82f80d 100644 --- a/src/journal/journald-stream.c +++ b/src/journal/journald-stream.c @@ -26,18 +26,20 @@ #include #endif -#include "sd-event.h" #include "sd-daemon.h" -#include "socket-util.h" -#include "selinux-util.h" -#include "mkdir.h" +#include "sd-event.h" + +#include "escape.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-kmsg.h" -#include "journald-console.h" #include "journald-wall.h" +#include "mkdir.h" +#include "selinux-util.h" +#include "socket-util.h" +#include "journald-stream.h" #define STDOUT_STREAMS_MAX 4096 diff --git a/src/libsystemd/sd-bus/busctl.c b/src/libsystemd/sd-bus/busctl.c index 49c97af339..04c6b1e8ef 100644 --- a/src/libsystemd/sd-bus/busctl.c +++ b/src/libsystemd/sd-bus/busctl.c @@ -29,6 +29,7 @@ #include "bus-type.h" #include "bus-util.h" #include "busctl-introspect.h" +#include "escape.h" #include "log.h" #include "pager.h" #include "path-util.h" diff --git a/src/libsystemd/sd-login/sd-login.c b/src/libsystemd/sd-login/sd-login.c index 265c7c7db2..db1fae2ebf 100644 --- a/src/libsystemd/sd-login/sd-login.c +++ b/src/libsystemd/sd-login/sd-login.c @@ -19,20 +19,21 @@ along with systemd; If not, see . ***/ -#include -#include #include -#include #include +#include +#include +#include -#include "util.h" #include "cgroup-util.h" -#include "macro.h" -#include "strv.h" +#include "escape.h" #include "fileio.h" -#include "login-util.h" #include "formats-util.h" #include "hostname-util.h" +#include "login-util.h" +#include "macro.h" +#include "strv.h" +#include "util.h" #include "sd-login.h" /* Error codes: diff --git a/src/login/logind-acl.c b/src/login/logind-acl.c index 466225d69c..c325c7bc0c 100644 --- a/src/login/logind-acl.c +++ b/src/login/logind-acl.c @@ -22,12 +22,13 @@ #include #include -#include "util.h" -#include "formats-util.h" #include "acl-util.h" +#include "escape.h" +#include "formats-util.h" #include "set.h" -#include "logind-acl.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-dbus.c b/src/login/logind-dbus.c index aeedf68e77..66807b3894 100644 --- a/src/login/logind-dbus.c +++ b/src/login/logind-dbus.c @@ -20,29 +20,31 @@ ***/ #include +#include #include #include -#include #include "sd-messages.h" -#include "strv.h" -#include "mkdir.h" -#include "path-util.h" -#include "special.h" -#include "sleep-config.h" -#include "fileio-label.h" -#include "unit-name.h" + #include "audit.h" -#include "bus-util.h" -#include "bus-error.h" #include "bus-common-errors.h" -#include "udev-util.h" -#include "selinux-util.h" +#include "bus-error.h" +#include "bus-util.h" #include "efivars.h" -#include "logind.h" +#include "escape.h" +#include "fileio-label.h" #include "formats-util.h" +#include "logind.h" +#include "mkdir.h" +#include "path-util.h" #include "process-util.h" +#include "selinux-util.h" +#include "sleep-config.h" +#include "special.h" +#include "strv.h" #include "terminal-util.h" +#include "udev-util.h" +#include "unit-name.h" #include "utmp-wtmp.h" int manager_get_session_from_creds(Manager *m, sd_bus_message *message, const char *name, sd_bus_error *error, Session **ret) { diff --git a/src/login/logind-inhibit.c b/src/login/logind-inhibit.c index 0c9c1e5e97..7c7dd3ecb2 100644 --- a/src/login/logind-inhibit.c +++ b/src/login/logind-inhibit.c @@ -24,11 +24,12 @@ #include #include -#include "util.h" -#include "mkdir.h" -#include "logind-inhibit.h" +#include "escape.h" #include "fileio.h" #include "formats-util.h" +#include "mkdir.h" +#include "util.h" +#include "logind-inhibit.h" Inhibitor* inhibitor_new(Manager *m, const char* id) { Inhibitor *i; diff --git a/src/login/logind-session.c b/src/login/logind-session.c index fa82e444ef..e35b5e71a1 100644 --- a/src/login/logind-session.c +++ b/src/login/logind-session.c @@ -21,24 +21,26 @@ #include #include -#include #include +#include #include #include #include #include #include "sd-messages.h" -#include "util.h" -#include "mkdir.h" -#include "path-util.h" -#include "fileio.h" + #include "audit.h" -#include "bus-util.h" #include "bus-error.h" -#include "logind-session.h" +#include "bus-util.h" +#include "escape.h" +#include "fileio.h" #include "formats-util.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 451954e860..ecfbf2c5cc 100644 --- a/src/login/logind-user.c +++ b/src/login/logind-user.c @@ -19,26 +19,27 @@ along with systemd; If not, see . ***/ -#include +#include #include +#include #include -#include -#include "util.h" -#include "mkdir.h" -#include "rm-rf.h" -#include "hashmap.h" -#include "fileio.h" -#include "path-util.h" -#include "special.h" -#include "unit-name.h" -#include "bus-util.h" #include "bus-error.h" -#include "conf-parser.h" +#include "bus-util.h" #include "clean-ipc.h" -#include "smack-util.h" +#include "conf-parser.h" +#include "escape.h" +#include "fileio.h" #include "formats-util.h" +#include "hashmap.h" #include "label.h" +#include "mkdir.h" +#include "path-util.h" +#include "rm-rf.h" +#include "smack-util.h" +#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) { diff --git a/src/machine/machine.c b/src/machine/machine.c index 7ab84607fb..e27d0af169 100644 --- a/src/machine/machine.c +++ b/src/machine/machine.c @@ -27,15 +27,16 @@ #include "bus-error.h" #include "bus-util.h" +#include "escape.h" #include "fileio.h" #include "formats-util.h" #include "hashmap.h" +#include "machine-dbus.h" #include "mkdir.h" #include "special.h" #include "terminal-util.h" #include "unit-name.h" #include "util.h" -#include "machine-dbus.h" #include "machine.h" Machine* machine_new(Manager *manager, MachineClass class, const char *name) { diff --git a/src/nspawn/nspawn-mount.c b/src/nspawn/nspawn-mount.c index 65bcb68242..02de2541c4 100644 --- a/src/nspawn/nspawn-mount.c +++ b/src/nspawn/nspawn-mount.c @@ -19,17 +19,18 @@ along with systemd; If not, see . ***/ -#include #include +#include -#include "util.h" -#include "rm-rf.h" -#include "strv.h" -#include "path-util.h" -#include "mkdir.h" +#include "cgroup-util.h" +#include "escape.h" #include "label.h" +#include "mkdir.h" +#include "path-util.h" +#include "rm-rf.h" #include "set.h" -#include "cgroup-util.h" +#include "strv.h" +#include "util.h" #include "nspawn-mount.h" diff --git a/src/rfkill/rfkill.c b/src/rfkill/rfkill.c index 72c9eb4446..d66f71772e 100644 --- a/src/rfkill/rfkill.c +++ b/src/rfkill/rfkill.c @@ -25,6 +25,7 @@ #include "libudev.h" #include "sd-daemon.h" +#include "escape.h" #include "fileio.h" #include "mkdir.h" #include "udev-util.h" diff --git a/src/shared/bus-util.c b/src/shared/bus-util.c index 9c4d6a2da0..13af8bfcce 100644 --- a/src/shared/bus-util.c +++ b/src/shared/bus-util.c @@ -21,9 +21,9 @@ #include +#include "sd-bus.h" #include "sd-daemon.h" #include "sd-event.h" -#include "sd-bus.h" #include "bus-error.h" #include "bus-internal.h" @@ -32,6 +32,7 @@ #include "cgroup-util.h" #include "def.h" #include "env-util.h" +#include "escape.h" #include "macro.h" #include "missing.h" #include "path-util.h" diff --git a/src/shared/dropin.c b/src/shared/dropin.c index 1845068adb..5e0436a55d 100644 --- a/src/shared/dropin.c +++ b/src/shared/dropin.c @@ -19,12 +19,13 @@ along with systemd; If not, see . ***/ -#include "dropin.h" -#include "util.h" -#include "strv.h" -#include "mkdir.h" -#include "fileio-label.h" #include "conf-files.h" +#include "escape.h" +#include "fileio-label.h" +#include "mkdir.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/generator.c b/src/shared/generator.c index d912bcd9e1..264a54fb94 100644 --- a/src/shared/generator.c +++ b/src/shared/generator.c @@ -21,15 +21,16 @@ #include -#include "util.h" -#include "special.h" +#include "dropin.h" +#include "escape.h" +#include "fileio.h" +#include "fstab-util.h" #include "mkdir.h" +#include "path-util.h" +#include "special.h" #include "unit-name.h" +#include "util.h" #include "generator.h" -#include "path-util.h" -#include "fstab-util.h" -#include "fileio.h" -#include "dropin.h" static int write_fsck_sysroot_service(const char *dir, const char *what) { _cleanup_free_ char *device = NULL, *escaped = NULL; diff --git a/src/test/test-util.c b/src/test/test-util.c index b5d9d01ba0..10bbb17b14 100644 --- a/src/test/test-util.c +++ b/src/test/test-util.c @@ -34,6 +34,7 @@ #include "conf-parser.h" #include "cpu-set-util.h" #include "def.h" +#include "escape.h" #include "fileio.h" #include "mkdir.h" #include "process-util.h" diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c index 1786e36674..ba9f82553b 100644 --- a/src/tmpfiles/tmpfiles.c +++ b/src/tmpfiles/tmpfiles.c @@ -43,6 +43,7 @@ #include "capability.h" #include "conf-files.h" #include "copy.h" +#include "escape.h" #include "formats-util.h" #include "label.h" #include "log.h" diff --git a/src/udev/udev-rules.c b/src/udev/udev-rules.c index 10bf3880b0..62db0016eb 100644 --- a/src/udev/udev-rules.c +++ b/src/udev/udev-rules.c @@ -15,27 +15,28 @@ * along with this program. If not, see . */ -#include -#include -#include -#include -#include -#include -#include #include -#include -#include #include +#include +#include #include +#include +#include +#include +#include +#include +#include #include +#include -#include "udev.h" -#include "path-util.h" #include "conf-files.h" +#include "escape.h" +#include "path-util.h" #include "strbuf.h" #include "strv.h" -#include "util.h" #include "sysctl-util.h" +#include "util.h" +#include "udev.h" #define PREALLOC_TOKEN 2048 @@ -51,7 +52,8 @@ static const char* const rules_dirs[] = { "/etc/udev/rules.d", "/run/udev/rules.d", UDEVLIBEXECDIR "/rules.d", - NULL}; + NULL +}; struct udev_rules { struct udev *udev; -- cgit v1.2.3-54-g00ecf From 07630cea1f3a845c09309f197ac7c4f11edd3b62 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Sat, 24 Oct 2015 22:58:24 +0200 Subject: util-lib: split our string related calls from util.[ch] into its own file string-util.[ch] There are more than enough calls doing string manipulations to deserve its own files, hence do something about it. This patch also sorts the #include blocks of all files that needed to be updated, according to the sorting suggestions from CODING_STYLE. Since pretty much every file needs our string manipulation functions this effectively means that most files have sorted #include blocks now. Also touches a few unrelated include files. --- Makefile.am | 2 + src/activate/activate.c | 1 + src/backlight/backlight.c | 4 +- src/basic/btrfs-util.c | 14 +- src/basic/calendarspec.c | 1 + src/basic/cgroup-util.c | 1 + src/basic/clock-util.c | 5 +- src/basic/conf-files.c | 15 +- src/basic/copy.c | 3 +- src/basic/env-util.c | 3 +- src/basic/fdset.c | 3 +- src/basic/fileio.c | 1 + src/basic/hostname-util.c | 3 +- src/basic/json.c | 4 +- src/basic/locale-util.c | 6 +- src/basic/log.c | 24 +- src/basic/log.h | 7 +- src/basic/login-util.c | 3 +- src/basic/memfd-util.c | 14 +- src/basic/path-util.c | 17 +- src/basic/process-util.c | 1 + src/basic/rm-rf.c | 5 +- src/basic/signal-util.c | 2 + src/basic/socket-util.c | 19 +- src/basic/string-util.c | 767 +++++++++++++++++++++ src/basic/string-util.h | 170 +++++ src/basic/strv.c | 5 +- src/basic/terminal-util.c | 27 +- src/basic/time-util.c | 7 +- src/basic/unit-name.c | 7 +- src/basic/util.c | 744 +------------------- src/basic/util.h | 139 ---- src/basic/verbs.c | 1 + src/basic/virt.c | 7 +- src/basic/xml.c | 1 + src/binfmt/binfmt.c | 1 + src/boot/bootctl.c | 1 + src/bootchart/bootchart.c | 30 +- src/bootchart/store.c | 17 +- src/bus-proxyd/bus-proxyd.c | 1 + src/bus-proxyd/bus-xml-policy.c | 14 +- src/bus-proxyd/driver.c | 11 +- src/bus-proxyd/proxy.h | 1 + src/bus-proxyd/synthesize.c | 5 +- src/bus-proxyd/synthesize.h | 1 + src/bus-proxyd/test-bus-xml-policy.c | 10 +- src/cgroups-agent/cgroups-agent.c | 3 +- src/core/automount.c | 31 +- src/core/busname.c | 13 +- src/core/busname.h | 2 + src/core/cgroup.c | 2 +- src/core/dbus-automount.c | 3 +- src/core/dbus-busname.c | 5 +- src/core/dbus-cgroup.h | 1 + src/core/dbus-execute.h | 1 + src/core/dbus-job.c | 8 +- src/core/dbus-job.h | 1 + src/core/dbus-kill.h | 1 + src/core/dbus-manager.c | 29 +- src/core/dbus-mount.c | 9 +- src/core/dbus-mount.h | 1 + src/core/dbus-path.c | 5 +- src/core/dbus-service.c | 13 +- src/core/dbus-socket.c | 9 +- src/core/dbus-swap.c | 9 +- src/core/dbus-target.h | 1 + src/core/dbus-unit.c | 10 +- src/core/dbus.c | 32 +- src/core/device.c | 10 +- src/core/execute.c | 1 + src/core/hostname-setup.c | 9 +- src/core/job.c | 1 + src/core/job.h | 6 +- src/core/killall.c | 11 +- src/core/load-fragment.c | 1 + src/core/locale-setup.c | 13 +- src/core/loopback-setup.c | 5 +- src/core/machine-id-setup.c | 1 + src/core/manager.c | 1 + src/core/mount.c | 1 + src/core/namespace.c | 21 +- src/core/path.c | 19 +- src/core/scope.c | 7 +- src/core/selinux-setup.c | 11 +- src/core/service.c | 1 + src/core/show-status.c | 3 +- src/core/shutdown.c | 31 +- src/core/slice.c | 5 +- src/core/smack-setup.c | 15 +- src/core/snapshot.c | 7 +- src/core/socket.c | 1 + src/core/swap.c | 4 +- src/core/swap.h | 2 +- src/core/target.c | 8 +- src/core/timer.c | 11 +- src/core/umount.c | 4 +- src/core/unit-printf.c | 9 +- src/core/unit.c | 2 +- src/cryptsetup/cryptsetup-generator.c | 3 +- src/cryptsetup/cryptsetup.c | 7 +- src/debug-generator/debug-generator.c | 1 + src/delta/delta.c | 1 + src/escape/escape.c | 1 + src/firstboot/firstboot.c | 1 + src/fstab-generator/fstab-generator.c | 17 +- src/getty-generator/getty-generator.c | 13 +- src/gpt-auto-generator/gpt-auto-generator.c | 26 +- src/hibernate-resume/hibernate-resume-generator.c | 7 +- src/hwdb/hwdb.c | 1 + src/import/aufs-util.c | 3 +- src/import/curl-util.c | 1 + src/import/curl-util.h | 3 +- src/import/export-raw.c | 8 +- src/import/export-tar.c | 10 +- src/import/export.c | 1 + src/import/import-raw.c | 18 +- src/import/import-tar.c | 20 +- src/import/import.c | 1 + src/import/pull-common.c | 1 + src/import/pull-dkr.c | 24 +- src/import/pull-job.c | 3 +- src/import/pull-raw.c | 28 +- src/import/pull-tar.c | 22 +- src/import/pull.c | 1 + src/journal-remote/journal-remote-parse.c | 3 +- src/journal-remote/journal-remote.c | 1 + src/journal-remote/journal-upload.c | 3 +- src/journal-remote/microhttpd-util.c | 13 +- src/journal/cat.c | 1 + src/journal/catalog.c | 22 +- src/journal/compress.c | 9 +- src/journal/coredump-vacuum.c | 6 +- src/journal/coredump.c | 1 + src/journal/coredumpctl.c | 1 + src/journal/journal-file.c | 17 +- src/journal/journal-internal.h | 8 +- src/journal/journal-send.c | 14 +- src/journal/journal-vacuum.c | 7 +- src/journal/journald-audit.c | 3 +- src/journal/journald-kmsg.c | 1 + src/journal/journald-native.c | 15 +- src/journal/journald-rate-limit.c | 9 +- src/journal/journald-server.c | 19 +- src/journal/journald-stream.c | 3 +- src/journal/journald-syslog.c | 18 +- src/journal/journald-wall.c | 7 +- src/journal/sd-journal.c | 26 +- src/journal/stacktrace.c | 5 +- src/journal/test-catalog.c | 4 +- src/journal/test-compress-benchmark.c | 3 +- src/journal/test-journal-enum.c | 3 +- src/journal/test-journal-flush.c | 4 +- src/journal/test-journal-match.c | 5 +- src/journal/test-journal-syslog.c | 1 + src/libsystemd-network/dhcp-identifier.c | 15 +- src/libsystemd-network/dhcp-identifier.h | 2 +- src/libsystemd-network/dhcp-internal.h | 8 +- src/libsystemd-network/dhcp6-internal.h | 3 +- src/libsystemd-network/lldp-internal.c | 3 +- src/libsystemd-network/lldp-internal.h | 5 +- src/libsystemd-network/network-internal.c | 16 +- src/libsystemd-network/sd-dhcp-client.c | 21 +- src/libsystemd-network/sd-dhcp-lease.c | 19 +- src/libsystemd-network/sd-dhcp-server.c | 9 +- src/libsystemd-network/sd-dhcp6-client.c | 14 +- src/libsystemd-network/sd-ipv4acd.c | 8 +- src/libsystemd-network/sd-ipv4ll.c | 12 +- src/libsystemd-network/sd-lldp.c | 13 +- src/libsystemd-network/sd-ndisc.c | 10 +- src/libsystemd-network/sd-pppoe.c | 12 +- src/libsystemd-network/test-dhcp-client.c | 8 +- src/libsystemd-network/test-dhcp-server.c | 4 +- src/libsystemd-network/test-dhcp6-client.c | 16 +- src/libsystemd-network/test-ipv4ll-manual.c | 12 +- src/libsystemd-network/test-ipv4ll.c | 12 +- src/libsystemd-network/test-lldp.c | 14 +- src/libsystemd-network/test-ndisc-rs.c | 4 +- src/libsystemd/sd-bus/bus-control.c | 8 +- src/libsystemd/sd-bus/bus-convenience.c | 3 +- src/libsystemd/sd-bus/bus-creds.c | 21 +- src/libsystemd/sd-bus/bus-dump.c | 16 +- src/libsystemd/sd-bus/bus-error.c | 11 +- src/libsystemd/sd-bus/bus-internal.c | 3 +- src/libsystemd/sd-bus/bus-internal.h | 18 +- src/libsystemd/sd-bus/bus-introspect.c | 7 +- src/libsystemd/sd-bus/bus-kernel.c | 18 +- src/libsystemd/sd-bus/bus-match.c | 3 +- src/libsystemd/sd-bus/bus-match.h | 4 +- src/libsystemd/sd-bus/bus-message.c | 19 +- src/libsystemd/sd-bus/bus-message.h | 7 +- src/libsystemd/sd-bus/bus-objects.c | 11 +- src/libsystemd/sd-bus/bus-slot.c | 2 + src/libsystemd/sd-bus/bus-socket.c | 17 +- src/libsystemd/sd-bus/bus-type.h | 3 +- src/libsystemd/sd-bus/busctl-introspect.c | 5 +- src/libsystemd/sd-bus/sd-bus.c | 33 +- src/libsystemd/sd-bus/test-bus-benchmark.c | 10 +- src/libsystemd/sd-bus/test-bus-chat.c | 12 +- src/libsystemd/sd-bus/test-bus-cleanup.c | 3 +- src/libsystemd/sd-bus/test-bus-gvariant.c | 9 +- src/libsystemd/sd-bus/test-bus-kernel-bloom.c | 6 +- src/libsystemd/sd-bus/test-bus-kernel.c | 8 +- src/libsystemd/sd-bus/test-bus-marshal.c | 10 +- src/libsystemd/sd-bus/test-bus-objects.c | 12 +- src/libsystemd/sd-bus/test-bus-proxy.c | 8 +- src/libsystemd/sd-bus/test-bus-server.c | 10 +- src/libsystemd/sd-bus/test-bus-signature.c | 2 +- src/libsystemd/sd-bus/test-bus-zero-copy.c | 13 +- src/libsystemd/sd-daemon/sd-daemon.c | 4 +- src/libsystemd/sd-device/device-enumerator.c | 12 +- src/libsystemd/sd-device/device-private.c | 26 +- src/libsystemd/sd-device/device-private.h | 6 + src/libsystemd/sd-device/sd-device.c | 22 +- src/libsystemd/sd-event/event-util.h | 3 +- src/libsystemd/sd-event/sd-event.c | 17 +- src/libsystemd/sd-hwdb/hwdb-util.h | 4 +- src/libsystemd/sd-hwdb/sd-hwdb.c | 12 +- src/libsystemd/sd-id128/sd-id128.c | 5 +- src/libsystemd/sd-login/sd-login.c | 4 +- src/libsystemd/sd-login/test-login.c | 7 +- src/libsystemd/sd-netlink/netlink-internal.h | 7 +- src/libsystemd/sd-netlink/netlink-message.c | 12 +- src/libsystemd/sd-netlink/netlink-socket.c | 12 +- src/libsystemd/sd-netlink/netlink-util.c | 1 - src/libsystemd/sd-netlink/netlink-util.h | 2 +- src/libsystemd/sd-netlink/rtnl-message.c | 12 +- src/libsystemd/sd-netlink/sd-netlink.c | 12 +- src/libsystemd/sd-netlink/test-netlink.c | 12 +- src/libsystemd/sd-network/sd-network.c | 12 +- src/libsystemd/sd-path/sd-path.c | 8 +- src/libsystemd/sd-resolve/resolve-util.h | 3 +- src/libsystemd/sd-resolve/sd-resolve.c | 21 +- src/libsystemd/sd-resolve/test-resolve.c | 14 +- src/libsystemd/sd-utf8/sd-utf8.c | 3 +- src/libudev/libudev-device-internal.h | 3 +- src/libudev/libudev-device-private.c | 4 +- src/libudev/libudev-device.c | 28 +- src/libudev/libudev-enumerate.c | 16 +- src/libudev/libudev-hwdb.c | 3 +- src/libudev/libudev-monitor.c | 18 +- src/libudev/libudev-private.h | 3 +- src/libudev/libudev-util.c | 13 +- src/libudev/libudev.c | 8 +- src/login/logind-acl.c | 1 + src/login/logind-acl.h | 3 +- src/login/logind-action.h | 1 + src/login/logind-button.c | 4 +- src/login/logind-inhibit.c | 1 + src/login/logind-seat.c | 10 +- src/login/logind-session-device.c | 3 +- src/login/logind.c | 11 +- src/login/logind.h | 11 +- src/login/sysfs-show.c | 10 +- src/login/test-inhibit.c | 5 +- src/machine/machined.h | 7 +- src/modules-load/modules-load.c | 3 +- src/network/networkctl.c | 1 + src/network/networkd-address-pool.c | 3 +- src/network/networkd-address.c | 4 +- src/network/networkd-dhcp6.c | 6 +- src/network/networkd-link.h | 4 +- src/network/networkd-manager.c | 17 +- src/network/networkd-ndisc.c | 4 +- src/network/networkd-netdev-bond.c | 6 +- src/network/networkd-netdev-tunnel.c | 8 +- src/network/networkd-netdev.c | 4 +- src/network/networkd-network-bus.c | 4 +- src/network/networkd-network.c | 6 +- src/network/networkd-route.c | 4 +- src/network/networkd-util.c | 4 +- src/network/networkd-wait-online-link.c | 2 +- src/notify/notify.c | 1 + src/nspawn/nspawn-cgroup.c | 10 +- src/nspawn/nspawn-expose-ports.c | 6 +- src/nspawn/nspawn-mount.c | 4 +- src/nspawn/nspawn-network.c | 8 +- src/nspawn/nspawn-setuid.c | 8 +- src/nspawn/nspawn.c | 16 +- src/nss-myhostname/nss-myhostname.c | 9 +- src/nss-mymachines/nss-mymachines.c | 14 +- src/nss-resolve/nss-resolve.c | 14 +- src/path/path.c | 1 + src/quotacheck/quotacheck.c | 9 +- src/random-seed/random-seed.c | 7 +- src/rc-local-generator/rc-local-generator.c | 3 +- src/reply-password/reply-password.c | 7 +- src/resolve/resolved-conf.c | 2 +- src/resolve/resolved-dns-answer.c | 3 +- src/resolve/resolved-dns-rr.c | 8 +- src/resolve/resolved-dns-zone.c | 6 +- src/resolve/resolved-link.c | 4 +- src/resolve/resolved-manager.c | 22 +- src/rfkill/rfkill.c | 1 + src/shared/acl-util.c | 5 +- src/shared/architecture.c | 1 + src/shared/ask-password-api.c | 1 + src/shared/base-filesystem.c | 5 +- src/shared/bus-util.c | 2 +- src/shared/bus-util.h | 4 +- src/shared/cgroup-show.c | 13 +- src/shared/clean-ipc.c | 13 +- src/shared/condition.c | 1 + src/shared/conf-parser.c | 14 +- src/shared/dns-domain.c | 1 + src/shared/dropin.c | 1 + src/shared/fstab-util.c | 3 +- src/shared/generator.c | 1 + src/shared/import-util.c | 1 + src/shared/install.c | 21 +- src/shared/logs-show.c | 22 +- src/shared/machine-image.c | 2 +- src/shared/machine-pool.c | 11 +- src/shared/pager.c | 13 +- src/shared/path-lookup.c | 3 +- src/shared/seccomp-util.c | 1 + src/shared/sleep-config.c | 3 +- src/shared/specifier.c | 3 +- src/shared/switch-root.c | 15 +- src/shared/sysctl-util.c | 1 + src/shared/utmp-wtmp.c | 9 +- src/sleep/sleep.c | 1 + src/socket-proxy/socket-proxyd.c | 1 + src/sysctl/sysctl.c | 1 + .../system-update-generator.c | 1 + src/systemd/sd-dhcp6-client.h | 1 + src/systemd/sd-lldp.h | 2 + src/sysusers/sysusers.c | 3 +- src/sysv-generator/sysv-generator.c | 17 +- src/test/test-af-list.c | 7 +- src/test/test-arphrd-list.c | 5 +- src/test/test-btrfs.c | 1 + src/test/test-calendarspec.c | 1 + src/test/test-cgroup-util.c | 2 +- src/test/test-cgroup.c | 3 +- src/test/test-condition.c | 17 +- src/test/test-conf-files.c | 5 +- src/test/test-conf-parser.c | 5 +- src/test/test-copy.c | 7 +- src/test/test-date.c | 1 + src/test/test-device-nodes.c | 1 + src/test/test-dns-domain.c | 3 +- src/test/test-ellipsize.c | 5 +- src/test/test-env-replace.c | 5 +- src/test/test-fileio.c | 1 + src/test/test-fstab-util.c | 3 +- src/test/test-hashmap-plain.c | 3 +- src/test/test-hostname-util.c | 1 + src/test/test-id128.c | 7 +- src/test/test-json.c | 3 +- src/test/test-libudev.c | 6 +- src/test/test-namespace.c | 3 +- src/test/test-netlink-manual.c | 9 +- src/test/test-path-lookup.c | 5 +- src/test/test-path-util.c | 9 +- src/test/test-path.c | 11 +- src/test/test-process-util.c | 9 +- src/test/test-replace-var.c | 3 +- src/test/test-socket-util.c | 9 +- src/test/test-strbuf.c | 1 + src/test/test-strip-tab-ansi.c | 3 +- src/test/test-strv.c | 3 +- src/test/test-strxcpyx.c | 3 +- src/test/test-tmpfiles.c | 7 +- src/test/test-udev.c | 9 +- src/test/test-unit-file.c | 19 +- src/test/test-unit-name.c | 15 +- src/test/test-utf8.c | 1 + src/test/test-util.c | 1 + src/test/test-xml.c | 3 +- src/timesync/timesyncd-conf.c | 2 +- src/timesync/timesyncd-manager.c | 26 +- src/tmpfiles/tmpfiles.c | 1 + .../tty-ask-password-agent.c | 1 + src/udev/ata_id/ata_id.c | 23 +- src/udev/cdrom_id/cdrom_id.c | 23 +- src/udev/collect/collect.c | 5 +- src/udev/net/link-config.c | 18 +- src/udev/net/link-config.h | 5 +- src/udev/scsi_id/scsi_id.c | 18 +- src/udev/scsi_id/scsi_serial.c | 24 +- src/udev/udev-builtin-blkid.c | 12 +- src/udev/udev-builtin-btrfs.c | 3 +- src/udev/udev-builtin-hwdb.c | 7 +- src/udev/udev-builtin-input_id.c | 7 +- src/udev/udev-builtin-keyboard.c | 3 +- src/udev/udev-builtin-kmod.c | 7 +- src/udev/udev-builtin-net_id.c | 15 +- src/udev/udev-builtin-path_id.c | 15 +- src/udev/udev-builtin-usb_id.c | 11 +- src/udev/udev-builtin.c | 3 +- src/udev/udev-event.c | 21 +- src/udev/udev-node.c | 21 +- src/udev/udev-rules.c | 3 +- src/udev/udev.h | 11 +- src/udev/udevadm-hwdb.c | 12 +- src/udev/udevadm-info.c | 13 +- src/udev/udevadm-test-builtin.c | 7 +- src/udev/udevadm-test.c | 13 +- src/udev/udevadm-trigger.c | 11 +- src/udev/udevadm-util.c | 1 + src/udev/udevadm.c | 5 +- src/udev/udevd.c | 1 + src/user-sessions/user-sessions.c | 5 +- src/vconsole/vconsole-setup.c | 21 +- 404 files changed, 2708 insertions(+), 2278 deletions(-) create mode 100644 src/basic/string-util.c create mode 100644 src/basic/string-util.h (limited to 'src/core') diff --git a/Makefile.am b/Makefile.am index db96d51aa4..9ef55f4e43 100644 --- a/Makefile.am +++ b/Makefile.am @@ -781,6 +781,8 @@ libbasic_la_SOURCES = \ src/basic/refcnt.h \ src/basic/util.c \ src/basic/util.h \ + src/basic/string-util.c \ + src/basic/string-util.h \ src/basic/extract-word.c \ src/basic/extract-word.h \ src/basic/escape.c \ diff --git a/src/activate/activate.c b/src/activate/activate.c index 4ece1367c1..adb43623cf 100644 --- a/src/activate/activate.c +++ b/src/activate/activate.c @@ -32,6 +32,7 @@ #include "macro.h" #include "signal-util.h" #include "socket-util.h" +#include "string-util.h" #include "strv.h" static char** arg_listen = NULL; diff --git a/src/backlight/backlight.c b/src/backlight/backlight.c index 84ce842cae..fc96eee6a9 100644 --- a/src/backlight/backlight.c +++ b/src/backlight/backlight.c @@ -19,11 +19,13 @@ along with systemd; If not, see . ***/ +#include "libudev.h" + #include "def.h" #include "escape.h" #include "fileio.h" -#include "libudev.h" #include "mkdir.h" +#include "string-util.h" #include "udev-util.h" #include "util.h" diff --git a/src/basic/btrfs-util.c b/src/basic/btrfs-util.c index f327c16a80..df7b959c12 100644 --- a/src/basic/btrfs-util.c +++ b/src/basic/btrfs-util.c @@ -20,22 +20,22 @@ ***/ #include -#include #include - +#include #ifdef HAVE_LINUX_BTRFS_H #include #endif +#include "btrfs-ctree.h" +#include "copy.h" +#include "fileio.h" +#include "macro.h" #include "missing.h" -#include "util.h" #include "path-util.h" -#include "macro.h" -#include "copy.h" #include "selinux-util.h" #include "smack-util.h" -#include "fileio.h" -#include "btrfs-ctree.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 diff --git a/src/basic/calendarspec.c b/src/basic/calendarspec.c index a2296f4709..987ca81910 100644 --- a/src/basic/calendarspec.c +++ b/src/basic/calendarspec.c @@ -22,6 +22,7 @@ #include #include +#include "string-util.h" #include "calendarspec.h" #define BITS_WEEKDAYS 127 diff --git a/src/basic/cgroup-util.c b/src/basic/cgroup-util.c index a3ea512165..ce21ef73eb 100644 --- a/src/basic/cgroup-util.c +++ b/src/basic/cgroup-util.c @@ -39,6 +39,7 @@ #include "process-util.h" #include "set.h" #include "special.h" +#include "string-util.h" #include "unit-name.h" #include "util.h" #include "cgroup-util.h" diff --git a/src/basic/clock-util.c b/src/basic/clock-util.c index e4e03df1e4..03ec5725ae 100644 --- a/src/basic/clock-util.c +++ b/src/basic/clock-util.c @@ -20,13 +20,14 @@ ***/ #include -#include #include +#include +#include #include #include -#include #include "macro.h" +#include "string-util.h" #include "util.h" #include "clock-util.h" diff --git a/src/basic/conf-files.c b/src/basic/conf-files.c index da8745b284..0e44d1bbad 100644 --- a/src/basic/conf-files.c +++ b/src/basic/conf-files.c @@ -19,19 +19,20 @@ along with systemd; If not, see . ***/ -#include +#include #include -#include #include -#include +#include +#include +#include "hashmap.h" +#include "log.h" #include "macro.h" -#include "util.h" #include "missing.h" -#include "log.h" -#include "strv.h" #include "path-util.h" -#include "hashmap.h" +#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) { diff --git a/src/basic/copy.c b/src/basic/copy.c index b20c178727..7702d906c7 100644 --- a/src/basic/copy.c +++ b/src/basic/copy.c @@ -22,9 +22,10 @@ #include #include -#include "util.h" #include "btrfs-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/env-util.c b/src/basic/env-util.c index ecb2192c4d..a392af737c 100644 --- a/src/basic/env-util.c +++ b/src/basic/env-util.c @@ -22,11 +22,12 @@ #include #include +#include "def.h" +#include "string-util.h" #include "strv.h" #include "utf8.h" #include "util.h" #include "env-util.h" -#include "def.h" #define VALID_CHARS_ENV_NAME \ DIGITS LETTERS \ diff --git a/src/basic/fdset.c b/src/basic/fdset.c index d70fe156a2..2882f515b5 100644 --- a/src/basic/fdset.c +++ b/src/basic/fdset.c @@ -23,11 +23,12 @@ #include #include +#include "sd-daemon.h" + #include "set.h" #include "util.h" #include "macro.h" #include "fdset.h" -#include "sd-daemon.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 65a6a6558b..f8ccf79221 100644 --- a/src/basic/fileio.c +++ b/src/basic/fileio.c @@ -23,6 +23,7 @@ #include "ctype.h" #include "escape.h" +#include "string-util.h" #include "strv.h" #include "utf8.h" #include "util.h" diff --git a/src/basic/hostname-util.c b/src/basic/hostname-util.c index 1b816fb77a..8d10615682 100644 --- a/src/basic/hostname-util.c +++ b/src/basic/hostname-util.c @@ -19,9 +19,10 @@ along with systemd; If not, see . ***/ -#include #include +#include +#include "string-util.h" #include "util.h" #include "hostname-util.h" diff --git a/src/basic/json.c b/src/basic/json.c index be40a0d203..2b634aa7f8 100644 --- a/src/basic/json.c +++ b/src/basic/json.c @@ -19,9 +19,11 @@ along with systemd; If not, see . ***/ -#include #include +#include + #include "macro.h" +#include "string-util.h" #include "utf8.h" #include "json.h" diff --git a/src/basic/locale-util.c b/src/basic/locale-util.c index 61db9a8125..a44daf8f5e 100644 --- a/src/basic/locale-util.c +++ b/src/basic/locale-util.c @@ -22,10 +22,10 @@ #include #include "set.h" -#include "util.h" -#include "utf8.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) { diff --git a/src/basic/log.c b/src/basic/log.c index e6d7d15182..acc390b8d3 100644 --- a/src/basic/log.c +++ b/src/basic/log.c @@ -19,26 +19,28 @@ along with systemd; If not, see . ***/ -#include -#include #include -#include #include +#include +#include +#include +#include #include #include -#include -#include +#include #include "sd-messages.h" -#include "log.h" -#include "util.h" -#include "missing.h" -#include "macro.h" -#include "socket-util.h" + #include "formats-util.h" +#include "macro.h" +#include "missing.h" #include "process-util.h" -#include "terminal-util.h" #include "signal-util.h" +#include "socket-util.h" +#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/log.h b/src/basic/log.h index 369d6b1127..cda1e45cc8 100644 --- a/src/basic/log.h +++ b/src/basic/log.h @@ -21,14 +21,15 @@ along with systemd; If not, see . ***/ -#include +#include #include +#include #include -#include #include -#include +#include #include "sd-id128.h" + #include "macro.h" typedef enum LogTarget{ diff --git a/src/basic/login-util.c b/src/basic/login-util.c index e25437f0f4..832f477bd2 100644 --- a/src/basic/login-util.c +++ b/src/basic/login-util.c @@ -19,8 +19,9 @@ along with systemd; If not, see . ***/ -#include "login-util.h" #include "def.h" +#include "string-util.h" +#include "login-util.h" bool session_id_valid(const char *id) { diff --git a/src/basic/memfd-util.c b/src/basic/memfd-util.c index e99a738e1f..4dafd69daf 100644 --- a/src/basic/memfd-util.c +++ b/src/basic/memfd-util.c @@ -19,19 +19,19 @@ along with systemd; If not, see . ***/ -#include #include -#include -#include - #ifdef HAVE_LINUX_MEMFD_H -# include +#include #endif +#include +#include +#include +#include "missing.h" +#include "string-util.h" +#include "utf8.h" #include "util.h" #include "memfd-util.h" -#include "utf8.h" -#include "missing.h" int memfd_new(const char *name) { _cleanup_free_ char *g = NULL; diff --git a/src/basic/path-util.c b/src/basic/path-util.c index 6b05b6edb1..31328807f4 100644 --- a/src/basic/path-util.c +++ b/src/basic/path-util.c @@ -19,21 +19,22 @@ along with systemd; If not, see . ***/ -#include -#include #include -#include -#include #include +#include +#include +#include #include +#include -#include "macro.h" -#include "util.h" +#include "fileio.h" #include "log.h" +#include "macro.h" +#include "missing.h" +#include "string-util.h" #include "strv.h" +#include "util.h" #include "path-util.h" -#include "missing.h" -#include "fileio.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 3199efeafd..bfde17a956 100644 --- a/src/basic/process-util.c +++ b/src/basic/process-util.c @@ -32,6 +32,7 @@ #include "fileio.h" #include "log.h" #include "signal-util.h" +#include "string-util.h" #include "util.h" #include "process-util.h" diff --git a/src/basic/rm-rf.c b/src/basic/rm-rf.c index 2ef63799d7..5a75090a6d 100644 --- a/src/basic/rm-rf.c +++ b/src/basic/rm-rf.c @@ -19,9 +19,10 @@ along with systemd; If not, see . ***/ -#include "util.h" -#include "path-util.h" #include "btrfs-util.h" +#include "path-util.h" +#include "string-util.h" +#include "util.h" #include "rm-rf.h" int rm_rf_children(int fd, RemoveFlags flags, struct stat *root_dev) { diff --git a/src/basic/signal-util.c b/src/basic/signal-util.c index 90abe8af81..730f99e0af 100644 --- a/src/basic/signal-util.c +++ b/src/basic/signal-util.c @@ -19,7 +19,9 @@ along with systemd; If not, see . ***/ +#include "string-util.h" #include "util.h" + #include "signal-util.h" int reset_all_signal_handlers(void) { diff --git a/src/basic/socket-util.c b/src/basic/socket-util.c index 8fd3149276..9ed5feb849 100644 --- a/src/basic/socket-util.c +++ b/src/basic/socket-util.c @@ -19,23 +19,24 @@ along with systemd; If not, see . ***/ -#include -#include -#include #include -#include +#include #include -#include -#include #include +#include +#include +#include +#include +#include +#include "fileio.h" +#include "formats-util.h" #include "macro.h" +#include "missing.h" #include "path-util.h" +#include "string-util.h" #include "util.h" #include "socket-util.h" -#include "missing.h" -#include "fileio.h" -#include "formats-util.h" int socket_address_parse(SocketAddress *a, const char *s) { char *e, *n; diff --git a/src/basic/string-util.c b/src/basic/string-util.c new file mode 100644 index 0000000000..a7cf4e8520 --- /dev/null +++ b/src/basic/string-util.c @@ -0,0 +1,767 @@ +/*-*- 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 . +***/ + +#include "gunicode.h" +#include "utf8.h" +#include "util.h" +#include "string-util.h" + +int strcmp_ptr(const char *a, const char *b) { + + /* Like strcmp(), but tries to make sense of NULL pointers */ + if (a && b) + return strcmp(a, b); + + if (!a && b) + return -1; + + if (a && !b) + return 1; + + return 0; +} + +char* endswith(const char *s, const char *postfix) { + size_t sl, pl; + + assert(s); + assert(postfix); + + sl = strlen(s); + pl = strlen(postfix); + + if (pl == 0) + return (char*) s + sl; + + if (sl < pl) + return NULL; + + if (memcmp(s + sl - pl, postfix, pl) != 0) + return NULL; + + return (char*) s + sl - pl; +} + +char* endswith_no_case(const char *s, const char *postfix) { + size_t sl, pl; + + assert(s); + assert(postfix); + + sl = strlen(s); + pl = strlen(postfix); + + if (pl == 0) + return (char*) s + sl; + + if (sl < pl) + return NULL; + + if (strcasecmp(s + sl - pl, postfix) != 0) + return NULL; + + return (char*) s + sl - pl; +} + +char* first_word(const char *s, const char *word) { + size_t sl, wl; + const char *p; + + assert(s); + assert(word); + + /* Checks if the string starts with the specified word, either + * followed by NUL or by whitespace. Returns a pointer to the + * NUL or the first character after the whitespace. */ + + sl = strlen(s); + wl = strlen(word); + + if (sl < wl) + return NULL; + + if (wl == 0) + return (char*) s; + + if (memcmp(s, word, wl) != 0) + return NULL; + + p = s + wl; + if (*p == 0) + return (char*) p; + + if (!strchr(WHITESPACE, *p)) + return NULL; + + p += strspn(p, WHITESPACE); + return (char*) p; +} + +static size_t strcspn_escaped(const char *s, const char *reject) { + bool escaped = false; + int n; + + for (n=0; s[n]; n++) { + if (escaped) + escaped = false; + else if (s[n] == '\\') + escaped = true; + else if (strchr(reject, s[n])) + break; + } + + /* if s ends in \, return index of previous char */ + return n - escaped; +} + +/* Split a string into words. */ +const char* split(const char **state, size_t *l, const char *separator, bool quoted) { + const char *current; + + current = *state; + + if (!*current) { + assert(**state == '\0'); + return NULL; + } + + current += strspn(current, separator); + if (!*current) { + *state = current; + return NULL; + } + + if (quoted && strchr("\'\"", *current)) { + char quotechars[2] = {*current, '\0'}; + + *l = strcspn_escaped(current + 1, quotechars); + if (current[*l + 1] == '\0' || current[*l + 1] != quotechars[0] || + (current[*l + 2] && !strchr(separator, current[*l + 2]))) { + /* right quote missing or garbage at the end */ + *state = current; + return NULL; + } + *state = current++ + *l + 2; + } else if (quoted) { + *l = strcspn_escaped(current, separator); + if (current[*l] && !strchr(separator, current[*l])) { + /* unfinished escape */ + *state = current; + return NULL; + } + *state = current + *l; + } else { + *l = strcspn(current, separator); + *state = current + *l; + } + + return current; +} + +char *strnappend(const char *s, const char *suffix, size_t b) { + size_t a; + char *r; + + if (!s && !suffix) + return strdup(""); + + if (!s) + return strndup(suffix, b); + + if (!suffix) + return strdup(s); + + assert(s); + assert(suffix); + + a = strlen(s); + if (b > ((size_t) -1) - a) + return NULL; + + r = new(char, a+b+1); + if (!r) + return NULL; + + memcpy(r, s, a); + memcpy(r+a, suffix, b); + r[a+b] = 0; + + return r; +} + +char *strappend(const char *s, const char *suffix) { + return strnappend(s, suffix, suffix ? strlen(suffix) : 0); +} + +char *strjoin(const char *x, ...) { + va_list ap; + size_t l; + char *r, *p; + + va_start(ap, x); + + if (x) { + l = strlen(x); + + for (;;) { + const char *t; + size_t n; + + t = va_arg(ap, const char *); + if (!t) + break; + + n = strlen(t); + if (n > ((size_t) -1) - l) { + va_end(ap); + return NULL; + } + + l += n; + } + } else + l = 0; + + va_end(ap); + + r = new(char, l+1); + if (!r) + return NULL; + + if (x) { + p = stpcpy(r, x); + + va_start(ap, x); + + for (;;) { + const char *t; + + t = va_arg(ap, const char *); + if (!t) + break; + + p = stpcpy(p, t); + } + + va_end(ap); + } else + r[0] = 0; + + return r; +} + +char *strstrip(char *s) { + char *e; + + /* Drops trailing whitespace. Modifies the string in + * place. Returns pointer to first non-space character */ + + s += strspn(s, WHITESPACE); + + for (e = strchr(s, 0); e > s; e --) + if (!strchr(WHITESPACE, e[-1])) + break; + + *e = 0; + + return s; +} + +char *delete_chars(char *s, const char *bad) { + char *f, *t; + + /* Drops all whitespace, regardless where in the string */ + + for (f = s, t = s; *f; f++) { + if (strchr(bad, *f)) + continue; + + *(t++) = *f; + } + + *t = 0; + + return s; +} + +char *truncate_nl(char *s) { + assert(s); + + s[strcspn(s, NEWLINE)] = 0; + return s; +} + +char *ascii_strlower(char *t) { + char *p; + + assert(t); + + for (p = t; *p; p++) + if (*p >= 'A' && *p <= 'Z') + *p = *p - 'A' + 'a'; + + return t; +} + +bool chars_intersect(const char *a, const char *b) { + const char *p; + + /* Returns true if any of the chars in a are in b. */ + for (p = a; *p; p++) + if (strchr(b, *p)) + return true; + + return false; +} + +bool string_has_cc(const char *p, const char *ok) { + const char *t; + + assert(p); + + /* + * Check if a string contains control characters. If 'ok' is + * non-NULL it may be a string containing additional CCs to be + * considered OK. + */ + + for (t = p; *t; t++) { + if (ok && strchr(ok, *t)) + continue; + + if (*t > 0 && *t < ' ') + return true; + + if (*t == 127) + return true; + } + + return false; +} + +static char *ascii_ellipsize_mem(const char *s, size_t old_length, size_t new_length, unsigned percent) { + size_t x; + char *r; + + assert(s); + assert(percent <= 100); + assert(new_length >= 3); + + if (old_length <= 3 || old_length <= new_length) + return strndup(s, old_length); + + r = new0(char, new_length+1); + if (!r) + return NULL; + + x = (new_length * percent) / 100; + + if (x > new_length - 3) + x = new_length - 3; + + memcpy(r, s, x); + r[x] = '.'; + r[x+1] = '.'; + r[x+2] = '.'; + memcpy(r + x + 3, + s + old_length - (new_length - x - 3), + new_length - x - 3); + + return r; +} + +char *ellipsize_mem(const char *s, size_t old_length, size_t new_length, unsigned percent) { + size_t x; + char *e; + const char *i, *j; + unsigned k, len, len2; + + assert(s); + assert(percent <= 100); + assert(new_length >= 3); + + /* if no multibyte characters use ascii_ellipsize_mem for speed */ + if (ascii_is_valid(s)) + return ascii_ellipsize_mem(s, old_length, new_length, percent); + + if (old_length <= 3 || old_length <= new_length) + return strndup(s, old_length); + + x = (new_length * percent) / 100; + + if (x > new_length - 3) + x = new_length - 3; + + k = 0; + for (i = s; k < x && i < s + old_length; i = utf8_next_char(i)) { + int c; + + c = utf8_encoded_to_unichar(i); + if (c < 0) + return NULL; + k += unichar_iswide(c) ? 2 : 1; + } + + if (k > x) /* last character was wide and went over quota */ + x ++; + + for (j = s + old_length; k < new_length && j > i; ) { + int c; + + j = utf8_prev_char(j); + c = utf8_encoded_to_unichar(j); + if (c < 0) + return NULL; + k += unichar_iswide(c) ? 2 : 1; + } + assert(i <= j); + + /* we don't actually need to ellipsize */ + if (i == j) + return memdup(s, old_length + 1); + + /* make space for ellipsis */ + j = utf8_next_char(j); + + len = i - s; + len2 = s + old_length - j; + e = new(char, len + 3 + len2 + 1); + if (!e) + return NULL; + + /* + printf("old_length=%zu new_length=%zu x=%zu len=%u len2=%u k=%u\n", + old_length, new_length, x, len, len2, k); + */ + + memcpy(e, s, len); + e[len] = 0xe2; /* tri-dot ellipsis: … */ + e[len + 1] = 0x80; + e[len + 2] = 0xa6; + + memcpy(e + len + 3, j, len2 + 1); + + return e; +} + +char *ellipsize(const char *s, size_t length, unsigned percent) { + return ellipsize_mem(s, strlen(s), length, percent); +} + +bool nulstr_contains(const char*nulstr, const char *needle) { + const char *i; + + if (!nulstr) + return false; + + NULSTR_FOREACH(i, nulstr) + if (streq(i, needle)) + return true; + + return false; +} + +char* strshorten(char *s, size_t l) { + assert(s); + + if (l < strlen(s)) + s[l] = 0; + + return s; +} + +char *strreplace(const char *text, const char *old_string, const char *new_string) { + const char *f; + char *t, *r; + size_t l, old_len, new_len; + + assert(text); + assert(old_string); + assert(new_string); + + old_len = strlen(old_string); + new_len = strlen(new_string); + + l = strlen(text); + r = new(char, l+1); + if (!r) + return NULL; + + f = text; + t = r; + while (*f) { + char *a; + size_t d, nl; + + if (!startswith(f, old_string)) { + *(t++) = *(f++); + continue; + } + + d = t - r; + nl = l - old_len + new_len; + a = realloc(r, nl + 1); + if (!a) + goto oom; + + l = nl; + r = a; + t = r + d; + + t = stpcpy(t, new_string); + f += old_len; + } + + *t = 0; + return r; + +oom: + free(r); + return NULL; +} + +char *strip_tab_ansi(char **ibuf, size_t *_isz) { + const char *i, *begin = NULL; + enum { + STATE_OTHER, + STATE_ESCAPE, + STATE_BRACKET + } state = STATE_OTHER; + char *obuf = NULL; + size_t osz = 0, isz; + FILE *f; + + assert(ibuf); + assert(*ibuf); + + /* Strips ANSI color and replaces TABs by 8 spaces */ + + isz = _isz ? *_isz : strlen(*ibuf); + + f = open_memstream(&obuf, &osz); + if (!f) + return NULL; + + for (i = *ibuf; i < *ibuf + isz + 1; i++) { + + switch (state) { + + case STATE_OTHER: + if (i >= *ibuf + isz) /* EOT */ + break; + else if (*i == '\x1B') + state = STATE_ESCAPE; + else if (*i == '\t') + fputs(" ", f); + else + fputc(*i, f); + break; + + case STATE_ESCAPE: + if (i >= *ibuf + isz) { /* EOT */ + fputc('\x1B', f); + break; + } else if (*i == '[') { + state = STATE_BRACKET; + begin = i + 1; + } else { + fputc('\x1B', f); + fputc(*i, f); + state = STATE_OTHER; + } + + break; + + case STATE_BRACKET: + + if (i >= *ibuf + isz || /* EOT */ + (!(*i >= '0' && *i <= '9') && *i != ';' && *i != 'm')) { + fputc('\x1B', f); + fputc('[', f); + state = STATE_OTHER; + i = begin-1; + } else if (*i == 'm') + state = STATE_OTHER; + break; + } + } + + if (ferror(f)) { + fclose(f); + free(obuf); + return NULL; + } + + fclose(f); + + free(*ibuf); + *ibuf = obuf; + + if (_isz) + *_isz = osz; + + return obuf; +} + +char *strextend(char **x, ...) { + va_list ap; + size_t f, l; + char *r, *p; + + assert(x); + + l = f = *x ? strlen(*x) : 0; + + va_start(ap, x); + for (;;) { + const char *t; + size_t n; + + t = va_arg(ap, const char *); + if (!t) + break; + + n = strlen(t); + if (n > ((size_t) -1) - l) { + va_end(ap); + return NULL; + } + + l += n; + } + va_end(ap); + + r = realloc(*x, l+1); + if (!r) + return NULL; + + p = r + f; + + va_start(ap, x); + for (;;) { + const char *t; + + t = va_arg(ap, const char *); + if (!t) + break; + + p = stpcpy(p, t); + } + va_end(ap); + + *p = 0; + *x = r; + + return r + l; +} + +char *strrep(const char *s, unsigned n) { + size_t l; + char *r, *p; + unsigned i; + + assert(s); + + l = strlen(s); + p = r = malloc(l * n + 1); + if (!r) + return NULL; + + for (i = 0; i < n; i++) + p = stpcpy(p, s); + + *p = 0; + return r; +} + +int split_pair(const char *s, const char *sep, char **l, char **r) { + char *x, *a, *b; + + assert(s); + assert(sep); + assert(l); + assert(r); + + if (isempty(sep)) + return -EINVAL; + + x = strstr(s, sep); + if (!x) + return -EINVAL; + + a = strndup(s, x - s); + if (!a) + return -ENOMEM; + + b = strdup(x + strlen(sep)); + if (!b) { + free(a); + return -ENOMEM; + } + + *l = a; + *r = b; + + return 0; +} + +int free_and_strdup(char **p, const char *s) { + char *t; + + assert(p); + + /* Replaces a string pointer with an strdup()ed new string, + * possibly freeing the old one. */ + + if (streq_ptr(*p, s)) + return 0; + + if (s) { + t = strdup(s); + if (!t) + return -ENOMEM; + } else + t = NULL; + + free(*p); + *p = t; + + return 1; +} + +void string_erase(char *x) { + + if (!x) + return; + + /* A delicious drop of snake-oil! To be called on memory where + * we stored passphrases or so, after we used them. */ + + memory_erase(x, strlen(x)); +} + +char *string_free_erase(char *s) { + if (!s) + return NULL; + + string_erase(s); + return mfree(s); +} diff --git a/src/basic/string-util.h b/src/basic/string-util.h new file mode 100644 index 0000000000..7b7c0e5f32 --- /dev/null +++ b/src/basic/string-util.h @@ -0,0 +1,170 @@ +/*-*- 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 . +***/ + +#include +#include + +#include "macro.h" + +#define streq(a,b) (strcmp((a),(b)) == 0) +#define strneq(a, b, n) (strncmp((a), (b), (n)) == 0) +#define strcaseeq(a,b) (strcasecmp((a),(b)) == 0) +#define strncaseeq(a, b, n) (strncasecmp((a), (b), (n)) == 0) + +int strcmp_ptr(const char *a, const char *b) _pure_; + +static inline bool streq_ptr(const char *a, const char *b) { + return strcmp_ptr(a, b) == 0; +} + +static inline const char* strempty(const char *s) { + return s ? s : ""; +} + +static inline const char* strnull(const char *s) { + return s ? s : "(null)"; +} + +static inline const char *strna(const char *s) { + return s ? s : "n/a"; +} + +static inline bool isempty(const char *p) { + return !p || !p[0]; +} + +static inline char *startswith(const char *s, const char *prefix) { + size_t l; + + l = strlen(prefix); + if (strncmp(s, prefix, l) == 0) + return (char*) s + l; + + return NULL; +} + +static inline char *startswith_no_case(const char *s, const char *prefix) { + size_t l; + + l = strlen(prefix); + if (strncasecmp(s, prefix, l) == 0) + return (char*) s + l; + + return NULL; +} + +char *endswith(const char *s, const char *postfix) _pure_; +char *endswith_no_case(const char *s, const char *postfix) _pure_; + +char *first_word(const char *s, const char *word) _pure_; + +const char* split(const char **state, size_t *l, const char *separator, bool quoted); + +#define FOREACH_WORD(word, length, s, state) \ + _FOREACH_WORD(word, length, s, WHITESPACE, false, state) + +#define FOREACH_WORD_SEPARATOR(word, length, s, separator, state) \ + _FOREACH_WORD(word, length, s, separator, false, state) + +#define FOREACH_WORD_QUOTED(word, length, s, state) \ + _FOREACH_WORD(word, length, s, WHITESPACE, true, state) + +#define _FOREACH_WORD(word, length, s, separator, quoted, state) \ + for ((state) = (s), (word) = split(&(state), &(length), (separator), (quoted)); (word); (word) = split(&(state), &(length), (separator), (quoted))) + +char *strappend(const char *s, const char *suffix); +char *strnappend(const char *s, const char *suffix, size_t length); + +char *strjoin(const char *x, ...) _sentinel_; + +#define strjoina(a, ...) \ + ({ \ + const char *_appendees_[] = { a, __VA_ARGS__ }; \ + char *_d_, *_p_; \ + int _len_ = 0; \ + unsigned _i_; \ + for (_i_ = 0; _i_ < ELEMENTSOF(_appendees_) && _appendees_[_i_]; _i_++) \ + _len_ += strlen(_appendees_[_i_]); \ + _p_ = _d_ = alloca(_len_ + 1); \ + for (_i_ = 0; _i_ < ELEMENTSOF(_appendees_) && _appendees_[_i_]; _i_++) \ + _p_ = stpcpy(_p_, _appendees_[_i_]); \ + *_p_ = 0; \ + _d_; \ + }) + +char *strstrip(char *s); +char *delete_chars(char *s, const char *bad); +char *truncate_nl(char *s); + +char *ascii_strlower(char *path); + +bool chars_intersect(const char *a, const char *b) _pure_; + +static inline bool _pure_ in_charset(const char *s, const char* charset) { + assert(s); + assert(charset); + return s[strspn(s, charset)] == '\0'; +} + +bool string_has_cc(const char *p, const char *ok) _pure_; + +char *ellipsize_mem(const char *s, size_t old_length_bytes, size_t new_length_columns, unsigned percent); +char *ellipsize(const char *s, size_t length, unsigned percent); + +bool nulstr_contains(const char*nulstr, const char *needle); + +char* strshorten(char *s, size_t l); + +char *strreplace(const char *text, const char *old_string, const char *new_string); + +char *strip_tab_ansi(char **p, size_t *l); + +char *strextend(char **x, ...) _sentinel_; + +char *strrep(const char *s, unsigned n); + +int split_pair(const char *s, const char *sep, char **l, char **r); + +int free_and_strdup(char **p, const char *s); + +/* Normal memmem() requires haystack to be nonnull, which is annoying for zero-length buffers */ +static inline void *memmem_safe(const void *haystack, size_t haystacklen, const void *needle, size_t needlelen) { + + if (needlelen <= 0) + return (void*) haystack; + + if (haystacklen < needlelen) + return NULL; + + assert(haystack); + assert(needle); + + return memmem(haystack, haystacklen, needle, needlelen); +} + +#define memory_erase(p, l) memset((p), 'x', (l)) +void string_erase(char *x); + +char *string_free_erase(char *s); +DEFINE_TRIVIAL_CLEANUP_FUNC(char *, string_free_erase); +#define _cleanup_string_free_erase_ _cleanup_(string_free_erasep) diff --git a/src/basic/strv.c b/src/basic/strv.c index 446d4a5631..f5df269006 100644 --- a/src/basic/strv.c +++ b/src/basic/strv.c @@ -19,12 +19,13 @@ along with systemd; If not, see . ***/ -#include +#include #include +#include #include -#include #include "escape.h" +#include "string-util.h" #include "util.h" #include "strv.h" diff --git a/src/basic/terminal-util.c b/src/basic/terminal-util.c index ca7554a9fa..4723653566 100644 --- a/src/basic/terminal-util.c +++ b/src/basic/terminal-util.c @@ -17,26 +17,27 @@ along with systemd; If not, see . ***/ +#include +#include +#include +#include +#include +#include +#include #include -#include #include +#include #include -#include -#include -#include #include -#include -#include -#include -#include -#include +#include -#include "terminal-util.h" -#include "time-util.h" -#include "process-util.h" -#include "util.h" #include "fileio.h" #include "path-util.h" +#include "process-util.h" +#include "string-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 d4e0914b27..a516d2807b 100644 --- a/src/basic/time-util.c +++ b/src/basic/time-util.c @@ -20,13 +20,14 @@ ***/ #include -#include #include +#include -#include "util.h" -#include "time-util.h" #include "path-util.h" +#include "string-util.h" #include "strv.h" +#include "util.h" +#include "time-util.h" usec_t now(clockid_t clock_id) { struct timespec ts; diff --git a/src/basic/unit-name.c b/src/basic/unit-name.c index a8b6b6dace..383c4ab871 100644 --- a/src/basic/unit-name.c +++ b/src/basic/unit-name.c @@ -22,12 +22,13 @@ #include #include -#include "path-util.h" #include "bus-label.h" -#include "util.h" -#include "unit-name.h" #include "def.h" +#include "path-util.h" +#include "string-util.h" #include "strv.h" +#include "util.h" +#include "unit-name.h" #define VALID_CHARS \ DIGITS LETTERS \ diff --git a/src/basic/util.c b/src/basic/util.c index d6488f8fd6..233a6c2e35 100644 --- a/src/basic/util.c +++ b/src/basic/util.c @@ -94,6 +94,7 @@ #include "random-util.h" #include "signal-util.h" #include "sparse-endian.h" +#include "string-util.h" #include "strv.h" #include "terminal-util.h" #include "utf8.h" @@ -120,101 +121,6 @@ size_t page_size(void) { return pgsz; } -int strcmp_ptr(const char *a, const char *b) { - - /* Like strcmp(), but tries to make sense of NULL pointers */ - if (a && b) - return strcmp(a, b); - - if (!a && b) - return -1; - - if (a && !b) - return 1; - - return 0; -} - -bool streq_ptr(const char *a, const char *b) { - return strcmp_ptr(a, b) == 0; -} - -char* endswith(const char *s, const char *postfix) { - size_t sl, pl; - - assert(s); - assert(postfix); - - sl = strlen(s); - pl = strlen(postfix); - - if (pl == 0) - return (char*) s + sl; - - if (sl < pl) - return NULL; - - if (memcmp(s + sl - pl, postfix, pl) != 0) - return NULL; - - return (char*) s + sl - pl; -} - -char* endswith_no_case(const char *s, const char *postfix) { - size_t sl, pl; - - assert(s); - assert(postfix); - - sl = strlen(s); - pl = strlen(postfix); - - if (pl == 0) - return (char*) s + sl; - - if (sl < pl) - return NULL; - - if (strcasecmp(s + sl - pl, postfix) != 0) - return NULL; - - return (char*) s + sl - pl; -} - -char* first_word(const char *s, const char *word) { - size_t sl, wl; - const char *p; - - assert(s); - assert(word); - - /* Checks if the string starts with the specified word, either - * followed by NUL or by whitespace. Returns a pointer to the - * NUL or the first character after the whitespace. */ - - sl = strlen(s); - wl = strlen(word); - - if (sl < wl) - return NULL; - - if (wl == 0) - return (char*) s; - - if (memcmp(s, word, wl) != 0) - return NULL; - - p = s + wl; - if (*p == 0) - return (char*) p; - - if (!strchr(WHITESPACE, *p)) - return NULL; - - p += strspn(p, WHITESPACE); - return (char*) p; -} - int close_nointr(int fd) { assert(fd >= 0); @@ -553,66 +459,6 @@ int safe_atod(const char *s, double *ret_d) { return 0; } -static size_t strcspn_escaped(const char *s, const char *reject) { - bool escaped = false; - int n; - - for (n=0; s[n]; n++) { - if (escaped) - escaped = false; - else if (s[n] == '\\') - escaped = true; - else if (strchr(reject, s[n])) - break; - } - - /* if s ends in \, return index of previous char */ - return n - escaped; -} - -/* Split a string into words. */ -const char* split(const char **state, size_t *l, const char *separator, bool quoted) { - const char *current; - - current = *state; - - if (!*current) { - assert(**state == '\0'); - return NULL; - } - - current += strspn(current, separator); - if (!*current) { - *state = current; - return NULL; - } - - if (quoted && strchr("\'\"", *current)) { - char quotechars[2] = {*current, '\0'}; - - *l = strcspn_escaped(current + 1, quotechars); - if (current[*l + 1] == '\0' || current[*l + 1] != quotechars[0] || - (current[*l + 2] && !strchr(separator, current[*l + 2]))) { - /* right quote missing or garbage at the end */ - *state = current; - return NULL; - } - *state = current++ + *l + 2; - } else if (quoted) { - *l = strcspn_escaped(current, separator); - if (current[*l] && !strchr(separator, current[*l])) { - /* unfinished escape */ - *state = current; - return NULL; - } - *state = current + *l; - } else { - *l = strcspn(current, separator); - *state = current + *l; - } - - return current; -} int fchmod_umask(int fd, mode_t m) { mode_t u; @@ -625,48 +471,6 @@ int fchmod_umask(int fd, mode_t m) { return r; } -char *truncate_nl(char *s) { - assert(s); - - s[strcspn(s, NEWLINE)] = 0; - return s; -} - -char *strnappend(const char *s, const char *suffix, size_t b) { - size_t a; - char *r; - - if (!s && !suffix) - return strdup(""); - - if (!s) - return strndup(suffix, b); - - if (!suffix) - return strdup(s); - - assert(s); - assert(suffix); - - a = strlen(s); - if (b > ((size_t) -1) - a) - return NULL; - - r = new(char, a+b+1); - if (!r) - return NULL; - - memcpy(r, s, a); - memcpy(r+a, suffix, b); - r[a+b] = 0; - - return r; -} - -char *strappend(const char *s, const char *suffix) { - return strnappend(s, suffix, suffix ? strlen(suffix) : 0); -} - int readlinkat_malloc(int fd, const char *p, char **ret) { size_t l = 100; int r; @@ -769,40 +573,6 @@ int readlink_and_canonicalize(const char *p, char **r) { return 0; } -char *strstrip(char *s) { - char *e; - - /* Drops trailing whitespace. Modifies the string in - * place. Returns pointer to first non-space character */ - - s += strspn(s, WHITESPACE); - - for (e = strchr(s, 0); e > s; e --) - if (!strchr(WHITESPACE, e[-1])) - break; - - *e = 0; - - return s; -} - -char *delete_chars(char *s, const char *bad) { - char *f, *t; - - /* Drops all whitespace, regardless where in the string */ - - for (f = s, t = s; *f; f++) { - if (strchr(bad, *f)) - continue; - - *(t++) = *f; - } - - *t = 0; - - return s; -} - char *file_in_same_dir(const char *path, const char *filename) { char *e, *ret; size_t k; @@ -1504,18 +1274,6 @@ int undecchar(char c) { return -EINVAL; } -char *ascii_strlower(char *t) { - char *p; - - assert(t); - - for (p = t; *p; p++) - if (*p >= 'A' && *p <= 'Z') - *p = *p - 'A' + 'a'; - - return t; -} - _pure_ static bool hidden_file_allow_backup(const char *filename) { assert(filename); @@ -1663,17 +1421,6 @@ int close_all_fds(const int except[], unsigned n_except) { return r; } -bool chars_intersect(const char *a, const char *b) { - const char *p; - - /* Returns true if any of the chars in a are in b. */ - for (p = a; *p; p++) - if (strchr(b, *p)) - return true; - - return false; -} - bool fstype_is_network(const char *fstype) { static const char table[] = "afs\0" @@ -2196,115 +1943,6 @@ int running_in_chroot(void) { return ret == 0; } -static char *ascii_ellipsize_mem(const char *s, size_t old_length, size_t new_length, unsigned percent) { - size_t x; - char *r; - - assert(s); - assert(percent <= 100); - assert(new_length >= 3); - - if (old_length <= 3 || old_length <= new_length) - return strndup(s, old_length); - - r = new0(char, new_length+1); - if (!r) - return NULL; - - x = (new_length * percent) / 100; - - if (x > new_length - 3) - x = new_length - 3; - - memcpy(r, s, x); - r[x] = '.'; - r[x+1] = '.'; - r[x+2] = '.'; - memcpy(r + x + 3, - s + old_length - (new_length - x - 3), - new_length - x - 3); - - return r; -} - -char *ellipsize_mem(const char *s, size_t old_length, size_t new_length, unsigned percent) { - size_t x; - char *e; - const char *i, *j; - unsigned k, len, len2; - - assert(s); - assert(percent <= 100); - assert(new_length >= 3); - - /* if no multibyte characters use ascii_ellipsize_mem for speed */ - if (ascii_is_valid(s)) - return ascii_ellipsize_mem(s, old_length, new_length, percent); - - if (old_length <= 3 || old_length <= new_length) - return strndup(s, old_length); - - x = (new_length * percent) / 100; - - if (x > new_length - 3) - x = new_length - 3; - - k = 0; - for (i = s; k < x && i < s + old_length; i = utf8_next_char(i)) { - int c; - - c = utf8_encoded_to_unichar(i); - if (c < 0) - return NULL; - k += unichar_iswide(c) ? 2 : 1; - } - - if (k > x) /* last character was wide and went over quota */ - x ++; - - for (j = s + old_length; k < new_length && j > i; ) { - int c; - - j = utf8_prev_char(j); - c = utf8_encoded_to_unichar(j); - if (c < 0) - return NULL; - k += unichar_iswide(c) ? 2 : 1; - } - assert(i <= j); - - /* we don't actually need to ellipsize */ - if (i == j) - return memdup(s, old_length + 1); - - /* make space for ellipsis */ - j = utf8_next_char(j); - - len = i - s; - len2 = s + old_length - j; - e = new(char, len + 3 + len2 + 1); - if (!e) - return NULL; - - /* - printf("old_length=%zu new_length=%zu x=%zu len=%u len2=%u k=%u\n", - old_length, new_length, x, len, len2, k); - */ - - memcpy(e, s, len); - e[len] = 0xe2; /* tri-dot ellipsis: … */ - e[len + 1] = 0x80; - e[len + 2] = 0xa6; - - memcpy(e + len + 3, j, len2 + 1); - - return e; -} - -char *ellipsize(const char *s, size_t length, unsigned percent) { - return ellipsize_mem(s, strlen(s), length, percent); -} - int touch_file(const char *path, bool parents, usec_t stamp, uid_t uid, gid_t gid, mode_t mode) { _cleanup_close_ int fd; int r; @@ -2637,32 +2275,10 @@ void execute_directories(const char* const* directories, usec_t timeout, char *a wait_for_terminate_and_warn(name, executor_pid, true); } -bool nulstr_contains(const char*nulstr, const char *needle) { - const char *i; - - if (!nulstr) - return false; - - NULSTR_FOREACH(i, nulstr) - if (streq(i, needle)) - return true; - - return false; -} - bool plymouth_running(void) { return access("/run/plymouth/pid", F_OK) >= 0; } -char* strshorten(char *s, size_t l) { - assert(s); - - if (l < strlen(s)) - s[l] = 0; - - return s; -} - int pipe_eof(int fd) { struct pollfd pollfd = { .fd = fd, @@ -3150,63 +2766,6 @@ int get_files_in_directory(const char *path, char ***list) { return n; } -char *strjoin(const char *x, ...) { - va_list ap; - size_t l; - char *r, *p; - - va_start(ap, x); - - if (x) { - l = strlen(x); - - for (;;) { - const char *t; - size_t n; - - t = va_arg(ap, const char *); - if (!t) - break; - - n = strlen(t); - if (n > ((size_t) -1) - l) { - va_end(ap); - return NULL; - } - - l += n; - } - } else - l = 0; - - va_end(ap); - - r = new(char, l+1); - if (!r) - return NULL; - - if (x) { - p = stpcpy(r, x); - - va_start(ap, x); - - for (;;) { - const char *t; - - t = va_arg(ap, const char *); - if (!t) - break; - - p = stpcpy(p, t); - } - - va_end(ap); - } else - r[0] = 0; - - return r; -} - bool is_main_thread(void) { static thread_local int cached = 0; @@ -3832,29 +3391,6 @@ bool string_is_safe(const char *p) { return true; } -/** - * Check if a string contains control characters. If 'ok' is non-NULL - * it may be a string containing additional CCs to be considered OK. - */ -bool string_has_cc(const char *p, const char *ok) { - const char *t; - - assert(p); - - for (t = p; *t; t++) { - if (ok && strchr(ok, *t)) - continue; - - if (*t > 0 && *t < ' ') - return true; - - if (*t == 127) - return true; - } - - return false; -} - bool path_is_safe(const char *p) { if (isempty(p)) @@ -3976,139 +3512,6 @@ const char *draw_special_char(DrawSpecialChar ch) { return draw_table[!is_locale_utf8()][ch]; } -char *strreplace(const char *text, const char *old_string, const char *new_string) { - const char *f; - char *t, *r; - size_t l, old_len, new_len; - - assert(text); - assert(old_string); - assert(new_string); - - old_len = strlen(old_string); - new_len = strlen(new_string); - - l = strlen(text); - r = new(char, l+1); - if (!r) - return NULL; - - f = text; - t = r; - while (*f) { - char *a; - size_t d, nl; - - if (!startswith(f, old_string)) { - *(t++) = *(f++); - continue; - } - - d = t - r; - nl = l - old_len + new_len; - a = realloc(r, nl + 1); - if (!a) - goto oom; - - l = nl; - r = a; - t = r + d; - - t = stpcpy(t, new_string); - f += old_len; - } - - *t = 0; - return r; - -oom: - free(r); - return NULL; -} - -char *strip_tab_ansi(char **ibuf, size_t *_isz) { - const char *i, *begin = NULL; - enum { - STATE_OTHER, - STATE_ESCAPE, - STATE_BRACKET - } state = STATE_OTHER; - char *obuf = NULL; - size_t osz = 0, isz; - FILE *f; - - assert(ibuf); - assert(*ibuf); - - /* Strips ANSI color and replaces TABs by 8 spaces */ - - isz = _isz ? *_isz : strlen(*ibuf); - - f = open_memstream(&obuf, &osz); - if (!f) - return NULL; - - for (i = *ibuf; i < *ibuf + isz + 1; i++) { - - switch (state) { - - case STATE_OTHER: - if (i >= *ibuf + isz) /* EOT */ - break; - else if (*i == '\x1B') - state = STATE_ESCAPE; - else if (*i == '\t') - fputs(" ", f); - else - fputc(*i, f); - break; - - case STATE_ESCAPE: - if (i >= *ibuf + isz) { /* EOT */ - fputc('\x1B', f); - break; - } else if (*i == '[') { - state = STATE_BRACKET; - begin = i + 1; - } else { - fputc('\x1B', f); - fputc(*i, f); - state = STATE_OTHER; - } - - break; - - case STATE_BRACKET: - - if (i >= *ibuf + isz || /* EOT */ - (!(*i >= '0' && *i <= '9') && *i != ';' && *i != 'm')) { - fputc('\x1B', f); - fputc('[', f); - state = STATE_OTHER; - i = begin-1; - } else if (*i == 'm') - state = STATE_OTHER; - break; - } - } - - if (ferror(f)) { - fclose(f); - free(obuf); - return NULL; - } - - fclose(f); - - free(*ibuf); - *ibuf = obuf; - - if (_isz) - *_isz = osz; - - return obuf; -} - int on_ac_power(void) { bool found_offline = false, found_online = false; _cleanup_closedir_ DIR *d = NULL; @@ -4267,77 +3670,6 @@ int search_and_fopen_nulstr(const char *path, const char *mode, const char *root return search_and_fopen_internal(path, mode, root, s, _f); } -char *strextend(char **x, ...) { - va_list ap; - size_t f, l; - char *r, *p; - - assert(x); - - l = f = *x ? strlen(*x) : 0; - - va_start(ap, x); - for (;;) { - const char *t; - size_t n; - - t = va_arg(ap, const char *); - if (!t) - break; - - n = strlen(t); - if (n > ((size_t) -1) - l) { - va_end(ap); - return NULL; - } - - l += n; - } - va_end(ap); - - r = realloc(*x, l+1); - if (!r) - return NULL; - - p = r + f; - - va_start(ap, x); - for (;;) { - const char *t; - - t = va_arg(ap, const char *); - if (!t) - break; - - p = stpcpy(p, t); - } - va_end(ap); - - *p = 0; - *x = r; - - return r + l; -} - -char *strrep(const char *s, unsigned n) { - size_t l; - char *r, *p; - unsigned i; - - assert(s); - - l = strlen(s); - p = r = malloc(l * n + 1); - if (!r) - return NULL; - - for (i = 0; i < n; i++) - p = stpcpy(p, s); - - *p = 0; - return r; -} - void* greedy_realloc(void **p, size_t *allocated, size_t need, size_t size) { size_t a, newalloc; void *q; @@ -4424,37 +3756,6 @@ bool id128_is_valid(const char *s) { return true; } -int split_pair(const char *s, const char *sep, char **l, char **r) { - char *x, *a, *b; - - assert(s); - assert(sep); - assert(l); - assert(r); - - if (isempty(sep)) - return -EINVAL; - - x = strstr(s, sep); - if (!x) - return -EINVAL; - - a = strndup(s, x - s); - if (!a) - return -ENOMEM; - - b = strdup(x + strlen(sep)); - if (!b) { - free(a); - return -ENOMEM; - } - - *l = a; - *r = b; - - return 0; -} - int shall_restore_state(void) { _cleanup_free_ char *value = NULL; int r; @@ -5407,30 +4708,6 @@ int is_device_node(const char *path) { return !!(S_ISBLK(info.st_mode) || S_ISCHR(info.st_mode)); } -int free_and_strdup(char **p, const char *s) { - char *t; - - assert(p); - - /* Replaces a string pointer with an strdup()ed new string, - * possibly freeing the old one. */ - - if (streq_ptr(*p, s)) - return 0; - - if (s) { - t = strdup(s); - if (!t) - return -ENOMEM; - } else - t = NULL; - - free(*p); - *p = t; - - return 1; -} - ssize_t fgetxattrat_fake(int dirfd, const char *filename, const char *attribute, void *value, size_t size, int flags) { char fn[strlen("/proc/self/fd/") + DECIMAL_STR_MAX(int) + 1]; _cleanup_close_ int fd = -1; @@ -6080,22 +5357,3 @@ bool fdname_is_valid(const char *s) { bool oom_score_adjust_is_valid(int oa) { return oa >= OOM_SCORE_ADJ_MIN && oa <= OOM_SCORE_ADJ_MAX; } - -void string_erase(char *x) { - - if (!x) - return; - - /* A delicious drop of snake-oil! To be called on memory where - * we stored passphrases or so, after we used them. */ - - memory_erase(x, strlen(x)); -} - -char *string_free_erase(char *s) { - if (!s) - return NULL; - - string_erase(s); - return mfree(s); -} diff --git a/src/basic/util.h b/src/basic/util.h index 6674111145..7d1e4e0f62 100644 --- a/src/basic/util.h +++ b/src/basic/util.h @@ -58,14 +58,6 @@ size_t page_size(void) _pure_; #define PAGE_ALIGN(l) ALIGN_TO((l), page_size()) -#define streq(a,b) (strcmp((a),(b)) == 0) -#define strneq(a, b, n) (strncmp((a), (b), (n)) == 0) -#define strcaseeq(a,b) (strcasecmp((a),(b)) == 0) -#define strncaseeq(a, b, n) (strncasecmp((a), (b), (n)) == 0) - -bool streq_ptr(const char *a, const char *b) _pure_; -int strcmp_ptr(const char *a, const char *b) _pure_; - #define new(t, n) ((t*) malloc_multiply(sizeof(t), (n))) #define new0(t, n) ((t*) calloc((n), sizeof(t))) @@ -95,47 +87,6 @@ static inline const char* one_zero(bool b) { return b ? "1" : "0"; } -static inline const char* strempty(const char *s) { - return s ? s : ""; -} - -static inline const char* strnull(const char *s) { - return s ? s : "(null)"; -} - -static inline const char *strna(const char *s) { - return s ? s : "n/a"; -} - -static inline bool isempty(const char *p) { - return !p || !p[0]; -} - -static inline char *startswith(const char *s, const char *prefix) { - size_t l; - - l = strlen(prefix); - if (strncmp(s, prefix, l) == 0) - return (char*) s + l; - - return NULL; -} - -static inline char *startswith_no_case(const char *s, const char *prefix) { - size_t l; - - l = strlen(prefix); - if (strncasecmp(s, prefix, l) == 0) - return (char*) s + l; - - return NULL; -} - -char *endswith(const char *s, const char *postfix) _pure_; -char *endswith_no_case(const char *s, const char *postfix) _pure_; - -char *first_word(const char *s, const char *word) _pure_; - int close_nointr(int fd); int safe_close(int fd); void safe_close_pair(int p[]); @@ -212,33 +163,12 @@ static inline int safe_atoi64(const char *s, int64_t *ret_i) { int safe_atou16(const char *s, uint16_t *ret); int safe_atoi16(const char *s, int16_t *ret); -const char* split(const char **state, size_t *l, const char *separator, bool quoted); - -#define FOREACH_WORD(word, length, s, state) \ - _FOREACH_WORD(word, length, s, WHITESPACE, false, state) - -#define FOREACH_WORD_SEPARATOR(word, length, s, separator, state) \ - _FOREACH_WORD(word, length, s, separator, false, state) - -#define FOREACH_WORD_QUOTED(word, length, s, state) \ - _FOREACH_WORD(word, length, s, WHITESPACE, true, state) - -#define _FOREACH_WORD(word, length, s, separator, quoted, state) \ - for ((state) = (s), (word) = split(&(state), &(length), (separator), (quoted)); (word); (word) = split(&(state), &(length), (separator), (quoted))) - -char *strappend(const char *s, const char *suffix); -char *strnappend(const char *s, const char *suffix, size_t length); - int readlinkat_malloc(int fd, const char *p, char **ret); int readlink_malloc(const char *p, char **r); int readlink_value(const char *p, char **ret); int readlink_and_make_absolute(const char *p, char **r); int readlink_and_canonicalize(const char *p, char **r); -char *strstrip(char *s); -char *delete_chars(char *s, const char *bad); -char *truncate_nl(char *s); - char *file_in_same_dir(const char *path, const char *filename); int rmdir_parents(const char *path, const char *stop); @@ -254,15 +184,11 @@ int unbase32hexchar(char c) _const_; char base64char(int x) _const_; int unbase64char(char c) _const_; -char *ascii_strlower(char *path); - bool dirent_is_file(const struct dirent *de) _pure_; bool dirent_is_file_with_suffix(const struct dirent *de, const char *suffix) _pure_; bool hidden_file(const char *filename) _pure_; -bool chars_intersect(const char *a, const char *b) _pure_; - /* For basic lookup tables with strictly enumerated entries */ #define _DEFINE_STRING_TABLE_LOOKUP_TO_STRING(name,type,scope) \ scope const char *name##_to_string(type i) { \ @@ -373,10 +299,6 @@ int files_same(const char *filea, const char *fileb); int running_in_chroot(void); -char *ellipsize(const char *s, size_t length, unsigned percent); - /* bytes columns */ -char *ellipsize_mem(const char *s, size_t old_length, size_t new_length, unsigned percent); - int touch_file(const char *path, bool parents, usec_t stamp, uid_t uid, gid_t gid, mode_t mode); int touch(const char *path); @@ -392,12 +314,8 @@ char *fstab_node_to_udev_node(const char *p); void execute_directories(const char* const* directories, usec_t timeout, char *argv[]); -bool nulstr_contains(const char*nulstr, const char *needle); - bool plymouth_running(void); -char* strshorten(char *s, size_t l); - int symlink_idempotent(const char *from, const char *to); int symlink_atomic(const char *from, const char *to); @@ -425,16 +343,8 @@ int dirent_ensure_type(DIR *d, struct dirent *de); int get_files_in_directory(const char *path, char ***list); -char *strjoin(const char *x, ...) _sentinel_; - bool is_main_thread(void); -static inline bool _pure_ in_charset(const char *s, const char* charset) { - assert(s); - assert(charset); - return s[strspn(s, charset)] == '\0'; -} - int block_get_whole_disk(dev_t d, dev_t *ret); #define NULSTR_FOREACH(i, l) \ @@ -554,7 +464,6 @@ _alloc_(2, 3) static inline void *memdup_multiply(const void *p, size_t a, size_ bool filename_is_valid(const char *p) _pure_; bool path_is_safe(const char *p) _pure_; bool string_is_safe(const char *p) _pure_; -bool string_has_cc(const char *p, const char *ok) _pure_; /** * Check if a string contains any glob patterns. @@ -586,10 +495,6 @@ typedef enum DrawSpecialChar { const char *draw_special_char(DrawSpecialChar ch); -char *strreplace(const char *text, const char *old_string, const char *new_string); - -char *strip_tab_ansi(char **p, size_t *l); - int on_ac_power(void); int search_and_fopen(const char *path, const char *mode, const char *root, const char **search, FILE **_f); @@ -638,9 +543,6 @@ int unbase32hexmem(const char *p, size_t l, bool padding, void **mem, size_t *le char *base64mem(const void *p, size_t l); int unbase64mem(const char *p, size_t l, void **mem, size_t *len); -char *strextend(char **x, ...) _sentinel_; -char *strrep(const char *s, unsigned n); - void* greedy_realloc(void **p, size_t *allocated, size_t need, size_t size); void* greedy_realloc0(void **p, size_t *allocated, size_t need, size_t size); #define GREEDY_REALLOC(array, allocated, need) \ @@ -755,25 +657,8 @@ int unlink_noerrno(const char *path); (void*)memset(_new_, 0, _size_); \ }) -#define strjoina(a, ...) \ - ({ \ - const char *_appendees_[] = { a, __VA_ARGS__ }; \ - char *_d_, *_p_; \ - int _len_ = 0; \ - unsigned _i_; \ - for (_i_ = 0; _i_ < ELEMENTSOF(_appendees_) && _appendees_[_i_]; _i_++) \ - _len_ += strlen(_appendees_[_i_]); \ - _p_ = _d_ = alloca(_len_ + 1); \ - for (_i_ = 0; _i_ < ELEMENTSOF(_appendees_) && _appendees_[_i_]; _i_++) \ - _p_ = stpcpy(_p_, _appendees_[_i_]); \ - *_p_ = 0; \ - _d_; \ - }) - bool id128_is_valid(const char *s) _pure_; -int split_pair(const char *s, const char *sep, char **l, char **r); - int shall_restore_state(void); /** @@ -788,21 +673,6 @@ static inline void qsort_safe(void *base, size_t nmemb, size_t size, comparison_ qsort(base, nmemb, size, compar); } -/* Normal memmem() requires haystack to be nonnull, which is annoying for zero-length buffers */ -static inline void *memmem_safe(const void *haystack, size_t haystacklen, const void *needle, size_t needlelen) { - - if (needlelen <= 0) - return (void*) haystack; - - if (haystacklen < needlelen) - return NULL; - - assert(haystack); - assert(needle); - - return memmem(haystack, haystacklen, needle, needlelen); -} - int proc_cmdline(char **ret); int parse_proc_cmdline(int (*parse_word)(const char *key, const char *value)); int get_proc_cmdline_key(const char *parameter, char **value); @@ -860,8 +730,6 @@ int is_symlink(const char *path); int is_dir(const char *path, bool follow); int is_device_node(const char *path); -int free_and_strdup(char **p, const char *s); - #define INOTIFY_EVENT_MAX (sizeof(struct inotify_event) + NAME_MAX + 1) #define FOREACH_INOTIFY_EVENT(e, buffer, sz) \ @@ -923,10 +791,3 @@ int version(void); bool fdname_is_valid(const char *s); bool oom_score_adjust_is_valid(int oa); - -#define memory_erase(p, l) memset((p), 'x', (l)) -void string_erase(char *x); - -char *string_free_erase(char *s); -DEFINE_TRIVIAL_CLEANUP_FUNC(char *, string_free_erase); -#define _cleanup_string_free_erase_ _cleanup_(string_free_erasep) diff --git a/src/basic/verbs.c b/src/basic/verbs.c index c7beccc2dc..d63062d39e 100644 --- a/src/basic/verbs.c +++ b/src/basic/verbs.c @@ -19,6 +19,7 @@ along with systemd; If not, see . ***/ +#include "string-util.h" #include "util.h" #include "verbs.h" diff --git a/src/basic/virt.c b/src/basic/virt.c index 70543177b6..9267a2730b 100644 --- a/src/basic/virt.c +++ b/src/basic/virt.c @@ -19,14 +19,15 @@ along with systemd; If not, see . ***/ -#include #include +#include #include -#include "util.h" +#include "fileio.h" #include "process-util.h" +#include "string-util.h" +#include "util.h" #include "virt.h" -#include "fileio.h" static int detect_vm_cpuid(void) { diff --git a/src/basic/xml.c b/src/basic/xml.c index 15c629b188..8126bce212 100644 --- a/src/basic/xml.c +++ b/src/basic/xml.c @@ -21,6 +21,7 @@ #include +#include "string-util.h" #include "util.h" #include "xml.h" diff --git a/src/binfmt/binfmt.c b/src/binfmt/binfmt.c index ddb5c88806..ca3f26a66f 100644 --- a/src/binfmt/binfmt.c +++ b/src/binfmt/binfmt.c @@ -30,6 +30,7 @@ #include "conf-files.h" #include "fileio.h" #include "log.h" +#include "string-util.h" #include "strv.h" #include "util.h" diff --git a/src/boot/bootctl.c b/src/boot/bootctl.c index f991e30cfa..1016890768 100644 --- a/src/boot/bootctl.c +++ b/src/boot/bootctl.c @@ -40,6 +40,7 @@ #include "blkid-util.h" #include "efivars.h" #include "rm-rf.h" +#include "string-util.h" #include "util.h" static int verify_esp(const char *p, uint32_t *part, uint64_t *pstart, uint64_t *psize, sd_id128_t *uuid) { diff --git a/src/bootchart/bootchart.c b/src/bootchart/bootchart.c index 83ad90c222..7842e0766d 100644 --- a/src/bootchart/bootchart.c +++ b/src/bootchart/bootchart.c @@ -33,30 +33,32 @@ ***/ -#include -#include +#include +#include +#include +#include #include +#include +#include #include #include -#include +#include #include -#include -#include -#include -#include -#include -#include "systemd/sd-journal.h" +#include -#include "util.h" +#include "sd-journal.h" + +#include "bootchart.h" +#include "conf-parser.h" #include "fileio.h" +#include "list.h" #include "macro.h" -#include "conf-parser.h" -#include "strxcpyx.h" #include "path-util.h" #include "store.h" +#include "string-util.h" +#include "strxcpyx.h" #include "svg.h" -#include "bootchart.h" -#include "list.h" +#include "util.h" static int exiting = 0; diff --git a/src/bootchart/store.c b/src/bootchart/store.c index caa97b97fc..f3f55781ad 100644 --- a/src/bootchart/store.c +++ b/src/bootchart/store.c @@ -22,22 +22,23 @@ along with systemd; If not, see . ***/ -#include -#include +#include +#include #include #include +#include #include -#include -#include #include +#include -#include "util.h" -#include "time-util.h" -#include "strxcpyx.h" -#include "store.h" #include "bootchart.h" #include "cgroup-util.h" #include "fileio.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/bus-proxyd/bus-proxyd.c b/src/bus-proxyd/bus-proxyd.c index 64d1c5231f..e558578bd0 100644 --- a/src/bus-proxyd/bus-proxyd.c +++ b/src/bus-proxyd/bus-proxyd.c @@ -40,6 +40,7 @@ #include "formats-util.h" #include "log.h" #include "proxy.h" +#include "string-util.h" #include "strv.h" #include "util.h" diff --git a/src/bus-proxyd/bus-xml-policy.c b/src/bus-proxyd/bus-xml-policy.c index 91717653c2..c5a1e09cf8 100644 --- a/src/bus-proxyd/bus-xml-policy.c +++ b/src/bus-proxyd/bus-xml-policy.c @@ -19,15 +19,17 @@ along with systemd; If not, see . ***/ -#include "xml.h" +#include "sd-login.h" + +#include "bus-internal.h" +#include "conf-files.h" #include "fileio.h" -#include "strv.h" +#include "formats-util.h" #include "set.h" -#include "conf-files.h" -#include "bus-internal.h" +#include "string-util.h" +#include "strv.h" +#include "xml.h" #include "bus-xml-policy.h" -#include "sd-login.h" -#include "formats-util.h" static void policy_item_free(PolicyItem *i) { assert(i); diff --git a/src/bus-proxyd/driver.c b/src/bus-proxyd/driver.c index fa4aee691a..4e859412f8 100644 --- a/src/bus-proxyd/driver.c +++ b/src/bus-proxyd/driver.c @@ -21,21 +21,22 @@ along with systemd; If not, see . ***/ -#include #include #include +#include -#include "util.h" #include "sd-bus.h" + #include "bus-internal.h" #include "bus-message.h" #include "bus-util.h" -#include "strv.h" -#include "set.h" #include "driver.h" +#include "env-util.h" #include "proxy.h" +#include "set.h" +#include "strv.h" #include "synthesize.h" -#include "env-util.h" +#include "util.h" static int get_creds_by_name(sd_bus *bus, const char *name, uint64_t mask, sd_bus_creds **_creds, sd_bus_error *error) { _cleanup_bus_creds_unref_ sd_bus_creds *c = NULL; diff --git a/src/bus-proxyd/proxy.h b/src/bus-proxyd/proxy.h index 6aac650ac9..7b2e5d422f 100644 --- a/src/bus-proxyd/proxy.h +++ b/src/bus-proxyd/proxy.h @@ -22,6 +22,7 @@ ***/ #include "sd-bus.h" + #include "bus-xml-policy.h" typedef struct Proxy Proxy; diff --git a/src/bus-proxyd/synthesize.c b/src/bus-proxyd/synthesize.c index 15d99103f6..7f1f9dc28d 100644 --- a/src/bus-proxyd/synthesize.c +++ b/src/bus-proxyd/synthesize.c @@ -23,13 +23,14 @@ #include -#include "util.h" #include "sd-bus.h" + #include "bus-internal.h" +#include "bus-match.h" #include "bus-message.h" #include "bus-util.h" -#include "bus-match.h" #include "synthesize.h" +#include "util.h" int synthetic_driver_send(sd_bus *b, sd_bus_message *m) { int r; diff --git a/src/bus-proxyd/synthesize.h b/src/bus-proxyd/synthesize.h index b596daddf2..ddfe2fd266 100644 --- a/src/bus-proxyd/synthesize.h +++ b/src/bus-proxyd/synthesize.h @@ -22,6 +22,7 @@ ***/ #include "sd-bus.h" + #include "proxy.h" int synthetic_driver_send(sd_bus *b, sd_bus_message *m); diff --git a/src/bus-proxyd/test-bus-xml-policy.c b/src/bus-proxyd/test-bus-xml-policy.c index d19d0e1b60..cb7ff6b970 100644 --- a/src/bus-proxyd/test-bus-xml-policy.c +++ b/src/bus-proxyd/test-bus-xml-policy.c @@ -19,15 +19,17 @@ along with systemd; If not, see . ***/ -#include #include #include +#include -#include "log.h" -#include "util.h" #include "sd-bus.h" -#include "strv.h" + #include "bus-xml-policy.h" +#include "log.h" +#include "string-util.h" +#include "strv.h" +#include "util.h" static int test_policy_load(Policy *p, const char *name) { _cleanup_free_ char *path = NULL; diff --git a/src/cgroups-agent/cgroups-agent.c b/src/cgroups-agent/cgroups-agent.c index b79519dd09..e48234f075 100644 --- a/src/cgroups-agent/cgroups-agent.c +++ b/src/cgroups-agent/cgroups-agent.c @@ -22,8 +22,9 @@ #include #include "sd-bus.h" -#include "log.h" + #include "bus-util.h" +#include "log.h" int main(int argc, char *argv[]) { _cleanup_bus_flush_close_unref_ sd_bus *bus = NULL; diff --git a/src/core/automount.c b/src/core/automount.c index e0535ec201..1995bb8b7d 100644 --- a/src/core/automount.c +++ b/src/core/automount.c @@ -20,29 +20,30 @@ ***/ #include -#include -#include -#include #include +#include +#include +#include #include +#include #include -#include -#include +#include -#include "unit.h" -#include "automount.h" -#include "mount.h" -#include "unit-name.h" -#include "special.h" +#include "async.h" +#include "bus-error.h" +#include "bus-util.h" +#include "dbus-automount.h" +#include "formats-util.h" #include "label.h" #include "mkdir.h" +#include "mount.h" #include "path-util.h" -#include "dbus-automount.h" -#include "bus-util.h" -#include "bus-error.h" -#include "formats-util.h" #include "process-util.h" -#include "async.h" +#include "special.h" +#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 b85fce5f8d..a7cb56dcbf 100644 --- a/src/core/busname.c +++ b/src/core/busname.c @@ -21,16 +21,17 @@ #include -#include "special.h" -#include "formats-util.h" -#include "signal-util.h" -#include "bus-kernel.h" #include "bus-internal.h" +#include "bus-kernel.h" +#include "bus-policy.h" #include "bus-util.h" +#include "dbus-busname.h" +#include "formats-util.h" #include "kdbus.h" -#include "bus-policy.h" #include "service.h" -#include "dbus-busname.h" +#include "signal-util.h" +#include "special.h" +#include "string-util.h" #include "busname.h" static const UnitActiveState state_translation_table[_BUSNAME_STATE_MAX] = { diff --git a/src/core/busname.h b/src/core/busname.h index 1bc3290596..46f7b6f097 100644 --- a/src/core/busname.h +++ b/src/core/busname.h @@ -24,6 +24,8 @@ typedef struct BusName BusName; typedef struct BusNamePolicy BusNamePolicy; +#include "unit.h" + typedef enum BusNameResult { BUSNAME_SUCCESS, BUSNAME_FAILURE_RESOURCES, diff --git a/src/core/cgroup.c b/src/core/cgroup.c index 0c790c33da..73e58f867c 100644 --- a/src/core/cgroup.c +++ b/src/core/cgroup.c @@ -26,7 +26,7 @@ #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-automount.c b/src/core/dbus-automount.c index 5162ce34cb..45f2c2ffd6 100644 --- a/src/core/dbus-automount.c +++ b/src/core/dbus-automount.c @@ -20,8 +20,9 @@ ***/ #include "automount.h" -#include "dbus-automount.h" #include "bus-util.h" +#include "string-util.h" +#include "dbus-automount.h" static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_result, automount_result, AutomountResult); diff --git a/src/core/dbus-busname.c b/src/core/dbus-busname.c index b1ceb05b1a..05ac89c3c0 100644 --- a/src/core/dbus-busname.c +++ b/src/core/dbus-busname.c @@ -19,10 +19,11 @@ along with systemd; If not, see . ***/ -#include "unit.h" +#include "bus-util.h" #include "busname.h" +#include "string-util.h" +#include "unit.h" #include "dbus-busname.h" -#include "bus-util.h" static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_result, busname_result, BusNameResult); diff --git a/src/core/dbus-cgroup.h b/src/core/dbus-cgroup.h index c2a3910f3d..9dc187c066 100644 --- a/src/core/dbus-cgroup.h +++ b/src/core/dbus-cgroup.h @@ -22,6 +22,7 @@ ***/ #include "sd-bus.h" + #include "cgroup.h" extern const sd_bus_vtable bus_cgroup_vtable[]; diff --git a/src/core/dbus-execute.h b/src/core/dbus-execute.h index e4c2d5ddf6..c44517ea22 100644 --- a/src/core/dbus-execute.h +++ b/src/core/dbus-execute.h @@ -22,6 +22,7 @@ ***/ #include "sd-bus.h" + #include "execute.h" #define BUS_EXEC_STATUS_VTABLE(prefix, offset, flags) \ diff --git a/src/core/dbus-job.c b/src/core/dbus-job.c index cd6b909426..e95ec5c0cb 100644 --- a/src/core/dbus-job.c +++ b/src/core/dbus-job.c @@ -19,12 +19,14 @@ along with systemd; If not, see . ***/ -#include "log.h" #include "sd-bus.h" -#include "selinux-access.h" + +#include "dbus.h" #include "job.h" +#include "log.h" +#include "selinux-access.h" +#include "string-util.h" #include "dbus-job.h" -#include "dbus.h" static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_type, job_type, JobType); static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_state, job_state, JobState); diff --git a/src/core/dbus-job.h b/src/core/dbus-job.h index fb5f1b513e..0f2fbe2ee2 100644 --- a/src/core/dbus-job.h +++ b/src/core/dbus-job.h @@ -22,6 +22,7 @@ ***/ #include "sd-bus.h" + #include "job.h" extern const sd_bus_vtable bus_job_vtable[]; diff --git a/src/core/dbus-kill.h b/src/core/dbus-kill.h index 7c15f3a90b..794c402048 100644 --- a/src/core/dbus-kill.h +++ b/src/core/dbus-kill.h @@ -22,6 +22,7 @@ ***/ #include "sd-bus.h" + #include "unit.h" #include "kill.h" diff --git a/src/core/dbus-manager.c b/src/core/dbus-manager.c index 00bb391106..3cd4467efe 100644 --- a/src/core/dbus-manager.c +++ b/src/core/dbus-manager.c @@ -23,25 +23,26 @@ #include #include -#include "log.h" -#include "strv.h" +#include "architecture.h" #include "build.h" -#include "install.h" -#include "selinux-access.h" -#include "watchdog.h" +#include "bus-common-errors.h" #include "clock-util.h" -#include "path-util.h" -#include "virt.h" -#include "architecture.h" -#include "env-util.h" -#include "dbus.h" +#include "dbus-execute.h" #include "dbus-job.h" -#include "dbus-manager.h" -#include "dbus-unit.h" #include "dbus-snapshot.h" -#include "dbus-execute.h" -#include "bus-common-errors.h" +#include "dbus-unit.h" +#include "dbus.h" +#include "env-util.h" #include "formats-util.h" +#include "install.h" +#include "log.h" +#include "path-util.h" +#include "selinux-access.h" +#include "string-util.h" +#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-mount.c b/src/core/dbus-mount.c index dbee7fc908..318e81abd6 100644 --- a/src/core/dbus-mount.c +++ b/src/core/dbus-mount.c @@ -19,13 +19,14 @@ along with systemd; If not, see . ***/ -#include "unit.h" -#include "mount.h" +#include "bus-util.h" +#include "dbus-cgroup.h" #include "dbus-execute.h" #include "dbus-kill.h" -#include "dbus-cgroup.h" +#include "mount.h" +#include "string-util.h" +#include "unit.h" #include "dbus-mount.h" -#include "bus-util.h" static int property_get_what( sd_bus *bus, diff --git a/src/core/dbus-mount.h b/src/core/dbus-mount.h index f7004d252f..dd0bf51bb0 100644 --- a/src/core/dbus-mount.h +++ b/src/core/dbus-mount.h @@ -22,6 +22,7 @@ ***/ #include "sd-bus.h" + #include "unit.h" extern const sd_bus_vtable bus_mount_vtable[]; diff --git a/src/core/dbus-path.c b/src/core/dbus-path.c index 683561999b..9e32b5fb06 100644 --- a/src/core/dbus-path.c +++ b/src/core/dbus-path.c @@ -19,10 +19,11 @@ along with systemd; If not, see . ***/ -#include "unit.h" +#include "bus-util.h" #include "path.h" +#include "string-util.h" +#include "unit.h" #include "dbus-path.h" -#include "bus-util.h" static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_result, path_result, PathResult); diff --git a/src/core/dbus-service.c b/src/core/dbus-service.c index fe2a4a3b37..0062f1f7f0 100644 --- a/src/core/dbus-service.c +++ b/src/core/dbus-service.c @@ -20,15 +20,16 @@ ***/ #include "async.h" -#include "strv.h" -#include "path-util.h" -#include "unit.h" -#include "service.h" +#include "bus-util.h" +#include "dbus-cgroup.h" #include "dbus-execute.h" #include "dbus-kill.h" -#include "dbus-cgroup.h" +#include "path-util.h" +#include "service.h" +#include "string-util.h" +#include "strv.h" +#include "unit.h" #include "dbus-service.h" -#include "bus-util.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-socket.c b/src/core/dbus-socket.c index 7444649f8b..5941b72bc0 100644 --- a/src/core/dbus-socket.c +++ b/src/core/dbus-socket.c @@ -19,12 +19,13 @@ along with systemd; If not, see . ***/ -#include "unit.h" -#include "socket.h" -#include "dbus-execute.h" +#include "bus-util.h" #include "dbus-cgroup.h" +#include "dbus-execute.h" +#include "socket.h" +#include "string-util.h" +#include "unit.h" #include "dbus-socket.h" -#include "bus-util.h" static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_result, socket_result, SocketResult); static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_bind_ipv6_only, socket_address_bind_ipv6_only, SocketAddressBindIPv6Only); diff --git a/src/core/dbus-swap.c b/src/core/dbus-swap.c index 0093371306..603ca95fd9 100644 --- a/src/core/dbus-swap.c +++ b/src/core/dbus-swap.c @@ -20,12 +20,13 @@ along with systemd; If not, see . ***/ -#include "unit.h" -#include "swap.h" -#include "dbus-execute.h" +#include "bus-util.h" #include "dbus-cgroup.h" +#include "dbus-execute.h" +#include "string-util.h" +#include "swap.h" +#include "unit.h" #include "dbus-swap.h" -#include "bus-util.h" static int property_get_priority( sd_bus *bus, diff --git a/src/core/dbus-target.h b/src/core/dbus-target.h index 4c4297bc9e..6be9c9f708 100644 --- a/src/core/dbus-target.h +++ b/src/core/dbus-target.h @@ -21,5 +21,6 @@ along with systemd; If not, see . ***/ +#include "sd-bus.h" extern const sd_bus_vtable bus_target_vtable[]; diff --git a/src/core/dbus-unit.c b/src/core/dbus-unit.c index 52daf11610..b2b9eceeb3 100644 --- a/src/core/dbus-unit.c +++ b/src/core/dbus-unit.c @@ -20,13 +20,15 @@ ***/ #include "sd-bus.h" + +#include "bus-common-errors.h" +#include "cgroup-util.h" +#include "dbus.h" #include "log.h" #include "selinux-access.h" -#include "cgroup-util.h" -#include "strv.h" -#include "bus-common-errors.h" #include "special.h" -#include "dbus.h" +#include "string-util.h" +#include "strv.h" #include "dbus-unit.h" static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_load_state, unit_load_state, UnitLoadState); diff --git a/src/core/dbus.c b/src/core/dbus.c index d8891d49d8..5f27ec4952 100644 --- a/src/core/dbus.c +++ b/src/core/dbus.c @@ -19,29 +19,31 @@ along with systemd; If not, see . ***/ -#include #include +#include #include #include "sd-bus.h" -#include "log.h" -#include "strv.h" -#include "mkdir.h" -#include "missing.h" -#include "dbus-unit.h" -#include "dbus-job.h" -#include "dbus-manager.h" + +#include "bus-common-errors.h" +#include "bus-error.h" +#include "bus-internal.h" +#include "bus-util.h" +#include "dbus-cgroup.h" #include "dbus-execute.h" +#include "dbus-job.h" #include "dbus-kill.h" -#include "dbus-cgroup.h" +#include "dbus-manager.h" +#include "dbus-unit.h" +#include "log.h" +#include "missing.h" +#include "mkdir.h" +#include "selinux-access.h" #include "special.h" -#include "dbus.h" -#include "bus-util.h" -#include "bus-error.h" -#include "bus-common-errors.h" +#include "string-util.h" +#include "strv.h" #include "strxcpyx.h" -#include "bus-internal.h" -#include "selinux-access.h" +#include "dbus.h" #define CONNECTIONS_MAX 4096 diff --git a/src/core/device.c b/src/core/device.c index a819ab8d4e..9127d2d225 100644 --- a/src/core/device.c +++ b/src/core/device.c @@ -21,15 +21,17 @@ #include #include -#include -#include "log.h" -#include "unit-name.h" +#include "libudev.h" + #include "dbus-device.h" +#include "log.h" #include "path-util.h" +#include "string-util.h" +#include "swap.h" #include "udev-util.h" +#include "unit-name.h" #include "unit.h" -#include "swap.h" #include "device.h" static const UnitActiveState state_translation_table[_DEVICE_STATE_MAX] = { diff --git a/src/core/execute.c b/src/core/execute.c index 51efb7c215..a99e636d86 100644 --- a/src/core/execute.c +++ b/src/core/execute.c @@ -77,6 +77,7 @@ #include "selinux-util.h" #include "signal-util.h" #include "smack-util.h" +#include "string-util.h" #include "strv.h" #include "terminal-util.h" #include "unit.h" diff --git a/src/core/hostname-setup.c b/src/core/hostname-setup.c index 932ddbf95a..f1563afff9 100644 --- a/src/core/hostname-setup.c +++ b/src/core/hostname-setup.c @@ -19,15 +19,16 @@ along with systemd; If not, see . ***/ -#include #include +#include #include -#include "macro.h" -#include "util.h" -#include "log.h" #include "fileio.h" #include "hostname-util.h" +#include "log.h" +#include "macro.h" +#include "string-util.h" +#include "util.h" #include "hostname-setup.h" int hostname_setup(void) { diff --git a/src/core/job.c b/src/core/job.c index 13a4e44ec7..8a0e0a0ea4 100644 --- a/src/core/job.c +++ b/src/core/job.c @@ -32,6 +32,7 @@ #include "macro.h" #include "set.h" #include "special.h" +#include "string-util.h" #include "strv.h" #include "terminal-util.h" #include "unit.h" diff --git a/src/core/job.h b/src/core/job.h index 1d1b10f1d3..350e9f385f 100644 --- a/src/core/job.h +++ b/src/core/job.h @@ -23,6 +23,10 @@ #include +#include "sd-event.h" + +#include "list.h" + typedef struct Job Job; typedef struct JobDependency JobDependency; typedef enum JobType JobType; @@ -105,9 +109,7 @@ enum JobResult { _JOB_RESULT_INVALID = -1 }; -#include "sd-event.h" #include "unit.h" -#include "list.h" struct JobDependency { /* Encodes that the 'subject' job needs the 'object' job in diff --git a/src/core/killall.c b/src/core/killall.c index ee5d388560..6857b0bbf9 100644 --- a/src/core/killall.c +++ b/src/core/killall.c @@ -19,17 +19,18 @@ along with systemd; If not, see . ***/ -#include -#include #include +#include +#include #include -#include "util.h" -#include "killall.h" -#include "set.h" #include "formats-util.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 ae85da25ac..3212ed24d2 100644 --- a/src/core/load-fragment.c +++ b/src/core/load-fragment.c @@ -52,6 +52,7 @@ #endif #include "securebits.h" #include "signal-util.h" +#include "string-util.h" #include "strv.h" #include "unit-name.h" #include "unit-printf.h" diff --git a/src/core/locale-setup.c b/src/core/locale-setup.c index 6961c26674..bd632131b9 100644 --- a/src/core/locale-setup.c +++ b/src/core/locale-setup.c @@ -19,16 +19,17 @@ along with systemd; If not, see . ***/ -#include #include +#include -#include "locale-setup.h" -#include "util.h" -#include "virt.h" -#include "fileio.h" -#include "strv.h" #include "env-util.h" +#include "fileio.h" #include "locale-util.h" +#include "string-util.h" +#include "strv.h" +#include "util.h" +#include "virt.h" +#include "locale-setup.h" int locale_setup(char ***environment) { char **add; diff --git a/src/core/loopback-setup.c b/src/core/loopback-setup.c index 4503fc9dcc..4a57793104 100644 --- a/src/core/loopback-setup.c +++ b/src/core/loopback-setup.c @@ -23,9 +23,10 @@ #include #include "sd-netlink.h" -#include "netlink-util.h" -#include "missing.h" + #include "loopback-setup.h" +#include "missing.h" +#include "netlink-util.h" static int start_loopback(sd_netlink *rtnl) { _cleanup_netlink_message_unref_ sd_netlink_message *req = NULL; diff --git a/src/core/machine-id-setup.c b/src/core/machine-id-setup.c index 363ffaaf05..caa5f3717a 100644 --- a/src/core/machine-id-setup.c +++ b/src/core/machine-id-setup.c @@ -35,6 +35,7 @@ #include "mkdir.h" #include "path-util.h" #include "process-util.h" +#include "string-util.h" #include "util.h" #include "virt.h" #include "machine-id-setup.h" diff --git a/src/core/manager.c b/src/core/manager.c index d1955a9701..2d30340828 100644 --- a/src/core/manager.c +++ b/src/core/manager.c @@ -66,6 +66,7 @@ #include "rm-rf.h" #include "signal-util.h" #include "special.h" +#include "string-util.h" #include "strv.h" #include "terminal-util.h" #include "time-util.h" diff --git a/src/core/mount.c b/src/core/mount.c index d6da99ecb9..47dd680b93 100644 --- a/src/core/mount.c +++ b/src/core/mount.c @@ -39,6 +39,7 @@ #include "path-util.h" #include "smack-util.h" #include "special.h" +#include "string-util.h" #include "strv.h" #include "unit-name.h" #include "unit.h" diff --git a/src/core/namespace.c b/src/core/namespace.c index 2b8b707df5..6806fc27e6 100644 --- a/src/core/namespace.c +++ b/src/core/namespace.c @@ -20,23 +20,24 @@ ***/ #include -#include -#include +#include #include -#include +#include +#include #include -#include +#include #include -#include "strv.h" -#include "util.h" -#include "path-util.h" -#include "missing.h" -#include "loopback-setup.h" #include "dev-setup.h" +#include "loopback-setup.h" +#include "missing.h" +#include "mkdir.h" +#include "path-util.h" #include "selinux-util.h" +#include "string-util.h" +#include "strv.h" +#include "util.h" #include "namespace.h" -#include "mkdir.h" typedef enum MountMode { /* This is ordered by priority! */ diff --git a/src/core/path.c b/src/core/path.c index 081ac2040d..4d276a79db 100644 --- a/src/core/path.c +++ b/src/core/path.c @@ -19,20 +19,21 @@ along with systemd; If not, see . ***/ -#include -#include #include +#include +#include #include -#include "unit.h" -#include "unit-name.h" -#include "path.h" -#include "mkdir.h" +#include "bus-error.h" +#include "bus-util.h" #include "dbus-path.h" -#include "special.h" #include "macro.h" -#include "bus-util.h" -#include "bus-error.h" +#include "mkdir.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/scope.c b/src/core/scope.c index ea7d846578..9f72851382 100644 --- a/src/core/scope.c +++ b/src/core/scope.c @@ -22,14 +22,15 @@ #include #include +#include "dbus-scope.h" +#include "load-dropin.h" #include "log.h" -#include "strv.h" #include "special.h" +#include "string-util.h" +#include "strv.h" #include "unit-name.h" #include "unit.h" #include "scope.h" -#include "dbus-scope.h" -#include "load-dropin.h" static const UnitActiveState state_translation_table[_SCOPE_STATE_MAX] = { [SCOPE_DEAD] = UNIT_INACTIVE, diff --git a/src/core/selinux-setup.c b/src/core/selinux-setup.c index ff1ea23528..d9b00fb95c 100644 --- a/src/core/selinux-setup.c +++ b/src/core/selinux-setup.c @@ -19,19 +19,20 @@ along with systemd; If not, see . ***/ -#include -#include #include +#include +#include #ifdef HAVE_SELINUX #include #endif -#include "selinux-setup.h" -#include "selinux-util.h" +#include "log.h" #include "macro.h" +#include "selinux-util.h" +#include "string-util.h" #include "util.h" -#include "log.h" +#include "selinux-setup.h" #ifdef HAVE_SELINUX _printf_(2,3) diff --git a/src/core/service.c b/src/core/service.c index 29be0928d3..042ce5d54d 100644 --- a/src/core/service.c +++ b/src/core/service.c @@ -42,6 +42,7 @@ #include "process-util.h" #include "signal-util.h" #include "special.h" +#include "string-util.h" #include "strv.h" #include "unit-name.h" #include "unit-printf.h" diff --git a/src/core/show-status.c b/src/core/show-status.c index 02b1be73e3..7951ea7303 100644 --- a/src/core/show-status.c +++ b/src/core/show-status.c @@ -19,8 +19,9 @@ along with systemd; If not, see . ***/ -#include "show-status.h" +#include "string-util.h" #include "util.h" +#include "show-status.h" int parse_show_status(const char *v, ShowStatus *ret) { int r; diff --git a/src/core/shutdown.c b/src/core/shutdown.c index 27c581d9c1..33383a4b0b 100644 --- a/src/core/shutdown.c +++ b/src/core/shutdown.c @@ -19,31 +19,32 @@ along with systemd; If not, see . ***/ -#include -#include -#include -#include -#include #include -#include +#include +#include #include #include #include -#include +#include +#include +#include +#include +#include -#include "missing.h" -#include "log.h" +#include "cgroup-util.h" +#include "def.h" #include "fileio.h" +#include "killall.h" +#include "log.h" +#include "missing.h" +#include "process-util.h" +#include "string-util.h" +#include "switch-root.h" +#include "terminal-util.h" #include "umount.h" #include "util.h" #include "virt.h" #include "watchdog.h" -#include "killall.h" -#include "cgroup-util.h" -#include "def.h" -#include "switch-root.h" -#include "process-util.h" -#include "terminal-util.h" #define FINALIZE_ATTEMPTS 50 diff --git a/src/core/slice.c b/src/core/slice.c index 1542e83eb6..8fb6d28a3c 100644 --- a/src/core/slice.c +++ b/src/core/slice.c @@ -21,13 +21,14 @@ #include +#include "dbus-slice.h" #include "log.h" -#include "strv.h" #include "special.h" +#include "string-util.h" +#include "strv.h" #include "unit-name.h" #include "unit.h" #include "slice.h" -#include "dbus-slice.h" static const UnitActiveState state_translation_table[_SLICE_STATE_MAX] = { [SLICE_DEAD] = UNIT_INACTIVE, diff --git a/src/core/smack-setup.c b/src/core/smack-setup.c index 761582c7a2..fb04e1135d 100644 --- a/src/core/smack-setup.c +++ b/src/core/smack-setup.c @@ -21,18 +21,19 @@ along with systemd; If not, see . ***/ -#include +#include #include -#include -#include #include -#include +#include +#include +#include -#include "macro.h" -#include "smack-setup.h" -#include "util.h" #include "fileio.h" #include "log.h" +#include "macro.h" +#include "string-util.h" +#include "util.h" +#include "smack-setup.h" #ifdef HAVE_SMACK diff --git a/src/core/snapshot.c b/src/core/snapshot.c index 867f3765e7..15726c344e 100644 --- a/src/core/snapshot.c +++ b/src/core/snapshot.c @@ -21,11 +21,12 @@ #include +#include "bus-common-errors.h" +#include "dbus-snapshot.h" +#include "string-util.h" +#include "unit-name.h" #include "unit.h" #include "snapshot.h" -#include "unit-name.h" -#include "dbus-snapshot.h" -#include "bus-common-errors.h" static const UnitActiveState state_translation_table[_SNAPSHOT_STATE_MAX] = { [SNAPSHOT_DEAD] = UNIT_INACTIVE, diff --git a/src/core/socket.c b/src/core/socket.c index e42ed62ef1..cfa17b3325 100644 --- a/src/core/socket.c +++ b/src/core/socket.c @@ -48,6 +48,7 @@ #include "smack-util.h" #include "socket.h" #include "special.h" +#include "string-util.h" #include "strv.h" #include "unit-name.h" #include "unit-printf.h" diff --git a/src/core/swap.c b/src/core/swap.c index 82ca58cd7a..eeb53d0632 100644 --- a/src/core/swap.c +++ b/src/core/swap.c @@ -20,11 +20,12 @@ ***/ #include -#include #include #include #include +#include "libudev.h" + #include "dbus-swap.h" #include "escape.h" #include "exit-status.h" @@ -32,6 +33,7 @@ #include "fstab-util.h" #include "path-util.h" #include "special.h" +#include "string-util.h" #include "udev-util.h" #include "unit-name.h" #include "unit.h" diff --git a/src/core/swap.h b/src/core/swap.h index 7f29603c32..303b926568 100644 --- a/src/core/swap.h +++ b/src/core/swap.h @@ -22,7 +22,7 @@ along with systemd; If not, see . ***/ -#include +#include "libudev.h" typedef struct Swap Swap; diff --git a/src/core/target.c b/src/core/target.c index a905a1adf6..c3e79fffc8 100644 --- a/src/core/target.c +++ b/src/core/target.c @@ -19,13 +19,13 @@ along with systemd; If not, see . ***/ - -#include "unit.h" -#include "target.h" -#include "log.h" #include "dbus-target.h" +#include "log.h" #include "special.h" +#include "string-util.h" #include "unit-name.h" +#include "unit.h" +#include "target.h" static const UnitActiveState state_translation_table[_TARGET_STATE_MAX] = { [TARGET_DEAD] = UNIT_INACTIVE, diff --git a/src/core/timer.c b/src/core/timer.c index 800e58261c..4548a4fa52 100644 --- a/src/core/timer.c +++ b/src/core/timer.c @@ -21,13 +21,14 @@ #include -#include "unit.h" -#include "unit-name.h" -#include "timer.h" +#include "bus-error.h" +#include "bus-util.h" #include "dbus-timer.h" #include "special.h" -#include "bus-util.h" -#include "bus-error.h" +#include "string-util.h" +#include "unit-name.h" +#include "unit.h" +#include "timer.h" static const UnitActiveState state_translation_table[_TIMER_STATE_MAX] = { [TIMER_DEAD] = UNIT_INACTIVE, diff --git a/src/core/umount.c b/src/core/umount.c index 38d004ece3..ec887760a1 100644 --- a/src/core/umount.c +++ b/src/core/umount.c @@ -27,11 +27,13 @@ #include #include -#include "escape.h" #include "libudev.h" + +#include "escape.h" #include "list.h" #include "mount-setup.h" #include "path-util.h" +#include "string-util.h" #include "udev-util.h" #include "util.h" #include "virt.h" diff --git a/src/core/unit-printf.c b/src/core/unit-printf.c index 0889769d03..0b7fd4e25b 100644 --- a/src/core/unit-printf.c +++ b/src/core/unit-printf.c @@ -19,14 +19,15 @@ along with systemd; If not, see . ***/ -#include "unit.h" +#include "cgroup-util.h" +#include "formats-util.h" +#include "macro.h" #include "specifier.h" +#include "string-util.h" #include "strv.h" #include "unit-name.h" +#include "unit.h" #include "unit-printf.h" -#include "macro.h" -#include "cgroup-util.h" -#include "formats-util.h" static int specifier_prefix_and_instance(char specifier, void *data, void *userdata, char **ret) { Unit *u = userdata; diff --git a/src/core/unit.c b/src/core/unit.c index 841c1ac018..a054cc79b0 100644 --- a/src/core/unit.c +++ b/src/core/unit.c @@ -48,10 +48,10 @@ #include "process-util.h" #include "set.h" #include "special.h" +#include "string-util.h" #include "strv.h" #include "unit-name.h" #include "virt.h" - #include "unit.h" const UnitVTable * const unit_vtable[_UNIT_TYPE_MAX] = { diff --git a/src/cryptsetup/cryptsetup-generator.c b/src/cryptsetup/cryptsetup-generator.c index ab91afec4d..fde508ac25 100644 --- a/src/cryptsetup/cryptsetup-generator.c +++ b/src/cryptsetup/cryptsetup-generator.c @@ -22,12 +22,13 @@ #include #include "dropin.h" +#include "fstab-util.h" #include "generator.h" #include "hashmap.h" #include "log.h" #include "mkdir.h" #include "path-util.h" -#include "fstab-util.h" +#include "string-util.h" #include "strv.h" #include "unit-name.h" #include "util.h" diff --git a/src/cryptsetup/cryptsetup.c b/src/cryptsetup/cryptsetup.c index 4b5f24ff2e..f5fb6a09fe 100644 --- a/src/cryptsetup/cryptsetup.c +++ b/src/cryptsetup/cryptsetup.c @@ -19,11 +19,11 @@ along with systemd; If not, see . ***/ -#include #include -#include -#include #include +#include +#include +#include #include "sd-device.h" @@ -33,6 +33,7 @@ #include "fileio.h" #include "log.h" #include "path-util.h" +#include "string-util.h" #include "strv.h" #include "util.h" diff --git a/src/debug-generator/debug-generator.c b/src/debug-generator/debug-generator.c index 8b29e8fd09..7f26108e9c 100644 --- a/src/debug-generator/debug-generator.c +++ b/src/debug-generator/debug-generator.c @@ -23,6 +23,7 @@ #include "strv.h" #include "unit-name.h" #include "mkdir.h" +#include "string-util.h" static const char *arg_dest = "/tmp"; static char **arg_mask = NULL; diff --git a/src/delta/delta.c b/src/delta/delta.c index 4edafc7cdf..fbb6ab564b 100644 --- a/src/delta/delta.c +++ b/src/delta/delta.c @@ -32,6 +32,7 @@ #include "path-util.h" #include "process-util.h" #include "signal-util.h" +#include "string-util.h" #include "strv.h" #include "terminal-util.h" #include "util.h" diff --git a/src/escape/escape.c b/src/escape/escape.c index a4bfeb5df5..9390558554 100644 --- a/src/escape/escape.c +++ b/src/escape/escape.c @@ -24,6 +24,7 @@ #include #include "log.h" +#include "string-util.h" #include "strv.h" #include "unit-name.h" diff --git a/src/firstboot/firstboot.c b/src/firstboot/firstboot.c index cc564d5cd8..f6b9c095bf 100644 --- a/src/firstboot/firstboot.c +++ b/src/firstboot/firstboot.c @@ -35,6 +35,7 @@ #include "strv.h" #include "terminal-util.h" #include "time-util.h" +#include "string-util.h" static char *arg_root = NULL; static char *arg_locale = NULL; /* $LANG */ diff --git a/src/fstab-generator/fstab-generator.c b/src/fstab-generator/fstab-generator.c index 3f8ea5647c..de2962d600 100644 --- a/src/fstab-generator/fstab-generator.c +++ b/src/fstab-generator/fstab-generator.c @@ -19,22 +19,23 @@ along with systemd; If not, see . ***/ -#include -#include #include +#include +#include #include #include -#include "log.h" -#include "util.h" -#include "unit-name.h" -#include "path-util.h" #include "fstab-util.h" +#include "generator.h" +#include "log.h" +#include "mkdir.h" #include "mount-setup.h" +#include "path-util.h" #include "special.h" -#include "mkdir.h" -#include "generator.h" +#include "string-util.h" #include "strv.h" +#include "unit-name.h" +#include "util.h" #include "virt.h" static const char *arg_dest = "/tmp"; diff --git a/src/getty-generator/getty-generator.c b/src/getty-generator/getty-generator.c index 9a4b038ef3..eff9ee236f 100644 --- a/src/getty-generator/getty-generator.c +++ b/src/getty-generator/getty-generator.c @@ -19,20 +19,21 @@ along with systemd; If not, see . ***/ -#include #include -#include #include +#include +#include +#include "fileio.h" #include "log.h" -#include "util.h" #include "mkdir.h" -#include "unit-name.h" -#include "virt.h" -#include "fileio.h" #include "path-util.h" #include "process-util.h" +#include "string-util.h" #include "terminal-util.h" +#include "unit-name.h" +#include "util.h" +#include "virt.h" static const char *arg_dest = "/tmp"; diff --git a/src/gpt-auto-generator/gpt-auto-generator.c b/src/gpt-auto-generator/gpt-auto-generator.c index 96425c5b07..3e8c745238 100644 --- a/src/gpt-auto-generator/gpt-auto-generator.c +++ b/src/gpt-auto-generator/gpt-auto-generator.c @@ -24,23 +24,25 @@ #include #include -#include "sd-id128.h" #include "libudev.h" -#include "path-util.h" -#include "util.h" -#include "mkdir.h" +#include "sd-id128.h" + +#include "blkid-util.h" +#include "btrfs-util.h" +#include "efivars.h" +#include "fileio.h" +#include "fstab-util.h" +#include "generator.h" +#include "gpt.h" #include "missing.h" -#include "udev-util.h" +#include "mkdir.h" +#include "path-util.h" #include "special.h" +#include "string-util.h" +#include "udev-util.h" #include "unit-name.h" +#include "util.h" #include "virt.h" -#include "generator.h" -#include "gpt.h" -#include "fileio.h" -#include "efivars.h" -#include "fstab-util.h" -#include "blkid-util.h" -#include "btrfs-util.h" static const char *arg_dest = "/tmp"; static bool arg_enabled = true; diff --git a/src/hibernate-resume/hibernate-resume-generator.c b/src/hibernate-resume/hibernate-resume-generator.c index 9fb6233336..dff2ada384 100644 --- a/src/hibernate-resume/hibernate-resume-generator.c +++ b/src/hibernate-resume/hibernate-resume-generator.c @@ -19,14 +19,15 @@ along with systemd; If not, see . ***/ -#include #include +#include #include "log.h" -#include "util.h" -#include "special.h" #include "mkdir.h" +#include "special.h" +#include "string-util.h" #include "unit-name.h" +#include "util.h" static const char *arg_dest = "/tmp"; static char *arg_resume_dev = NULL; diff --git a/src/hwdb/hwdb.c b/src/hwdb/hwdb.c index 1e415db845..f60ed4b28b 100644 --- a/src/hwdb/hwdb.c +++ b/src/hwdb/hwdb.c @@ -27,6 +27,7 @@ #include "hwdb-util.h" #include "mkdir.h" #include "strbuf.h" +#include "string-util.h" #include "strv.h" #include "util.h" #include "verbs.h" diff --git a/src/import/aufs-util.c b/src/import/aufs-util.c index 18c42b8b6d..7b1ac134a0 100644 --- a/src/import/aufs-util.c +++ b/src/import/aufs-util.c @@ -21,8 +21,9 @@ #include -#include "util.h" #include "rm-rf.h" +#include "string-util.h" +#include "util.h" #include "aufs-util.h" static int nftw_cb( diff --git a/src/import/curl-util.c b/src/import/curl-util.c index d390cfb1f3..422d517529 100644 --- a/src/import/curl-util.c +++ b/src/import/curl-util.c @@ -19,6 +19,7 @@ along with systemd; If not, see . ***/ +#include "string-util.h" #include "curl-util.h" static void curl_glue_check_finished(CurlGlue *g) { diff --git a/src/import/curl-util.h b/src/import/curl-util.h index c249069ffa..6a2aa81c76 100644 --- a/src/import/curl-util.h +++ b/src/import/curl-util.h @@ -24,9 +24,10 @@ #include #include -#include "hashmap.h" #include "sd-event.h" +#include "hashmap.h" + typedef struct CurlGlue CurlGlue; struct CurlGlue { diff --git a/src/import/export-raw.c b/src/import/export-raw.c index 8f9c9bbc80..dc4db481ca 100644 --- a/src/import/export-raw.c +++ b/src/import/export-raw.c @@ -24,12 +24,14 @@ #undef basename #include "sd-daemon.h" -#include "util.h" -#include "ratelimit.h" + #include "btrfs-util.h" #include "copy.h" -#include "import-common.h" #include "export-raw.h" +#include "import-common.h" +#include "ratelimit.h" +#include "string-util.h" +#include "util.h" #define COPY_BUFFER_SIZE (16*1024) diff --git a/src/import/export-tar.c b/src/import/export-tar.c index a623745f5f..93f2fdbd44 100644 --- a/src/import/export-tar.c +++ b/src/import/export-tar.c @@ -19,15 +19,15 @@ along with systemd; If not, see . ***/ -#include - #include "sd-daemon.h" -#include "util.h" -#include "ratelimit.h" + #include "btrfs-util.h" #include "import-common.h" -#include "export-tar.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 d34105e4ca..89e23899b1 100644 --- a/src/import/export.c +++ b/src/import/export.c @@ -30,6 +30,7 @@ #include "import-util.h" #include "machine-image.h" #include "signal-util.h" +#include "string-util.h" #include "verbs.h" static ImportCompressType arg_compress = IMPORT_COMPRESS_UNKNOWN; diff --git a/src/import/import-raw.c b/src/import/import-raw.c index 5f7d25d063..b13e80584d 100644 --- a/src/import/import-raw.c +++ b/src/import/import-raw.c @@ -23,18 +23,20 @@ #include "sd-daemon.h" #include "sd-event.h" -#include "util.h" -#include "path-util.h" + #include "btrfs-util.h" -#include "hostname-util.h" #include "copy.h" -#include "mkdir.h" -#include "rm-rf.h" -#include "ratelimit.h" +#include "hostname-util.h" +#include "import-common.h" +#include "import-compress.h" #include "machine-pool.h" +#include "mkdir.h" +#include "path-util.h" #include "qcow2-util.h" -#include "import-compress.h" -#include "import-common.h" +#include "ratelimit.h" +#include "rm-rf.h" +#include "string-util.h" +#include "util.h" #include "import-raw.h" struct RawImport { diff --git a/src/import/import-tar.c b/src/import/import-tar.c index 5c288d438e..0145dcb452 100644 --- a/src/import/import-tar.c +++ b/src/import/import-tar.c @@ -23,20 +23,22 @@ #include "sd-daemon.h" #include "sd-event.h" -#include "util.h" -#include "path-util.h" + #include "btrfs-util.h" -#include "hostname-util.h" #include "copy.h" -#include "mkdir.h" -#include "rm-rf.h" -#include "ratelimit.h" +#include "hostname-util.h" +#include "import-common.h" +#include "import-compress.h" #include "machine-pool.h" +#include "mkdir.h" +#include "path-util.h" +#include "process-util.h" #include "qcow2-util.h" -#include "import-compress.h" -#include "import-common.h" +#include "ratelimit.h" +#include "rm-rf.h" +#include "string-util.h" +#include "util.h" #include "import-tar.h" -#include "process-util.h" struct TarImport { sd_event *event; diff --git a/src/import/import.c b/src/import/import.c index 1c92312585..bc0bc78924 100644 --- a/src/import/import.c +++ b/src/import/import.c @@ -30,6 +30,7 @@ #include "import-util.h" #include "machine-image.h" #include "signal-util.h" +#include "string-util.h" #include "verbs.h" static bool arg_force = false; diff --git a/src/import/pull-common.c b/src/import/pull-common.c index 94d4438912..a79cc5825b 100644 --- a/src/import/pull-common.c +++ b/src/import/pull-common.c @@ -30,6 +30,7 @@ #include "rm-rf.h" #include "signal-util.h" #include "siphash24.h" +#include "string-util.h" #include "strv.h" #include "util.h" #include "pull-common.h" diff --git a/src/import/pull-dkr.c b/src/import/pull-dkr.c index 84211d282b..ea31d11641 100644 --- a/src/import/pull-dkr.c +++ b/src/import/pull-dkr.c @@ -23,22 +23,24 @@ #include #include "sd-daemon.h" -#include "json.h" -#include "strv.h" + +#include "aufs-util.h" #include "btrfs-util.h" -#include "utf8.h" +#include "curl-util.h" +#include "hostname-util.h" +#include "import-common.h" +#include "import-util.h" +#include "json.h" #include "mkdir.h" -#include "rm-rf.h" #include "path-util.h" -#include "import-util.h" -#include "curl-util.h" -#include "aufs-util.h" -#include "pull-job.h" +#include "process-util.h" #include "pull-common.h" -#include "import-common.h" #include "pull-dkr.h" -#include "process-util.h" -#include "hostname-util.h" +#include "pull-job.h" +#include "rm-rf.h" +#include "string-util.h" +#include "strv.h" +#include "utf8.h" typedef enum DkrProgress { DKR_SEARCHING, diff --git a/src/import/pull-job.c b/src/import/pull-job.c index 42939f2104..f8b597c9c3 100644 --- a/src/import/pull-job.c +++ b/src/import/pull-job.c @@ -21,8 +21,9 @@ #include -#include "strv.h" #include "machine-pool.h" +#include "string-util.h" +#include "strv.h" #include "pull-job.h" PullJob* pull_job_unref(PullJob *j) { diff --git a/src/import/pull-raw.c b/src/import/pull-raw.c index 3e13f4ea9a..a8b2c24507 100644 --- a/src/import/pull-raw.c +++ b/src/import/pull-raw.c @@ -19,27 +19,29 @@ along with systemd; If not, see . ***/ -#include -#include #include +#include +#include #include "sd-daemon.h" -#include "utf8.h" -#include "strv.h" -#include "copy.h" + #include "btrfs-util.h" -#include "util.h" +#include "copy.h" +#include "curl-util.h" +#include "hostname-util.h" +#include "import-common.h" +#include "import-util.h" #include "macro.h" #include "mkdir.h" -#include "rm-rf.h" #include "path-util.h" -#include "hostname-util.h" -#include "import-util.h" -#include "import-common.h" -#include "curl-util.h" -#include "qcow2-util.h" -#include "pull-job.h" #include "pull-common.h" +#include "pull-job.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 { diff --git a/src/import/pull-tar.c b/src/import/pull-tar.c index bd35f1b842..fb4d5bf512 100644 --- a/src/import/pull-tar.c +++ b/src/import/pull-tar.c @@ -23,22 +23,24 @@ #include #include "sd-daemon.h" -#include "utf8.h" -#include "strv.h" -#include "copy.h" + #include "btrfs-util.h" -#include "util.h" +#include "copy.h" +#include "curl-util.h" +#include "hostname-util.h" +#include "import-common.h" +#include "import-util.h" #include "macro.h" #include "mkdir.h" -#include "rm-rf.h" #include "path-util.h" #include "process-util.h" -#include "hostname-util.h" -#include "import-util.h" -#include "import-common.h" -#include "curl-util.h" -#include "pull-job.h" #include "pull-common.h" +#include "pull-job.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 { diff --git a/src/import/pull.c b/src/import/pull.c index 29e9424b52..73d5f391c2 100644 --- a/src/import/pull.c +++ b/src/import/pull.c @@ -31,6 +31,7 @@ #include "pull-raw.h" #include "pull-tar.h" #include "signal-util.h" +#include "string-util.h" #include "verbs.h" static bool arg_force = false; diff --git a/src/journal-remote/journal-remote-parse.c b/src/journal-remote/journal-remote-parse.c index 2e0f78701a..e9bca39a20 100644 --- a/src/journal-remote/journal-remote-parse.c +++ b/src/journal-remote/journal-remote-parse.c @@ -19,8 +19,9 @@ along with systemd; If not, see . ***/ -#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 0fcd987664..27385d9b94 100644 --- a/src/journal-remote/journal-remote.c +++ b/src/journal-remote/journal-remote.c @@ -44,6 +44,7 @@ #include "macro.h" #include "signal-util.h" #include "socket-util.h" +#include "string-util.h" #include "strv.h" #include "journal-remote.h" diff --git a/src/journal-remote/journal-upload.c b/src/journal-remote/journal-upload.c index 92ce56805a..471a8cad49 100644 --- a/src/journal-remote/journal-upload.c +++ b/src/journal-remote/journal-upload.c @@ -19,11 +19,11 @@ along with systemd; If not, see . ***/ +#include #include #include #include #include -#include #include "sd-daemon.h" @@ -34,6 +34,7 @@ #include "mkdir.h" #include "sigbus.h" #include "signal-util.h" +#include "string-util.h" #include "util.h" #include "journal-upload.h" diff --git a/src/journal-remote/microhttpd-util.c b/src/journal-remote/microhttpd-util.c index 8a11fba044..df068a089c 100644 --- a/src/journal-remote/microhttpd-util.c +++ b/src/journal-remote/microhttpd-util.c @@ -24,17 +24,18 @@ #include #include -#include "microhttpd-util.h" -#include "log.h" -#include "macro.h" -#include "util.h" -#include "strv.h" - #ifdef HAVE_GNUTLS #include #include #endif +#include "log.h" +#include "macro.h" +#include "string-util.h" +#include "strv.h" +#include "util.h" +#include "microhttpd-util.h" + void microhttpd_logger(void *arg, const char *fmt, va_list ap) { char *f; diff --git a/src/journal/cat.c b/src/journal/cat.c index f9b279d7de..7074552a15 100644 --- a/src/journal/cat.c +++ b/src/journal/cat.c @@ -28,6 +28,7 @@ #include "sd-journal.h" +#include "string-util.h" #include "util.h" static char *arg_identifier = NULL; diff --git a/src/journal/catalog.c b/src/journal/catalog.c index 4c43500ef5..32b851aea3 100644 --- a/src/journal/catalog.c +++ b/src/journal/catalog.c @@ -19,25 +19,27 @@ along with systemd; If not, see . ***/ +#include #include +#include #include -#include -#include #include #include -#include +#include -#include "util.h" -#include "log.h" -#include "sparse-endian.h" #include "sd-id128.h" -#include "hashmap.h" -#include "strv.h" -#include "strbuf.h" + +#include "catalog.h" #include "conf-files.h" +#include "hashmap.h" +#include "log.h" #include "mkdir.h" -#include "catalog.h" #include "siphash24.h" +#include "sparse-endian.h" +#include "strbuf.h" +#include "string-util.h" +#include "strv.h" +#include "util.h" const char * const catalog_file_dirs[] = { "/usr/local/lib/systemd/catalog/", diff --git a/src/journal/compress.c b/src/journal/compress.c index 8c92e26edd..46a5410482 100644 --- a/src/journal/compress.c +++ b/src/journal/compress.c @@ -21,8 +21,8 @@ #include #include -#include #include +#include #ifdef HAVE_XZ # include @@ -33,11 +33,12 @@ # include #endif -#include "compress.h" +#include "journal-def.h" #include "macro.h" -#include "util.h" #include "sparse-endian.h" -#include "journal-def.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 efe418615a..ba9994ac47 100644 --- a/src/journal/coredump-vacuum.c +++ b/src/journal/coredump-vacuum.c @@ -21,11 +21,11 @@ #include -#include "util.h" -#include "time-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 */ diff --git a/src/journal/coredump.c b/src/journal/coredump.c index e20a73c159..5c1badd66d 100644 --- a/src/journal/coredump.c +++ b/src/journal/coredump.c @@ -49,6 +49,7 @@ #include "process-util.h" #include "special.h" #include "stacktrace.h" +#include "string-util.h" #include "strv.h" #include "util.h" diff --git a/src/journal/coredumpctl.c b/src/journal/coredumpctl.c index 97a721c114..80f692e044 100644 --- a/src/journal/coredumpctl.c +++ b/src/journal/coredumpctl.c @@ -38,6 +38,7 @@ #include "set.h" #include "sigbus.h" #include "signal-util.h" +#include "string-util.h" #include "terminal-util.h" #include "util.h" diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c index 1071c6d6d7..f0962faeb5 100644 --- a/src/journal/journal-file.c +++ b/src/journal/journal-file.c @@ -19,22 +19,23 @@ along with systemd; If not, see . ***/ -#include #include -#include -#include -#include #include -#include #include +#include +#include +#include +#include +#include #include "btrfs-util.h" -#include "journal-def.h" -#include "journal-file.h" +#include "compress.h" #include "journal-authenticate.h" +#include "journal-def.h" #include "lookup3.h" -#include "compress.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-internal.h b/src/journal/journal-internal.h index b51ecdb600..1221799c1d 100644 --- a/src/journal/journal-internal.h +++ b/src/journal/journal-internal.h @@ -25,14 +25,14 @@ #include #include -#include "systemd/sd-id128.h" +#include "sd-id128.h" +#include "sd-journal.h" +#include "hashmap.h" #include "journal-def.h" +#include "journal-file.h" #include "list.h" -#include "hashmap.h" #include "set.h" -#include "journal-file.h" -#include "sd-journal.h" typedef struct Match Match; typedef struct Location Location; diff --git a/src/journal/journal-send.c b/src/journal/journal-send.c index dc1b2105dd..79ef5b13d2 100644 --- a/src/journal/journal-send.c +++ b/src/journal/journal-send.c @@ -19,20 +19,22 @@ along with systemd; If not, see . ***/ -#include -#include #include -#include -#include #include #include +#include +#include +#include +#include #define SD_JOURNAL_SUPPRESS_LOCATION #include "sd-journal.h" -#include "util.h" -#include "socket-util.h" + #include "memfd-util.h" +#include "socket-util.h" +#include "string-util.h" +#include "util.h" #define SNDBUF_SIZE (8*1024*1024) diff --git a/src/journal/journal-vacuum.c b/src/journal/journal-vacuum.c index c7ecd360b9..692b875fae 100644 --- a/src/journal/journal-vacuum.c +++ b/src/journal/journal-vacuum.c @@ -23,12 +23,15 @@ #include #include +#include "sd-id128.h" + #include "journal-def.h" #include "journal-file.h" -#include "journal-vacuum.h" -#include "sd-id128.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/journald-audit.c b/src/journal/journald-audit.c index fe8ae194c9..58778a697a 100644 --- a/src/journal/journald-audit.c +++ b/src/journal/journald-audit.c @@ -19,9 +19,10 @@ along with systemd; If not, see . ***/ +#include "audit-type.h" #include "missing.h" +#include "string-util.h" #include "journald-audit.h" -#include "audit-type.h" typedef struct MapField { const char *audit_field; diff --git a/src/journal/journald-kmsg.c b/src/journal/journald-kmsg.c index 9ed368b586..a8be704716 100644 --- a/src/journal/journald-kmsg.c +++ b/src/journal/journald-kmsg.c @@ -33,6 +33,7 @@ #include "journald-server.h" #include "journald-syslog.h" #include "process-util.h" +#include "string-util.h" #include "journald-kmsg.h" void server_forward_kmsg( diff --git a/src/journal/journald-native.c b/src/journal/journald-native.c index 3e8a7a05f6..7a514b2848 100644 --- a/src/journal/journald-native.c +++ b/src/journal/journald-native.c @@ -19,21 +19,22 @@ along with systemd; If not, see . ***/ -#include #include #include #include +#include -#include "socket-util.h" -#include "path-util.h" -#include "selinux-util.h" -#include "journald-server.h" -#include "journald-native.h" -#include "journald-kmsg.h" #include "journald-console.h" +#include "journald-kmsg.h" +#include "journald-server.h" #include "journald-syslog.h" #include "journald-wall.h" #include "memfd-util.h" +#include "path-util.h" +#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-rate-limit.c b/src/journal/journald-rate-limit.c index 8afd493b50..6e9557c06e 100644 --- a/src/journal/journald-rate-limit.c +++ b/src/journal/journald-rate-limit.c @@ -19,14 +19,15 @@ along with systemd; If not, see . ***/ -#include #include +#include -#include "journald-rate-limit.h" -#include "list.h" -#include "util.h" #include "hashmap.h" +#include "list.h" #include "random-util.h" +#include "string-util.h" +#include "util.h" +#include "journald-rate-limit.h" #define POOLS_MAX 5 #define BUCKETS_MAX 127 diff --git a/src/journal/journald-server.c b/src/journal/journald-server.c index 140d40667e..2dfd309310 100644 --- a/src/journal/journald-server.c +++ b/src/journal/journald-server.c @@ -19,7 +19,6 @@ along with systemd; If not, see . ***/ -#include #ifdef HAVE_SELINUX #include #endif @@ -27,6 +26,7 @@ #include #include #include +#include #include "libudev.h" #include "sd-daemon.h" @@ -39,13 +39,6 @@ #include "formats-util.h" #include "hashmap.h" #include "hostname-util.h" -#include "missing.h" -#include "mkdir.h" -#include "process-util.h" -#include "rm-rf.h" -#include "selinux-util.h" -#include "signal-util.h" -#include "socket-util.h" #include "journal-authenticate.h" #include "journal-file.h" #include "journal-internal.h" @@ -54,9 +47,17 @@ #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" +#include "mkdir.h" +#include "process-util.h" +#include "rm-rf.h" +#include "selinux-util.h" +#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 0c4b82f80d..e06be6267f 100644 --- a/src/journal/journald-stream.c +++ b/src/journal/journald-stream.c @@ -19,8 +19,8 @@ along with systemd; If not, see . ***/ -#include #include +#include #ifdef HAVE_SELINUX #include @@ -39,6 +39,7 @@ #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 ffba451955..fc69cd7d9e 100644 --- a/src/journal/journald-syslog.c +++ b/src/journal/journald-syslog.c @@ -19,20 +19,22 @@ along with systemd; If not, see . ***/ -#include #include #include +#include -#include "systemd/sd-messages.h" -#include "socket-util.h" -#include "selinux-util.h" -#include "journald-server.h" -#include "journald-syslog.h" -#include "journald-kmsg.h" +#include "sd-messages.h" + +#include "formats-util.h" #include "journald-console.h" +#include "journald-kmsg.h" +#include "journald-server.h" #include "journald-wall.h" -#include "formats-util.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/journald-wall.c b/src/journal/journald-wall.c index 7863766ae7..5284914941 100644 --- a/src/journal/journald-wall.c +++ b/src/journal/journald-wall.c @@ -19,11 +19,12 @@ along with systemd; If not, see . ***/ -#include "utmp-wtmp.h" -#include "journald-server.h" -#include "journald-wall.h" #include "formats-util.h" +#include "journald-server.h" #include "process-util.h" +#include "string-util.h" +#include "utmp-wtmp.h" +#include "journald-wall.h" void server_forward_wall( Server *s, diff --git a/src/journal/sd-journal.c b/src/journal/sd-journal.c index 13fa9b52fc..442e352ae2 100644 --- a/src/journal/sd-journal.c +++ b/src/journal/sd-journal.c @@ -21,29 +21,31 @@ #include #include +#include +#include #include -#include #include -#include #include -#include +#include #include "sd-journal.h" + +#include "catalog.h" +#include "compress.h" +#include "fileio.h" +#include "formats-util.h" +#include "hashmap.h" +#include "hostname-util.h" #include "journal-def.h" #include "journal-file.h" -#include "hashmap.h" +#include "journal-internal.h" #include "list.h" -#include "strv.h" -#include "path-util.h" #include "lookup3.h" -#include "compress.h" -#include "journal-internal.h" #include "missing.h" -#include "catalog.h" +#include "path-util.h" #include "replace-var.h" -#include "fileio.h" -#include "formats-util.h" -#include "hostname-util.h" +#include "string-util.h" +#include "strv.h" #define JOURNAL_FILES_MAX 7168 diff --git a/src/journal/stacktrace.c b/src/journal/stacktrace.c index 98a54ff269..c4ba9e3890 100644 --- a/src/journal/stacktrace.c +++ b/src/journal/stacktrace.c @@ -22,10 +22,11 @@ #include #include -#include "util.h" +#include "formats-util.h" #include "macro.h" +#include "string-util.h" +#include "util.h" #include "stacktrace.h" -#include "formats-util.h" #define FRAMES_MAX 64 #define THREADS_MAX 64 diff --git a/src/journal/test-catalog.c b/src/journal/test-catalog.c index dbfdea609d..222d6cc72a 100644 --- a/src/journal/test-catalog.c +++ b/src/journal/test-catalog.c @@ -25,11 +25,13 @@ #include #include +#include "sd-messages.h" + #include "util.h" #include "log.h" #include "macro.h" -#include "sd-messages.h" #include "catalog.h" +#include "string-util.h" static const char *catalog_dirs[] = { CATALOG_DIR, diff --git a/src/journal/test-compress-benchmark.c b/src/journal/test-compress-benchmark.c index 782b85db26..0a9ab7f52c 100644 --- a/src/journal/test-compress-benchmark.c +++ b/src/journal/test-compress-benchmark.c @@ -20,9 +20,10 @@ ***/ #include "compress.h" -#include "util.h" #include "macro.h" #include "random-util.h" +#include "string-util.h" +#include "util.h" typedef int (compress_t)(const void *src, uint64_t src_size, void *dst, size_t *dst_size); typedef int (decompress_t)(const void *src, uint64_t src_size, diff --git a/src/journal/test-journal-enum.c b/src/journal/test-journal-enum.c index cde2025ae9..040c7d58fb 100644 --- a/src/journal/test-journal-enum.c +++ b/src/journal/test-journal-enum.c @@ -21,8 +21,9 @@ #include -#include "log.h" #include "sd-journal.h" + +#include "log.h" #include "macro.h" #include "journal-internal.h" diff --git a/src/journal/test-journal-flush.c b/src/journal/test-journal-flush.c index 2d4f531e9b..6061623ae7 100644 --- a/src/journal/test-journal-flush.c +++ b/src/journal/test-journal-flush.c @@ -22,9 +22,11 @@ #include #include "sd-journal.h" -#include "macro.h" + #include "journal-file.h" #include "journal-internal.h" +#include "macro.h" +#include "string-util.h" int main(int argc, char *argv[]) { _cleanup_free_ char *fn = NULL; diff --git a/src/journal/test-journal-match.c b/src/journal/test-journal-match.c index a3187053c9..476477055a 100644 --- a/src/journal/test-journal-match.c +++ b/src/journal/test-journal-match.c @@ -21,11 +21,12 @@ #include -#include "systemd/sd-journal.h" +#include "sd-journal.h" #include "journal-internal.h" -#include "util.h" #include "log.h" +#include "string-util.h" +#include "util.h" int main(int argc, char *argv[]) { _cleanup_journal_close_ sd_journal*j; diff --git a/src/journal/test-journal-syslog.c b/src/journal/test-journal-syslog.c index c99ca0654b..de942c50cc 100644 --- a/src/journal/test-journal-syslog.c +++ b/src/journal/test-journal-syslog.c @@ -21,6 +21,7 @@ #include "journald-syslog.h" #include "macro.h" +#include "string-util.h" static void test_syslog_parse_identifier(const char* str, const char *ident, const char*pid, int ret) { diff --git a/src/libsystemd-network/dhcp-identifier.c b/src/libsystemd-network/dhcp-identifier.c index 7d9cad2a70..51ee7bcce4 100644 --- a/src/libsystemd-network/dhcp-identifier.c +++ b/src/libsystemd-network/dhcp-identifier.c @@ -19,18 +19,16 @@ along with systemd; If not, see . ***/ - -#include "sd-id128.h" #include "libudev.h" -#include "udev-util.h" - -#include "virt.h" -#include "sparse-endian.h" -#include "siphash24.h" +#include "sd-id128.h" -#include "dhcp6-protocol.h" #include "dhcp-identifier.h" +#include "dhcp6-protocol.h" #include "network-internal.h" +#include "siphash24.h" +#include "sparse-endian.h" +#include "udev-util.h" +#include "virt.h" #define SYSTEMD_PEN 43793 #define HASH_KEY SD_ID128_MAKE(80,11,8c,c2,fe,4a,03,ee,3e,d6,0c,6f,36,39,14,09) @@ -58,7 +56,6 @@ int dhcp_identifier_set_duid_en(struct duid *duid, size_t *len) { return 0; } - int dhcp_identifier_set_iaid(int ifindex, uint8_t *mac, size_t mac_len, void *_id) { /* name is a pointer to memory in the udev_device struct, so must have the same scope */ diff --git a/src/libsystemd-network/dhcp-identifier.h b/src/libsystemd-network/dhcp-identifier.h index 95117915f4..2291736f8b 100644 --- a/src/libsystemd-network/dhcp-identifier.h +++ b/src/libsystemd-network/dhcp-identifier.h @@ -21,11 +21,11 @@ along with systemd; If not, see . ***/ +#include "sd-id128.h" #include "macro.h" #include "sparse-endian.h" #include "unaligned.h" -#include "sd-id128.h" /* RFC 3315 section 9.1: * A DUID can be no more than 128 octets long (not including the type code). diff --git a/src/libsystemd-network/dhcp-internal.h b/src/libsystemd-network/dhcp-internal.h index df6f882af5..a5daaa543a 100644 --- a/src/libsystemd-network/dhcp-internal.h +++ b/src/libsystemd-network/dhcp-internal.h @@ -22,15 +22,15 @@ along with systemd; If not, see . ***/ -#include #include -#include #include - -#include "socket-util.h" +#include +#include #include "sd-dhcp-client.h" + #include "dhcp-protocol.h" +#include "socket-util.h" int dhcp_network_bind_raw_socket(int index, union sockaddr_union *link, uint32_t xid, const uint8_t *mac_addr, diff --git a/src/libsystemd-network/dhcp6-internal.h b/src/libsystemd-network/dhcp6-internal.h index eeff74fbb9..ecc220f2f6 100644 --- a/src/libsystemd-network/dhcp6-internal.h +++ b/src/libsystemd-network/dhcp6-internal.h @@ -24,10 +24,11 @@ #include #include -#include "sparse-endian.h" #include "sd-event.h" + #include "list.h" #include "macro.h" +#include "sparse-endian.h" typedef struct DHCP6Address DHCP6Address; diff --git a/src/libsystemd-network/lldp-internal.c b/src/libsystemd-network/lldp-internal.c index 4012cd483b..70061e914f 100644 --- a/src/libsystemd-network/lldp-internal.c +++ b/src/libsystemd-network/lldp-internal.c @@ -20,9 +20,10 @@ along with systemd; If not, see . ***/ -#include "lldp-internal.h" #include "sd-lldp.h" +#include "lldp-internal.h" + /* We store maximum 1K chassis entries */ #define LLDP_MIB_MAX_CHASSIS 1024 diff --git a/src/libsystemd-network/lldp-internal.h b/src/libsystemd-network/lldp-internal.h index 284cc6720e..5d19fa0fea 100644 --- a/src/libsystemd-network/lldp-internal.h +++ b/src/libsystemd-network/lldp-internal.h @@ -22,11 +22,12 @@ #pragma once -#include "log.h" +#include "sd-event.h" + #include "list.h" #include "lldp-tlv.h" +#include "log.h" #include "prioq.h" -#include "sd-event.h" typedef struct lldp_neighbour_port lldp_neighbour_port; typedef struct lldp_chassis lldp_chassis; diff --git a/src/libsystemd-network/network-internal.c b/src/libsystemd-network/network-internal.c index faf14fe6a2..39551b5761 100644 --- a/src/libsystemd-network/network-internal.c +++ b/src/libsystemd-network/network-internal.c @@ -19,20 +19,22 @@ along with systemd; If not, see . ***/ -#include -#include #include +#include +#include -#include "strv.h" -#include "siphash24.h" +#include "sd-ndisc.h" + +#include "condition.h" +#include "conf-parser.h" #include "dhcp-lease-internal.h" #include "log.h" +#include "siphash24.h" +#include "string-util.h" +#include "strv.h" #include "utf8.h" #include "util.h" -#include "conf-parser.h" -#include "condition.h" #include "network-internal.h" -#include "sd-ndisc.h" const char *net_get_name(struct udev_device *device) { const char *name, *field; diff --git a/src/libsystemd-network/sd-dhcp-client.c b/src/libsystemd-network/sd-dhcp-client.c index 28e012afca..a6d6a176e4 100644 --- a/src/libsystemd-network/sd-dhcp-client.c +++ b/src/libsystemd-network/sd-dhcp-client.c @@ -17,24 +17,25 @@ along with systemd; If not, see . ***/ -#include #include -#include -#include #include #include -#include +#include +#include +#include #include +#include -#include "util.h" -#include "random-util.h" -#include "async.h" +#include "sd-dhcp-client.h" -#include "dhcp-protocol.h" +#include "async.h" +#include "dhcp-identifier.h" #include "dhcp-internal.h" #include "dhcp-lease-internal.h" -#include "dhcp-identifier.h" -#include "sd-dhcp-client.h" +#include "dhcp-protocol.h" +#include "random-util.h" +#include "string-util.h" +#include "util.h" #define MAX_CLIENT_ID_LEN (sizeof(uint32_t) + MAX_DUID_LEN) /* Arbitrary limit */ #define MAX_MAC_ADDR_LEN CONST_MAX(INFINIBAND_ALEN, ETH_ALEN) diff --git a/src/libsystemd-network/sd-dhcp-lease.c b/src/libsystemd-network/sd-dhcp-lease.c index df3d8e6e3c..bc01b5b535 100644 --- a/src/libsystemd-network/sd-dhcp-lease.c +++ b/src/libsystemd-network/sd-dhcp-lease.c @@ -18,21 +18,22 @@ along with systemd; If not, see . ***/ -#include +#include #include -#include #include -#include +#include +#include + +#include "sd-dhcp-lease.h" +#include "dhcp-lease-internal.h" +#include "dhcp-protocol.h" +#include "dns-domain.h" #include "fileio.h" -#include "unaligned.h" -#include "in-addr-util.h" #include "hostname-util.h" -#include "dns-domain.h" +#include "in-addr-util.h" #include "network-internal.h" -#include "dhcp-protocol.h" -#include "dhcp-lease-internal.h" -#include "sd-dhcp-lease.h" +#include "unaligned.h" int sd_dhcp_lease_get_address(sd_dhcp_lease *lease, struct in_addr *addr) { assert_return(lease, -EINVAL); diff --git a/src/libsystemd-network/sd-dhcp-server.c b/src/libsystemd-network/sd-dhcp-server.c index d27bb561ca..39afffc72c 100644 --- a/src/libsystemd-network/sd-dhcp-server.c +++ b/src/libsystemd-network/sd-dhcp-server.c @@ -22,12 +22,13 @@ #include -#include "in-addr-util.h" -#include "siphash24.h" - #include "sd-dhcp-server.h" -#include "dhcp-server-internal.h" + #include "dhcp-internal.h" +#include "dhcp-server-internal.h" +#include "in-addr-util.h" +#include "siphash24.h" +#include "string-util.h" #define DHCP_DEFAULT_LEASE_TIME_USEC USEC_PER_HOUR #define DHCP_MAX_LEASE_TIME_USEC (USEC_PER_HOUR*12) diff --git a/src/libsystemd-network/sd-dhcp6-client.c b/src/libsystemd-network/sd-dhcp6-client.c index 9cd4bd3032..cb8b0713f4 100644 --- a/src/libsystemd-network/sd-dhcp6-client.c +++ b/src/libsystemd-network/sd-dhcp6-client.c @@ -24,17 +24,15 @@ #include #include -#include "udev.h" -#include "udev-util.h" -#include "util.h" -#include "random-util.h" - -#include "network-internal.h" #include "sd-dhcp6-client.h" -#include "dhcp6-protocol.h" + +#include "dhcp-identifier.h" #include "dhcp6-internal.h" #include "dhcp6-lease-internal.h" -#include "dhcp-identifier.h" +#include "dhcp6-protocol.h" +#include "network-internal.h" +#include "random-util.h" +#include "util.h" #define MAX_MAC_ADDR_LEN INFINIBAND_ALEN diff --git a/src/libsystemd-network/sd-ipv4acd.c b/src/libsystemd-network/sd-ipv4acd.c index 95b96bfd52..ae9805bfaa 100644 --- a/src/libsystemd-network/sd-ipv4acd.c +++ b/src/libsystemd-network/sd-ipv4acd.c @@ -24,17 +24,17 @@ #include #include +#include "sd-ipv4acd.h" + +#include "arp-util.h" #include "event-util.h" #include "in-addr-util.h" #include "list.h" -#include "refcnt.h" #include "random-util.h" +#include "refcnt.h" #include "siphash24.h" #include "util.h" -#include "arp-util.h" -#include "sd-ipv4acd.h" - /* Constants from the RFC */ #define PROBE_WAIT 1 #define PROBE_NUM 3 diff --git a/src/libsystemd-network/sd-ipv4ll.c b/src/libsystemd-network/sd-ipv4ll.c index 57bd337a9a..0d025768a9 100644 --- a/src/libsystemd-network/sd-ipv4ll.c +++ b/src/libsystemd-network/sd-ipv4ll.c @@ -18,11 +18,14 @@ along with systemd; If not, see . ***/ -#include +#include #include -#include #include -#include +#include +#include + +#include "sd-ipv4acd.h" +#include "sd-ipv4ll.h" #include "event-util.h" #include "in-addr-util.h" @@ -33,9 +36,6 @@ #include "sparse-endian.h" #include "util.h" -#include "sd-ipv4acd.h" -#include "sd-ipv4ll.h" - #define IPV4LL_NETWORK 0xA9FE0000L #define IPV4LL_NETMASK 0xFFFF0000L diff --git a/src/libsystemd-network/sd-lldp.c b/src/libsystemd-network/sd-lldp.c index 06949a1e83..b73673c55c 100644 --- a/src/libsystemd-network/sd-lldp.c +++ b/src/libsystemd-network/sd-lldp.c @@ -22,15 +22,16 @@ #include -#include "siphash24.h" -#include "hashmap.h" - -#include "lldp-tlv.h" -#include "lldp-port.h" #include "sd-lldp.h" -#include "prioq.h" + +#include "hashmap.h" #include "lldp-internal.h" +#include "lldp-port.h" +#include "lldp-tlv.h" #include "lldp-util.h" +#include "prioq.h" +#include "siphash24.h" +#include "string-util.h" typedef enum LLDPAgentRXState { LLDP_AGENT_RX_WAIT_PORT_OPERATIONAL = 4, diff --git a/src/libsystemd-network/sd-ndisc.c b/src/libsystemd-network/sd-ndisc.c index a361662072..ca4bb6325b 100644 --- a/src/libsystemd-network/sd-ndisc.c +++ b/src/libsystemd-network/sd-ndisc.c @@ -18,19 +18,19 @@ ***/ #include +#include #include -#include #include -#include +#include #include +#include "sd-ndisc.h" + #include "async.h" +#include "icmp6-util.h" #include "list.h" #include "socket-util.h" -#include "icmp6-util.h" -#include "sd-ndisc.h" - #define NDISC_ROUTER_SOLICITATION_INTERVAL 4 * USEC_PER_SEC #define NDISC_MAX_ROUTER_SOLICITATIONS 3 diff --git a/src/libsystemd-network/sd-pppoe.c b/src/libsystemd-network/sd-pppoe.c index cd5a204f8c..87e3ce4b1d 100644 --- a/src/libsystemd-network/sd-pppoe.c +++ b/src/libsystemd-network/sd-pppoe.c @@ -21,22 +21,22 @@ /* See RFC 2516 */ -#include -#include -#include #include #include +#include #include +#include +#include #include "sd-pppoe.h" +#include "async.h" #include "event-util.h" - -#include "util.h" #include "random-util.h" #include "socket-util.h" -#include "async.h" +#include "string-util.h" #include "utf8.h" +#include "util.h" #define PPPOE_MAX_PACKET_SIZE 1484 #define PPPOE_MAX_PADR_RESEND 16 diff --git a/src/libsystemd-network/test-dhcp-client.c b/src/libsystemd-network/test-dhcp-client.c index c112ec8134..41c817e3d3 100644 --- a/src/libsystemd-network/test-dhcp-client.c +++ b/src/libsystemd-network/test-dhcp-client.c @@ -24,14 +24,14 @@ #include #include -#include "util.h" +#include "sd-dhcp-client.h" #include "sd-event.h" -#include "event-util.h" #include "dhcp-identifier.h" -#include "dhcp-protocol.h" #include "dhcp-internal.h" -#include "sd-dhcp-client.h" +#include "dhcp-protocol.h" +#include "event-util.h" +#include "util.h" static uint8_t mac_addr[] = {'A', 'B', 'C', '1', '2', '3'}; diff --git a/src/libsystemd-network/test-dhcp-server.c b/src/libsystemd-network/test-dhcp-server.c index c3bcb9cb4b..1a5c8c4605 100644 --- a/src/libsystemd-network/test-dhcp-server.c +++ b/src/libsystemd-network/test-dhcp-server.c @@ -22,11 +22,11 @@ #include +#include "sd-dhcp-server.h" #include "sd-event.h" -#include "event-util.h" -#include "sd-dhcp-server.h" #include "dhcp-server-internal.h" +#include "event-util.h" static void test_pool(struct in_addr *address, unsigned size, int ret) { _cleanup_dhcp_server_unref_ sd_dhcp_server *server = NULL; diff --git a/src/libsystemd-network/test-dhcp6-client.c b/src/libsystemd-network/test-dhcp6-client.c index 0c131a9897..fdf8d2ef89 100644 --- a/src/libsystemd-network/test-dhcp6-client.c +++ b/src/libsystemd-network/test-dhcp6-client.c @@ -19,23 +19,23 @@ along with systemd; If not, see . ***/ +#include #include #include -#include #include +#include #include -#include -#include "socket-util.h" -#include "macro.h" +#include "sd-dhcp6-client.h" #include "sd-event.h" -#include "event-util.h" -#include "virt.h" -#include "sd-dhcp6-client.h" -#include "dhcp6-protocol.h" #include "dhcp6-internal.h" #include "dhcp6-lease-internal.h" +#include "dhcp6-protocol.h" +#include "event-util.h" +#include "macro.h" +#include "socket-util.h" +#include "virt.h" static struct ether_addr mac_addr = { .ether_addr_octet = {'A', 'B', 'C', '1', '2', '3'} diff --git a/src/libsystemd-network/test-ipv4ll-manual.c b/src/libsystemd-network/test-ipv4ll-manual.c index dd2e44e7a3..08421c3575 100644 --- a/src/libsystemd-network/test-ipv4ll-manual.c +++ b/src/libsystemd-network/test-ipv4ll-manual.c @@ -19,21 +19,21 @@ along with systemd; If not, see . ***/ -#include #include +#include +#include #include - #include -#include #include "sd-event.h" -#include "sd-netlink.h" #include "sd-ipv4ll.h" +#include "sd-netlink.h" -#include "util.h" #include "event-util.h" -#include "netlink-util.h" #include "in-addr-util.h" +#include "netlink-util.h" +#include "string-util.h" +#include "util.h" static void ll_handler(sd_ipv4ll *ll, int event, void *userdata) { _cleanup_free_ char *address = NULL; diff --git a/src/libsystemd-network/test-ipv4ll.c b/src/libsystemd-network/test-ipv4ll.c index b67a9f17d7..3958a98a36 100644 --- a/src/libsystemd-network/test-ipv4ll.c +++ b/src/libsystemd-network/test-ipv4ll.c @@ -18,20 +18,20 @@ along with systemd; If not, see . ***/ -#include #include #include #include -#include +#include #include +#include #include -#include "util.h" -#include "socket-util.h" -#include "event-util.h" - #include "sd-ipv4ll.h" + #include "arp-util.h" +#include "event-util.h" +#include "socket-util.h" +#include "util.h" static bool verbose = false; static bool extended = false; diff --git a/src/libsystemd-network/test-lldp.c b/src/libsystemd-network/test-lldp.c index e57102a576..4e84caa4b0 100644 --- a/src/libsystemd-network/test-lldp.c +++ b/src/libsystemd-network/test-lldp.c @@ -20,18 +20,20 @@ along with systemd; If not, see . ***/ +#include +#include #include #include -#include -#include -#include "sd-lldp.h" #include "sd-event.h" +#include "sd-lldp.h" + #include "event-util.h" -#include "macro.h" -#include "lldp.h" -#include "lldp-tlv.h" #include "lldp-network.h" +#include "lldp-tlv.h" +#include "lldp.h" +#include "macro.h" +#include "string-util.h" #define TEST_LLDP_PORT "em1" #define TEST_LLDP_TYPE_SYSTEM_NAME "systemd-lldp" diff --git a/src/libsystemd-network/test-ndisc-rs.c b/src/libsystemd-network/test-ndisc-rs.c index 765198e46c..44eab94e8b 100644 --- a/src/libsystemd-network/test-ndisc-rs.c +++ b/src/libsystemd-network/test-ndisc-rs.c @@ -21,10 +21,10 @@ #include -#include "socket-util.h" +#include "sd-ndisc.h" #include "icmp6-util.h" -#include "sd-ndisc.h" +#include "socket-util.h" static struct ether_addr mac_addr = { .ether_addr_octet = {'A', 'B', 'C', '1', '2', '3'} diff --git a/src/libsystemd/sd-bus/bus-control.c b/src/libsystemd/sd-bus/bus-control.c index aeb48bedd1..e68207ae07 100644 --- a/src/libsystemd/sd-bus/bus-control.c +++ b/src/libsystemd/sd-bus/bus-control.c @@ -26,14 +26,16 @@ #include #include -#include "strv.h" #include "sd-bus.h" + +#include "bus-bloom.h" #include "bus-internal.h" #include "bus-message.h" -#include "bus-control.h" -#include "bus-bloom.h" #include "bus-util.h" #include "capability.h" +#include "string-util.h" +#include "strv.h" +#include "bus-control.h" _public_ int sd_bus_get_unique_name(sd_bus *bus, const char **unique) { int r; diff --git a/src/libsystemd/sd-bus/bus-convenience.c b/src/libsystemd/sd-bus/bus-convenience.c index af5f7da11c..0afafc2942 100644 --- a/src/libsystemd/sd-bus/bus-convenience.c +++ b/src/libsystemd/sd-bus/bus-convenience.c @@ -22,8 +22,9 @@ #include "bus-internal.h" #include "bus-message.h" #include "bus-signature.h" -#include "bus-util.h" #include "bus-type.h" +#include "bus-util.h" +#include "string-util.h" _public_ int sd_bus_emit_signal( sd_bus *bus, diff --git a/src/libsystemd/sd-bus/bus-creds.c b/src/libsystemd/sd-bus/bus-creds.c index 3e8cb0b7d0..92978da09c 100644 --- a/src/libsystemd/sd-bus/bus-creds.c +++ b/src/libsystemd/sd-bus/bus-creds.c @@ -19,22 +19,23 @@ along with systemd; If not, see . ***/ -#include #include +#include -#include "util.h" -#include "formats-util.h" -#include "process-util.h" -#include "terminal-util.h" -#include "capability.h" -#include "cgroup-util.h" -#include "fileio.h" #include "audit.h" +#include "bus-creds.h" +#include "bus-label.h" #include "bus-message.h" #include "bus-util.h" +#include "capability.h" +#include "cgroup-util.h" +#include "fileio.h" +#include "formats-util.h" +#include "process-util.h" +#include "string-util.h" #include "strv.h" -#include "bus-creds.h" -#include "bus-label.h" +#include "terminal-util.h" +#include "util.h" enum { CAP_OFFSET_INHERITABLE = 0, diff --git a/src/libsystemd/sd-bus/bus-dump.c b/src/libsystemd/sd-bus/bus-dump.c index 8833b9c677..cd7fcc7c80 100644 --- a/src/libsystemd/sd-bus/bus-dump.c +++ b/src/libsystemd/sd-bus/bus-dump.c @@ -19,17 +19,17 @@ along with systemd; If not, see . ***/ -#include "util.h" -#include "capability.h" -#include "strv.h" -#include "macro.h" +#include "bus-internal.h" +#include "bus-message.h" +#include "bus-type.h" #include "cap-list.h" +#include "capability.h" #include "formats-util.h" +#include "macro.h" +#include "string-util.h" +#include "strv.h" #include "terminal-util.h" - -#include "bus-message.h" -#include "bus-internal.h" -#include "bus-type.h" +#include "util.h" #include "bus-dump.h" static char *indent(unsigned level, unsigned flags) { diff --git a/src/libsystemd/sd-bus/bus-error.c b/src/libsystemd/sd-bus/bus-error.c index 64a5a972ae..831ceb86b9 100644 --- a/src/libsystemd/sd-bus/bus-error.c +++ b/src/libsystemd/sd-bus/bus-error.c @@ -20,16 +20,17 @@ ***/ #include -#include #include #include -#include #include - -#include "util.h" -#include "errno-list.h" +#include +#include #include "sd-bus.h" + +#include "errno-list.h" +#include "string-util.h" +#include "util.h" #include "bus-error.h" BUS_ERROR_MAP_ELF_REGISTER const sd_bus_error_map bus_standard_errors[] = { diff --git a/src/libsystemd/sd-bus/bus-internal.c b/src/libsystemd/sd-bus/bus-internal.c index fea796cd30..486a8cf8de 100644 --- a/src/libsystemd/sd-bus/bus-internal.c +++ b/src/libsystemd/sd-bus/bus-internal.c @@ -19,8 +19,9 @@ along with systemd; If not, see . ***/ -#include "bus-message.h" #include "bus-internal.h" +#include "bus-message.h" +#include "string-util.h" bool object_path_is_valid(const char *p) { const char *q; diff --git a/src/libsystemd/sd-bus/bus-internal.h b/src/libsystemd/sd-bus/bus-internal.h index e399701beb..5fc0926f06 100644 --- a/src/libsystemd/sd-bus/bus-internal.h +++ b/src/libsystemd/sd-bus/bus-internal.h @@ -21,21 +21,21 @@ along with systemd; If not, see . ***/ -#include #include - -#include "hashmap.h" -#include "prioq.h" -#include "list.h" -#include "util.h" -#include "refcnt.h" -#include "socket-util.h" +#include #include "sd-bus.h" + #include "bus-error.h" -#include "bus-match.h" #include "bus-kernel.h" +#include "bus-match.h" +#include "hashmap.h" #include "kdbus.h" +#include "list.h" +#include "prioq.h" +#include "refcnt.h" +#include "socket-util.h" +#include "util.h" struct reply_callback { sd_bus_message_handler_t callback; diff --git a/src/libsystemd/sd-bus/bus-introspect.c b/src/libsystemd/sd-bus/bus-introspect.c index 3149a56397..7ad5474439 100644 --- a/src/libsystemd/sd-bus/bus-introspect.c +++ b/src/libsystemd/sd-bus/bus-introspect.c @@ -19,11 +19,12 @@ along with systemd; If not, see . ***/ -#include "util.h" -#include "bus-introspect.h" -#include "bus-signature.h" #include "bus-internal.h" #include "bus-protocol.h" +#include "bus-signature.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 570d35c7ad..32246cbf59 100644 --- a/src/libsystemd/sd-bus/bus-kernel.c +++ b/src/libsystemd/sd-bus/bus-kernel.c @@ -34,19 +34,19 @@ #include #undef basename -#include "util.h" -#include "strv.h" -#include "memfd-util.h" +#include "bus-bloom.h" +#include "bus-internal.h" +#include "bus-label.h" +#include "bus-message.h" +#include "bus-util.h" #include "capability.h" #include "fileio.h" #include "formats-util.h" - -#include "bus-internal.h" -#include "bus-message.h" +#include "memfd-util.h" +#include "string-util.h" +#include "strv.h" +#include "util.h" #include "bus-kernel.h" -#include "bus-bloom.h" -#include "bus-util.h" -#include "bus-label.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 7234e7926a..efab756ef4 100644 --- a/src/libsystemd/sd-bus/bus-match.c +++ b/src/libsystemd/sd-bus/bus-match.c @@ -21,9 +21,10 @@ #include "bus-internal.h" #include "bus-message.h" -#include "bus-match.h" #include "bus-util.h" +#include "string-util.h" #include "strv.h" +#include "bus-match.h" /* Example: * diff --git a/src/libsystemd/sd-bus/bus-match.h b/src/libsystemd/sd-bus/bus-match.h index 53ee0463ca..bc85af3ec0 100644 --- a/src/libsystemd/sd-bus/bus-match.h +++ b/src/libsystemd/sd-bus/bus-match.h @@ -21,10 +21,10 @@ along with systemd; If not, see . ***/ -#include "hashmap.h" - #include "sd-bus.h" +#include "hashmap.h" + enum bus_match_node_type { BUS_MATCH_ROOT, BUS_MATCH_VALUE, diff --git a/src/libsystemd/sd-bus/bus-message.c b/src/libsystemd/sd-bus/bus-message.c index 72e2b9f785..0e35b3a358 100644 --- a/src/libsystemd/sd-bus/bus-message.c +++ b/src/libsystemd/sd-bus/bus-message.c @@ -23,19 +23,20 @@ #include #include -#include "util.h" -#include "utf8.h" -#include "strv.h" -#include "time-util.h" -#include "memfd-util.h" - #include "sd-bus.h" -#include "bus-message.h" + +#include "bus-gvariant.h" #include "bus-internal.h" -#include "bus-type.h" #include "bus-signature.h" -#include "bus-gvariant.h" +#include "bus-type.h" #include "bus-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-message.h b/src/libsystemd/sd-bus/bus-message.h index ff25003461..4c91dbae09 100644 --- a/src/libsystemd/sd-bus/bus-message.h +++ b/src/libsystemd/sd-bus/bus-message.h @@ -21,15 +21,16 @@ along with systemd; If not, see . ***/ -#include #include +#include #include -#include "macro.h" #include "sd-bus.h" -#include "time-util.h" + #include "bus-creds.h" #include "bus-protocol.h" +#include "macro.h" +#include "time-util.h" struct bus_container { char enclosing; diff --git a/src/libsystemd/sd-bus/bus-objects.c b/src/libsystemd/sd-bus/bus-objects.c index 728f20447a..d3679800b5 100644 --- a/src/libsystemd/sd-bus/bus-objects.c +++ b/src/libsystemd/sd-bus/bus-objects.c @@ -19,15 +19,16 @@ along with systemd; If not, see . ***/ -#include "strv.h" -#include "set.h" #include "bus-internal.h" +#include "bus-introspect.h" #include "bus-message.h" -#include "bus-type.h" #include "bus-signature.h" -#include "bus-introspect.h" -#include "bus-util.h" #include "bus-slot.h" +#include "bus-type.h" +#include "bus-util.h" +#include "set.h" +#include "string-util.h" +#include "strv.h" #include "bus-objects.h" static int node_vtable_get_userdata( diff --git a/src/libsystemd/sd-bus/bus-slot.c b/src/libsystemd/sd-bus/bus-slot.c index b149ea16da..63f10eba2c 100644 --- a/src/libsystemd/sd-bus/bus-slot.c +++ b/src/libsystemd/sd-bus/bus-slot.c @@ -20,8 +20,10 @@ ***/ #include "sd-bus.h" + #include "bus-control.h" #include "bus-objects.h" +#include "string-util.h" #include "bus-slot.h" sd_bus_slot *bus_slot_allocate( diff --git a/src/libsystemd/sd-bus/bus-socket.c b/src/libsystemd/sd-bus/bus-socket.c index d0b1e3d7dc..e4994b491f 100644 --- a/src/libsystemd/sd-bus/bus-socket.c +++ b/src/libsystemd/sd-bus/bus-socket.c @@ -20,22 +20,23 @@ ***/ #include +#include #include #include -#include +#include "sd-bus.h" #include "sd-daemon.h" -#include "util.h" + +#include "bus-internal.h" +#include "bus-message.h" +#include "formats-util.h" #include "macro.h" #include "missing.h" -#include "utf8.h" -#include "formats-util.h" #include "signal-util.h" - -#include "sd-bus.h" +#include "string-util.h" +#include "utf8.h" +#include "util.h" #include "bus-socket.h" -#include "bus-internal.h" -#include "bus-message.h" #define SNDBUF_SIZE (8*1024*1024) diff --git a/src/libsystemd/sd-bus/bus-type.h b/src/libsystemd/sd-bus/bus-type.h index 581574ab73..ad89e6c911 100644 --- a/src/libsystemd/sd-bus/bus-type.h +++ b/src/libsystemd/sd-bus/bus-type.h @@ -23,9 +23,10 @@ #include -#include "macro.h" #include "sd-bus.h" +#include "macro.h" + bool bus_type_is_valid(char c) _const_; bool bus_type_is_valid_in_signature(char c) _const_; bool bus_type_is_basic(char c) _const_; diff --git a/src/libsystemd/sd-bus/busctl-introspect.c b/src/libsystemd/sd-bus/busctl-introspect.c index abe482fc46..5604db9716 100644 --- a/src/libsystemd/sd-bus/busctl-introspect.c +++ b/src/libsystemd/sd-bus/busctl-introspect.c @@ -19,10 +19,11 @@ along with systemd; If not, see . ***/ +#include "sd-bus.h" + +#include "string-util.h" #include "util.h" #include "xml.h" -#include "sd-bus-vtable.h" - #include "busctl-introspect.h" #define NODE_DEPTH_MAX 16 diff --git a/src/libsystemd/sd-bus/sd-bus.c b/src/libsystemd/sd-bus/sd-bus.c index a23f7257fa..2fb483171e 100644 --- a/src/libsystemd/sd-bus/sd-bus.c +++ b/src/libsystemd/sd-bus/sd-bus.c @@ -27,28 +27,29 @@ #include #include -#include "util.h" -#include "macro.h" -#include "strv.h" -#include "missing.h" -#include "def.h" -#include "cgroup-util.h" -#include "hostname-util.h" -#include "bus-label.h" - #include "sd-bus.h" + +#include "bus-container.h" +#include "bus-control.h" #include "bus-internal.h" -#include "bus-message.h" -#include "bus-type.h" -#include "bus-socket.h" #include "bus-kernel.h" -#include "bus-control.h" +#include "bus-label.h" +#include "bus-message.h" #include "bus-objects.h" -#include "bus-util.h" -#include "bus-container.h" #include "bus-protocol.h" -#include "bus-track.h" #include "bus-slot.h" +#include "bus-socket.h" +#include "bus-track.h" +#include "bus-type.h" +#include "bus-util.h" +#include "cgroup-util.h" +#include "def.h" +#include "hostname-util.h" +#include "macro.h" +#include "missing.h" +#include "string-util.h" +#include "strv.h" +#include "util.h" #define log_debug_bus_message(m) \ do { \ diff --git a/src/libsystemd/sd-bus/test-bus-benchmark.c b/src/libsystemd/sd-bus/test-bus-benchmark.c index d14110aa04..4c7c58f57e 100644 --- a/src/libsystemd/sd-bus/test-bus-benchmark.c +++ b/src/libsystemd/sd-bus/test-bus-benchmark.c @@ -21,14 +21,14 @@ #include -#include "def.h" -#include "util.h" -#include "time-util.h" - #include "sd-bus.h" -#include "bus-kernel.h" + #include "bus-internal.h" +#include "bus-kernel.h" #include "bus-util.h" +#include "def.h" +#include "time-util.h" +#include "util.h" #define MAX_SIZE (2*1024*1024) diff --git a/src/libsystemd/sd-bus/test-bus-chat.c b/src/libsystemd/sd-bus/test-bus-chat.c index 20f1b532b7..c6a81a1894 100644 --- a/src/libsystemd/sd-bus/test-bus-chat.c +++ b/src/libsystemd/sd-bus/test-bus-chat.c @@ -24,16 +24,16 @@ #include #include -#include "log.h" -#include "util.h" -#include "macro.h" -#include "formats-util.h" - #include "sd-bus.h" + #include "bus-error.h" -#include "bus-match.h" #include "bus-internal.h" +#include "bus-match.h" #include "bus-util.h" +#include "formats-util.h" +#include "log.h" +#include "macro.h" +#include "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-cleanup.c b/src/libsystemd/sd-bus/test-bus-cleanup.c index f586880593..51aa0a9ad0 100644 --- a/src/libsystemd/sd-bus/test-bus-cleanup.c +++ b/src/libsystemd/sd-bus/test-bus-cleanup.c @@ -22,9 +22,10 @@ #include #include "sd-bus.h" -#include "bus-util.h" + #include "bus-internal.h" #include "bus-message.h" +#include "bus-util.h" #include "refcnt.h" static void test_bus_new(void) { diff --git a/src/libsystemd/sd-bus/test-bus-gvariant.c b/src/libsystemd/sd-bus/test-bus-gvariant.c index b078bdc5f6..f94da4cccd 100644 --- a/src/libsystemd/sd-bus/test-bus-gvariant.c +++ b/src/libsystemd/sd-bus/test-bus-gvariant.c @@ -23,14 +23,15 @@ #include #endif -#include "util.h" -#include "macro.h" #include "sd-bus.h" + +#include "bus-dump.h" #include "bus-gvariant.h" -#include "bus-util.h" #include "bus-internal.h" #include "bus-message.h" -#include "bus-dump.h" +#include "bus-util.h" +#include "macro.h" +#include "util.h" static void test_bus_gvariant_is_fixed_size(void) { assert_se(bus_gvariant_is_fixed_size("") > 0); diff --git a/src/libsystemd/sd-bus/test-bus-kernel-bloom.c b/src/libsystemd/sd-bus/test-bus-kernel-bloom.c index f3d1099dd2..02ccbd7260 100644 --- a/src/libsystemd/sd-bus/test-bus-kernel-bloom.c +++ b/src/libsystemd/sd-bus/test-bus-kernel-bloom.c @@ -19,12 +19,12 @@ along with systemd; If not, see . ***/ -#include "util.h" -#include "log.h" - #include "sd-bus.h" + #include "bus-kernel.h" #include "bus-util.h" +#include "log.h" +#include "util.h" static int test_match(sd_bus_message *m, void *userdata, sd_bus_error *ret_error) { int *found = userdata; diff --git a/src/libsystemd/sd-bus/test-bus-kernel.c b/src/libsystemd/sd-bus/test-bus-kernel.c index 6506eaab2e..436bc017a4 100644 --- a/src/libsystemd/sd-bus/test-bus-kernel.c +++ b/src/libsystemd/sd-bus/test-bus-kernel.c @@ -21,13 +21,13 @@ #include -#include "util.h" -#include "log.h" - #include "sd-bus.h" + +#include "bus-dump.h" #include "bus-kernel.h" #include "bus-util.h" -#include "bus-dump.h" +#include "log.h" +#include "util.h" int main(int argc, char *argv[]) { _cleanup_close_ int bus_ref = -1; diff --git a/src/libsystemd/sd-bus/test-bus-marshal.c b/src/libsystemd/sd-bus/test-bus-marshal.c index ff6bba5988..b54d931c1c 100644 --- a/src/libsystemd/sd-bus/test-bus-marshal.c +++ b/src/libsystemd/sd-bus/test-bus-marshal.c @@ -30,14 +30,14 @@ #include #endif -#include "log.h" -#include "util.h" - #include "sd-bus.h" -#include "bus-message.h" -#include "bus-util.h" + #include "bus-dump.h" #include "bus-label.h" +#include "bus-message.h" +#include "bus-util.h" +#include "log.h" +#include "util.h" static void test_bus_path_encode_unique(void) { _cleanup_free_ char *a = NULL, *b = NULL, *c = NULL, *d = NULL, *e = NULL; diff --git a/src/libsystemd/sd-bus/test-bus-objects.c b/src/libsystemd/sd-bus/test-bus-objects.c index 0a35b750b3..138db910ea 100644 --- a/src/libsystemd/sd-bus/test-bus-objects.c +++ b/src/libsystemd/sd-bus/test-bus-objects.c @@ -22,16 +22,16 @@ #include #include -#include "log.h" -#include "util.h" -#include "macro.h" -#include "strv.h" - #include "sd-bus.h" + +#include "bus-dump.h" #include "bus-internal.h" #include "bus-message.h" #include "bus-util.h" -#include "bus-dump.h" +#include "log.h" +#include "macro.h" +#include "strv.h" +#include "util.h" struct context { int fds[2]; diff --git a/src/libsystemd/sd-bus/test-bus-proxy.c b/src/libsystemd/sd-bus/test-bus-proxy.c index aef768dc18..ae04ff5b0d 100644 --- a/src/libsystemd/sd-bus/test-bus-proxy.c +++ b/src/libsystemd/sd-bus/test-bus-proxy.c @@ -23,13 +23,13 @@ #include #include -#include "util.h" -#include "log.h" - #include "sd-bus.h" + +#include "bus-dump.h" #include "bus-kernel.h" #include "bus-util.h" -#include "bus-dump.h" +#include "log.h" +#include "util.h" typedef struct { const char *sender; diff --git a/src/libsystemd/sd-bus/test-bus-server.c b/src/libsystemd/sd-bus/test-bus-server.c index 080d8eddb7..5bf2c1ecf8 100644 --- a/src/libsystemd/sd-bus/test-bus-server.c +++ b/src/libsystemd/sd-bus/test-bus-server.c @@ -19,16 +19,16 @@ along with systemd; If not, see . ***/ -#include #include - -#include "log.h" -#include "util.h" -#include "macro.h" +#include #include "sd-bus.h" + #include "bus-internal.h" #include "bus-util.h" +#include "log.h" +#include "macro.h" +#include "util.h" struct context { int fds[2]; diff --git a/src/libsystemd/sd-bus/test-bus-signature.c b/src/libsystemd/sd-bus/test-bus-signature.c index 17c6188ca0..92a810a7d8 100644 --- a/src/libsystemd/sd-bus/test-bus-signature.c +++ b/src/libsystemd/sd-bus/test-bus-signature.c @@ -19,7 +19,7 @@ along with systemd; If not, see . ***/ - +#include "string-util.h" #include "log.h" #include "bus-signature.h" #include "bus-internal.h" diff --git a/src/libsystemd/sd-bus/test-bus-zero-copy.c b/src/libsystemd/sd-bus/test-bus-zero-copy.c index 2d062fc9b5..42c95240d4 100644 --- a/src/libsystemd/sd-bus/test-bus-zero-copy.c +++ b/src/libsystemd/sd-bus/test-bus-zero-copy.c @@ -21,14 +21,15 @@ #include -#include "util.h" -#include "log.h" -#include "memfd-util.h" - #include "sd-bus.h" -#include "bus-message.h" -#include "bus-kernel.h" + #include "bus-dump.h" +#include "bus-kernel.h" +#include "bus-message.h" +#include "log.h" +#include "memfd-util.h" +#include "string-util.h" +#include "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 ae534ba5b9..bae37e8034 100644 --- a/src/libsystemd/sd-daemon/sd-daemon.c +++ b/src/libsystemd/sd-daemon/sd-daemon.c @@ -33,13 +33,13 @@ #include #include +#include "sd-daemon.h" + #include "path-util.h" #include "socket-util.h" #include "strv.h" #include "util.h" -#include "sd-daemon.h" - static void unsetenv_all(bool unset_environment) { if (!unset_environment) diff --git a/src/libsystemd/sd-device/device-enumerator.c b/src/libsystemd/sd-device/device-enumerator.c index 45a4d12eb7..9379209a58 100644 --- a/src/libsystemd/sd-device/device-enumerator.c +++ b/src/libsystemd/sd-device/device-enumerator.c @@ -18,15 +18,15 @@ along with systemd; If not, see . ***/ -#include "util.h" -#include "prioq.h" -#include "strv.h" -#include "set.h" - #include "sd-device.h" -#include "device-util.h" #include "device-enumerator-private.h" +#include "device-util.h" +#include "prioq.h" +#include "set.h" +#include "string-util.h" +#include "strv.h" +#include "util.h" #define DEVICE_ENUMERATE_MAX_DEPTH 256 diff --git a/src/libsystemd/sd-device/device-private.c b/src/libsystemd/sd-device/device-private.c index b5215cb9b5..f6263121b6 100644 --- a/src/libsystemd/sd-device/device-private.c +++ b/src/libsystemd/sd-device/device-private.c @@ -19,25 +19,25 @@ ***/ #include -#include #include - -#include "util.h" -#include "macro.h" -#include "refcnt.h" -#include "path-util.h" -#include "strxcpyx.h" -#include "fileio.h" -#include "hashmap.h" -#include "set.h" -#include "strv.h" -#include "mkdir.h" +#include #include "sd-device.h" -#include "device-util.h" #include "device-internal.h" #include "device-private.h" +#include "device-util.h" +#include "fileio.h" +#include "hashmap.h" +#include "macro.h" +#include "mkdir.h" +#include "path-util.h" +#include "refcnt.h" +#include "set.h" +#include "string-util.h" +#include "strv.h" +#include "strxcpyx.h" +#include "util.h" int device_add_property(sd_device *device, const char *key, const char *value) { int r; diff --git a/src/libsystemd/sd-device/device-private.h b/src/libsystemd/sd-device/device-private.h index 49a7b66a2b..d1f34efc2d 100644 --- a/src/libsystemd/sd-device/device-private.h +++ b/src/libsystemd/sd-device/device-private.h @@ -21,6 +21,12 @@ along with systemd; If not, see . ***/ +#include +#include +#include + +#include "sd-device.h" + int device_new_from_nulstr(sd_device **ret, uint8_t *nulstr, size_t len); int device_new_from_strv(sd_device **ret, char **strv); diff --git a/src/libsystemd/sd-device/sd-device.c b/src/libsystemd/sd-device/sd-device.c index e46546ed91..ca42b4318e 100644 --- a/src/libsystemd/sd-device/sd-device.c +++ b/src/libsystemd/sd-device/sd-device.c @@ -19,23 +19,23 @@ ***/ #include -#include #include +#include -#include "util.h" -#include "macro.h" -#include "path-util.h" -#include "strxcpyx.h" +#include "sd-device.h" + +#include "device-internal.h" +#include "device-private.h" +#include "device-util.h" #include "fileio.h" #include "hashmap.h" +#include "macro.h" +#include "path-util.h" #include "set.h" +#include "string-util.h" #include "strv.h" - -#include "sd-device.h" - -#include "device-util.h" -#include "device-private.h" -#include "device-internal.h" +#include "strxcpyx.h" +#include "util.h" int device_new_aux(sd_device **ret) { _cleanup_device_unref_ sd_device *device = NULL; diff --git a/src/libsystemd/sd-event/event-util.h b/src/libsystemd/sd-event/event-util.h index e7cad9be46..ae020340a5 100644 --- a/src/libsystemd/sd-event/event-util.h +++ b/src/libsystemd/sd-event/event-util.h @@ -21,9 +21,10 @@ along with systemd; If not, see . ***/ -#include "util.h" #include "sd-event.h" +#include "util.h" + DEFINE_TRIVIAL_CLEANUP_FUNC(sd_event*, sd_event_unref); DEFINE_TRIVIAL_CLEANUP_FUNC(sd_event_source*, sd_event_source_unref); diff --git a/src/libsystemd/sd-event/sd-event.c b/src/libsystemd/sd-event/sd-event.c index 1905ebfc73..cab35e185e 100644 --- a/src/libsystemd/sd-event/sd-event.c +++ b/src/libsystemd/sd-event/sd-event.c @@ -23,19 +23,20 @@ #include #include -#include "sd-id128.h" #include "sd-daemon.h" -#include "macro.h" -#include "prioq.h" +#include "sd-event.h" +#include "sd-id128.h" + #include "hashmap.h" -#include "util.h" -#include "time-util.h" +#include "list.h" +#include "macro.h" #include "missing.h" +#include "prioq.h" #include "set.h" -#include "list.h" #include "signal-util.h" - -#include "sd-event.h" +#include "string-util.h" +#include "time-util.h" +#include "util.h" #define DEFAULT_ACCURACY_USEC (250 * USEC_PER_MSEC) diff --git a/src/libsystemd/sd-hwdb/hwdb-util.h b/src/libsystemd/sd-hwdb/hwdb-util.h index ee020a2942..d366c6fa41 100644 --- a/src/libsystemd/sd-hwdb/hwdb-util.h +++ b/src/libsystemd/sd-hwdb/hwdb-util.h @@ -21,10 +21,10 @@ along with systemd; If not, see . ***/ -#include "util.h" - #include "sd-hwdb.h" +#include "util.h" + DEFINE_TRIVIAL_CLEANUP_FUNC(sd_hwdb*, sd_hwdb_unref); #define _cleanup_hwdb_unref_ _cleanup_(sd_hwdb_unrefp) diff --git a/src/libsystemd/sd-hwdb/sd-hwdb.c b/src/libsystemd/sd-hwdb/sd-hwdb.c index f0316be659..4932c19199 100644 --- a/src/libsystemd/sd-hwdb/sd-hwdb.c +++ b/src/libsystemd/sd-hwdb/sd-hwdb.c @@ -19,21 +19,21 @@ along with systemd; If not, see . ***/ -#include #include -#include +#include #include +#include #include -#include +#include #include #include "sd-hwdb.h" #include "hashmap.h" -#include "refcnt.h" - -#include "hwdb-util.h" #include "hwdb-internal.h" +#include "hwdb-util.h" +#include "refcnt.h" +#include "string-util.h" struct sd_hwdb { RefCount n_ref; diff --git a/src/libsystemd/sd-id128/sd-id128.c b/src/libsystemd/sd-id128/sd-id128.c index eb539ad318..a6dbc413ac 100644 --- a/src/libsystemd/sd-id128/sd-id128.c +++ b/src/libsystemd/sd-id128/sd-id128.c @@ -23,10 +23,11 @@ #include #include -#include "util.h" -#include "macro.h" #include "sd-id128.h" + +#include "macro.h" #include "random-util.h" +#include "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 db1fae2ebf..28f935aa66 100644 --- a/src/libsystemd/sd-login/sd-login.c +++ b/src/libsystemd/sd-login/sd-login.c @@ -25,6 +25,8 @@ #include #include +#include "sd-login.h" + #include "cgroup-util.h" #include "escape.h" #include "fileio.h" @@ -32,9 +34,9 @@ #include "hostname-util.h" #include "login-util.h" #include "macro.h" +#include "string-util.h" #include "strv.h" #include "util.h" -#include "sd-login.h" /* Error codes: * diff --git a/src/libsystemd/sd-login/test-login.c b/src/libsystemd/sd-login/test-login.c index f734ce9eee..014323321e 100644 --- a/src/libsystemd/sd-login/test-login.c +++ b/src/libsystemd/sd-login/test-login.c @@ -22,11 +22,12 @@ #include #include -#include "systemd/sd-login.h" +#include "sd-login.h" -#include "util.h" -#include "strv.h" #include "formats-util.h" +#include "string-util.h" +#include "strv.h" +#include "util.h" static void test_login(void) { _cleanup_close_pair_ int pair[2] = { -1, -1 }; diff --git a/src/libsystemd/sd-netlink/netlink-internal.h b/src/libsystemd/sd-netlink/netlink-internal.h index b9cb80668d..8519a4d523 100644 --- a/src/libsystemd/sd-netlink/netlink-internal.h +++ b/src/libsystemd/sd-netlink/netlink-internal.h @@ -23,13 +23,12 @@ #include -#include "refcnt.h" -#include "prioq.h" -#include "list.h" - #include "sd-netlink.h" +#include "list.h" #include "netlink-types.h" +#include "prioq.h" +#include "refcnt.h" #define RTNL_DEFAULT_TIMEOUT ((usec_t) (25 * USEC_PER_SEC)) diff --git a/src/libsystemd/sd-netlink/netlink-message.c b/src/libsystemd/sd-netlink/netlink-message.c index cf693de5fb..80ad70cfee 100644 --- a/src/libsystemd/sd-netlink/netlink-message.c +++ b/src/libsystemd/sd-netlink/netlink-message.c @@ -23,16 +23,16 @@ #include #include -#include "util.h" -#include "socket-util.h" +#include "sd-netlink.h" + #include "formats-util.h" -#include "refcnt.h" #include "missing.h" - -#include "sd-netlink.h" -#include "netlink-util.h" #include "netlink-internal.h" #include "netlink-types.h" +#include "netlink-util.h" +#include "refcnt.h" +#include "socket-util.h" +#include "util.h" #define GET_CONTAINER(m, i) ((i) < (m)->n_containers ? (struct rtattr*)((uint8_t*)(m)->hdr + (m)->containers[i].offset) : NULL) #define PUSH_CONTAINER(m, new) (m)->container_offsets[(m)->n_containers ++] = (uint8_t*)(new) - (uint8_t*)(m)->hdr; diff --git a/src/libsystemd/sd-netlink/netlink-socket.c b/src/libsystemd/sd-netlink/netlink-socket.c index e1b14c3ed2..68a4d3c0d1 100644 --- a/src/libsystemd/sd-netlink/netlink-socket.c +++ b/src/libsystemd/sd-netlink/netlink-socket.c @@ -23,16 +23,16 @@ #include #include -#include "util.h" -#include "socket-util.h" +#include "sd-netlink.h" + #include "formats-util.h" -#include "refcnt.h" #include "missing.h" - -#include "sd-netlink.h" -#include "netlink-util.h" #include "netlink-internal.h" #include "netlink-types.h" +#include "netlink-util.h" +#include "refcnt.h" +#include "socket-util.h" +#include "util.h" int socket_open(int family) { int fd; diff --git a/src/libsystemd/sd-netlink/netlink-util.c b/src/libsystemd/sd-netlink/netlink-util.c index 482ff6b1c2..6f9fd2993b 100644 --- a/src/libsystemd/sd-netlink/netlink-util.c +++ b/src/libsystemd/sd-netlink/netlink-util.c @@ -19,7 +19,6 @@ along with systemd; If not, see . ***/ - #include "sd-netlink.h" #include "netlink-util.h" diff --git a/src/libsystemd/sd-netlink/netlink-util.h b/src/libsystemd/sd-netlink/netlink-util.h index 9df0aa28bf..acc6c15ff3 100644 --- a/src/libsystemd/sd-netlink/netlink-util.h +++ b/src/libsystemd/sd-netlink/netlink-util.h @@ -21,9 +21,9 @@ along with systemd; If not, see . ***/ +#include "sd-netlink.h" #include "util.h" -#include "sd-netlink.h" int rtnl_message_new_synthetic_error(int error, uint32_t serial, sd_netlink_message **ret); uint32_t rtnl_message_get_serial(sd_netlink_message *m); diff --git a/src/libsystemd/sd-netlink/rtnl-message.c b/src/libsystemd/sd-netlink/rtnl-message.c index 03049bd31f..7cccb9b1d5 100644 --- a/src/libsystemd/sd-netlink/rtnl-message.c +++ b/src/libsystemd/sd-netlink/rtnl-message.c @@ -23,16 +23,16 @@ #include #include -#include "util.h" -#include "socket-util.h" +#include "sd-netlink.h" + #include "formats-util.h" -#include "refcnt.h" #include "missing.h" - -#include "sd-netlink.h" -#include "netlink-util.h" #include "netlink-internal.h" #include "netlink-types.h" +#include "netlink-util.h" +#include "refcnt.h" +#include "socket-util.h" +#include "util.h" int sd_rtnl_message_route_set_dst_prefixlen(sd_netlink_message *m, unsigned char prefixlen) { struct rtmsg *rtm; diff --git a/src/libsystemd/sd-netlink/sd-netlink.c b/src/libsystemd/sd-netlink/sd-netlink.c index 5af28600ba..2adc4499b6 100644 --- a/src/libsystemd/sd-netlink/sd-netlink.c +++ b/src/libsystemd/sd-netlink/sd-netlink.c @@ -19,17 +19,17 @@ along with systemd; If not, see . ***/ -#include #include - -#include "missing.h" -#include "macro.h" -#include "util.h" -#include "hashmap.h" +#include #include "sd-netlink.h" + +#include "hashmap.h" +#include "macro.h" +#include "missing.h" #include "netlink-internal.h" #include "netlink-util.h" +#include "util.h" static int sd_netlink_new(sd_netlink **ret) { _cleanup_netlink_unref_ sd_netlink *rtnl = NULL; diff --git a/src/libsystemd/sd-netlink/test-netlink.c b/src/libsystemd/sd-netlink/test-netlink.c index c9cb415ca0..419a28725f 100644 --- a/src/libsystemd/sd-netlink/test-netlink.c +++ b/src/libsystemd/sd-netlink/test-netlink.c @@ -19,16 +19,18 @@ along with systemd; If not, see . ***/ -#include #include +#include -#include "util.h" -#include "macro.h" #include "sd-netlink.h" -#include "socket-util.h" -#include "netlink-util.h" + #include "event-util.h" +#include "macro.h" #include "missing.h" +#include "netlink-util.h" +#include "socket-util.h" +#include "string-util.h" +#include "util.h" static void test_message_link_bridge(sd_netlink *rtnl) { _cleanup_netlink_message_unref_ sd_netlink_message *message = NULL; diff --git a/src/libsystemd/sd-network/sd-network.c b/src/libsystemd/sd-network/sd-network.c index 87d87359b8..d330712aaf 100644 --- a/src/libsystemd/sd-network/sd-network.c +++ b/src/libsystemd/sd-network/sd-network.c @@ -20,16 +20,18 @@ along with systemd; If not, see . ***/ -#include #include -#include #include +#include +#include -#include "util.h" +#include "sd-network.h" + +#include "fileio.h" #include "macro.h" +#include "string-util.h" #include "strv.h" -#include "fileio.h" -#include "sd-network.h" +#include "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 7363be2794..927b6f8b2d 100644 --- a/src/libsystemd/sd-path/sd-path.c +++ b/src/libsystemd/sd-path/sd-path.c @@ -17,12 +17,14 @@ along with systemd; If not, see . ***/ -#include "util.h" +#include "sd-path.h" + #include "architecture.h" +#include "missing.h" #include "path-util.h" +#include "string-util.h" #include "strv.h" -#include "sd-path.h" -#include "missing.h" +#include "util.h" static int from_environment(const char *envname, const char *fallback, const char **ret) { assert(ret); diff --git a/src/libsystemd/sd-resolve/resolve-util.h b/src/libsystemd/sd-resolve/resolve-util.h index 019cdaffe1..51a8a8af83 100644 --- a/src/libsystemd/sd-resolve/resolve-util.h +++ b/src/libsystemd/sd-resolve/resolve-util.h @@ -21,9 +21,10 @@ along with systemd; If not, see . ***/ -#include "util.h" #include "sd-resolve.h" +#include "util.h" + DEFINE_TRIVIAL_CLEANUP_FUNC(sd_resolve*, sd_resolve_unref); DEFINE_TRIVIAL_CLEANUP_FUNC(sd_resolve_query*, sd_resolve_query_unref); diff --git a/src/libsystemd/sd-resolve/sd-resolve.c b/src/libsystemd/sd-resolve/sd-resolve.c index 888b372c99..024ad9ead1 100644 --- a/src/libsystemd/sd-resolve/sd-resolve.c +++ b/src/libsystemd/sd-resolve/sd-resolve.c @@ -19,24 +19,25 @@ along with systemd; If not, see . ***/ -#include -#include -#include -#include -#include #include +#include +#include #include +#include #include -#include +#include +#include +#include #include -#include +#include + +#include "sd-resolve.h" -#include "util.h" #include "list.h" -#include "socket-util.h" #include "missing.h" #include "resolve-util.h" -#include "sd-resolve.h" +#include "socket-util.h" +#include "util.h" #define WORKERS_MIN 1U #define WORKERS_MAX 16U diff --git a/src/libsystemd/sd-resolve/test-resolve.c b/src/libsystemd/sd-resolve/test-resolve.c index e8056529f5..87e6e47041 100644 --- a/src/libsystemd/sd-resolve/test-resolve.c +++ b/src/libsystemd/sd-resolve/test-resolve.c @@ -20,18 +20,20 @@ along with systemd; If not, see . ***/ -#include -#include #include -#include +#include #include #include -#include +#include +#include +#include -#include "socket-util.h" #include "sd-resolve.h" -#include "resolve-util.h" + #include "macro.h" +#include "resolve-util.h" +#include "socket-util.h" +#include "string-util.h" static int getaddrinfo_handler(sd_resolve_query *q, int ret, const struct addrinfo *ai, void *userdata) { const struct addrinfo *i; diff --git a/src/libsystemd/sd-utf8/sd-utf8.c b/src/libsystemd/sd-utf8/sd-utf8.c index 6f2aa6064c..381397cc52 100644 --- a/src/libsystemd/sd-utf8/sd-utf8.c +++ b/src/libsystemd/sd-utf8/sd-utf8.c @@ -19,9 +19,10 @@ along with systemd; If not, see . ***/ +#include "sd-utf8.h" + #include "util.h" #include "utf8.h" -#include "sd-utf8.h" _public_ const char *sd_utf8_is_valid(const char *s) { assert_return(s, NULL); diff --git a/src/libudev/libudev-device-internal.h b/src/libudev/libudev-device-internal.h index aa36b8cb12..40d59201cf 100644 --- a/src/libudev/libudev-device-internal.h +++ b/src/libudev/libudev-device-internal.h @@ -21,9 +21,10 @@ #pragma once #include "libudev.h" -#include "libudev-private.h" #include "sd-device.h" +#include "libudev-private.h" + /** * udev_device: * diff --git a/src/libudev/libudev-device-private.c b/src/libudev/libudev-device-private.c index 4b9c053b54..2d3e62410c 100644 --- a/src/libudev/libudev-device-private.c +++ b/src/libudev/libudev-device-private.c @@ -19,10 +19,10 @@ ***/ #include "libudev.h" -#include "libudev-private.h" -#include "libudev-device-internal.h" #include "device-private.h" +#include "libudev-device-internal.h" +#include "libudev-private.h" int udev_device_tag_index(struct udev_device *udev_device, struct udev_device *udev_device_old, bool add) { sd_device *device_old = NULL; diff --git a/src/libudev/libudev-device.c b/src/libudev/libudev-device.c index 9a8d682107..1e513f3ff7 100644 --- a/src/libudev/libudev-device.c +++ b/src/libudev/libudev-device.c @@ -18,29 +18,29 @@ along with systemd; If not, see . ***/ -#include -#include -#include -#include -#include -#include -#include +#include #include +#include #include -#include +#include #include -#include +#include +#include +#include +#include +#include #include #include -#include +#include +#include +#include "libudev.h" #include "sd-device.h" -#include "device-util.h" -#include "device-private.h" -#include "libudev.h" -#include "libudev-private.h" +#include "device-private.h" +#include "device-util.h" #include "libudev-device-internal.h" +#include "libudev-private.h" /** * SECTION:libudev-device diff --git a/src/libudev/libudev-enumerate.c b/src/libudev/libudev-enumerate.c index df088946df..56436772b0 100644 --- a/src/libudev/libudev-enumerate.c +++ b/src/libudev/libudev-enumerate.c @@ -18,22 +18,22 @@ along with systemd; If not, see . ***/ -#include -#include -#include -#include -#include #include +#include #include #include +#include +#include +#include +#include #include #include "libudev.h" -#include "libudev-device-internal.h" #include "sd-device.h" -#include "device-util.h" -#include "device-enumerator-private.h" +#include "device-enumerator-private.h" +#include "device-util.h" +#include "libudev-device-internal.h" /** * SECTION:libudev-enumerate diff --git a/src/libudev/libudev-hwdb.c b/src/libudev/libudev-hwdb.c index 98951fb85b..6dc2b0533e 100644 --- a/src/libudev/libudev-hwdb.c +++ b/src/libudev/libudev-hwdb.c @@ -17,9 +17,10 @@ along with systemd; If not, see . ***/ -#include "libudev-private.h" #include "sd-hwdb.h" + #include "hwdb-util.h" +#include "libudev-private.h" /** * SECTION:libudev-hwdb diff --git a/src/libudev/libudev-monitor.c b/src/libudev/libudev-monitor.c index 282aa2b0d9..00472fedc9 100644 --- a/src/libudev/libudev-monitor.c +++ b/src/libudev/libudev-monitor.c @@ -17,22 +17,24 @@ along with systemd; If not, see . ***/ +#include +#include +#include +#include +#include #include #include -#include -#include -#include #include -#include #include -#include -#include +#include #include "libudev.h" + +#include "formats-util.h" #include "libudev-private.h" -#include "socket-util.h" #include "missing.h" -#include "formats-util.h" +#include "socket-util.h" +#include "string-util.h" /** * SECTION:libudev-monitor diff --git a/src/libudev/libudev-private.h b/src/libudev/libudev-private.h index c1785bf4c2..5f50496291 100644 --- a/src/libudev/libudev-private.h +++ b/src/libudev/libudev-private.h @@ -25,10 +25,11 @@ #include #include "libudev.h" + #include "macro.h" -#include "util.h" #include "mkdir.h" #include "strxcpyx.h" +#include "util.h" #define READ_END 0 #define WRITE_END 1 diff --git a/src/libudev/libudev-util.c b/src/libudev/libudev-util.c index 4408bb59f6..a614230df4 100644 --- a/src/libudev/libudev-util.c +++ b/src/libudev/libudev-util.c @@ -17,18 +17,19 @@ along with systemd; If not, see . ***/ -#include -#include -#include +#include #include +#include +#include #include -#include +#include -#include "device-nodes.h" #include "libudev.h" + +#include "MurmurHash2.h" +#include "device-nodes.h" #include "libudev-private.h" #include "utf8.h" -#include "MurmurHash2.h" /** * SECTION:libudev-util diff --git a/src/libudev/libudev.c b/src/libudev/libudev.c index ec15d2576b..00605d0126 100644 --- a/src/libudev/libudev.c +++ b/src/libudev/libudev.c @@ -17,16 +17,18 @@ along with systemd; If not, see . ***/ +#include +#include +#include #include #include -#include -#include #include -#include #include "libudev.h" + #include "libudev-private.h" #include "missing.h" +#include "string-util.h" /** * SECTION:libudev diff --git a/src/login/logind-acl.c b/src/login/logind-acl.c index c325c7bc0c..1acdc5aa22 100644 --- a/src/login/logind-acl.c +++ b/src/login/logind-acl.c @@ -26,6 +26,7 @@ #include "escape.h" #include "formats-util.h" #include "set.h" +#include "string-util.h" #include "udev-util.h" #include "util.h" #include "logind-acl.h" diff --git a/src/login/logind-acl.h b/src/login/logind-acl.h index ec09843a78..93e9ed02eb 100644 --- a/src/login/logind-acl.h +++ b/src/login/logind-acl.h @@ -23,7 +23,8 @@ #include #include -#include + +#include "libudev.h" #ifdef HAVE_ACL diff --git a/src/login/logind-action.h b/src/login/logind-action.h index ff98065371..e9b424b5f6 100644 --- a/src/login/logind-action.h +++ b/src/login/logind-action.h @@ -36,6 +36,7 @@ typedef enum HandleAction { } HandleAction; #include "logind.h" +#include "logind-inhibit.h" int manager_handle_action( Manager *m, diff --git a/src/login/logind-button.c b/src/login/logind-button.c index f40e35a8cb..caa844e601 100644 --- a/src/login/logind-button.c +++ b/src/login/logind-button.c @@ -19,14 +19,16 @@ along with systemd; If not, see . ***/ -#include #include #include +#include #include #include #include #include "sd-messages.h" + +#include "string-util.h" #include "util.h" #include "logind-button.h" diff --git a/src/login/logind-inhibit.c b/src/login/logind-inhibit.c index 7c7dd3ecb2..5b247f48d6 100644 --- a/src/login/logind-inhibit.c +++ b/src/login/logind-inhibit.c @@ -28,6 +28,7 @@ #include "fileio.h" #include "formats-util.h" #include "mkdir.h" +#include "string-util.h" #include "util.h" #include "logind-inhibit.h" diff --git a/src/login/logind-seat.c b/src/login/logind-seat.c index 8d13a63688..757993a953 100644 --- a/src/login/logind-seat.c +++ b/src/login/logind-seat.c @@ -20,17 +20,19 @@ ***/ #include -#include #include #include +#include #include "sd-messages.h" -#include "logind-seat.h" + +#include "formats-util.h" #include "logind-acl.h" -#include "util.h" #include "mkdir.h" -#include "formats-util.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-device.c b/src/login/logind-session-device.c index 656f268dba..d4d9052d10 100644 --- a/src/login/logind-session-device.c +++ b/src/login/logind-session-device.c @@ -20,12 +20,13 @@ ***/ #include -#include #include #include #include #include +#include "libudev.h" + #include "util.h" #include "missing.h" #include "bus-util.h" diff --git a/src/login/logind.c b/src/login/logind.c index 8ac2aceb9b..6ce7e1fd78 100644 --- a/src/login/logind.c +++ b/src/login/logind.c @@ -20,19 +20,20 @@ ***/ #include -#include #include #include #include +#include "libudev.h" #include "sd-daemon.h" -#include "strv.h" -#include "conf-parser.h" -#include "bus-util.h" + #include "bus-error.h" -#include "udev-util.h" +#include "bus-util.h" +#include "conf-parser.h" #include "formats-util.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/logind.h b/src/login/logind.h index 7990da5a93..44e05d8b01 100644 --- a/src/login/logind.h +++ b/src/login/logind.h @@ -22,20 +22,21 @@ ***/ #include -#include -#include "sd-event.h" +#include "libudev.h" #include "sd-bus.h" -#include "list.h" +#include "sd-event.h" + #include "hashmap.h" +#include "list.h" #include "set.h" typedef struct Manager Manager; +#include "logind-action.h" +#include "logind-button.h" #include "logind-device.h" #include "logind-inhibit.h" -#include "logind-button.h" -#include "logind-action.h" struct Manager { sd_event *event; diff --git a/src/login/sysfs-show.c b/src/login/sysfs-show.c index f38f06baf9..32e53c0a11 100644 --- a/src/login/sysfs-show.c +++ b/src/login/sysfs-show.c @@ -21,13 +21,15 @@ #include #include -#include -#include "util.h" -#include "sysfs-show.h" +#include "libudev.h" + #include "path-util.h" -#include "udev-util.h" +#include "string-util.h" +#include "sysfs-show.h" #include "terminal-util.h" +#include "udev-util.h" +#include "util.h" static int show_sysfs_one( struct udev *udev, diff --git a/src/login/test-inhibit.c b/src/login/test-inhibit.c index 03516de916..f231e54cde 100644 --- a/src/login/test-inhibit.c +++ b/src/login/test-inhibit.c @@ -21,10 +21,11 @@ #include -#include "macro.h" -#include "util.h" #include "sd-bus.h" + #include "bus-util.h" +#include "macro.h" +#include "util.h" static int inhibit(sd_bus *bus, const char *what) { _cleanup_bus_message_unref_ sd_bus_message *reply = NULL; diff --git a/src/machine/machined.h b/src/machine/machined.h index b3e59bf998..dac7a29ed1 100644 --- a/src/machine/machined.h +++ b/src/machine/machined.h @@ -23,10 +23,11 @@ #include -#include "list.h" -#include "hashmap.h" -#include "sd-event.h" #include "sd-bus.h" +#include "sd-event.h" + +#include "hashmap.h" +#include "list.h" typedef struct Manager Manager; diff --git a/src/modules-load/modules-load.c b/src/modules-load/modules-load.c index b0a3add3e7..4a58ce1082 100644 --- a/src/modules-load/modules-load.c +++ b/src/modules-load/modules-load.c @@ -21,13 +21,14 @@ #include #include +#include #include #include #include -#include #include "conf-files.h" #include "log.h" +#include "string-util.h" #include "strv.h" #include "util.h" diff --git a/src/network/networkctl.c b/src/network/networkctl.c index c78b9444b6..acb6b7ce24 100644 --- a/src/network/networkctl.c +++ b/src/network/networkctl.c @@ -37,6 +37,7 @@ #include "netlink-util.h" #include "pager.h" #include "socket-util.h" +#include "string-util.h" #include "strv.h" #include "terminal-util.h" #include "util.h" diff --git a/src/network/networkd-address-pool.c b/src/network/networkd-address-pool.c index b3450c1456..08e0b9a64b 100644 --- a/src/network/networkd-address-pool.c +++ b/src/network/networkd-address-pool.c @@ -19,9 +19,10 @@ along with systemd; If not, see . ***/ -#include "networkd.h" #include "networkd-address-pool.h" +#include "networkd.h" #include "set.h" +#include "string-util.h" int address_pool_new( Manager *m, diff --git a/src/network/networkd-address.c b/src/network/networkd-address.c index 5d443e9b9b..dcd7b482d3 100644 --- a/src/network/networkd-address.c +++ b/src/network/networkd-address.c @@ -24,11 +24,11 @@ #include "conf-parser.h" #include "firewall-util.h" #include "netlink-util.h" +#include "networkd.h" #include "set.h" +#include "string-util.h" #include "utf8.h" #include "util.h" - -#include "networkd.h" #include "networkd-address.h" int address_new(Address **ret) { diff --git a/src/network/networkd-dhcp6.c b/src/network/networkd-dhcp6.c index 57c81cb646..623359def6 100644 --- a/src/network/networkd-dhcp6.c +++ b/src/network/networkd-dhcp6.c @@ -22,11 +22,11 @@ #include #include -#include "networkd-link.h" -#include "network-internal.h" - #include "sd-dhcp6-client.h" +#include "network-internal.h" +#include "networkd-link.h" + static int dhcp6_lease_address_acquired(sd_dhcp6_client *client, Link *link); static int dhcp6_lease_information_acquired(sd_dhcp6_client *client, diff --git a/src/network/networkd-link.h b/src/network/networkd-link.h index 5c92df4ca8..2a69f1c16b 100644 --- a/src/network/networkd-link.h +++ b/src/network/networkd-link.h @@ -25,10 +25,10 @@ #include "sd-dhcp-client.h" #include "sd-dhcp-server.h" -#include "sd-ipv4ll.h" -#include "sd-ndisc.h" #include "sd-dhcp6-client.h" +#include "sd-ipv4ll.h" #include "sd-lldp.h" +#include "sd-ndisc.h" typedef struct Link Link; diff --git a/src/network/networkd-manager.c b/src/network/networkd-manager.c index e0e1679ede..23d3aac694 100644 --- a/src/network/networkd-manager.c +++ b/src/network/networkd-manager.c @@ -22,21 +22,20 @@ #include #include -#include "sd-netlink.h" #include "sd-daemon.h" +#include "sd-netlink.h" -#include "conf-parser.h" -#include "path-util.h" -#include "libudev-private.h" -#include "udev-util.h" -#include "netlink-util.h" #include "bus-util.h" +#include "conf-parser.h" #include "def.h" -#include "virt.h" -#include "set.h" +#include "libudev-private.h" #include "local-addresses.h" - +#include "netlink-util.h" #include "networkd.h" +#include "path-util.h" +#include "set.h" +#include "udev-util.h" +#include "virt.h" /* use 8 MB for receive socket kernel queue. */ #define RCVBUF_SIZE (8*1024*1024) diff --git a/src/network/networkd-ndisc.c b/src/network/networkd-ndisc.c index 637c29973e..33e692f97f 100644 --- a/src/network/networkd-ndisc.c +++ b/src/network/networkd-ndisc.c @@ -22,10 +22,10 @@ #include #include -#include "networkd-link.h" - #include "sd-ndisc.h" +#include "networkd-link.h" + static void ndisc_router_handler(sd_ndisc *nd, int event, void *userdata) { Link *link = userdata; diff --git a/src/network/networkd-netdev-bond.c b/src/network/networkd-netdev-bond.c index bcaba57937..f66c88c35e 100644 --- a/src/network/networkd-netdev-bond.c +++ b/src/network/networkd-netdev-bond.c @@ -23,10 +23,12 @@ #include #include -#include "conf-parser.h" #include "sd-netlink.h" -#include "networkd-netdev-bond.h" + +#include "conf-parser.h" #include "missing.h" +#include "string-util.h" +#include "networkd-netdev-bond.h" /* * Number of seconds between instances where the bonding diff --git a/src/network/networkd-netdev-tunnel.c b/src/network/networkd-netdev-tunnel.c index c9b7fa96e2..bbc4606258 100644 --- a/src/network/networkd-netdev-tunnel.c +++ b/src/network/networkd-netdev-tunnel.c @@ -26,11 +26,13 @@ #include #include "sd-netlink.h" -#include "networkd-netdev-tunnel.h" + +#include "conf-parser.h" +#include "missing.h" #include "networkd-link.h" +#include "string-util.h" #include "util.h" -#include "missing.h" -#include "conf-parser.h" +#include "networkd-netdev-tunnel.h" #define DEFAULT_TNL_HOP_LIMIT 64 #define IP6_FLOWINFO_FLOWLABEL htonl(0x000FFFFF) diff --git a/src/network/networkd-netdev.c b/src/network/networkd-netdev.c index 3d4865a780..d9ccc19d3d 100644 --- a/src/network/networkd-netdev.c +++ b/src/network/networkd-netdev.c @@ -24,11 +24,11 @@ #include "conf-files.h" #include "conf-parser.h" #include "list.h" -#include "siphash24.h" #include "netlink-util.h" #include "network-internal.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-bus.c b/src/network/networkd-network-bus.c index 5717a15327..2199b93baa 100644 --- a/src/network/networkd-network-bus.c +++ b/src/network/networkd-network-bus.c @@ -19,9 +19,9 @@ along with systemd; If not, see . ***/ -#include "strv.h" - #include "networkd.h" +#include "string-util.h" +#include "strv.h" static int property_get_ether_addrs( sd_bus *bus, diff --git a/src/network/networkd-network.c b/src/network/networkd-network.c index 97ada56866..9f9a6911e3 100644 --- a/src/network/networkd-network.c +++ b/src/network/networkd-network.c @@ -24,12 +24,12 @@ #include "conf-files.h" #include "conf-parser.h" -#include "util.h" -#include "hostname-util.h" #include "dns-domain.h" +#include "hostname-util.h" #include "network-internal.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) { diff --git a/src/network/networkd-route.c b/src/network/networkd-route.c index aa4ec230ab..fcca679093 100644 --- a/src/network/networkd-route.c +++ b/src/network/networkd-route.c @@ -22,9 +22,9 @@ #include "conf-parser.h" #include "in-addr-util.h" #include "netlink-util.h" -#include "util.h" - #include "networkd.h" +#include "string-util.h" +#include "util.h" #include "networkd-route.h" int route_new(Route **ret) { diff --git a/src/network/networkd-util.c b/src/network/networkd-util.c index dde6b327ed..4e4a4bbd58 100644 --- a/src/network/networkd-util.c +++ b/src/network/networkd-util.c @@ -19,10 +19,10 @@ along with systemd; If not, see . ***/ -#include "util.h" #include "conf-parser.h" - #include "networkd-util.h" +#include "string-util.h" +#include "util.h" const char *address_family_boolean_to_string(AddressFamilyBoolean b) { if (b == ADDRESS_FAMILY_YES || diff --git a/src/network/networkd-wait-online-link.c b/src/network/networkd-wait-online-link.c index cacb4c257e..cc4b46d5b0 100644 --- a/src/network/networkd-wait-online-link.c +++ b/src/network/networkd-wait-online-link.c @@ -20,10 +20,10 @@ along with systemd; If not, see . ***/ - #include "sd-network.h" #include "networkd-wait-online-link.h" +#include "string-util.h" int link_new(Manager *m, Link **ret, int ifindex, const char *ifname) { _cleanup_(link_freep) Link *l = NULL; diff --git a/src/notify/notify.c b/src/notify/notify.c index 805ea1a627..288e0a4316 100644 --- a/src/notify/notify.c +++ b/src/notify/notify.c @@ -30,6 +30,7 @@ #include "env-util.h" #include "formats-util.h" #include "log.h" +#include "string-util.h" #include "strv.h" #include "util.h" diff --git a/src/nspawn/nspawn-cgroup.c b/src/nspawn/nspawn-cgroup.c index c0e9ccd7a4..9e1f58f730 100644 --- a/src/nspawn/nspawn-cgroup.c +++ b/src/nspawn/nspawn-cgroup.c @@ -21,12 +21,12 @@ #include -#include "util.h" -#include "strv.h" -#include "mkdir.h" -#include "fileio.h" #include "cgroup-util.h" - +#include "fileio.h" +#include "mkdir.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) { diff --git a/src/nspawn/nspawn-expose-ports.c b/src/nspawn/nspawn-expose-ports.c index 3658f45381..1081a38c58 100644 --- a/src/nspawn/nspawn-expose-ports.c +++ b/src/nspawn/nspawn-expose-ports.c @@ -21,12 +21,12 @@ #include "sd-netlink.h" -#include "util.h" -#include "in-addr-util.h" #include "firewall-util.h" +#include "in-addr-util.h" #include "local-addresses.h" #include "netlink-util.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-mount.c b/src/nspawn/nspawn-mount.c index 02de2541c4..25457fd62d 100644 --- a/src/nspawn/nspawn-mount.c +++ b/src/nspawn/nspawn-mount.c @@ -19,8 +19,8 @@ along with systemd; If not, see . ***/ -#include #include +#include #include "cgroup-util.h" #include "escape.h" @@ -29,9 +29,9 @@ #include "path-util.h" #include "rm-rf.h" #include "set.h" +#include "string-util.h" #include "strv.h" #include "util.h" - #include "nspawn-mount.h" CustomMount* custom_mount_add(CustomMount **l, unsigned *n, CustomMountType t) { diff --git a/src/nspawn/nspawn-network.c b/src/nspawn/nspawn-network.c index 74abe5379a..4af18a4e94 100644 --- a/src/nspawn/nspawn-network.c +++ b/src/nspawn/nspawn-network.c @@ -22,16 +22,16 @@ #include #include +#include "libudev.h" #include "sd-id128.h" #include "sd-netlink.h" -#include "libudev.h" -#include "util.h" #include "ether-addr-util.h" -#include "siphash24.h" #include "netlink-util.h" +#include "siphash24.h" +#include "string-util.h" #include "udev-util.h" - +#include "util.h" #include "nspawn-network.h" #define HOST_HASH_KEY SD_ID128_MAKE(1a,37,6f,c7,46,ec,45,0b,ad,a3,d5,31,06,60,5d,b1) diff --git a/src/nspawn/nspawn-setuid.c b/src/nspawn/nspawn-setuid.c index eda7f62900..b6d18574e8 100644 --- a/src/nspawn/nspawn-setuid.c +++ b/src/nspawn/nspawn-setuid.c @@ -19,15 +19,15 @@ along with systemd; If not, see . ***/ +#include #include #include -#include -#include "util.h" -#include "signal-util.h" #include "mkdir.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) { diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c index 1a2e4b184b..8ef6cfd731 100644 --- a/src/nspawn/nspawn.c +++ b/src/nspawn/nspawn.c @@ -69,6 +69,13 @@ #include "missing.h" #include "mkdir.h" #include "netlink-util.h" +#include "nspawn-cgroup.h" +#include "nspawn-expose-ports.h" +#include "nspawn-mount.h" +#include "nspawn-network.h" +#include "nspawn-register.h" +#include "nspawn-settings.h" +#include "nspawn-setuid.h" #include "path-util.h" #include "process-util.h" #include "ptyfwd.h" @@ -78,19 +85,12 @@ #include "seccomp-util.h" #endif #include "signal-util.h" +#include "string-util.h" #include "strv.h" #include "terminal-util.h" #include "udev-util.h" #include "util.h" -#include "nspawn-cgroup.h" -#include "nspawn-expose-ports.h" -#include "nspawn-mount.h" -#include "nspawn-network.h" -#include "nspawn-register.h" -#include "nspawn-settings.h" -#include "nspawn-setuid.h" - typedef enum ContainerStatus { CONTAINER_TERMINATED, CONTAINER_REBOOTED diff --git a/src/nss-myhostname/nss-myhostname.c b/src/nss-myhostname/nss-myhostname.c index 0dca891447..009a9ad886 100644 --- a/src/nss-myhostname/nss-myhostname.c +++ b/src/nss-myhostname/nss-myhostname.c @@ -19,17 +19,18 @@ along with systemd; If not, see . ***/ -#include -#include #include -#include #include +#include +#include #include +#include +#include "hostname-util.h" #include "local-addresses.h" #include "macro.h" #include "nss-util.h" -#include "hostname-util.h" +#include "string-util.h" #include "util.h" /* We use 127.0.0.2 as IPv4 address. This has the advantage over diff --git a/src/nss-mymachines/nss-mymachines.c b/src/nss-mymachines/nss-mymachines.c index 604130ed25..d05a32290b 100644 --- a/src/nss-mymachines/nss-mymachines.c +++ b/src/nss-mymachines/nss-mymachines.c @@ -19,18 +19,20 @@ along with systemd; If not, see . ***/ -#include #include +#include #include "sd-bus.h" #include "sd-login.h" -#include "macro.h" -#include "util.h" -#include "nss-util.h" -#include "bus-util.h" + #include "bus-common-errors.h" -#include "in-addr-util.h" +#include "bus-util.h" #include "hostname-util.h" +#include "in-addr-util.h" +#include "macro.h" +#include "nss-util.h" +#include "string-util.h" +#include "util.h" NSS_GETHOSTBYNAME_PROTOTYPES(mymachines); NSS_GETPW_PROTOTYPES(mymachines); diff --git a/src/nss-resolve/nss-resolve.c b/src/nss-resolve/nss-resolve.c index ef5eb7b4cf..ed59a71e3d 100644 --- a/src/nss-resolve/nss-resolve.c +++ b/src/nss-resolve/nss-resolve.c @@ -19,20 +19,22 @@ along with systemd; If not, see . ***/ -#include -#include +#include #include -#include +#include +#include #include -#include +#include #include "sd-bus.h" -#include "bus-util.h" + #include "bus-common-errors.h" +#include "bus-util.h" +#include "in-addr-util.h" #include "macro.h" #include "nss-util.h" +#include "string-util.h" #include "util.h" -#include "in-addr-util.h" NSS_GETHOSTBYNAME_PROTOTYPES(resolve); NSS_GETHOSTBYADDR_PROTOTYPES(resolve); diff --git a/src/path/path.c b/src/path/path.c index 73b7bd2c01..97e8323de1 100644 --- a/src/path/path.c +++ b/src/path/path.c @@ -28,6 +28,7 @@ #include "log.h" #include "macro.h" +#include "string-util.h" #include "util.h" static const char *arg_suffix = NULL; diff --git a/src/quotacheck/quotacheck.c b/src/quotacheck/quotacheck.c index cf6a239402..a2a035f4f1 100644 --- a/src/quotacheck/quotacheck.c +++ b/src/quotacheck/quotacheck.c @@ -19,15 +19,16 @@ along with systemd; If not, see . ***/ -#include -#include #include -#include +#include +#include #include +#include -#include "util.h" #include "process-util.h" #include "signal-util.h" +#include "string-util.h" +#include "util.h" static bool arg_skip = false; static bool arg_force = false; diff --git a/src/random-seed/random-seed.c b/src/random-seed/random-seed.c index f4778fc16a..a21a0fb916 100644 --- a/src/random-seed/random-seed.c +++ b/src/random-seed/random-seed.c @@ -19,15 +19,16 @@ along with systemd; If not, see . ***/ -#include -#include #include +#include #include #include +#include #include "log.h" -#include "util.h" #include "mkdir.h" +#include "string-util.h" +#include "util.h" #define POOL_SIZE_MIN 512 diff --git a/src/rc-local-generator/rc-local-generator.c b/src/rc-local-generator/rc-local-generator.c index d4e6ba4bf9..1007de3959 100644 --- a/src/rc-local-generator/rc-local-generator.c +++ b/src/rc-local-generator/rc-local-generator.c @@ -25,8 +25,9 @@ #include #include "log.h" -#include "util.h" #include "mkdir.h" +#include "string-util.h" +#include "util.h" #ifndef RC_LOCAL_SCRIPT_PATH_START #define RC_LOCAL_SCRIPT_PATH_START "/etc/rc.d/rc.local" diff --git a/src/reply-password/reply-password.c b/src/reply-password/reply-password.c index 534cf729b9..61deafe728 100644 --- a/src/reply-password/reply-password.c +++ b/src/reply-password/reply-password.c @@ -19,14 +19,15 @@ along with systemd; If not, see . ***/ -#include -#include #include -#include #include +#include +#include +#include #include "log.h" #include "macro.h" +#include "string-util.h" #include "util.h" static int send_on_socket(int fd, const char *socket_name, const void *packet, size_t size) { diff --git a/src/resolve/resolved-conf.c b/src/resolve/resolved-conf.c index cc8d5fa76a..aca0d891c6 100644 --- a/src/resolve/resolved-conf.c +++ b/src/resolve/resolved-conf.c @@ -20,7 +20,7 @@ ***/ #include "conf-parser.h" - +#include "string-util.h" #include "resolved-conf.h" int manager_parse_dns_server(Manager *m, DnsServerType type, const char *string) { diff --git a/src/resolve/resolved-dns-answer.c b/src/resolve/resolved-dns-answer.c index 89b9b0e1ea..e1a2865007 100644 --- a/src/resolve/resolved-dns-answer.c +++ b/src/resolve/resolved-dns-answer.c @@ -19,8 +19,9 @@ along with systemd; If not, see . ***/ -#include "resolved-dns-answer.h" #include "dns-domain.h" +#include "resolved-dns-answer.h" +#include "string-util.h" DnsAnswer *dns_answer_new(unsigned n) { DnsAnswer *a; diff --git a/src/resolve/resolved-dns-rr.c b/src/resolve/resolved-dns-rr.c index 2bc8cc1639..c8f591d005 100644 --- a/src/resolve/resolved-dns-rr.c +++ b/src/resolve/resolved-dns-rr.c @@ -21,12 +21,12 @@ #include -#include "strv.h" - #include "dns-domain.h" -#include "resolved-dns-rr.h" -#include "resolved-dns-packet.h" #include "dns-type.h" +#include "resolved-dns-packet.h" +#include "string-util.h" +#include "strv.h" +#include "resolved-dns-rr.h" DnsResourceKey* dns_resource_key_new(uint16_t class, uint16_t type, const char *name) { DnsResourceKey *k; diff --git a/src/resolve/resolved-dns-zone.c b/src/resolve/resolved-dns-zone.c index 8a59bd1c3c..8a6086a4de 100644 --- a/src/resolve/resolved-dns-zone.c +++ b/src/resolve/resolved-dns-zone.c @@ -19,11 +19,11 @@ along with systemd; If not, see . ***/ -#include "list.h" - -#include "resolved-dns-zone.h" #include "dns-domain.h" +#include "list.h" #include "resolved-dns-packet.h" +#include "resolved-dns-zone.h" +#include "string-util.h" /* Never allow more than 1K entries */ #define ZONE_MAX 1024 diff --git a/src/resolve/resolved-link.c b/src/resolve/resolved-link.c index b9fd8e3dbc..43a3b61b08 100644 --- a/src/resolve/resolved-link.c +++ b/src/resolve/resolved-link.c @@ -22,9 +22,11 @@ #include #include "sd-network.h" -#include "strv.h" + #include "missing.h" #include "resolved-link.h" +#include "string-util.h" +#include "strv.h" int link_new(Manager *m, Link **ret, int ifindex) { _cleanup_(link_freep) Link *l = NULL; diff --git a/src/resolve/resolved-manager.c b/src/resolve/resolved-manager.c index de924e3ed9..b410e40308 100644 --- a/src/resolve/resolved-manager.c +++ b/src/resolve/resolved-manager.c @@ -19,26 +19,26 @@ along with systemd; If not, see . ***/ +#include +#include #include #include -#include -#include -#include "netlink-util.h" -#include "network-internal.h" -#include "socket-util.h" #include "af-list.h" -#include "utf8.h" +#include "dns-domain.h" #include "fileio-label.h" +#include "hostname-util.h" +#include "netlink-util.h" +#include "network-internal.h" #include "ordered-set.h" #include "random-util.h" -#include "hostname-util.h" - -#include "dns-domain.h" -#include "resolved-conf.h" #include "resolved-bus.h" -#include "resolved-manager.h" +#include "resolved-conf.h" #include "resolved-llmnr.h" +#include "resolved-manager.h" +#include "socket-util.h" +#include "string-util.h" +#include "utf8.h" #define SEND_TIMEOUT_USEC (200 * USEC_PER_MSEC) diff --git a/src/rfkill/rfkill.c b/src/rfkill/rfkill.c index d66f71772e..ece778b8ef 100644 --- a/src/rfkill/rfkill.c +++ b/src/rfkill/rfkill.c @@ -28,6 +28,7 @@ #include "escape.h" #include "fileio.h" #include "mkdir.h" +#include "string-util.h" #include "udev-util.h" #include "util.h" diff --git a/src/shared/acl-util.c b/src/shared/acl-util.c index bd8c988751..47295ae379 100644 --- a/src/shared/acl-util.c +++ b/src/shared/acl-util.c @@ -22,9 +22,10 @@ #include #include -#include "acl-util.h" -#include "util.h" +#include "string-util.h" #include "strv.h" +#include "util.h" +#include "acl-util.h" int acl_find_uid(acl_t acl, uid_t uid, acl_entry_t *entry) { acl_entry_t i; diff --git a/src/shared/architecture.c b/src/shared/architecture.c index 8e72e7a36a..e5efcd77b6 100644 --- a/src/shared/architecture.c +++ b/src/shared/architecture.c @@ -21,6 +21,7 @@ #include +#include "string-util.h" #include "architecture.h" int uname_architecture(void) { diff --git a/src/shared/ask-password-api.c b/src/shared/ask-password-api.c index ddf42f11e1..4bf87576f2 100644 --- a/src/shared/ask-password-api.c +++ b/src/shared/ask-password-api.c @@ -38,6 +38,7 @@ #include "random-util.h" #include "signal-util.h" #include "socket-util.h" +#include "string-util.h" #include "strv.h" #include "terminal-util.h" #include "util.h" diff --git a/src/shared/base-filesystem.c b/src/shared/base-filesystem.c index 48492ed13d..f2796c6d64 100644 --- a/src/shared/base-filesystem.c +++ b/src/shared/base-filesystem.c @@ -20,14 +20,15 @@ ***/ #include -#include #include +#include #include -#include "base-filesystem.h" #include "log.h" #include "macro.h" +#include "string-util.h" #include "util.h" +#include "base-filesystem.h" typedef struct BaseFilesystem { const char *dir; diff --git a/src/shared/bus-util.c b/src/shared/bus-util.c index 13af8bfcce..bc77884751 100644 --- a/src/shared/bus-util.c +++ b/src/shared/bus-util.c @@ -38,11 +38,11 @@ #include "path-util.h" #include "set.h" #include "signal-util.h" +#include "string-util.h" #include "strv.h" #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) { diff --git a/src/shared/bus-util.h b/src/shared/bus-util.h index fd70842b9e..3925c10fde 100644 --- a/src/shared/bus-util.h +++ b/src/shared/bus-util.h @@ -21,10 +21,12 @@ along with systemd; If not, see . ***/ -#include "sd-event.h" #include "sd-bus.h" +#include "sd-event.h" + #include "hashmap.h" #include "install.h" +#include "string-util.h" #include "time-util.h" typedef enum BusTransport { diff --git a/src/shared/cgroup-show.c b/src/shared/cgroup-show.c index 31b4f6c684..57b7aeb228 100644 --- a/src/shared/cgroup-show.c +++ b/src/shared/cgroup-show.c @@ -19,19 +19,20 @@ along with systemd; If not, see . ***/ -#include -#include #include #include +#include +#include -#include "util.h" +#include "cgroup-util.h" #include "formats-util.h" -#include "process-util.h" #include "macro.h" #include "path-util.h" -#include "cgroup-util.h" -#include "cgroup-show.h" +#include "process-util.h" +#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 d1cdb151b2..baf4bc0b87 100644 --- a/src/shared/clean-ipc.c +++ b/src/shared/clean-ipc.c @@ -19,18 +19,19 @@ along with systemd; If not, see . ***/ +#include +#include +#include #include -#include -#include #include +#include +#include #include -#include -#include -#include -#include "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) { diff --git a/src/shared/condition.c b/src/shared/condition.c index 6987cf7120..2556436542 100644 --- a/src/shared/condition.c +++ b/src/shared/condition.c @@ -37,6 +37,7 @@ #include "path-util.h" #include "selinux-util.h" #include "smack-util.h" +#include "string-util.h" #include "util.h" #include "virt.h" #include "condition.h" diff --git a/src/shared/conf-parser.c b/src/shared/conf-parser.c index c282fb1231..3f2e34c2e3 100644 --- a/src/shared/conf-parser.c +++ b/src/shared/conf-parser.c @@ -19,20 +19,22 @@ along with systemd; If not, see . ***/ -#include -#include #include +#include #include +#include #include "sd-messages.h" + #include "conf-files.h" -#include "util.h" -#include "macro.h" -#include "strv.h" #include "log.h" -#include "utf8.h" +#include "macro.h" #include "path-util.h" #include "signal-util.h" +#include "string-util.h" +#include "strv.h" +#include "utf8.h" +#include "util.h" #include "conf-parser.h" int config_item_table_lookup( diff --git a/src/shared/dns-domain.c b/src/shared/dns-domain.c index 5680f01bd9..d4df9d2acb 100644 --- a/src/shared/dns-domain.c +++ b/src/shared/dns-domain.c @@ -24,6 +24,7 @@ #include #endif +#include "string-util.h" #include "dns-domain.h" int dns_label_unescape(const char **name, char *dest, size_t sz) { diff --git a/src/shared/dropin.c b/src/shared/dropin.c index 5e0436a55d..52ea8086fe 100644 --- a/src/shared/dropin.c +++ b/src/shared/dropin.c @@ -23,6 +23,7 @@ #include "escape.h" #include "fileio-label.h" #include "mkdir.h" +#include "string-util.h" #include "strv.h" #include "util.h" #include "dropin.h" diff --git a/src/shared/fstab-util.c b/src/shared/fstab-util.c index c065adcfdf..bdfc13e3cd 100644 --- a/src/shared/fstab-util.c +++ b/src/shared/fstab-util.c @@ -19,10 +19,11 @@ along with systemd; If not, see . ***/ -#include "fstab-util.h" #include "path-util.h" +#include "string-util.h" #include "strv.h" #include "util.h" +#include "fstab-util.h" bool fstab_is_mount_point(const char *mount) { _cleanup_endmntent_ FILE *f = NULL; diff --git a/src/shared/generator.c b/src/shared/generator.c index 264a54fb94..b52b9623fa 100644 --- a/src/shared/generator.c +++ b/src/shared/generator.c @@ -28,6 +28,7 @@ #include "mkdir.h" #include "path-util.h" #include "special.h" +#include "string-util.h" #include "unit-name.h" #include "util.h" #include "generator.h" diff --git a/src/shared/import-util.c b/src/shared/import-util.c index 56388d5dd6..c4c66c847d 100644 --- a/src/shared/import-util.c +++ b/src/shared/import-util.c @@ -20,6 +20,7 @@ ***/ #include "btrfs-util.h" +#include "string-util.h" #include "util.h" #include "import-util.h" diff --git a/src/shared/install.c b/src/shared/install.c index 238433c808..5368623b74 100644 --- a/src/shared/install.c +++ b/src/shared/install.c @@ -21,23 +21,24 @@ #include #include -#include -#include #include +#include +#include -#include "util.h" -#include "mkdir.h" +#include "conf-files.h" +#include "conf-parser.h" #include "hashmap.h" -#include "set.h" -#include "path-util.h" +#include "install-printf.h" +#include "mkdir.h" #include "path-lookup.h" +#include "path-util.h" +#include "set.h" +#include "special.h" +#include "string-util.h" #include "strv.h" #include "unit-name.h" +#include "util.h" #include "install.h" -#include "conf-parser.h" -#include "conf-files.h" -#include "install-printf.h" -#include "special.h" typedef struct { OrderedHashmap *will_install; diff --git a/src/shared/logs-show.c b/src/shared/logs-show.c index dbc07aa7ad..cb4a0d2172 100644 --- a/src/shared/logs-show.c +++ b/src/shared/logs-show.c @@ -19,25 +19,25 @@ along with systemd; If not, see . ***/ -#include #include -#include -#include #include +#include +#include +#include -#include "logs-show.h" -#include "log.h" -#include "util.h" -#include "utf8.h" +#include "formats-util.h" #include "hashmap.h" +#include "hostname-util.h" #include "journal-internal.h" -#include "formats-util.h" +#include "log.h" #include "process-util.h" +#include "string-util.h" #include "terminal-util.h" -#include "hostname-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 */ +/* up to three lines (each up to 100 characters) or 300 characters, whichever is less */ #define PRINT_LINE_THRESHOLD 3 #define PRINT_CHAR_THRESHOLD 300 diff --git a/src/shared/machine-image.c b/src/shared/machine-image.c index 8ed3ad7f44..8261d87091 100644 --- a/src/shared/machine-image.c +++ b/src/shared/machine-image.c @@ -28,9 +28,9 @@ #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[] = diff --git a/src/shared/machine-pool.c b/src/shared/machine-pool.c index 1da7d0815f..597680ef5f 100644 --- a/src/shared/machine-pool.c +++ b/src/shared/machine-pool.c @@ -19,18 +19,19 @@ along with systemd; If not, see . ***/ +#include #include -#include #include -#include +#include -#include "util.h" -#include "process-util.h" +#include "btrfs-util.h" #include "lockfile-util.h" #include "mkdir.h" -#include "btrfs-util.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) diff --git a/src/shared/pager.c b/src/shared/pager.c index d8f0fb404d..b82b526309 100644 --- a/src/shared/pager.c +++ b/src/shared/pager.c @@ -21,17 +21,18 @@ #include #include -#include #include #include +#include -#include "pager.h" -#include "util.h" -#include "process-util.h" +#include "copy.h" #include "macro.h" -#include "terminal-util.h" +#include "process-util.h" #include "signal-util.h" -#include "copy.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/path-lookup.c b/src/shared/path-lookup.c index 897dc9065f..1e63c72047 100644 --- a/src/shared/path-lookup.c +++ b/src/shared/path-lookup.c @@ -27,8 +27,9 @@ #include "util.h" #include "strv.h" #include "path-util.h" -#include "path-lookup.h" #include "install.h" +#include "string-util.h" +#include "path-lookup.h" int user_config_home(char **config_home) { const char *e; diff --git a/src/shared/seccomp-util.c b/src/shared/seccomp-util.c index d73a74912e..c518cf83ec 100644 --- a/src/shared/seccomp-util.c +++ b/src/shared/seccomp-util.c @@ -21,6 +21,7 @@ #include +#include "string-util.h" #include "util.h" #include "seccomp-util.h" diff --git a/src/shared/sleep-config.c b/src/shared/sleep-config.c index 3dedbd1f62..e69300b1db 100644 --- a/src/shared/sleep-config.c +++ b/src/shared/sleep-config.c @@ -22,11 +22,12 @@ #include #include "conf-parser.h" -#include "sleep-config.h" #include "fileio.h" #include "log.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/specifier.c b/src/shared/specifier.c index 85bd477f2d..610aec0df5 100644 --- a/src/shared/specifier.c +++ b/src/shared/specifier.c @@ -22,9 +22,10 @@ #include #include +#include "hostname-util.h" #include "macro.h" +#include "string-util.h" #include "util.h" -#include "hostname-util.h" #include "specifier.h" /* diff --git a/src/shared/switch-root.c b/src/shared/switch-root.c index b12189cd10..205a2e1449 100644 --- a/src/shared/switch-root.c +++ b/src/shared/switch-root.c @@ -19,20 +19,21 @@ along with systemd; If not, see . ***/ -#include -#include #include +#include +#include #include #include +#include #include -#include -#include "util.h" -#include "path-util.h" -#include "mkdir.h" -#include "rm-rf.h" #include "base-filesystem.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" int switch_root(const char *new_root, const char *oldroot, bool detach_oldroot, unsigned long mountflags) { diff --git a/src/shared/sysctl-util.c b/src/shared/sysctl-util.c index b2cab948ef..21cb82ea1c 100644 --- a/src/shared/sysctl-util.c +++ b/src/shared/sysctl-util.c @@ -29,6 +29,7 @@ #include "fileio.h" #include "log.h" +#include "string-util.h" #include "util.h" #include "sysctl-util.h" diff --git a/src/shared/utmp-wtmp.c b/src/shared/utmp-wtmp.c index 63f1e4ca6f..235f10d1a6 100644 --- a/src/shared/utmp-wtmp.c +++ b/src/shared/utmp-wtmp.c @@ -19,18 +19,19 @@ along with systemd; If not, see . ***/ -#include #include +#include +#include #include #include -#include #include -#include +#include +#include "hostname-util.h" #include "macro.h" #include "path-util.h" +#include "string-util.h" #include "terminal-util.h" -#include "hostname-util.h" #include "utmp-wtmp.h" int utmp_get_runlevel(int *runlevel, int *previous) { diff --git a/src/sleep/sleep.c b/src/sleep/sleep.c index 1ba66eb998..b92b77c381 100644 --- a/src/sleep/sleep.c +++ b/src/sleep/sleep.c @@ -30,6 +30,7 @@ #include "fileio.h" #include "log.h" #include "sleep-config.h" +#include "string-util.h" #include "strv.h" #include "util.h" diff --git a/src/socket-proxy/socket-proxyd.c b/src/socket-proxy/socket-proxyd.c index 73c04fdfc0..521dbb2840 100644 --- a/src/socket-proxy/socket-proxyd.c +++ b/src/socket-proxy/socket-proxyd.c @@ -38,6 +38,7 @@ #include "path-util.h" #include "set.h" #include "socket-util.h" +#include "string-util.h" #include "util.h" #define BUFFER_SIZE (256 * 1024) diff --git a/src/sysctl/sysctl.c b/src/sysctl/sysctl.c index ee34209a30..e247264a83 100644 --- a/src/sysctl/sysctl.c +++ b/src/sysctl/sysctl.c @@ -32,6 +32,7 @@ #include "hashmap.h" #include "log.h" #include "path-util.h" +#include "string-util.h" #include "strv.h" #include "sysctl-util.h" #include "util.h" diff --git a/src/system-update-generator/system-update-generator.c b/src/system-update-generator/system-update-generator.c index 00045150f6..794aa1a0c7 100644 --- a/src/system-update-generator/system-update-generator.c +++ b/src/system-update-generator/system-update-generator.c @@ -23,6 +23,7 @@ #include #include "log.h" +#include "string-util.h" #include "util.h" /* diff --git a/src/systemd/sd-dhcp6-client.h b/src/systemd/sd-dhcp6-client.h index 90c35ef3f6..e95d758815 100644 --- a/src/systemd/sd-dhcp6-client.h +++ b/src/systemd/sd-dhcp6-client.h @@ -23,6 +23,7 @@ ***/ #include +#include #include "sd-event.h" diff --git a/src/systemd/sd-lldp.h b/src/systemd/sd-lldp.h index 30d9dedf2c..e9abdf349f 100644 --- a/src/systemd/sd-lldp.h +++ b/src/systemd/sd-lldp.h @@ -22,6 +22,8 @@ #pragma once +#include + #include "sd-event.h" enum { diff --git a/src/sysusers/sysusers.c b/src/sysusers/sysusers.c index 238b1086b2..4c88f28e28 100644 --- a/src/sysusers/sysusers.c +++ b/src/sysusers/sysusers.c @@ -33,12 +33,13 @@ #include "hashmap.h" #include "path-util.h" #include "selinux-util.h" +#include "smack-util.h" #include "specifier.h" +#include "string-util.h" #include "strv.h" #include "uid-range.h" #include "utf8.h" #include "util.h" -#include "smack-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 964750076a..4d1ecaff40 100644 --- a/src/sysv-generator/sysv-generator.c +++ b/src/sysv-generator/sysv-generator.c @@ -25,17 +25,18 @@ #include #include -#include "util.h" +#include "hashmap.h" +#include "install.h" +#include "log.h" #include "mkdir.h" -#include "strv.h" -#include "path-util.h" #include "path-lookup.h" -#include "log.h" -#include "unit-name.h" -#include "special.h" -#include "hashmap.h" +#include "path-util.h" #include "set.h" -#include "install.h" +#include "special.h" +#include "string-util.h" +#include "strv.h" +#include "unit-name.h" +#include "util.h" typedef enum RunlevelType { RUNLEVEL_UP, diff --git a/src/test/test-af-list.c b/src/test/test-af-list.c index d69104f540..aeaa0929b1 100644 --- a/src/test/test-af-list.c +++ b/src/test/test-af-list.c @@ -17,17 +17,18 @@ along with systemd; If not, see . ***/ -#include #include +#include #include "macro.h" +#include "string-util.h" #include "util.h" static const struct af_name* lookup_af(register const char *str, register unsigned int len); +#include "af-from-name.h" #include "af-list.h" #include "af-to-name.h" -#include "af-from-name.h" int main(int argc, const char *argv[]) { @@ -45,4 +46,4 @@ int main(int argc, const char *argv[]) { assert_se(af_from_name("huddlduddl") == AF_UNSPEC); return 0; -} \ No newline at end of file +} diff --git a/src/test/test-arphrd-list.c b/src/test/test-arphrd-list.c index d7c8eaa4a9..f3989ad201 100644 --- a/src/test/test-arphrd-list.c +++ b/src/test/test-arphrd-list.c @@ -21,13 +21,14 @@ #include #include "macro.h" +#include "string-util.h" #include "util.h" static const struct arphrd_name* lookup_arphrd(register const char *str, register unsigned int len); +#include "arphrd-from-name.h" #include "arphrd-list.h" #include "arphrd-to-name.h" -#include "arphrd-from-name.h" int main(int argc, const char *argv[]) { @@ -45,4 +46,4 @@ int main(int argc, const char *argv[]) { assert_se(arphrd_from_name("huddlduddl") == 0); return 0; -} \ No newline at end of file +} diff --git a/src/test/test-btrfs.c b/src/test/test-btrfs.c index 60d1258a9b..b772e31963 100644 --- a/src/test/test-btrfs.c +++ b/src/test/test-btrfs.c @@ -25,6 +25,7 @@ #include "fileio.h" #include "util.h" #include "btrfs-util.h" +#include "string-util.h" int main(int argc, char *argv[]) { BtrfsQuotaInfo quota; diff --git a/src/test/test-calendarspec.c b/src/test/test-calendarspec.c index ad36ef19b0..12f366a34c 100644 --- a/src/test/test-calendarspec.c +++ b/src/test/test-calendarspec.c @@ -22,6 +22,7 @@ #include #include "calendarspec.h" +#include "string-util.h" #include "util.h" static void test_one(const char *input, const char *output) { diff --git a/src/test/test-cgroup-util.c b/src/test/test-cgroup-util.c index 4ecf09a29e..267dda651d 100644 --- a/src/test/test-cgroup-util.c +++ b/src/test/test-cgroup-util.c @@ -19,12 +19,12 @@ along with systemd; If not, see . ***/ - #include "util.h" #include "cgroup-util.h" #include "test-helper.h" #include "formats-util.h" #include "process-util.h" +#include "string-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-cgroup.c b/src/test/test-cgroup.c index 37b1c3554a..c20a29ba1f 100644 --- a/src/test/test-cgroup.c +++ b/src/test/test-cgroup.c @@ -19,11 +19,12 @@ along with systemd; If not, see . ***/ -#include #include +#include #include "cgroup-util.h" #include "path-util.h" +#include "string-util.h" #include "util.h" int main(int argc, char*argv[]) { diff --git a/src/test/test-condition.c b/src/test/test-condition.c index b788c9532d..91a27138eb 100644 --- a/src/test/test-condition.c +++ b/src/test/test-condition.c @@ -17,18 +17,19 @@ along with systemd; If not, see . ***/ -#include "condition.h" -#include "macro.h" -#include "util.h" -#include "log.h" -#include "architecture.h" #include "sd-id128.h" -#include "selinux-util.h" + +#include "apparmor-util.h" +#include "architecture.h" #include "audit.h" +#include "condition.h" +#include "hostname-util.h" #include "ima-util.h" -#include "apparmor-util.h" +#include "log.h" +#include "macro.h" +#include "selinux-util.h" #include "smack-util.h" -#include "hostname-util.h" +#include "util.h" static void test_condition_test_path(void) { Condition *condition; diff --git a/src/test/test-conf-files.c b/src/test/test-conf-files.c index 01ece022c1..30ba5364c4 100644 --- a/src/test/test-conf-files.c +++ b/src/test/test-conf-files.c @@ -19,14 +19,15 @@ along with systemd; If not, see . ***/ -#include #include +#include #include "conf-files.h" #include "macro.h" +#include "rm-rf.h" +#include "string-util.h" #include "strv.h" #include "util.h" -#include "rm-rf.h" static void setup_test_dir(char *tmp_dir, const char *files, ...) { va_list ap; diff --git a/src/test/test-conf-parser.c b/src/test/test-conf-parser.c index 463906d304..b3a4c40339 100644 --- a/src/test/test-conf-parser.c +++ b/src/test/test-conf-parser.c @@ -18,10 +18,11 @@ ***/ #include "conf-parser.h" +#include "log.h" #include "macro.h" -#include "util.h" +#include "string-util.h" #include "strv.h" -#include "log.h" +#include "util.h" static void test_config_parse_path_one(const char *rvalue, const char *expected) { char *path = NULL; diff --git a/src/test/test-copy.c b/src/test/test-copy.c index a03a68bd43..000d407db1 100644 --- a/src/test/test-copy.c +++ b/src/test/test-copy.c @@ -20,13 +20,14 @@ #include #include "copy.h" -#include "path-util.h" #include "fileio.h" +#include "macro.h" #include "mkdir.h" +#include "path-util.h" +#include "rm-rf.h" +#include "string-util.h" #include "strv.h" -#include "macro.h" #include "util.h" -#include "rm-rf.h" static void test_copy_file(void) { _cleanup_free_ char *buf = NULL; diff --git a/src/test/test-date.c b/src/test/test-date.c index bd1b2781df..8d78ab89d0 100644 --- a/src/test/test-date.c +++ b/src/test/test-date.c @@ -22,6 +22,7 @@ #include #include "util.h" +#include "string-util.h" static void test_should_pass(const char *p) { usec_t t, q; diff --git a/src/test/test-device-nodes.c b/src/test/test-device-nodes.c index 59ba4be087..1c745d6e5b 100644 --- a/src/test/test-device-nodes.c +++ b/src/test/test-device-nodes.c @@ -22,6 +22,7 @@ #include #include "device-nodes.h" +#include "string-util.h" #include "util.h" /* helpers for test_encode_devnode_name */ diff --git a/src/test/test-dns-domain.c b/src/test/test-dns-domain.c index 2193eb6f7d..1a8541e1cc 100644 --- a/src/test/test-dns-domain.c +++ b/src/test/test-dns-domain.c @@ -19,8 +19,9 @@ along with systemd; If not, see . ***/ -#include "macro.h" #include "dns-domain.h" +#include "macro.h" +#include "string-util.h" static void test_dns_label_unescape_one(const char *what, const char *expect, size_t buffer_sz, int ret) { char buffer[buffer_sz]; diff --git a/src/test/test-ellipsize.c b/src/test/test-ellipsize.c index 27df9089c3..033d5af719 100644 --- a/src/test/test-ellipsize.c +++ b/src/test/test-ellipsize.c @@ -21,9 +21,10 @@ #include -#include "util.h" -#include "terminal-util.h" #include "def.h" +#include "string-util.h" +#include "terminal-util.h" +#include "util.h" static void test_one(const char *p) { _cleanup_free_ char *t; diff --git a/src/test/test-env-replace.c b/src/test/test-env-replace.c index 110223f3b8..c1315bbf9f 100644 --- a/src/test/test-env-replace.c +++ b/src/test/test-env-replace.c @@ -21,9 +21,10 @@ #include -#include "util.h" -#include "strv.h" #include "env-util.h" +#include "string-util.h" +#include "strv.h" +#include "util.h" static void test_strv_env_delete(void) { _cleanup_strv_free_ char **a = NULL, **b = NULL, **c = NULL, **d = NULL; diff --git a/src/test/test-fileio.c b/src/test/test-fileio.c index ad547822e7..a72e84bc66 100644 --- a/src/test/test-fileio.c +++ b/src/test/test-fileio.c @@ -30,6 +30,7 @@ #include "env-util.h" #include "def.h" #include "ctype.h" +#include "string-util.h" static void test_parse_env_file(void) { char t[] = "/tmp/test-fileio-in-XXXXXX", diff --git a/src/test/test-fstab-util.c b/src/test/test-fstab-util.c index 50e5dee0a7..b02f3a6e7c 100644 --- a/src/test/test-fstab-util.c +++ b/src/test/test-fstab-util.c @@ -20,8 +20,9 @@ ***/ #include "fstab-util.h" -#include "util.h" #include "log.h" +#include "string-util.h" +#include "util.h" /* int fstab_filter_options(const char *opts, const char *names, diff --git a/src/test/test-hashmap-plain.c b/src/test/test-hashmap-plain.c index c691f577c6..2da6446961 100644 --- a/src/test/test-hashmap-plain.c +++ b/src/test/test-hashmap-plain.c @@ -17,9 +17,10 @@ along with systemd; If not, see . ***/ +#include "hashmap.h" +#include "string-util.h" #include "strv.h" #include "util.h" -#include "hashmap.h" void test_hashmap_funcs(void); diff --git a/src/test/test-hostname-util.c b/src/test/test-hostname-util.c index 6f5ef2615e..ac8f4ecc68 100644 --- a/src/test/test-hostname-util.c +++ b/src/test/test-hostname-util.c @@ -24,6 +24,7 @@ #include "util.h" #include "fileio.h" #include "hostname-util.h" +#include "string-util.h" static void test_hostname_is_valid(void) { assert_se(hostname_is_valid("foobar", false)); diff --git a/src/test/test-id128.c b/src/test/test-id128.c index a6a0cd77a1..2c8ba70ffb 100644 --- a/src/test/test-id128.c +++ b/src/test/test-id128.c @@ -21,11 +21,12 @@ #include -#include "systemd/sd-id128.h" +#include "sd-daemon.h" +#include "sd-id128.h" -#include "util.h" #include "macro.h" -#include "sd-daemon.h" +#include "string-util.h" +#include "util.h" #define ID128_WALDI SD_ID128_MAKE(01, 02, 03, 04, 05, 06, 07, 08, 09, 0a, 0b, 0c, 0d, 0e, 0f, 10) #define STR_WALDI "0102030405060708090a0b0c0d0e0f10" diff --git a/src/test/test-json.c b/src/test/test-json.c index 1058c583c3..ba4d75c0c8 100644 --- a/src/test/test-json.c +++ b/src/test/test-json.c @@ -21,8 +21,9 @@ #include -#include "util.h" #include "json.h" +#include "string-util.h" +#include "util.h" static void test_one(const char *data, ...) { void *state = NULL; diff --git a/src/test/test-libudev.c b/src/test/test-libudev.c index 34c49b969a..350eaf734d 100644 --- a/src/test/test-libudev.c +++ b/src/test/test-libudev.c @@ -18,12 +18,14 @@ along with systemd; If not, see . ***/ -#include -#include #include +#include #include +#include #include "libudev.h" + +#include "string-util.h" #include "udev-util.h" #include "util.h" diff --git a/src/test/test-namespace.c b/src/test/test-namespace.c index 7d7e08dc5d..de11443c7a 100644 --- a/src/test/test-namespace.c +++ b/src/test/test-namespace.c @@ -22,8 +22,9 @@ #include #include "namespace.h" -#include "util.h" #include "process-util.h" +#include "string-util.h" +#include "util.h" static void test_tmpdir(const char *id, const char *A, const char *B) { _cleanup_free_ char *a, *b; diff --git a/src/test/test-netlink-manual.c b/src/test/test-netlink-manual.c index 2879d7450f..a1e8774063 100644 --- a/src/test/test-netlink-manual.c +++ b/src/test/test-netlink-manual.c @@ -20,15 +20,16 @@ ***/ #include -#include +#include #include +#include #include -#include -#include "util.h" -#include "macro.h" #include "sd-netlink.h" +#include "macro.h" +#include "util.h" + static int load_module(const char *mod_name) { struct kmod_ctx *ctx; struct kmod_list *list = NULL, *l; diff --git a/src/test/test-path-lookup.c b/src/test/test-path-lookup.c index aa4bac6cdd..92ffa65925 100644 --- a/src/test/test-path-lookup.c +++ b/src/test/test-path-lookup.c @@ -21,10 +21,11 @@ #include -#include "path-lookup.h" #include "log.h" -#include "strv.h" +#include "path-lookup.h" #include "rm-rf.h" +#include "string-util.h" +#include "strv.h" static void test_paths(ManagerRunningAs running_as, bool personal) { char template[] = "/tmp/test-path-lookup.XXXXXXX"; diff --git a/src/test/test-path-util.c b/src/test/test-path-util.c index a930196a6c..2977487c88 100644 --- a/src/test/test-path-util.c +++ b/src/test/test-path-util.c @@ -20,14 +20,15 @@ ***/ #include -#include #include +#include -#include "path-util.h" -#include "util.h" #include "macro.h" -#include "strv.h" +#include "path-util.h" #include "rm-rf.h" +#include "string-util.h" +#include "strv.h" +#include "util.h" #define test_path_compare(a, b, result) { \ assert_se(path_compare(a, b) == result); \ diff --git a/src/test/test-path.c b/src/test/test-path.c index 676c9f1793..19796bd6cb 100644 --- a/src/test/test-path.c +++ b/src/test/test-path.c @@ -17,16 +17,17 @@ along with systemd; If not, see . ***/ -#include #include +#include -#include "unit.h" -#include "manager.h" -#include "util.h" #include "macro.h" -#include "strv.h" +#include "manager.h" #include "mkdir.h" #include "rm-rf.h" +#include "string-util.h" +#include "strv.h" +#include "unit.h" +#include "util.h" typedef void (*test_function_t)(Manager *m); diff --git a/src/test/test-process-util.c b/src/test/test-process-util.c index eb0f443a43..16a7148b19 100644 --- a/src/test/test-process-util.c +++ b/src/test/test-process-util.c @@ -18,17 +18,18 @@ along with systemd; If not, see . ***/ -#include #include +#include #include #include -#include "process-util.h" #include "log.h" -#include "util.h" #include "macro.h" -#include "virt.h" +#include "process-util.h" +#include "string-util.h" #include "terminal-util.h" +#include "util.h" +#include "virt.h" static void test_get_process_comm(void) { struct stat st; diff --git a/src/test/test-replace-var.c b/src/test/test-replace-var.c index b1d42d77fd..2de2091561 100644 --- a/src/test/test-replace-var.c +++ b/src/test/test-replace-var.c @@ -21,9 +21,10 @@ #include -#include "util.h" #include "macro.h" #include "replace-var.h" +#include "string-util.h" +#include "util.h" static char *lookup(const char *variable, void *userdata) { return strjoin("<<<", variable, ">>>", NULL); diff --git a/src/test/test-socket-util.c b/src/test/test-socket-util.c index 2c18090ae5..ba1c7e6877 100644 --- a/src/test/test-socket-util.c +++ b/src/test/test-socket-util.c @@ -17,12 +17,13 @@ along with systemd; If not, see . ***/ -#include "socket-util.h" +#include "async.h" #include "in-addr-util.h" -#include "util.h" -#include "macro.h" #include "log.h" -#include "async.h" +#include "macro.h" +#include "socket-util.h" +#include "string-util.h" +#include "util.h" static void test_socket_address_parse(void) { SocketAddress a; diff --git a/src/test/test-strbuf.c b/src/test/test-strbuf.c index 4ec648ae66..1d8eda0c15 100644 --- a/src/test/test-strbuf.c +++ b/src/test/test-strbuf.c @@ -23,6 +23,7 @@ #include #include "strbuf.h" +#include "string-util.h" #include "strv.h" #include "util.h" diff --git a/src/test/test-strip-tab-ansi.c b/src/test/test-strip-tab-ansi.c index 6cec8768b1..10fc98ced5 100644 --- a/src/test/test-strip-tab-ansi.c +++ b/src/test/test-strip-tab-ansi.c @@ -21,8 +21,9 @@ #include -#include "util.h" +#include "string-util.h" #include "terminal-util.h" +#include "util.h" int main(int argc, char *argv[]) { char *p; diff --git a/src/test/test-strv.c b/src/test/test-strv.c index 623c926521..c676893719 100644 --- a/src/test/test-strv.c +++ b/src/test/test-strv.c @@ -22,9 +22,10 @@ #include -#include "util.h" #include "specifier.h" +#include "string-util.h" #include "strv.h" +#include "util.h" static void test_specifier_printf(void) { static const Specifier table[] = { diff --git a/src/test/test-strxcpyx.c b/src/test/test-strxcpyx.c index 858a4081da..e411d479ab 100644 --- a/src/test/test-strxcpyx.c +++ b/src/test/test-strxcpyx.c @@ -21,8 +21,9 @@ #include -#include "util.h" +#include "string-util.h" #include "strxcpyx.h" +#include "util.h" static void test_strpcpy(void) { char target[25]; diff --git a/src/test/test-tmpfiles.c b/src/test/test-tmpfiles.c index 221dd67eb2..ab255c7c83 100644 --- a/src/test/test-tmpfiles.c +++ b/src/test/test-tmpfiles.c @@ -20,12 +20,13 @@ ***/ #include -#include -#include #include +#include +#include -#include "util.h" #include "formats-util.h" +#include "string-util.h" +#include "util.h" int main(int argc, char** argv) { const char *p = argv[1] ?: "/tmp"; diff --git a/src/test/test-udev.c b/src/test/test-udev.c index 2b765a3e90..3b9f71e3a2 100644 --- a/src/test/test-udev.c +++ b/src/test/test-udev.c @@ -18,19 +18,20 @@ along with systemd; If not, see . ***/ -#include -#include #include -#include #include +#include +#include #include #include +#include #include "missing.h" #include "selinux-util.h" #include "signal-util.h" -#include "udev.h" +#include "string-util.h" #include "udev-util.h" +#include "udev.h" static int fake_filesystems(void) { static const struct fakefs { diff --git a/src/test/test-unit-file.c b/src/test/test-unit-file.c index 8358789e6f..e4573956a5 100644 --- a/src/test/test-unit-file.c +++ b/src/test/test-unit-file.c @@ -20,23 +20,24 @@ along with systemd; If not, see . ***/ -#include +#include #include +#include #include #include -#include -#include "install.h" -#include "install-printf.h" -#include "specifier.h" -#include "util.h" -#include "macro.h" +#include "fileio.h" #include "hashmap.h" +#include "hostname-util.h" +#include "install-printf.h" +#include "install.h" #include "load-fragment.h" +#include "macro.h" +#include "specifier.h" +#include "string-util.h" #include "strv.h" -#include "fileio.h" #include "test-helper.h" -#include "hostname-util.h" +#include "util.h" static int test_unit_file_get_set(void) { int r; diff --git a/src/test/test-unit-name.c b/src/test/test-unit-name.c index e5405fb7f3..5aff771af5 100644 --- a/src/test/test-unit-name.c +++ b/src/test/test-unit-name.c @@ -21,21 +21,22 @@ along with systemd; If not, see . ***/ +#include #include #include #include -#include +#include "hostname-util.h" +#include "macro.h" #include "manager.h" -#include "unit.h" +#include "path-util.h" +#include "specifier.h" +#include "string-util.h" +#include "test-helper.h" #include "unit-name.h" #include "unit-printf.h" -#include "specifier.h" +#include "unit.h" #include "util.h" -#include "macro.h" -#include "path-util.h" -#include "test-helper.h" -#include "hostname-util.h" static void test_unit_name_is_valid(void) { assert_se(unit_name_is_valid("foo.service", UNIT_NAME_ANY)); diff --git a/src/test/test-utf8.c b/src/test/test-utf8.c index 346f8524c6..a8e15b7cf1 100644 --- a/src/test/test-utf8.c +++ b/src/test/test-utf8.c @@ -21,6 +21,7 @@ #include "utf8.h" #include "util.h" +#include "string-util.h" static void test_utf8_is_printable(void) { assert_se(utf8_is_printable("ascii is valid\tunicode", 22)); diff --git a/src/test/test-util.c b/src/test/test-util.c index 10bbb17b14..49a30601bc 100644 --- a/src/test/test-util.c +++ b/src/test/test-util.c @@ -40,6 +40,7 @@ #include "process-util.h" #include "rm-rf.h" #include "signal-util.h" +#include "string-util.h" #include "strv.h" #include "util.h" #include "virt.h" diff --git a/src/test/test-xml.c b/src/test/test-xml.c index ea109fbde0..93b0e7c3fb 100644 --- a/src/test/test-xml.c +++ b/src/test/test-xml.c @@ -21,8 +21,9 @@ #include -#include "xml.h" +#include "string-util.h" #include "util.h" +#include "xml.h" static void test_one(const char *data, ...) { void *state = NULL; diff --git a/src/timesync/timesyncd-conf.c b/src/timesync/timesyncd-conf.c index 28ad378a93..28e0636604 100644 --- a/src/timesync/timesyncd-conf.c +++ b/src/timesync/timesyncd-conf.c @@ -19,7 +19,7 @@ along with systemd; If not, see . ***/ - +#include "string-util.h" #include "timesyncd-manager.h" #include "timesyncd-server.h" #include "timesyncd-conf.h" diff --git a/src/timesync/timesyncd-manager.c b/src/timesync/timesyncd-manager.c index 40e0fd31fe..2964aa7652 100644 --- a/src/timesync/timesyncd-manager.c +++ b/src/timesync/timesyncd-manager.c @@ -19,31 +19,33 @@ along with systemd; If not, see . ***/ -#include #include -#include #include #include #include +#include +#include +#include #include #include -#include -#include #include +#include + +#include "sd-daemon.h" -#include "missing.h" -#include "util.h" -#include "sparse-endian.h" -#include "log.h" -#include "socket-util.h" #include "list.h" +#include "log.h" +#include "missing.h" +#include "network-util.h" #include "ratelimit.h" +#include "socket-util.h" +#include "sparse-endian.h" +#include "string-util.h" #include "strv.h" -#include "sd-daemon.h" -#include "network-util.h" +#include "time-util.h" #include "timesyncd-conf.h" +#include "util.h" #include "timesyncd-manager.h" -#include "time-util.h" #ifndef ADJ_SETOFFSET #define ADJ_SETOFFSET 0x0100 /* add 'time' to current time */ diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c index ba9f82553b..d81382528f 100644 --- a/src/tmpfiles/tmpfiles.c +++ b/src/tmpfiles/tmpfiles.c @@ -55,6 +55,7 @@ #include "selinux-util.h" #include "set.h" #include "specifier.h" +#include "string-util.h" #include "strv.h" #include "util.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 8423364046..d9b6cb3524 100644 --- a/src/tty-ask-password-agent/tty-ask-password-agent.c +++ b/src/tty-ask-password-agent/tty-ask-password-agent.c @@ -40,6 +40,7 @@ #include "process-util.h" #include "signal-util.h" #include "socket-util.h" +#include "string-util.h" #include "strv.h" #include "terminal-util.h" #include "util.h" diff --git a/src/udev/ata_id/ata_id.c b/src/udev/ata_id/ata_id.c index 1d1798dd10..7acd7b4e92 100644 --- a/src/udev/ata_id/ata_id.c +++ b/src/udev/ata_id/ata_id.c @@ -19,28 +19,29 @@ * along with this program. If not, see . */ -#include -#include -#include -#include -#include #include -#include #include +#include #include +#include +#include #include -#include #include +#include +#include +#include +#include +#include #include -#include #include -#include -#include +#include +#include #include "libudev.h" + #include "libudev-private.h" -#include "udev-util.h" #include "log.h" +#include "udev-util.h" #define COMMAND_TIMEOUT_MSEC (30 * 1000) diff --git a/src/udev/cdrom_id/cdrom_id.c b/src/udev/cdrom_id/cdrom_id.c index 001bae7a24..72f284f710 100644 --- a/src/udev/cdrom_id/cdrom_id.c +++ b/src/udev/cdrom_id/cdrom_id.c @@ -17,24 +17,25 @@ * along with this program. If not, see . */ -#include -#include -#include -#include -#include -#include -#include #include +#include #include -#include +#include +#include #include -#include +#include +#include +#include +#include +#include #include #include -#include -#include +#include +#include +#include #include "libudev.h" + #include "libudev-private.h" #include "random-util.h" diff --git a/src/udev/collect/collect.c b/src/udev/collect/collect.c index b3a1f0bca1..b234792e23 100644 --- a/src/udev/collect/collect.c +++ b/src/udev/collect/collect.c @@ -19,13 +19,14 @@ * */ -#include -#include #include #include +#include +#include #include "libudev-private.h" #include "macro.h" +#include "string-util.h" #define BUFSIZE 16 #define UDEV_ALARM_TIMEOUT 180 diff --git a/src/udev/net/link-config.c b/src/udev/net/link-config.c index 4b8c5053a4..c308f898ea 100644 --- a/src/udev/net/link-config.c +++ b/src/udev/net/link-config.c @@ -22,22 +22,22 @@ #include #include +#include "sd-netlink.h" -#include "missing.h" -#include "link-config.h" +#include "conf-files.h" +#include "conf-parser.h" #include "ethtool-util.h" - #include "libudev-private.h" -#include "sd-netlink.h" -#include "util.h" +#include "link-config.h" #include "log.h" -#include "strv.h" -#include "path-util.h" -#include "conf-parser.h" -#include "conf-files.h" +#include "missing.h" #include "netlink-util.h" #include "network-internal.h" +#include "path-util.h" #include "random-util.h" +#include "string-util.h" +#include "strv.h" +#include "util.h" struct link_config_ctx { LIST_HEAD(link_config, links); diff --git a/src/udev/net/link-config.h b/src/udev/net/link-config.h index c52db2ce55..4fcbee8b92 100644 --- a/src/udev/net/link-config.h +++ b/src/udev/net/link-config.h @@ -21,10 +21,11 @@ #pragma once -#include "ethtool-util.h" +#include "libudev.h" + #include "condition.h" +#include "ethtool-util.h" #include "list.h" -#include "libudev.h" typedef struct link_config_ctx link_config_ctx; typedef struct link_config link_config; diff --git a/src/udev/scsi_id/scsi_id.c b/src/udev/scsi_id/scsi_id.c index adb91869df..cbf9478e72 100644 --- a/src/udev/scsi_id/scsi_id.c +++ b/src/udev/scsi_id/scsi_id.c @@ -16,22 +16,24 @@ * along with this program. If not, see . */ -#include -#include +#include +#include +#include +#include +#include #include #include -#include -#include -#include -#include +#include +#include #include -#include -#include #include +#include #include "libudev.h" + #include "libudev-private.h" #include "scsi_id.h" +#include "string-util.h" #include "udev-util.h" static const struct option options[] = { diff --git a/src/udev/scsi_id/scsi_serial.c b/src/udev/scsi_id/scsi_serial.c index de3b4f7581..c7ef783684 100644 --- a/src/udev/scsi_id/scsi_serial.c +++ b/src/udev/scsi_id/scsi_serial.c @@ -17,27 +17,29 @@ * along with this program. If not, see . */ -#include -#include -#include -#include #include -#include #include -#include -#include -#include #include +#include +#include #include #include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include #include "libudev.h" + #include "libudev-private.h" +#include "random-util.h" #include "scsi.h" #include "scsi_id.h" -#include "random-util.h" +#include "string-util.h" /* * A priority based list of id, naa, and binary/ascii for the identifier diff --git a/src/udev/udev-builtin-blkid.c b/src/udev/udev-builtin-blkid.c index b8066ea6e9..004ddb023f 100644 --- a/src/udev/udev-builtin-blkid.c +++ b/src/udev/udev-builtin-blkid.c @@ -18,18 +18,20 @@ * along with this program. If not, see . */ -#include -#include -#include +#include #include #include #include +#include +#include +#include #include -#include #include "sd-id128.h" -#include "gpt.h" + #include "efivars.h" +#include "gpt.h" +#include "string-util.h" #include "udev.h" static void print_property(struct udev_device *dev, bool test, const char *name, const char *value) { diff --git a/src/udev/udev-builtin-btrfs.c b/src/udev/udev-builtin-btrfs.c index 3352821567..ce1a0c3882 100644 --- a/src/udev/udev-builtin-btrfs.c +++ b/src/udev/udev-builtin-btrfs.c @@ -17,8 +17,8 @@ along with systemd; If not, see . ***/ -#include #include +#include #include #ifdef HAVE_LINUX_BTRFS_H @@ -26,6 +26,7 @@ #endif #include "missing.h" +#include "string-util.h" #include "udev.h" static int builtin_btrfs(struct udev_device *dev, int argc, char *argv[], bool test) { diff --git a/src/udev/udev-builtin-hwdb.c b/src/udev/udev-builtin-hwdb.c index 72109d93d2..97a5a9c77f 100644 --- a/src/udev/udev-builtin-hwdb.c +++ b/src/udev/udev-builtin-hwdb.c @@ -17,16 +17,17 @@ along with systemd; If not, see . ***/ -#include -#include #include #include +#include +#include -#include "udev.h" #include "sd-hwdb.h" #include "hwdb-util.h" +#include "string-util.h" #include "udev-util.h" +#include "udev.h" static sd_hwdb *hwdb; diff --git a/src/udev/udev-builtin-input_id.c b/src/udev/udev-builtin-input_id.c index e3fa4bc162..f36f719a94 100644 --- a/src/udev/udev-builtin-input_id.c +++ b/src/udev/udev-builtin-input_id.c @@ -21,15 +21,16 @@ * along with this program. If not, see . */ +#include +#include #include #include -#include -#include #include -#include +#include #include #include +#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 d63a8e2760..ce534ae0f9 100644 --- a/src/udev/udev-builtin-keyboard.c +++ b/src/udev/udev-builtin-keyboard.c @@ -18,11 +18,12 @@ ***/ #include -#include #include +#include #include #include +#include "string-util.h" #include "udev.h" static const struct key *keyboard_lookup_key(const char *str, unsigned len); diff --git a/src/udev/udev-builtin-kmod.c b/src/udev/udev-builtin-kmod.c index 81e78a8aa3..9665f678fd 100644 --- a/src/udev/udev-builtin-kmod.c +++ b/src/udev/udev-builtin-kmod.c @@ -18,12 +18,13 @@ * along with this program. If not, see . */ -#include -#include -#include #include #include +#include +#include +#include +#include "string-util.h" #include "udev.h" static struct kmod_ctx *ctx = NULL; diff --git a/src/udev/udev-builtin-net_id.c b/src/udev/udev-builtin-net_id.c index 589f1f7822..bb721d6f0d 100644 --- a/src/udev/udev-builtin-net_id.c +++ b/src/udev/udev-builtin-net_id.c @@ -87,19 +87,20 @@ * ID_NET_NAME_PATH=enp0s29u1u2 */ -#include -#include -#include -#include -#include -#include #include +#include #include #include +#include +#include +#include +#include +#include #include -#include "udev.h" #include "fileio.h" +#include "string-util.h" +#include "udev.h" enum netname_type{ NET_UNDEF, diff --git a/src/udev/udev-builtin-path_id.c b/src/udev/udev-builtin-path_id.c index 01e2c659ae..2c40988c7a 100644 --- a/src/udev/udev-builtin-path_id.c +++ b/src/udev/udev-builtin-path_id.c @@ -19,17 +19,18 @@ * along with this program. If not, see . */ -#include -#include -#include -#include -#include #include -#include -#include #include +#include +#include #include +#include +#include +#include +#include +#include +#include "string-util.h" #include "udev.h" _printf_(2,3) diff --git a/src/udev/udev-builtin-usb_id.c b/src/udev/udev-builtin-usb_id.c index d309dc31cb..c7d47891a7 100644 --- a/src/udev/udev-builtin-usb_id.c +++ b/src/udev/udev-builtin-usb_id.c @@ -20,15 +20,16 @@ * along with this program. If not, see . */ +#include +#include +#include +#include #include #include -#include -#include #include -#include -#include -#include +#include +#include "string-util.h" #include "udev.h" static void set_usb_iftype(char *to, int if_class_num, size_t len) { diff --git a/src/udev/udev-builtin.c b/src/udev/udev-builtin.c index 4f625251d6..e6b36f124f 100644 --- a/src/udev/udev-builtin.c +++ b/src/udev/udev-builtin.c @@ -17,10 +17,11 @@ along with systemd; If not, see . ***/ +#include #include #include -#include +#include "string-util.h" #include "udev.h" static bool initialized; diff --git a/src/udev/udev-event.c b/src/udev/udev-event.c index 1e34cbc2f5..49a45811a6 100644 --- a/src/udev/udev-event.c +++ b/src/udev/udev-event.c @@ -15,26 +15,27 @@ * along with this program. If not, see . */ -#include -#include -#include -#include -#include -#include #include -#include +#include +#include #include -#include #include +#include +#include +#include +#include #include -#include +#include #include +#include +#include -#include "netlink-util.h" #include "event-util.h" #include "formats-util.h" +#include "netlink-util.h" #include "process-util.h" #include "signal-util.h" +#include "string-util.h" #include "udev.h" typedef struct Spawn { diff --git a/src/udev/udev-node.c b/src/udev/udev-node.c index e730fb45f1..4ed6416ecd 100644 --- a/src/udev/udev-node.c +++ b/src/udev/udev-node.c @@ -15,20 +15,21 @@ * along with this program. If not, see . */ -#include -#include -#include -#include -#include -#include -#include #include +#include +#include +#include +#include +#include +#include #include +#include -#include "udev.h" -#include "smack-util.h" -#include "selinux-util.h" #include "formats-util.h" +#include "selinux-util.h" +#include "smack-util.h" +#include "string-util.h" +#include "udev.h" static int node_symlink(struct udev_device *dev, const char *node, const char *slink) { struct stat stats; diff --git a/src/udev/udev-rules.c b/src/udev/udev-rules.c index 62db0016eb..c8abac7fef 100644 --- a/src/udev/udev-rules.c +++ b/src/udev/udev-rules.c @@ -33,10 +33,11 @@ #include "escape.h" #include "path-util.h" #include "strbuf.h" +#include "string-util.h" #include "strv.h" #include "sysctl-util.h" -#include "util.h" #include "udev.h" +#include "util.h" #define PREALLOC_TOKEN 2048 diff --git a/src/udev/udev.h b/src/udev/udev.h index d17fc8c1ea..1f9c8120c0 100644 --- a/src/udev/udev.h +++ b/src/udev/udev.h @@ -18,16 +18,17 @@ #pragma once -#include #include +#include -#include "macro.h" -#include "sd-netlink.h" #include "libudev.h" -#include "libudev-private.h" -#include "util.h" +#include "sd-netlink.h" + #include "label.h" +#include "libudev-private.h" +#include "macro.h" #include "strv.h" +#include "util.h" struct udev_event { struct udev *udev; diff --git a/src/udev/udevadm-hwdb.c b/src/udev/udevadm-hwdb.c index 00609e31b5..f9509ad640 100644 --- a/src/udev/udevadm-hwdb.c +++ b/src/udev/udevadm-hwdb.c @@ -17,18 +17,18 @@ along with systemd; If not, see . ***/ -#include +#include #include +#include #include -#include -#include "util.h" -#include "strbuf.h" #include "conf-files.h" - -#include "udev.h" #include "hwdb-internal.h" #include "hwdb-util.h" +#include "strbuf.h" +#include "string-util.h" +#include "udev.h" +#include "util.h" /* * Generic udev properties, key/value database based on modalias strings. diff --git a/src/udev/udevadm-info.c b/src/udev/udevadm-info.c index b3d5565c48..911818eb00 100644 --- a/src/udev/udevadm-info.c +++ b/src/udev/udevadm-info.c @@ -15,19 +15,20 @@ * along with this program. If not, see . */ -#include -#include -#include #include -#include #include #include -#include #include +#include +#include +#include +#include #include +#include -#include "udev.h" +#include "string-util.h" #include "udev-util.h" +#include "udev.h" #include "udevadm-util.h" static bool skip_attribute(const char *name) { diff --git a/src/udev/udevadm-test-builtin.c b/src/udev/udevadm-test-builtin.c index 35a7349439..0b180d03eb 100644 --- a/src/udev/udevadm-test-builtin.c +++ b/src/udev/udevadm-test-builtin.c @@ -15,12 +15,13 @@ * along with this program. If not, see . */ -#include -#include -#include #include #include +#include +#include +#include +#include "string-util.h" #include "udev.h" static void help(struct udev *udev) { diff --git a/src/udev/udevadm-test.c b/src/udev/udevadm-test.c index d04e618d0d..ff427cf292 100644 --- a/src/udev/udevadm-test.c +++ b/src/udev/udevadm-test.c @@ -16,17 +16,18 @@ * along with this program. If not, see . */ -#include -#include -#include -#include #include -#include #include +#include +#include +#include +#include #include +#include -#include "udev.h" +#include "string-util.h" #include "udev-util.h" +#include "udev.h" static void help(void) { diff --git a/src/udev/udevadm-trigger.c b/src/udev/udevadm-trigger.c index 7af9665f8a..9d52345d92 100644 --- a/src/udev/udevadm-trigger.c +++ b/src/udev/udevadm-trigger.c @@ -15,16 +15,17 @@ * along with this program. If not, see . */ +#include +#include +#include #include -#include #include +#include #include -#include -#include -#include -#include "udev.h" +#include "string-util.h" #include "udev-util.h" +#include "udev.h" #include "udevadm-util.h" #include "util.h" diff --git a/src/udev/udevadm-util.c b/src/udev/udevadm-util.c index 3f0e45e26c..3539c1d6ab 100644 --- a/src/udev/udevadm-util.c +++ b/src/udev/udevadm-util.c @@ -15,6 +15,7 @@ * along with this program. If not, see . */ +#include "string-util.h" #include "udevadm-util.h" struct udev_device *find_device(struct udev *udev, diff --git a/src/udev/udevadm.c b/src/udev/udevadm.c index b86d8921f3..60f122ebda 100644 --- a/src/udev/udevadm.c +++ b/src/udev/udevadm.c @@ -16,12 +16,13 @@ * along with this program. If not, see . */ -#include -#include #include #include +#include +#include #include "selinux-util.h" +#include "string-util.h" #include "udev.h" static int adm_version(struct udev *udev, int argc, char *argv[]) { diff --git a/src/udev/udevd.c b/src/udev/udevd.c index e4d2f47745..a3f0298ae7 100644 --- a/src/udev/udevd.c +++ b/src/udev/udevd.c @@ -54,6 +54,7 @@ #include "process-util.h" #include "selinux-util.h" #include "signal-util.h" +#include "string-util.h" #include "terminal-util.h" #include "udev-util.h" #include "udev.h" diff --git a/src/user-sessions/user-sessions.c b/src/user-sessions/user-sessions.c index 7c736c44d2..252cbdb26c 100644 --- a/src/user-sessions/user-sessions.c +++ b/src/user-sessions/user-sessions.c @@ -19,12 +19,13 @@ along with systemd; If not, see . ***/ -#include #include +#include +#include "fileio.h" #include "log.h" +#include "string-util.h" #include "util.h" -#include "fileio.h" int main(int argc, char*argv[]) { diff --git a/src/vconsole/vconsole-setup.c b/src/vconsole/vconsole-setup.c index 6353579283..b0c61cddc5 100644 --- a/src/vconsole/vconsole-setup.c +++ b/src/vconsole/vconsole-setup.c @@ -19,25 +19,26 @@ along with systemd; If not, see . ***/ -#include -#include -#include #include #include -#include #include -#include -#include #include +#include #include +#include +#include +#include +#include +#include -#include "util.h" -#include "log.h" -#include "virt.h" #include "fileio.h" +#include "log.h" #include "process-util.h" -#include "terminal-util.h" #include "signal-util.h" +#include "string-util.h" +#include "terminal-util.h" +#include "util.h" +#include "virt.h" static bool is_vconsole(int fd) { unsigned char data[1]; -- cgit v1.2.3-54-g00ecf From 3ffd4af22052963e7a29431721ee204e634bea75 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Sun, 25 Oct 2015 13:14:12 +0100 Subject: util-lib: split out fd-related operations into fd-util.[ch] There are more than enough to deserve their own .c file, hence move them over. --- Makefile.am | 2 + src/activate/activate.c | 1 + src/basic/async.c | 1 + src/basic/audit.c | 7 +- src/basic/barrier.c | 1 + src/basic/btrfs-util.c | 3 +- src/basic/capability.c | 10 +- src/basic/cgroup-util.c | 3 +- src/basic/clock-util.c | 3 +- src/basic/clock-util.h | 1 + src/basic/conf-files.c | 3 +- src/basic/copy.c | 3 +- src/basic/extract-word.c | 1 - src/basic/fd-util.c | 321 +++++++++++++++++++++ src/basic/fd-util.h | 69 +++++ src/basic/fdset.c | 5 +- src/basic/fileio.c | 3 +- src/basic/hostname-util.c | 3 +- src/basic/locale-util.c | 3 +- src/basic/lockfile-util.c | 5 +- src/basic/log.c | 3 +- src/basic/memfd-util.c | 3 +- src/basic/memfd-util.h | 3 +- src/basic/path-util.c | 3 +- src/basic/process-util.c | 3 +- src/basic/random-util.c | 13 +- src/basic/rm-rf.c | 3 +- src/basic/socket-label.c | 11 +- src/basic/terminal-util.c | 3 +- src/basic/time-util.c | 3 +- src/basic/util.c | 301 +------------------ src/basic/util.h | 38 --- src/binfmt/binfmt.c | 1 + src/boot/bootctl.c | 1 + src/bootchart/bootchart.c | 1 + src/bootchart/store.c | 3 +- src/bootchart/svg.c | 1 + src/bus-proxyd/bus-proxyd.c | 1 + src/bus-proxyd/proxy.c | 22 +- src/cgtop/cgtop.c | 1 + src/core/audit-fd.c | 1 + src/core/automount.c | 3 +- src/core/busname.c | 3 +- src/core/cgroup.c | 3 +- src/core/dbus-cgroup.c | 3 +- src/core/dbus-execute.c | 15 +- src/core/dbus-manager.c | 3 +- src/core/dbus-service.c | 3 +- src/core/dbus.c | 3 +- src/core/execute.c | 18 +- src/core/ima-setup.c | 3 +- src/core/killall.c | 3 +- src/core/load-fragment.c | 3 +- src/core/machine-id-setup.c | 3 +- src/core/main.c | 1 + src/core/manager.c | 3 +- src/core/namespace.c | 3 +- src/core/path.c | 3 +- src/core/service.c | 3 +- src/core/smack-setup.c | 3 +- src/core/socket.c | 7 +- src/core/swap.c | 3 +- src/core/umount.c | 3 +- src/cryptsetup/cryptsetup-generator.c | 1 + src/dbus1-generator/dbus1-generator.c | 11 +- src/delta/delta.c | 1 + src/firstboot/firstboot.c | 1 + src/fsck/fsck.c | 13 +- src/fstab-generator/fstab-generator.c | 1 + src/getty-generator/getty-generator.c | 1 + src/gpt-auto-generator/gpt-auto-generator.c | 1 + src/hwdb/hwdb.c | 1 + src/import/curl-util.c | 3 +- src/import/export-raw.c | 1 + src/import/export-tar.c | 3 +- src/import/export.c | 1 + src/import/import-common.c | 3 +- src/import/import-raw.c | 3 +- src/import/import-tar.c | 3 +- src/import/import.c | 1 + src/import/importd.c | 18 +- src/import/pull-common.c | 3 +- src/import/pull-dkr.c | 1 + src/import/pull-job.c | 3 +- src/import/pull-raw.c | 3 +- src/import/pull-tar.c | 3 +- src/import/test-qcow2.c | 4 +- src/initctl/initctl.c | 15 +- src/journal-remote/journal-gatewayd.c | 13 +- src/journal-remote/journal-remote-parse.c | 3 +- src/journal-remote/journal-remote.c | 3 +- src/journal-remote/journal-upload.c | 3 +- src/journal/cat.c | 1 + src/journal/catalog.c | 1 + src/journal/compress.c | 9 +- src/journal/coredump-vacuum.c | 3 +- src/journal/coredump.c | 1 + src/journal/coredumpctl.c | 1 + src/journal/journal-authenticate.c | 5 +- src/journal/journal-def.h | 5 +- src/journal/journal-file.c | 3 +- src/journal/journal-qrcode.h | 3 +- src/journal/journal-send.c | 1 + src/journal/journal-vacuum.c | 4 +- src/journal/journal-verify.c | 9 +- src/journal/journalctl.c | 1 + src/journal/journald-audit.c | 3 +- src/journal/journald-console.c | 1 + src/journal/journald-kmsg.c | 3 +- src/journal/journald-native.c | 3 +- src/journal/journald-server.c | 3 +- src/journal/journald-stream.c | 3 +- src/journal/journald-syslog.c | 3 +- src/journal/sd-journal.c | 2 +- src/journal/stacktrace.c | 3 +- src/journal/test-catalog.c | 5 +- src/journal/test-compress.c | 3 +- src/journal/test-journal-init.c | 4 +- src/journal/test-journal-send.c | 3 +- src/journal/test-journal-verify.c | 7 +- src/journal/test-mmap-cache.c | 3 +- src/libsystemd-network/arp-util.c | 3 +- src/libsystemd-network/dhcp-network.c | 12 +- src/libsystemd-network/dhcp6-network.c | 16 +- src/libsystemd-network/icmp6-util.c | 18 +- src/libsystemd-network/lldp-network.c | 7 +- src/libsystemd-network/sd-dhcp-lease.c | 1 + src/libsystemd-network/sd-dhcp-server.c | 1 + src/libsystemd-network/sd-dhcp6-client.c | 1 + src/libsystemd-network/sd-ipv4acd.c | 1 + src/libsystemd-network/sd-lldp.c | 1 + src/libsystemd-network/sd-pppoe.c | 3 +- src/libsystemd-network/test-dhcp-client.c | 1 + src/libsystemd-network/test-dhcp6-client.c | 1 + src/libsystemd-network/test-ipv4ll.c | 1 + src/libsystemd-network/test-lldp.c | 1 + src/libsystemd/sd-bus/bus-container.c | 7 +- src/libsystemd/sd-bus/bus-creds.c | 1 + src/libsystemd/sd-bus/bus-introspect.c | 3 +- src/libsystemd/sd-bus/bus-kernel.c | 3 +- src/libsystemd/sd-bus/bus-match.c | 3 +- src/libsystemd/sd-bus/bus-message.c | 3 +- src/libsystemd/sd-bus/bus-socket.c | 3 +- src/libsystemd/sd-bus/bus-track.c | 3 +- src/libsystemd/sd-bus/busctl.c | 1 + src/libsystemd/sd-bus/sd-bus.c | 1 + src/libsystemd/sd-bus/test-bus-benchmark.c | 1 + src/libsystemd/sd-bus/test-bus-chat.c | 1 + src/libsystemd/sd-bus/test-bus-kernel-bloom.c | 1 + src/libsystemd/sd-bus/test-bus-kernel.c | 1 + src/libsystemd/sd-bus/test-bus-marshal.c | 1 + src/libsystemd/sd-bus/test-bus-zero-copy.c | 1 + src/libsystemd/sd-daemon/sd-daemon.c | 1 + src/libsystemd/sd-device/device-enumerator.c | 1 + src/libsystemd/sd-device/device-private.c | 1 + src/libsystemd/sd-device/sd-device.c | 1 + src/libsystemd/sd-event/sd-event.c | 1 + src/libsystemd/sd-event/test-event.c | 4 +- src/libsystemd/sd-hwdb/sd-hwdb.c | 1 + src/libsystemd/sd-id128/sd-id128.c | 1 + src/libsystemd/sd-login/sd-login.c | 1 + src/libsystemd/sd-login/test-login.c | 1 + src/libsystemd/sd-netlink/sd-netlink.c | 1 + src/libsystemd/sd-network/network-util.c | 3 +- src/libsystemd/sd-network/sd-network.c | 1 + src/libsystemd/sd-path/sd-path.c | 1 + src/libsystemd/sd-resolve/sd-resolve.c | 1 + src/libudev/libudev-monitor.c | 1 + src/libudev/libudev-queue.c | 1 + src/libudev/libudev.c | 1 + src/locale/localectl.c | 1 + src/locale/localed.c | 9 +- src/login/inhibit.c | 1 + src/login/logind-acl.c | 3 +- src/login/logind-button.c | 3 +- src/login/logind-core.c | 9 +- src/login/logind-dbus.c | 1 + src/login/logind-inhibit.c | 3 +- src/login/logind-seat.c | 3 +- src/login/logind-session-dbus.c | 12 +- src/login/logind-session-device.c | 5 +- src/login/logind-session.c | 3 +- src/login/logind-user.c | 3 +- src/login/logind.c | 3 +- src/login/pam_systemd.c | 1 + src/login/test-inhibit.c | 1 + src/machine/machine-dbus.c | 19 +- src/machine/machine.c | 3 +- src/machine/machinectl.c | 1 + src/machine/machined-dbus.c | 18 +- src/machine/machined.c | 10 +- src/modules-load/modules-load.c | 1 + src/network/networkd-link.c | 6 +- src/network/networkd-manager.c | 1 + src/network/networkd-netdev-tuntap.c | 1 + src/network/networkd-netdev.c | 3 +- src/network/networkd-network.c | 3 +- src/nspawn/nspawn-cgroup.c | 3 +- src/nspawn/nspawn-expose-ports.c | 3 +- src/nspawn/nspawn-setuid.c | 3 +- src/nspawn/nspawn.c | 1 + src/random-seed/random-seed.c | 1 + src/reply-password/reply-password.c | 1 + src/resolve/resolved-dns-scope.c | 13 +- src/resolve/resolved-dns-stream.c | 1 + src/resolve/resolved-dns-transaction.c | 7 +- src/resolve/resolved-llmnr.c | 3 +- src/resolve/resolved-manager.c | 1 + src/rfkill/rfkill.c | 1 + src/run/run.c | 1 + src/shared/acpi-fpdt.c | 13 +- src/shared/ask-password-api.c | 3 +- src/shared/base-filesystem.c | 1 + src/shared/bus-util.c | 3 +- src/shared/cgroup-show.c | 3 +- src/shared/clean-ipc.c | 3 +- src/shared/condition.c | 3 +- src/shared/conf-parser.c | 1 + src/shared/dropin.c | 3 +- src/shared/efivars.c | 5 +- src/shared/generator.c | 3 +- src/shared/install.c | 1 + src/shared/logs-show.c | 3 +- src/shared/machine-image.c | 3 +- src/shared/machine-pool.c | 3 +- src/shared/pager.c | 3 +- src/shared/ptyfwd.c | 3 +- src/shared/sleep-config.c | 3 +- src/shared/spawn-polkit-agent.c | 1 + src/shared/switch-root.c | 3 +- src/shared/utmp-wtmp.c | 1 + src/shared/watchdog.c | 1 + src/sleep/sleep.c | 1 + src/socket-proxy/socket-proxyd.c | 1 + src/sysctl/sysctl.c | 1 + src/systemctl/systemctl.c | 1 + src/sysusers/sysusers.c | 1 + src/sysv-generator/sysv-generator.c | 1 + src/test/test-btrfs.c | 7 +- src/test/test-capability.c | 12 +- src/test/test-cgroup-util.c | 5 +- src/test/test-copy.c | 1 + src/test/test-fdset.c | 3 +- src/test/test-fileio.c | 13 +- src/test/test-namespace.c | 1 + src/test/test-path-util.c | 1 + src/test/test-path.c | 1 + src/test/test-sigbus.c | 3 +- src/test/test-socket-util.c | 1 + src/test/test-terminal-util.c | 1 + src/test/test-tmpfiles.c | 1 + src/test/test-unit-file.c | 1 + src/test/test-util.c | 1 + src/timesync/timesyncd-manager.c | 3 +- src/timesync/timesyncd.c | 7 +- src/tmpfiles/tmpfiles.c | 1 + .../tty-ask-password-agent.c | 1 + src/udev/ata_id/ata_id.c | 1 + src/udev/net/link-config.c | 1 + src/udev/scsi_id/scsi_id.c | 1 + src/udev/udev-builtin-blkid.c | 1 + src/udev/udev-builtin-btrfs.c | 1 + src/udev/udev-builtin-input_id.c | 1 + src/udev/udev-builtin-keyboard.c | 1 + src/udev/udev-builtin-net_id.c | 1 + src/udev/udev-builtin-usb_id.c | 1 + src/udev/udev-ctrl.c | 3 +- src/udev/udev-event.c | 1 + src/udev/udev-rules.c | 1 + src/udev/udevadm-info.c | 1 + src/udev/udevadm-monitor.c | 5 +- src/udev/udevd.c | 1 + src/udev/v4l_id/v4l_id.c | 1 + src/update-done/update-done.c | 3 +- src/vconsole/vconsole-setup.c | 1 + 275 files changed, 973 insertions(+), 659 deletions(-) create mode 100644 src/basic/fd-util.c create mode 100644 src/basic/fd-util.h (limited to 'src/core') diff --git a/Makefile.am b/Makefile.am index 9ef55f4e43..2bfd3aeea1 100644 --- a/Makefile.am +++ b/Makefile.am @@ -783,6 +783,8 @@ libbasic_la_SOURCES = \ src/basic/util.h \ src/basic/string-util.c \ src/basic/string-util.h \ + src/basic/fd-util.c \ + src/basic/fd-util.h \ src/basic/extract-word.c \ src/basic/extract-word.h \ src/basic/escape.c \ 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 #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 #include -#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 #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 . ***/ -#include #include +#include #include #include #include -#include "grp.h" +#include +#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 #include +#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 #include +#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 . ***/ +#include 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 #include +#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 #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 . +***/ + +#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 . +***/ + +#include +#include +#include +#include + +#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 #include +#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 +#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 #include -#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 #include +#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 . ***/ - +#include +#include 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 #include +#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 #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 . ***/ -#include #include -#include -#include #include -#include +#include +#include #ifdef HAVE_SYS_AUXV_H #include #endif -#include +#include +#include +#include +#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 . ***/ -#include -#include #include -#include #include +#include +#include +#include +#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 #include +#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 #include +#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 #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 . ***/ -#include -#include -#include #include #include +#include +#include +#include -#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 #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 #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 #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 #include +#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 #include +#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 #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 #include +#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 #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 . ***/ -#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 #include +#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 #include +#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 #include +#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 . ***/ -#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 #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 +#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 . ***/ +#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 #include -#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 . ***/ -#include -#include -#include #include #include -#include #ifdef HAVE_GNUTLS #include #endif +#include +#include +#include +#include -#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 . ***/ +#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 #ifdef HAVE_XZ -# include +#include #endif #ifdef HAVE_LZ4 -# include -# include +#include +#include #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 +#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 #include +#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 . ***/ -#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 . ***/ +#include #include -#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 #include -#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 #include +#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 #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 #include +#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 . ***/ -#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 . ***/ -#include "systemd/sd-journal.h" #include #include +#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 #include -#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 #include +#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 #include -#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 -#include -#include -#include -#include #include #include #include +#include +#include #include - -#include "socket-util.h" +#include +#include #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 -#include -#include -#include -#include +#include +#include #include +#include +#include +#include #include -#include -#include - -#include "socket-util.h" +#include #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 -#include -#include -#include -#include -#include -#include -#include #include #include +#include +#include +#include +#include +#include +#include +#include -#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 #include -#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 #include #include -#include #include +#include #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 #include -#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 . ***/ -#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 #include +#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 #include +#ifdef HAVE_XKBCOMMON +#include +#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 -#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 #include -#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 #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 #include -#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 #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 #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 #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 #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 #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 #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 #include +#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 #include +#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 #include +#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 -#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 +#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 #include -#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 . ***/ -#include +#include #include +#include #include #include -#include -#include -#include -#include -#include +#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 #include +#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 #include +#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 #include +#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 #include -#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 #include +#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 #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 #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 #include -#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 #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 #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 #include +#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 #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 #include +#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 -#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 . ***/ -#include -#include -#include #include #include +#include +#include +#include #include #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 . ***/ -#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 #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 #include +#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 #include -#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 +#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 #include +#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 -#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 #include +#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 #include +#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 . ***/ -#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 #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 #include +#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 #include +#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 #include +#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 #include +#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 #include -#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 #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 #include +#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 #include -#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 #include +#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 . ***/ -#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 #include +#include "fd-util.h" #include "fileio.h" #include "log.h" #include "process-util.h" -- cgit v1.2.3-54-g00ecf