summaryrefslogtreecommitdiff
path: root/src/shared
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2015-10-25 13:14:12 +0100
committerLennart Poettering <lennart@poettering.net>2015-10-25 13:19:18 +0100
commit3ffd4af22052963e7a29431721ee204e634bea75 (patch)
treefe60142dfddd37cfc02b7a135542107e772b36c3 /src/shared
parent04c0136989b7eb896bfb0fb176e11233d69e1453 (diff)
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.
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/acpi-fpdt.c13
-rw-r--r--src/shared/ask-password-api.c3
-rw-r--r--src/shared/base-filesystem.c1
-rw-r--r--src/shared/bus-util.c3
-rw-r--r--src/shared/cgroup-show.c3
-rw-r--r--src/shared/clean-ipc.c3
-rw-r--r--src/shared/condition.c3
-rw-r--r--src/shared/conf-parser.c1
-rw-r--r--src/shared/dropin.c3
-rw-r--r--src/shared/efivars.c5
-rw-r--r--src/shared/generator.c3
-rw-r--r--src/shared/install.c1
-rw-r--r--src/shared/logs-show.c3
-rw-r--r--src/shared/machine-image.c3
-rw-r--r--src/shared/machine-pool.c3
-rw-r--r--src/shared/pager.c3
-rw-r--r--src/shared/ptyfwd.c3
-rw-r--r--src/shared/sleep-config.c3
-rw-r--r--src/shared/spawn-polkit-agent.c1
-rw-r--r--src/shared/switch-root.c3
-rw-r--r--src/shared/utmp-wtmp.c1
-rw-r--r--src/shared/watchdog.c1
22 files changed, 44 insertions, 22 deletions
diff --git a/src/shared/acpi-fpdt.c b/src/shared/acpi-fpdt.c
index 64e50401b9..b3d2f96885 100644
--- a/src/shared/acpi-fpdt.c
+++ b/src/shared/acpi-fpdt.c
@@ -19,16 +19,17 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
-#include <stdio.h>
+#include <fcntl.h>
#include <stdint.h>
+#include <stdio.h>
#include <string.h>
#include <unistd.h>
-#include <fcntl.h>
-#include <util.h>
-#include <fileio.h>
-#include <time-util.h>
-#include <acpi-fpdt.h>
+#include "acpi-fpdt.h"
+#include "fd-util.h"
+#include "fileio.h"
+#include "time-util.h"
+#include "util.h"
struct acpi_table_header {
char signature[4];
diff --git a/src/shared/ask-password-api.c b/src/shared/ask-password-api.c
index 4bf87576f2..baa6f159f8 100644
--- a/src/shared/ask-password-api.c
+++ b/src/shared/ask-password-api.c
@@ -32,6 +32,8 @@
#include <termios.h>
#include <unistd.h>
+#include "ask-password-api.h"
+#include "fd-util.h"
#include "formats-util.h"
#include "missing.h"
#include "mkdir.h"
@@ -42,7 +44,6 @@
#include "strv.h"
#include "terminal-util.h"
#include "util.h"
-#include "ask-password-api.h"
#define KEYRING_TIMEOUT_USEC ((5 * USEC_PER_MINUTE) / 2)
diff --git a/src/shared/base-filesystem.c b/src/shared/base-filesystem.c
index f2796c6d64..751dfdec45 100644
--- a/src/shared/base-filesystem.c
+++ b/src/shared/base-filesystem.c
@@ -29,6 +29,7 @@
#include "string-util.h"
#include "util.h"
#include "base-filesystem.h"
+#include "fd-util.h"
typedef struct BaseFilesystem {
const char *dir;
diff --git a/src/shared/bus-util.c b/src/shared/bus-util.c
index bc77884751..e0a8ecc7fd 100644
--- a/src/shared/bus-util.c
+++ b/src/shared/bus-util.c
@@ -29,10 +29,12 @@
#include "bus-internal.h"
#include "bus-label.h"
#include "bus-message.h"
+#include "bus-util.h"
#include "cgroup-util.h"
#include "def.h"
#include "env-util.h"
#include "escape.h"
+#include "fd-util.h"
#include "macro.h"
#include "missing.h"
#include "path-util.h"
@@ -43,7 +45,6 @@
#include "unit-name.h"
#include "utf8.h"
#include "util.h"
-#include "bus-util.h"
static int name_owner_change_callback(sd_bus_message *m, void *userdata, sd_bus_error *ret_error) {
sd_event *e = userdata;
diff --git a/src/shared/cgroup-show.c b/src/shared/cgroup-show.c
index 57b7aeb228..395e41930c 100644
--- a/src/shared/cgroup-show.c
+++ b/src/shared/cgroup-show.c
@@ -24,7 +24,9 @@
#include <stdio.h>
#include <string.h>
+#include "cgroup-show.h"
#include "cgroup-util.h"
+#include "fd-util.h"
#include "formats-util.h"
#include "macro.h"
#include "path-util.h"
@@ -32,7 +34,6 @@
#include "string-util.h"
#include "terminal-util.h"
#include "util.h"
-#include "cgroup-show.h"
static int compare(const void *a, const void *b) {
const pid_t *p = a, *q = b;
diff --git a/src/shared/clean-ipc.c b/src/shared/clean-ipc.c
index baf4bc0b87..fe3187384f 100644
--- a/src/shared/clean-ipc.c
+++ b/src/shared/clean-ipc.c
@@ -28,11 +28,12 @@
#include <sys/shm.h>
#include <sys/stat.h>
+#include "clean-ipc.h"
+#include "fd-util.h"
#include "formats-util.h"
#include "string-util.h"
#include "strv.h"
#include "util.h"
-#include "clean-ipc.h"
static int clean_sysvipc_shm(uid_t delete_uid) {
_cleanup_fclose_ FILE *f = NULL;
diff --git a/src/shared/condition.c b/src/shared/condition.c
index 2556436542..b8915dab8a 100644
--- a/src/shared/condition.c
+++ b/src/shared/condition.c
@@ -31,7 +31,9 @@
#include "architecture.h"
#include "audit.h"
#include "cap-list.h"
+#include "condition.h"
#include "extract-word.h"
+#include "fd-util.h"
#include "hostname-util.h"
#include "ima-util.h"
#include "path-util.h"
@@ -40,7 +42,6 @@
#include "string-util.h"
#include "util.h"
#include "virt.h"
-#include "condition.h"
Condition* condition_new(ConditionType type, const char *parameter, bool trigger, bool negate) {
Condition *c;
diff --git a/src/shared/conf-parser.c b/src/shared/conf-parser.c
index 3f2e34c2e3..1b47c0ab52 100644
--- a/src/shared/conf-parser.c
+++ b/src/shared/conf-parser.c
@@ -36,6 +36,7 @@
#include "utf8.h"
#include "util.h"
#include "conf-parser.h"
+#include "fd-util.h"
int config_item_table_lookup(
const void *table,
diff --git a/src/shared/dropin.c b/src/shared/dropin.c
index 52ea8086fe..1836e91acd 100644
--- a/src/shared/dropin.c
+++ b/src/shared/dropin.c
@@ -20,13 +20,14 @@
***/
#include "conf-files.h"
+#include "dropin.h"
#include "escape.h"
+#include "fd-util.h"
#include "fileio-label.h"
#include "mkdir.h"
#include "string-util.h"
#include "strv.h"
#include "util.h"
-#include "dropin.h"
int drop_in_file(const char *dir, const char *unit, unsigned level,
const char *name, char **_p, char **_q) {
diff --git a/src/shared/efivars.c b/src/shared/efivars.c
index f087c2a566..b482603bce 100644
--- a/src/shared/efivars.c
+++ b/src/shared/efivars.c
@@ -23,10 +23,11 @@
#include <string.h>
#include <fcntl.h>
-#include "util.h"
+#include "efivars.h"
+#include "fd-util.h"
#include "utf8.h"
+#include "util.h"
#include "virt.h"
-#include "efivars.h"
#ifdef ENABLE_EFI
diff --git a/src/shared/generator.c b/src/shared/generator.c
index b52b9623fa..0a8e282949 100644
--- a/src/shared/generator.c
+++ b/src/shared/generator.c
@@ -23,15 +23,16 @@
#include "dropin.h"
#include "escape.h"
+#include "fd-util.h"
#include "fileio.h"
#include "fstab-util.h"
+#include "generator.h"
#include "mkdir.h"
#include "path-util.h"
#include "special.h"
#include "string-util.h"
#include "unit-name.h"
#include "util.h"
-#include "generator.h"
static int write_fsck_sysroot_service(const char *dir, const char *what) {
_cleanup_free_ char *device = NULL, *escaped = NULL;
diff --git a/src/shared/install.c b/src/shared/install.c
index 5368623b74..9b72f76662 100644
--- a/src/shared/install.c
+++ b/src/shared/install.c
@@ -39,6 +39,7 @@
#include "unit-name.h"
#include "util.h"
#include "install.h"
+#include "fd-util.h"
typedef struct {
OrderedHashmap *will_install;
diff --git a/src/shared/logs-show.c b/src/shared/logs-show.c
index cb4a0d2172..6f5b83d08d 100644
--- a/src/shared/logs-show.c
+++ b/src/shared/logs-show.c
@@ -25,17 +25,18 @@
#include <sys/socket.h>
#include <time.h>
+#include "fd-util.h"
#include "formats-util.h"
#include "hashmap.h"
#include "hostname-util.h"
#include "journal-internal.h"
#include "log.h"
+#include "logs-show.h"
#include "process-util.h"
#include "string-util.h"
#include "terminal-util.h"
#include "utf8.h"
#include "util.h"
-#include "logs-show.h"
/* up to three lines (each up to 100 characters) or 300 characters, whichever is less */
#define PRINT_LINE_THRESHOLD 3
diff --git a/src/shared/machine-image.c b/src/shared/machine-image.c
index 8261d87091..415d939fc6 100644
--- a/src/shared/machine-image.c
+++ b/src/shared/machine-image.c
@@ -25,13 +25,14 @@
#include "btrfs-util.h"
#include "copy.h"
+#include "fd-util.h"
+#include "machine-image.h"
#include "mkdir.h"
#include "path-util.h"
#include "rm-rf.h"
#include "string-util.h"
#include "strv.h"
#include "utf8.h"
-#include "machine-image.h"
static const char image_search_path[] =
"/var/lib/machines\0"
diff --git a/src/shared/machine-pool.c b/src/shared/machine-pool.c
index 597680ef5f..a2cb5fc5a0 100644
--- a/src/shared/machine-pool.c
+++ b/src/shared/machine-pool.c
@@ -25,14 +25,15 @@
#include <sys/vfs.h>
#include "btrfs-util.h"
+#include "fd-util.h"
#include "lockfile-util.h"
+#include "machine-pool.h"
#include "mkdir.h"
#include "path-util.h"
#include "process-util.h"
#include "signal-util.h"
#include "string-util.h"
#include "util.h"
-#include "machine-pool.h"
#define VAR_LIB_MACHINES_SIZE_START (1024UL*1024UL*500UL)
#define VAR_LIB_MACHINES_FREE_MIN (1024UL*1024UL*750UL)
diff --git a/src/shared/pager.c b/src/shared/pager.c
index b82b526309..7029d6b2e2 100644
--- a/src/shared/pager.c
+++ b/src/shared/pager.c
@@ -26,13 +26,14 @@
#include <unistd.h>
#include "copy.h"
+#include "fd-util.h"
#include "macro.h"
+#include "pager.h"
#include "process-util.h"
#include "signal-util.h"
#include "string-util.h"
#include "terminal-util.h"
#include "util.h"
-#include "pager.h"
static pid_t pager_pid = 0;
diff --git a/src/shared/ptyfwd.c b/src/shared/ptyfwd.c
index 7749f20540..e5e0f37adf 100644
--- a/src/shared/ptyfwd.c
+++ b/src/shared/ptyfwd.c
@@ -24,8 +24,9 @@
#include <limits.h>
#include <termios.h>
-#include "util.h"
+#include "fd-util.h"
#include "ptyfwd.h"
+#include "util.h"
struct PTYForward {
sd_event *event;
diff --git a/src/shared/sleep-config.c b/src/shared/sleep-config.c
index e69300b1db..b5cb9508bf 100644
--- a/src/shared/sleep-config.c
+++ b/src/shared/sleep-config.c
@@ -22,12 +22,13 @@
#include <stdio.h>
#include "conf-parser.h"
+#include "fd-util.h"
#include "fileio.h"
#include "log.h"
+#include "sleep-config.h"
#include "string-util.h"
#include "strv.h"
#include "util.h"
-#include "sleep-config.h"
#define USE(x, y) do{ (x) = (y); (y) = NULL; } while(0)
diff --git a/src/shared/spawn-polkit-agent.c b/src/shared/spawn-polkit-agent.c
index 4db249e1ca..472cdecf20 100644
--- a/src/shared/spawn-polkit-agent.c
+++ b/src/shared/spawn-polkit-agent.c
@@ -29,6 +29,7 @@
#include "util.h"
#include "process-util.h"
#include "spawn-polkit-agent.h"
+#include "fd-util.h"
#ifdef ENABLE_POLKIT
static pid_t agent_pid = 0;
diff --git a/src/shared/switch-root.c b/src/shared/switch-root.c
index 205a2e1449..60d7043fda 100644
--- a/src/shared/switch-root.c
+++ b/src/shared/switch-root.c
@@ -28,13 +28,14 @@
#include <unistd.h>
#include "base-filesystem.h"
+#include "fd-util.h"
#include "missing.h"
#include "mkdir.h"
#include "path-util.h"
#include "rm-rf.h"
#include "string-util.h"
-#include "util.h"
#include "switch-root.h"
+#include "util.h"
int switch_root(const char *new_root, const char *oldroot, bool detach_oldroot, unsigned long mountflags) {
diff --git a/src/shared/utmp-wtmp.c b/src/shared/utmp-wtmp.c
index 235f10d1a6..93e6313360 100644
--- a/src/shared/utmp-wtmp.c
+++ b/src/shared/utmp-wtmp.c
@@ -27,6 +27,7 @@
#include <unistd.h>
#include <utmpx.h>
+#include "fd-util.h"
#include "hostname-util.h"
#include "macro.h"
#include "path-util.h"
diff --git a/src/shared/watchdog.c b/src/shared/watchdog.c
index 9d39beb340..d58f9873d5 100644
--- a/src/shared/watchdog.c
+++ b/src/shared/watchdog.c
@@ -27,6 +27,7 @@
#include "watchdog.h"
#include "log.h"
+#include "fd-util.h"
static int watchdog_fd = -1;
static usec_t watchdog_timeout = USEC_INFINITY;