summaryrefslogtreecommitdiff
path: root/src/core
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/core
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/core')
-rw-r--r--src/core/audit-fd.c1
-rw-r--r--src/core/automount.c3
-rw-r--r--src/core/busname.c3
-rw-r--r--src/core/cgroup.c3
-rw-r--r--src/core/dbus-cgroup.c3
-rw-r--r--src/core/dbus-execute.c15
-rw-r--r--src/core/dbus-manager.c3
-rw-r--r--src/core/dbus-service.c3
-rw-r--r--src/core/dbus.c3
-rw-r--r--src/core/execute.c18
-rw-r--r--src/core/ima-setup.c3
-rw-r--r--src/core/killall.c3
-rw-r--r--src/core/load-fragment.c3
-rw-r--r--src/core/machine-id-setup.c3
-rw-r--r--src/core/main.c1
-rw-r--r--src/core/manager.c3
-rw-r--r--src/core/namespace.c3
-rw-r--r--src/core/path.c3
-rw-r--r--src/core/service.c3
-rw-r--r--src/core/smack-setup.c3
-rw-r--r--src/core/socket.c7
-rw-r--r--src/core/swap.c3
-rw-r--r--src/core/umount.c3
23 files changed, 57 insertions, 39 deletions
diff --git a/src/core/audit-fd.c b/src/core/audit-fd.c
index 5a18e263a8..3ae46d8cfb 100644
--- a/src/core/audit-fd.c
+++ b/src/core/audit-fd.c
@@ -30,6 +30,7 @@
#include "log.h"
#include "util.h"
+#include "fd-util.h"
static bool initialized = false;
static int audit_fd;
diff --git a/src/core/automount.c b/src/core/automount.c
index 1995bb8b7d..c25038ca50 100644
--- a/src/core/automount.c
+++ b/src/core/automount.c
@@ -30,9 +30,11 @@
#include <unistd.h>
#include "async.h"
+#include "automount.h"
#include "bus-error.h"
#include "bus-util.h"
#include "dbus-automount.h"
+#include "fd-util.h"
#include "formats-util.h"
#include "label.h"
#include "mkdir.h"
@@ -43,7 +45,6 @@
#include "string-util.h"
#include "unit-name.h"
#include "unit.h"
-#include "automount.h"
static const UnitActiveState state_translation_table[_AUTOMOUNT_STATE_MAX] = {
[AUTOMOUNT_DEAD] = UNIT_INACTIVE,
diff --git a/src/core/busname.c b/src/core/busname.c
index a7cb56dcbf..335a1fdc4c 100644
--- a/src/core/busname.c
+++ b/src/core/busname.c
@@ -25,14 +25,15 @@
#include "bus-kernel.h"
#include "bus-policy.h"
#include "bus-util.h"
+#include "busname.h"
#include "dbus-busname.h"
+#include "fd-util.h"
#include "formats-util.h"
#include "kdbus.h"
#include "service.h"
#include "signal-util.h"
#include "special.h"
#include "string-util.h"
-#include "busname.h"
static const UnitActiveState state_translation_table[_BUSNAME_STATE_MAX] = {
[BUSNAME_DEAD] = UNIT_INACTIVE,
diff --git a/src/core/cgroup.c b/src/core/cgroup.c
index 73e58f867c..2a2cf02774 100644
--- a/src/core/cgroup.c
+++ b/src/core/cgroup.c
@@ -23,11 +23,12 @@
#include <fnmatch.h>
#include "cgroup-util.h"
+#include "cgroup.h"
+#include "fd-util.h"
#include "path-util.h"
#include "process-util.h"
#include "special.h"
#include "string-util.h"
-#include "cgroup.h"
#define CGROUP_CPU_QUOTA_PERIOD_USEC ((usec_t) 100 * USEC_PER_MSEC)
diff --git a/src/core/dbus-cgroup.c b/src/core/dbus-cgroup.c
index affb997304..6a43be873a 100644
--- a/src/core/dbus-cgroup.c
+++ b/src/core/dbus-cgroup.c
@@ -20,10 +20,11 @@
***/
#include "bus-util.h"
-#include "path-util.h"
#include "cgroup-util.h"
#include "cgroup.h"
#include "dbus-cgroup.h"
+#include "fd-util.h"
+#include "path-util.h"
static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_cgroup_device_policy, cgroup_device_policy, CGroupDevicePolicy);
diff --git a/src/core/dbus-execute.c b/src/core/dbus-execute.c
index b8da66c985..cfd89d0fa8 100644
--- a/src/core/dbus-execute.c
+++ b/src/core/dbus-execute.c
@@ -25,19 +25,20 @@
#include <seccomp.h>
#endif
+#include "af-list.h"
#include "bus-util.h"
-#include "missing.h"
-#include "ioprio.h"
-#include "strv.h"
-#include "fileio.h"
-#include "execute.h"
#include "capability.h"
+#include "dbus-execute.h"
#include "env-util.h"
-#include "af-list.h"
+#include "execute.h"
+#include "fd-util.h"
+#include "fileio.h"
+#include "ioprio.h"
+#include "missing.h"
#include "namespace.h"
#include "path-util.h"
+#include "strv.h"
#include "utf8.h"
-#include "dbus-execute.h"
#ifdef HAVE_SECCOMP
#include "seccomp-util.h"
diff --git a/src/core/dbus-manager.c b/src/core/dbus-manager.c
index 3cd4467efe..1ef259ec7a 100644
--- a/src/core/dbus-manager.c
+++ b/src/core/dbus-manager.c
@@ -29,10 +29,12 @@
#include "clock-util.h"
#include "dbus-execute.h"
#include "dbus-job.h"
+#include "dbus-manager.h"
#include "dbus-snapshot.h"
#include "dbus-unit.h"
#include "dbus.h"
#include "env-util.h"
+#include "fd-util.h"
#include "formats-util.h"
#include "install.h"
#include "log.h"
@@ -42,7 +44,6 @@
#include "strv.h"
#include "virt.h"
#include "watchdog.h"
-#include "dbus-manager.h"
static int property_get_version(
sd_bus *bus,
diff --git a/src/core/dbus-service.c b/src/core/dbus-service.c
index 0062f1f7f0..22b8690c54 100644
--- a/src/core/dbus-service.c
+++ b/src/core/dbus-service.c
@@ -24,12 +24,13 @@
#include "dbus-cgroup.h"
#include "dbus-execute.h"
#include "dbus-kill.h"
+#include "dbus-service.h"
+#include "fd-util.h"
#include "path-util.h"
#include "service.h"
#include "string-util.h"
#include "strv.h"
#include "unit.h"
-#include "dbus-service.h"
static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_type, service_type, ServiceType);
static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_result, service_result, ServiceResult);
diff --git a/src/core/dbus.c b/src/core/dbus.c
index 5f27ec4952..37410a9870 100644
--- a/src/core/dbus.c
+++ b/src/core/dbus.c
@@ -35,6 +35,8 @@
#include "dbus-kill.h"
#include "dbus-manager.h"
#include "dbus-unit.h"
+#include "dbus.h"
+#include "fd-util.h"
#include "log.h"
#include "missing.h"
#include "mkdir.h"
@@ -43,7 +45,6 @@
#include "string-util.h"
#include "strv.h"
#include "strxcpyx.h"
-#include "dbus.h"
#define CONNECTIONS_MAX 4096
diff --git a/src/core/execute.c b/src/core/execute.c
index a99e636d86..83ae3f6253 100644
--- a/src/core/execute.c
+++ b/src/core/execute.c
@@ -53,6 +53,9 @@
#include "sd-messages.h"
#include "af-list.h"
+#ifdef HAVE_APPARMOR
+#include "apparmor-util.h"
+#endif
#include "async.h"
#include "barrier.h"
#include "bus-endpoint.h"
@@ -61,7 +64,9 @@
#include "def.h"
#include "env-util.h"
#include "errno-list.h"
+#include "execute.h"
#include "exit-status.h"
+#include "fd-util.h"
#include "fileio.h"
#include "formats-util.h"
#include "ioprio.h"
@@ -73,6 +78,9 @@
#include "path-util.h"
#include "process-util.h"
#include "rm-rf.h"
+#ifdef HAVE_SECCOMP
+#include "seccomp-util.h"
+#endif
#include "securebits.h"
#include "selinux-util.h"
#include "signal-util.h"
@@ -84,16 +92,6 @@
#include "util.h"
#include "utmp-wtmp.h"
-#ifdef HAVE_APPARMOR
-#include "apparmor-util.h"
-#endif
-
-#ifdef HAVE_SECCOMP
-#include "seccomp-util.h"
-#endif
-
-#include "execute.h"
-
#define IDLE_TIMEOUT_USEC (5*USEC_PER_SEC)
#define IDLE_TIMEOUT2_USEC (1*USEC_PER_SEC)
diff --git a/src/core/ima-setup.c b/src/core/ima-setup.c
index 42a3e97459..0c0982b0b4 100644
--- a/src/core/ima-setup.c
+++ b/src/core/ima-setup.c
@@ -24,9 +24,10 @@
#include <unistd.h>
#include <errno.h>
+#include "fd-util.h"
#include "ima-setup.h"
-#include "util.h"
#include "log.h"
+#include "util.h"
#define IMA_SECFS_DIR "/sys/kernel/security/ima"
#define IMA_SECFS_POLICY IMA_SECFS_DIR "/policy"
diff --git a/src/core/killall.c b/src/core/killall.c
index 6857b0bbf9..cb11987166 100644
--- a/src/core/killall.c
+++ b/src/core/killall.c
@@ -24,13 +24,14 @@
#include <sys/wait.h>
#include <unistd.h>
+#include "fd-util.h"
#include "formats-util.h"
+#include "killall.h"
#include "process-util.h"
#include "set.h"
#include "string-util.h"
#include "terminal-util.h"
#include "util.h"
-#include "killall.h"
#define TIMEOUT_USEC (10 * USEC_PER_SEC)
diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c
index 3212ed24d2..31fdc48823 100644
--- a/src/core/load-fragment.c
+++ b/src/core/load-fragment.c
@@ -43,7 +43,9 @@
#include "env-util.h"
#include "errno-list.h"
#include "escape.h"
+#include "fd-util.h"
#include "ioprio.h"
+#include "load-fragment.h"
#include "log.h"
#include "missing.h"
#include "path-util.h"
@@ -58,7 +60,6 @@
#include "unit-printf.h"
#include "unit.h"
#include "utf8.h"
-#include "load-fragment.h"
int config_parse_warn_compat(
const char *unit,
diff --git a/src/core/machine-id-setup.c b/src/core/machine-id-setup.c
index caa5f3717a..f59bf56c73 100644
--- a/src/core/machine-id-setup.c
+++ b/src/core/machine-id-setup.c
@@ -29,8 +29,10 @@
#include "sd-id128.h"
+#include "fd-util.h"
#include "fileio.h"
#include "log.h"
+#include "machine-id-setup.h"
#include "macro.h"
#include "mkdir.h"
#include "path-util.h"
@@ -38,7 +40,6 @@
#include "string-util.h"
#include "util.h"
#include "virt.h"
-#include "machine-id-setup.h"
static int shorten_uuid(char destination[34], const char source[36]) {
unsigned i, j;
diff --git a/src/core/main.c b/src/core/main.c
index 87b3af92bc..68ec730406 100644
--- a/src/core/main.c
+++ b/src/core/main.c
@@ -51,6 +51,7 @@
#include "dbus-manager.h"
#include "def.h"
#include "env-util.h"
+#include "fd-util.h"
#include "fdset.h"
#include "fileio.h"
#include "formats-util.h"
diff --git a/src/core/manager.c b/src/core/manager.c
index 2d30340828..400c66977b 100644
--- a/src/core/manager.c
+++ b/src/core/manager.c
@@ -53,10 +53,12 @@
#include "env-util.h"
#include "escape.h"
#include "exit-status.h"
+#include "fd-util.h"
#include "hashmap.h"
#include "locale-setup.h"
#include "log.h"
#include "macro.h"
+#include "manager.h"
#include "missing.h"
#include "mkdir.h"
#include "path-lookup.h"
@@ -75,7 +77,6 @@
#include "util.h"
#include "virt.h"
#include "watchdog.h"
-#include "manager.h"
/* Initial delay and the interval for printing status messages about running jobs */
#define JOBS_IN_PROGRESS_WAIT_USEC (5*USEC_PER_SEC)
diff --git a/src/core/namespace.c b/src/core/namespace.c
index 6806fc27e6..470f384056 100644
--- a/src/core/namespace.c
+++ b/src/core/namespace.c
@@ -29,15 +29,16 @@
#include <linux/fs.h>
#include "dev-setup.h"
+#include "fd-util.h"
#include "loopback-setup.h"
#include "missing.h"
#include "mkdir.h"
+#include "namespace.h"
#include "path-util.h"
#include "selinux-util.h"
#include "string-util.h"
#include "strv.h"
#include "util.h"
-#include "namespace.h"
typedef enum MountMode {
/* This is ordered by priority! */
diff --git a/src/core/path.c b/src/core/path.c
index 4d276a79db..11054d8c78 100644
--- a/src/core/path.c
+++ b/src/core/path.c
@@ -27,13 +27,14 @@
#include "bus-error.h"
#include "bus-util.h"
#include "dbus-path.h"
+#include "fd-util.h"
#include "macro.h"
#include "mkdir.h"
+#include "path.h"
#include "special.h"
#include "string-util.h"
#include "unit-name.h"
#include "unit.h"
-#include "path.h"
static const UnitActiveState state_translation_table[_PATH_STATE_MAX] = {
[PATH_DEAD] = UNIT_INACTIVE,
diff --git a/src/core/service.c b/src/core/service.c
index 042ce5d54d..abcbd4954f 100644
--- a/src/core/service.c
+++ b/src/core/service.c
@@ -32,6 +32,7 @@
#include "env-util.h"
#include "escape.h"
#include "exit-status.h"
+#include "fd-util.h"
#include "fileio.h"
#include "formats-util.h"
#include "load-dropin.h"
@@ -40,6 +41,7 @@
#include "manager.h"
#include "path-util.h"
#include "process-util.h"
+#include "service.h"
#include "signal-util.h"
#include "special.h"
#include "string-util.h"
@@ -49,7 +51,6 @@
#include "unit.h"
#include "utf8.h"
#include "util.h"
-#include "service.h"
static const UnitActiveState state_translation_table[_SERVICE_STATE_MAX] = {
[SERVICE_DEAD] = UNIT_INACTIVE,
diff --git a/src/core/smack-setup.c b/src/core/smack-setup.c
index fb04e1135d..34df392184 100644
--- a/src/core/smack-setup.c
+++ b/src/core/smack-setup.c
@@ -28,12 +28,13 @@
#include <stdlib.h>
#include <string.h>
+#include "fd-util.h"
#include "fileio.h"
#include "log.h"
#include "macro.h"
+#include "smack-setup.h"
#include "string-util.h"
#include "util.h"
-#include "smack-setup.h"
#ifdef HAVE_SMACK
diff --git a/src/core/socket.c b/src/core/socket.c
index cfa17b3325..e2085dac1c 100644
--- a/src/core/socket.c
+++ b/src/core/socket.c
@@ -37,6 +37,7 @@
#include "dbus-socket.h"
#include "def.h"
#include "exit-status.h"
+#include "fd-util.h"
#include "formats-util.h"
#include "label.h"
#include "log.h"
@@ -108,11 +109,9 @@ static void socket_unwatch_control_pid(Socket *s) {
}
static void socket_cleanup_fd_list(SocketPort *p) {
- int k = p->n_auxiliary_fds;
-
- while (k--)
- safe_close(p->auxiliary_fds[k]);
+ assert(p);
+ close_many(p->auxiliary_fds, p->n_auxiliary_fds);
p->auxiliary_fds = mfree(p->auxiliary_fds);
p->n_auxiliary_fds = 0;
}
diff --git a/src/core/swap.c b/src/core/swap.c
index eeb53d0632..d864c7b304 100644
--- a/src/core/swap.c
+++ b/src/core/swap.c
@@ -29,16 +29,17 @@
#include "dbus-swap.h"
#include "escape.h"
#include "exit-status.h"
+#include "fd-util.h"
#include "formats-util.h"
#include "fstab-util.h"
#include "path-util.h"
#include "special.h"
#include "string-util.h"
+#include "swap.h"
#include "udev-util.h"
#include "unit-name.h"
#include "unit.h"
#include "virt.h"
-#include "swap.h"
static const UnitActiveState state_translation_table[_SWAP_STATE_MAX] = {
[SWAP_DEAD] = UNIT_INACTIVE,
diff --git a/src/core/umount.c b/src/core/umount.c
index ec887760a1..0e61bcaebb 100644
--- a/src/core/umount.c
+++ b/src/core/umount.c
@@ -30,14 +30,15 @@
#include "libudev.h"
#include "escape.h"
+#include "fd-util.h"
#include "list.h"
#include "mount-setup.h"
#include "path-util.h"
#include "string-util.h"
#include "udev-util.h"
+#include "umount.h"
#include "util.h"
#include "virt.h"
-#include "umount.h"
typedef struct MountPoint {
char *path;