]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core: Remove circular dependencies between headers
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Fri, 18 Apr 2025 18:53:51 +0000 (20:53 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Wed, 23 Apr 2025 08:33:35 +0000 (10:33 +0200)
Currently there are various circular dependencies between headers
in core/. Let's get rid of these by making judicious use of forward
declarations and moving includes into implementation files instead of
having them in header files.

Getting rid of circular header includes simplifies the code and makes
various clang based tooling such as iwyu work much better on our code.

The most important change is getting rid of the manager.h include in
unit.h which is possible thanks to the previous commits. We also move
the OOMPolicy and StatusType enums to unit.h to remove the need for
other unit headers to include manager.h to get access to these enums.

66 files changed:
src/core/all-units.h
src/core/automount.c
src/core/automount.h
src/core/bpf-firewall.c
src/core/bpf-restrict-ifaces.c
src/core/bpf-restrict-ifaces.h
src/core/bpf-socket-bind.c
src/core/bpf-socket-bind.h
src/core/cgroup.c
src/core/core-varlink.c
src/core/core-varlink.h
src/core/dbus-cgroup.c
src/core/dbus-execute.h
src/core/dbus-job.h
src/core/dbus-manager.c
src/core/dbus-manager.h
src/core/dbus-scope.h
src/core/dbus-util.c
src/core/dbus.h
src/core/device.c
src/core/device.h
src/core/dynamic-user.c
src/core/dynamic-user.h
src/core/emergency-action.c
src/core/emergency-action.h
src/core/exec-invoke.c
src/core/execute-serialize.c
src/core/execute.c
src/core/execute.h
src/core/executor.c
src/core/fuzz-execute-serialize.c
src/core/fuzz-unit-file.c
src/core/job.c
src/core/job.h
src/core/kill.h
src/core/load-dropin.c
src/core/load-dropin.h
src/core/load-fragment.h
src/core/manager-dump.c
src/core/manager-dump.h
src/core/manager-serialize.c
src/core/manager-serialize.h
src/core/manager.c
src/core/manager.h
src/core/mount.h
src/core/path.c
src/core/path.h
src/core/scope.c
src/core/scope.h
src/core/service.h
src/core/slice.c
src/core/slice.h
src/core/socket.c
src/core/socket.h
src/core/swap.c
src/core/swap.h
src/core/target.h
src/core/timer.c
src/core/timer.h
src/core/transaction.c
src/core/transaction.h
src/core/unit-printf.c
src/core/unit-serialize.c
src/core/unit-serialize.h
src/core/unit.c
src/core/unit.h

index fad814bf20f25c6726ed2a3659cd99e6e9414bb0..cb2563d2c88d83311b498adc3d7accde81459789 100644 (file)
@@ -5,6 +5,7 @@
 
 #include "automount.h"
 #include "device.h"
+#include "mount.h"
 #include "path.h"
 #include "scope.h"
 #include "service.h"
index b4611981f2cd3c62f2f7c17d26b7e851f84fb8fc..ef5db87a7e167ea7596d08c73bb24dd28e6ce7ad 100644 (file)
@@ -22,6 +22,7 @@
 #include "io-util.h"
 #include "label-util.h"
 #include "mkdir-label.h"
+#include "manager.h"
 #include "mount-util.h"
 #include "mount.h"
 #include "mountpoint-util.h"
index e413f237cad3e77d1edbe74ec6240edbde33f92f..6f2ca7657bc77cd394783ef628fe980400b79ce8 100644 (file)
@@ -1,8 +1,6 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-typedef struct Automount Automount;
-
 #include "unit.h"
 
 typedef enum AutomountResult {
@@ -15,7 +13,7 @@ typedef enum AutomountResult {
         _AUTOMOUNT_RESULT_INVALID = -EINVAL,
 } AutomountResult;
 
-struct Automount {
+typedef struct Automount {
         Unit meta;
 
         AutomountState state, deserialized_state;
@@ -35,7 +33,7 @@ struct Automount {
         sd_event_source *expire_event_source;
 
         AutomountResult result;
-};
+} Automount;
 
 extern const UnitVTable automount_vtable;
 
index 69000c1389f1225279736f4e40132224eabfcbdc..85fce6f32a3fe3c92d55eccea430b2d08cb57791 100644 (file)
@@ -20,6 +20,7 @@
 #include "bpf-program.h"
 #include "fd-util.h"
 #include "in-addr-prefix-util.h"
+#include "manager.h"
 #include "memory-util.h"
 #include "missing_syscall.h"
 #include "unit.h"
index af49abd677bd1de69efd0017302716feb7f134da..a9066ee2a91c244b93b20e64a92bbe9f43d5a87e 100644 (file)
@@ -3,6 +3,7 @@
 #include "fd-util.h"
 #include "bpf-restrict-ifaces.h"
 #include "netlink-util.h"
+#include "unit.h"
 
 #if BPF_FRAMEWORK
 /* libbpf, clang and llc compile time dependencies are satisfied */
index 28f74279f519a3409b11e0f247b307b656cda82d..80af1f3e5b8203ffa78576e6cc2f0ed77ebeb065 100644 (file)
@@ -2,7 +2,6 @@
 #pragma once
 
 #include "fdset.h"
-#include "unit.h"
 
 typedef struct Unit Unit;
 
index 8853f3eecc9a8f7208703dd0609b62d573e1a19d..437b084392dce0eb03ef2db11a96ab89d288a7ac 100644 (file)
@@ -6,6 +6,7 @@
 
 #include "fd-util.h"
 #include "bpf-socket-bind.h"
+#include "unit.h"
 
 #if BPF_FRAMEWORK
 /* libbpf, clang, llvm and bpftool compile time dependencies are satisfied */
index 28b25f68724772487df5d1469c7111b988c40a41..13a0fc15215365f107432ff2c72859a79d3ddbeb 100644 (file)
@@ -2,7 +2,8 @@
 #pragma once
 
 #include "fdset.h"
-#include "unit.h"
+
+typedef struct Unit Unit;
 
 int bpf_socket_bind_supported(void);
 
index 7e4f7efa5e54990e1d5de2620d57f5789fdf6f5e..27d81b0b858da8312cabeace13650dc3192bccd1 100644 (file)
@@ -27,6 +27,7 @@
 #include "io-util.h"
 #include "ip-protocol-list.h"
 #include "limits-util.h"
+#include "manager.h"
 #include "nulstr-util.h"
 #include "parse-util.h"
 #include "path-util.h"
index c5735d0eaa180b932b0f61104d01a2d28631fcc0..0dee43c01b272b2c9c9463577877aca619881d35 100644 (file)
@@ -3,9 +3,12 @@
 #include "sd-varlink.h"
 
 #include "core-varlink.h"
+#include "dynamic-user.h"
 #include "json-util.h"
+#include "manager.h"
 #include "mkdir-label.h"
 #include "strv.h"
+#include "unit.h"
 #include "user-util.h"
 #include "varlink-internal.h"
 #include "varlink-io.systemd.UserDatabase.h"
index 4b776200289be2bc63e168969a0c3f41a1926c6a..e4996f01ada3cc2942a81309078cfcebae493d49 100644 (file)
@@ -1,7 +1,8 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include "manager.h"
+typedef struct Manager Manager;
+typedef struct Unit Unit;
 
 int manager_setup_varlink_server(Manager *m);
 
index 882c916c1027d27073fce083d8d7c7bb2e85ec1e..09692a93ec57e892cc4c618138e70b86361f30bf 100644 (file)
@@ -22,6 +22,7 @@
 #include "in-addr-prefix-util.h"
 #include "ip-protocol-list.h"
 #include "limits-util.h"
+#include "manager.h"
 #include "memstream-util.h"
 #include "parse-util.h"
 #include "path-util.h"
index 4b7cb86d3e5070a3eeaddf848b7ac20fcf2b6134..4ad7dd27a9d0db0bbd121936d60769a53a6849d0 100644 (file)
@@ -5,6 +5,7 @@
 #include "sd-bus-vtable.h"
 
 #include "execute.h"
+#include "unit.h"
 
 #define BUS_EXEC_STATUS_VTABLE(prefix, offset, flags)                   \
         BUS_PROPERTY_DUAL_TIMESTAMP(prefix "StartTimestamp", (offset) + offsetof(ExecStatus, start_timestamp), flags), \
index 6f005811cb2ec0091daef61fbfc3cf3827c0fbc2..50957303de6aa0bbfca9256a12977a13ae449445 100644 (file)
@@ -3,9 +3,10 @@
 
 #include "sd-bus.h"
 
-#include "unit.h"
 #include "bus-object.h"
 
+typedef struct Job Job;
+
 extern const sd_bus_vtable bus_job_vtable[];
 extern const BusObjectImplementation job_object;
 
index 6320e267a1e0d1e29752ff654daa7cbe14390822..903f45d10298a8a657e9fd937ae9b354463336c9 100644 (file)
@@ -25,6 +25,7 @@
 #include "dbus-unit.h"
 #include "dbus-util.h"
 #include "dbus.h"
+#include "dynamic-user.h"
 #include "env-util.h"
 #include "fd-util.h"
 #include "fileio.h"
index 9b050801a71468117c63d12cef25d9ba19645df5..fcabca57c9c9683f1b4018b3ff8732054d58eb48 100644 (file)
@@ -3,7 +3,9 @@
 
 #include "sd-bus-vtable.h"
 
-#include "manager.h"
+#include "time-util.h"
+
+typedef struct Manager Manager;
 
 extern const sd_bus_vtable bus_manager_vtable[];
 extern const sd_bus_vtable bus_manager_log_control_vtable[];
index 8f1bc02e31c25abfaab4299991a75a704e983b04..fb7467a0f5514b997d5ac81680f17a8852ccd9e7 100644 (file)
@@ -4,9 +4,10 @@
 #include "sd-bus.h"
 #include "sd-bus-vtable.h"
 
-#include "scope.h"
 #include "unit.h"
 
+typedef struct Scope Scope;
+
 extern const sd_bus_vtable bus_scope_vtable[];
 
 int bus_scope_set_property(Unit *u, const char *name, sd_bus_message *i, UnitWriteFlags flags, sd_bus_error *error);
index b44afc42587e3dcd80c6b0645e005f2dcb415d27..e1a4cf0bdc1643ccb41971f78289e7ea0236f46d 100644 (file)
@@ -4,6 +4,7 @@
 #include "bus-util.h"
 #include "dbus-util.h"
 #include "escape.h"
+#include "manager.h"
 #include "parse-util.h"
 #include "path-util.h"
 #include "reboot-util.h"
index bfd4c8ea4e5e8b3749ebdf1050b9f28d1193a834..a362a652af0caa7ccc832490f8c3d67921b2b0e0 100644 (file)
@@ -3,7 +3,9 @@
 
 #include "sd-bus.h"
 
-#include "manager.h"
+#include "fdset.h"
+
+typedef struct Manager Manager;
 
 void bus_send_pending_reload_message(Manager *m);
 
index b6cdee73d4473c795d54af98086790f207c4c8c8..08235caa42c5b393512e40e2f64065520416fa63 100644 (file)
@@ -13,6 +13,7 @@
 #include "device-util.h"
 #include "device.h"
 #include "log.h"
+#include "manager.h"
 #include "parse-util.h"
 #include "path-util.h"
 #include "ratelimit.h"
index 631f45d45ebec647d5f2847b1c4a7cae5307bc4a..6f42cfa93ab2304310fe14a5bf2a4633c26e0da9 100644 (file)
@@ -3,8 +3,6 @@
 
 #include "unit.h"
 
-typedef struct Device Device;
-
 /* A mask specifying where we have seen the device currently. This is a bitmask because the device might show up
  * asynchronously from each other at various places. For example, in very common case a device might already be mounted
  * before udev finished probing it (think: a script setting up a loopback block device, formatting it and mounting it
@@ -17,7 +15,7 @@ typedef enum DeviceFound {
         _DEVICE_FOUND_MASK = DEVICE_FOUND_UDEV|DEVICE_FOUND_MOUNT|DEVICE_FOUND_SWAP,
 } DeviceFound;
 
-struct Device {
+typedef struct Device {
         Unit meta;
 
         char *sysfs, *deserialized_sysfs;
@@ -36,7 +34,7 @@ struct Device {
 
         /* The SYSTEMD_WANTS udev property for this device the last time we saw it */
         char **wants_property;
-};
+} Device;
 
 extern const UnitVTable device_vtable;
 
index acfa1f52afb8548f88d0ff4f8d036eee60ac8d40..d21c709de738c35b5ed7c6ec0c6f75ae0bfe91fa 100644 (file)
@@ -12,6 +12,7 @@
 #include "fs-util.h"
 #include "iovec-util.h"
 #include "lock-util.h"
+#include "manager.h"
 #include "parse-util.h"
 #include "random-util.h"
 #include "serialize.h"
index 303a7d081c912b75e44b80622bdcdf280e5e6036..594595038d393fbf971bc31d849f921c23ec2387 100644 (file)
@@ -1,7 +1,15 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
+#include <stdio.h>
+#include <stdbool.h>
+#include <sys/types.h>
+
+#include "fdset.h"
+#include "memory-util.h"
+
 typedef struct DynamicUser DynamicUser;
+typedef struct Manager Manager;
 
 typedef struct DynamicCreds {
         /* A combination of a dynamic user and group */
@@ -9,8 +17,6 @@ typedef struct DynamicCreds {
         DynamicUser *group;
 } DynamicCreds;
 
-#include "manager.h"
-
 /* Note that this object always allocates a pair of user and group under the same name, even if one of them isn't
  * used. This means, if you want to allocate a group and user pair, and they might have two different names, then you
  * need to allocated two of these objects. DynamicCreds below makes that easy. */
index 2d756b306c9f64eb63ecf55c089ed119a098489b..6752926bd9660b6c00ea8ad03bda0db11b33833e 100644 (file)
@@ -6,6 +6,7 @@
 #include "bus-error.h"
 #include "bus-util.h"
 #include "emergency-action.h"
+#include "manager.h"
 #include "raw-reboot.h"
 #include "reboot-util.h"
 #include "special.h"
index 5f7b0b4bc9bd70818515457468c9d91fe1eb9848..d0f1898a60d70a557f8553cc0d87f4afc2c815f6 100644 (file)
@@ -3,8 +3,11 @@
 
 #include <errno.h>
 
+#include "macro.h"
 #include "runtime-scope.h"
 
+typedef struct Manager Manager;
+
 typedef enum EmergencyAction {
         EMERGENCY_ACTION_NONE,
         EMERGENCY_ACTION_EXIT,
@@ -34,9 +37,6 @@ typedef enum EmergencyActionFlags {
         _EMERGENCY_ACTION_FLAGS_MAX  = (1 << 3) - 1,
 } EmergencyActionFlags;
 
-#include "macro.h"
-#include "manager.h"
-
 void emergency_action(
                 Manager *m,
                 EmergencyAction action,
index f22aad76d275bae146b315273e5ce711065c9ea9..fcbd62744be9a47754105530bb653ed540326396 100644 (file)
 #include "bpf-restrict-fs.h"
 #include "btrfs-util.h"
 #include "capability-util.h"
+#include "cgroup.h"
 #include "cgroup-setup.h"
 #include "chase.h"
 #include "chattr-util.h"
 #include "chown-recursive.h"
 #include "copy.h"
+#include "dynamic-user.h"
 #include "env-util.h"
 #include "escape.h"
 #include "exec-credential.h"
 #include "ioprio-util.h"
 #include "iovec-util.h"
 #include "journal-send.h"
+#include "manager.h"
 #include "memfd-util.h"
 #include "missing_sched.h"
 #include "missing_syscall.h"
 #include "mkdir-label.h"
+#include "mount-util.h"
 #include "osc-context.h"
 #include "proc-cmdline.h"
 #include "process-util.h"
index 380d6fa6bbbd9506b4f7d42f3d91ccea8ae8e2e9..0aea6fe8048ebd354d65fb5e4fbd5f97d45dd798 100644 (file)
@@ -2,7 +2,9 @@
 
 #include "af-list.h"
 #include "capability-util.h"
+#include "cgroup.h"
 #include "cgroup-setup.h"
+#include "dynamic-user.h"
 #include "escape.h"
 #include "exec-credential.h"
 #include "execute-serialize.h"
index 76ad7345ca07af2c65f9c01453726a7c2d3ad14d..4aef0ad81988fea35ae787e6b29376a8be519695 100644 (file)
@@ -25,6 +25,7 @@
 #include "cgroup-setup.h"
 #include "constants.h"
 #include "cpu-set-util.h"
+#include "dynamic-user.h"
 #include "env-file.h"
 #include "env-util.h"
 #include "errno-list.h"
index 63d5b448defc50733e506181e1321ed75a461c4d..9b449012b23c5b845ac59b4beb6e3250e8600d8b 100644 (file)
@@ -1,19 +1,11 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-typedef struct ExecStatus ExecStatus;
-typedef struct ExecCommand ExecCommand;
-typedef struct ExecContext ExecContext;
-typedef struct ExecSharedRuntime ExecSharedRuntime;
-typedef struct DynamicCreds DynamicCreds;
-typedef struct ExecRuntime ExecRuntime;
-typedef struct ExecParameters ExecParameters;
-typedef struct Manager Manager;
-
 #include <sched.h>
 #include <stdbool.h>
 #include <stdio.h>
 #include <sys/capability.h>
+#include <sys/socket.h>
 
 #include "bus-unit-util.h"
 #include "cgroup-util.h"
@@ -22,6 +14,7 @@ typedef struct Manager Manager;
 #include "exec-util.h"
 #include "fdset.h"
 #include "list.h"
+#include "log-context.h"
 #include "namespace.h"
 #include "nsflags.h"
 #include "numa-util.h"
@@ -34,6 +27,17 @@ typedef struct Manager Manager;
 #include "set.h"
 #include "time-util.h"
 
+typedef struct CGroupContext CGroupContext;
+typedef struct ExecStatus ExecStatus;
+typedef struct ExecCommand ExecCommand;
+typedef struct ExecContext ExecContext;
+typedef struct ExecSharedRuntime ExecSharedRuntime;
+typedef struct DynamicCreds DynamicCreds;
+typedef struct ExecRuntime ExecRuntime;
+typedef struct ExecParameters ExecParameters;
+typedef struct Manager Manager;
+typedef struct Unit Unit;
+
 #define EXEC_STDIN_DATA_MAX (64U*1024U*1024U)
 
 typedef enum ExecUtmpMode {
@@ -494,9 +498,6 @@ struct ExecParameters {
                 .pidref_transport_fd    = -EBADF, \
         }
 
-#include "unit.h"
-#include "dynamic-user.h"
-
 int exec_spawn(
                 Unit *unit,
                 ExecCommand *command,
index bc3566a9fc45f1184fda0e84d32aab46efffe43f..daee9ea955a0e42c39e4af0571a721b74122b37f 100644 (file)
@@ -9,6 +9,8 @@
 #include "argv-util.h"
 #include "build.h"
 #include "capability-util.h"
+#include "cgroup.h"
+#include "dynamic-user.h"
 #include "exec-invoke.h"
 #include "execute-serialize.h"
 #include "execute.h"
index 05abee5a4e69a62db24bfb5589ba3101c202de5e..67437549eaf62b0ce757e0e1710cfdf08281d999 100644 (file)
@@ -20,6 +20,7 @@
 #include <stdio.h>
 
 #include "alloc-util.h"
+#include "dynamic-user.h"
 #include "execute-serialize.h"
 #include "fd-util.h"
 #include "fuzz.h"
index 57480cf76632b69ce8038579b205f1e2af7d613c..d8987c9648d2654e57e2b99c38d85f4c21086627 100644 (file)
@@ -5,6 +5,7 @@
 #include "fuzz.h"
 #include "install.h"
 #include "load-fragment.h"
+#include "manager.h"
 #include "manager-dump.h"
 #include "memstream-util.h"
 #include "string-util.h"
index 4209a7c8d499dec4007bf77b99cba9e710cb9b34..d051b3db6d5a5010d69bc3286028bec446085083 100644 (file)
@@ -16,6 +16,7 @@
 #include "job.h"
 #include "log.h"
 #include "macro.h"
+#include "manager.h"
 #include "parse-util.h"
 #include "serialize.h"
 #include "set.h"
index 388890e368a58d238696c0b04a7c0398186ff890..3c1e861bbc1694b9fe383fab8ff522872167fa29 100644 (file)
@@ -7,6 +7,8 @@
 #include "sd-event.h"
 
 #include "list.h"
+#include "memory-util.h"
+#include "time-util.h"
 #include "unit-dependency-atom.h"
 
 typedef struct ActivationDetails ActivationDetails;
index 3add663d719e948e4c18661ac67b4a6fe2660ffa..97a295e1e57223143ae3252577669527d8ae5702 100644 (file)
@@ -1,8 +1,6 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-typedef struct KillContext KillContext;
-
 #include <stdbool.h>
 #include <stdio.h>
 
@@ -18,7 +16,7 @@ typedef enum KillMode {
         _KILL_MODE_INVALID = -EINVAL,
 } KillMode;
 
-struct KillContext {
+typedef struct KillContext {
         KillMode kill_mode;
         int kill_signal;
         int restart_kill_signal;
@@ -26,7 +24,7 @@ struct KillContext {
         int watchdog_signal;
         bool send_sigkill;
         bool send_sighup;
-};
+} KillContext;
 
 typedef enum KillWhom {
         /* Kill whom is a property of an operation */
index 5c1ccc966f66a43a08b5c233c90e9930c8f3da7f..0256f7063579d2bded4dcb32027c673bc5141ba6 100644 (file)
@@ -1,16 +1,29 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
 #include "conf-parser.h"
+#include "dropin.h"
 #include "fs-util.h"
 #include "load-dropin.h"
 #include "load-fragment.h"
 #include "log.h"
+#include "manager.h"
 #include "stat-util.h"
 #include "string-util.h"
 #include "strv.h"
 #include "unit-name.h"
 #include "unit.h"
 
+int unit_find_dropin_paths(Unit *u, bool use_unit_path_cache, char ***paths) {
+        assert(u);
+
+        return unit_file_find_dropin_paths(NULL,
+                                           u->manager->lookup_paths.search_path,
+                                           use_unit_path_cache ? u->manager->unit_path_cache : NULL,
+                                           ".d", ".conf",
+                                           u->id, u->aliases,
+                                           paths);
+}
+
 static int process_deps(Unit *u, UnitDependency dependency, const char *dir_suffix) {
         _cleanup_strv_free_ char **paths = NULL;
         int r;
index 141bc7dd0f2b67b194530cbc96e6edddeeda8caf..864ea4f0837a4763cd1772868ea3f911bc4f148c 100644 (file)
@@ -1,20 +1,12 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include "dropin.h"
-#include "unit.h"
+#include <stdbool.h>
 
-/* Read service data supplementary drop-in directories */
+typedef struct Unit Unit;
 
-static inline int unit_find_dropin_paths(Unit *u, bool use_unit_path_cache, char ***paths) {
-        assert(u);
+/* Read service data supplementary drop-in directories */
 
-        return unit_file_find_dropin_paths(NULL,
-                                           u->manager->lookup_paths.search_path,
-                                           use_unit_path_cache ? u->manager->unit_path_cache : NULL,
-                                           ".d", ".conf",
-                                           u->id, u->aliases,
-                                           paths);
-}
+int unit_find_dropin_paths(Unit *u, bool use_unit_path_cache, char ***paths);
 
 int unit_load_dropin(Unit *u);
index 0e68d1bb84a5d5ee328de5a9d179cea30c787df4..6aa8f479f5dcbf5c6c30a8171b859476b9bcde33 100644 (file)
@@ -2,7 +2,8 @@
 #pragma once
 
 #include "conf-parser.h"
-#include "unit.h"
+
+typedef struct Unit Unit;
 
 /* These functions are declared in the header to make them accessible to unit tests. */
 bool contains_instance_specifier_superset(const char *s);
index 7e678fa03ee46a201dc17a692729660f5435abc4..9cb184b4d2a80007ee1c936f43c2265371e52b41 100644 (file)
@@ -4,6 +4,7 @@
 #include "fd-util.h"
 #include "fileio.h"
 #include "hashmap.h"
+#include "manager.h"
 #include "manager-dump.h"
 #include "memstream-util.h"
 #include "unit-serialize.h"
index 5b96f26f543fad97ddefbdb02411d40b4ee8aed7..a02c29ad686d1bfd37a28b95d99817725ec64a86 100644 (file)
@@ -3,7 +3,7 @@
 
 #include <stdio.h>
 
-#include "manager.h"
+typedef struct Manager Manager;
 
 void manager_dump_jobs(Manager *s, FILE *f, char **patterns, const char *prefix);
 int manager_get_dump_jobs_string(Manager *m, char **patterns, const char *prefix, char **ret);
index c5cb82e8d5416d5775b8fe00eafcbc20d9abda4e..ae4472b38b6a9e810426828bb4dffb897a7de37e 100644 (file)
@@ -5,6 +5,7 @@
 #include "clean-ipc.h"
 #include "core-varlink.h"
 #include "dbus.h"
+#include "dynamic-user.h"
 #include "fd-util.h"
 #include "fileio.h"
 #include "format-util.h"
index c52261e37840e99cce15fdb4b53c3a7a8eb3003a..7d4e8effb28a601e47a3d1ccc51eff65d37c734d 100644 (file)
@@ -2,10 +2,12 @@
 #pragma once
 
 #include <stdbool.h>
+#include <stdio.h>
 
-#include "manager.h"
 #include "fdset.h"
 
+typedef struct Manager Manager;
+
 #define DESTROY_IPC_FLAG (UINT32_C(1) << 31)
 
 int manager_open_serialization(Manager *m, FILE **ret_f);
index cf000d8f2188060720bec0974abacb3bd372f793..15c8f2b90dfa3c77b2ed71f2656d2ea01791103f 100644 (file)
@@ -42,6 +42,7 @@
 #include "dbus-unit.h"
 #include "dbus.h"
 #include "dirent-util.h"
+#include "dynamic-user.h"
 #include "env-util.h"
 #include "escape.h"
 #include "event-util.h"
@@ -5182,11 +5183,3 @@ static const char* const manager_timestamp_table[_MANAGER_TIMESTAMP_MAX] = {
 };
 
 DEFINE_STRING_TABLE_LOOKUP(manager_timestamp, ManagerTimestamp);
-
-static const char* const oom_policy_table[_OOM_POLICY_MAX] = {
-        [OOM_CONTINUE] = "continue",
-        [OOM_STOP]     = "stop",
-        [OOM_KILL]     = "kill",
-};
-
-DEFINE_STRING_TABLE_LOOKUP(oom_policy, OOMPolicy);
index a07c665e5b5b1c651ab97090b60231227c32cd7d..cbad223d1bfdfefad50d724399b6bd73cb8db3af 100644 (file)
@@ -9,14 +9,22 @@
 #include "sd-event.h"
 #include "sd-varlink.h"
 
-#include "common-signal.h"
 #include "cgroup-util.h"
 #include "cgroup.h"
+#include "common-signal.h"
+#include "emergency-action.h"
+#include "execute.h"
 #include "fdset.h"
 #include "hashmap.h"
+#include "job.h"
 #include "list.h"
+#include "path-lookup.h"
 #include "prioq.h"
 #include "ratelimit.h"
+#include "show-status.h"
+#include "transaction.h"
+#include "unit-name.h"
+#include "unit.h"
 
 struct libmnt_monitor;
 typedef struct Unit Unit;
@@ -62,21 +70,6 @@ typedef enum ManagerObjective {
         _MANAGER_OBJECTIVE_INVALID = -EINVAL,
 } ManagerObjective;
 
-typedef enum StatusType {
-        STATUS_TYPE_EPHEMERAL,
-        STATUS_TYPE_NORMAL,
-        STATUS_TYPE_NOTICE,
-        STATUS_TYPE_EMERGENCY,
-} StatusType;
-
-typedef enum OOMPolicy {
-        OOM_CONTINUE,          /* The kernel or systemd-oomd kills the process it wants to kill, and that's it */
-        OOM_STOP,              /* The kernel or systemd-oomd kills the process it wants to kill, and we stop the unit */
-        OOM_KILL,              /* The kernel or systemd-oomd kills the process it wants to kill, and all others in the unit, and we stop the unit */
-        _OOM_POLICY_MAX,
-        _OOM_POLICY_INVALID = -EINVAL,
-} OOMPolicy;
-
 /* Notes:
  * 1. TIMESTAMP_FIRMWARE, TIMESTAMP_LOADER, TIMESTAMP_KERNEL, TIMESTAMP_INITRD,
  *    TIMESTAMP_SECURITY_START, and TIMESTAMP_SECURITY_FINISH are set only when
@@ -135,14 +128,6 @@ typedef enum WatchdogType {
         _WATCHDOG_TYPE_MAX,
 } WatchdogType;
 
-#include "execute.h"
-#include "job.h"
-#include "path-lookup.h"
-#include "show-status.h"
-#include "transaction.h"
-#include "unit-name.h"
-#include "unit.h"
-
 typedef enum ManagerTestRunFlags {
         MANAGER_TEST_NORMAL                  = 0,       /* run normally */
         MANAGER_TEST_RUN_MINIMAL             = 1 << 0,  /* create basic data structures */
@@ -670,9 +655,6 @@ LogTarget manager_get_executor_log_target(Manager *m);
 
 int manager_allocate_idle_pipe(Manager *m);
 
-const char* oom_policy_to_string(OOMPolicy i) _const_;
-OOMPolicy oom_policy_from_string(const char *s) _pure_;
-
 void unit_defaults_init(UnitDefaults *defaults, RuntimeScope scope);
 void unit_defaults_done(UnitDefaults *defaults);
 
index 7fd643f6fa0dbf43cb387753576c64245ad6e229..c754ae7933a6f70bbd923bf6499e0aa40fdb5ff2 100644 (file)
@@ -1,9 +1,6 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-typedef struct Mount Mount;
-
-#include "dynamic-user.h"
 #include "kill.h"
 #include "pidref.h"
 #include "unit.h"
@@ -42,7 +39,7 @@ typedef enum MountProcFlags {
         MOUNT_PROC_JUST_CHANGED = 1 << 2,
 } MountProcFlags;
 
-struct Mount {
+typedef struct Mount {
         Unit meta;
 
         char *where;
@@ -88,7 +85,7 @@ struct Mount {
         sd_event_source *timer_event_source;
 
         unsigned n_retry_umount;
-};
+} Mount;
 
 extern const UnitVTable mount_vtable;
 
index 4556dbfc71a0a12443eaf5be9d3c65fd758df417..364d94f528ef02f9759191825e763a19473d1e23 100644 (file)
@@ -16,6 +16,7 @@
 #include "glob-util.h"
 #include "inotify-util.h"
 #include "macro.h"
+#include "manager.h"
 #include "mkdir-label.h"
 #include "path.h"
 #include "path-util.h"
index cb5b6629110bf4a43df1e2ef3671bff85bb81a09..8a3b8b35924d28cdb9e30f50aaf8be229cc8d41f 100644 (file)
@@ -1,10 +1,6 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-typedef struct Path Path;
-typedef struct PathSpec PathSpec;
-typedef struct ActivationDetailsPath ActivationDetailsPath;
-
 #include "unit.h"
 
 typedef enum PathType {
@@ -52,7 +48,7 @@ typedef enum PathResult {
         _PATH_RESULT_INVALID = -EINVAL,
 } PathResult;
 
-struct Path {
+typedef struct Path {
         Unit meta;
 
         LIST_HEAD(PathSpec, specs);
@@ -67,12 +63,12 @@ struct Path {
         RateLimit trigger_limit;
 
         sd_event_source *trigger_notify_event_source;
-};
+} Path;
 
-struct ActivationDetailsPath {
+typedef struct ActivationDetailsPath {
         ActivationDetails meta;
         char *trigger_path_filename;
-};
+} ActivationDetailsPath;
 
 void path_free_specs(Path *p);
 
index 208716ea074b844052bb7293c9ce5b279418d859..caeadd7e232975f3540cbe0f5e0bdaeb9f46e812 100644 (file)
@@ -10,6 +10,7 @@
 #include "exit-status.h"
 #include "load-dropin.h"
 #include "log.h"
+#include "manager.h"
 #include "process-util.h"
 #include "random-util.h"
 #include "scope.h"
index 1090431c13e117eef1a85214d7bf4840246ebb74..27f2c83b232991f48c739b8cc82ad002950f4359 100644 (file)
@@ -1,8 +1,6 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-typedef struct Scope Scope;
-
 #include "cgroup.h"
 #include "kill.h"
 #include "unit.h"
@@ -16,7 +14,7 @@ typedef enum ScopeResult {
         _SCOPE_RESULT_INVALID = -EINVAL,
 } ScopeResult;
 
-struct Scope {
+typedef struct Scope {
         Unit meta;
 
         CGroupContext cgroup_context;
@@ -41,7 +39,7 @@ struct Scope {
         char *group;
 
         OOMPolicy oom_policy;
-};
+} Scope;
 
 extern const UnitVTable scope_vtable;
 
index 68be9075c1214b61b493ac9eda3caa0d50849803..a542c0fb111da8b5aa3703e6ffb6b75da6d5c202 100644 (file)
@@ -1,12 +1,9 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-typedef struct Service Service;
-typedef struct ServiceFDStore ServiceFDStore;
-typedef struct ServiceExtraFD ServiceExtraFD;
-
 #include "exit-status.h"
 #include "kill.h"
+#include "manager.h"
 #include "open-file.h"
 #include "path.h"
 #include "pidref.h"
@@ -14,6 +11,8 @@ typedef struct ServiceExtraFD ServiceExtraFD;
 #include "socket.h"
 #include "unit.h"
 
+typedef struct Service Service;
+
 typedef enum ServiceRestart {
         SERVICE_RESTART_NO,
         SERVICE_RESTART_ON_SUCCESS,
@@ -101,7 +100,7 @@ typedef enum ServiceRestartMode {
         _SERVICE_RESTART_MODE_INVALID = -EINVAL,
 } ServiceRestartMode;
 
-struct ServiceFDStore {
+typedef struct ServiceFDStore {
         Service *service;
 
         int fd;
@@ -109,13 +108,13 @@ struct ServiceFDStore {
         sd_event_source *event_source;
         bool do_poll;
 
-        LIST_FIELDS(ServiceFDStore, fd_store);
-};
+        LIST_FIELDS(struct ServiceFDStore, fd_store);
+} ServiceFDStore;
 
-struct ServiceExtraFD {
+typedef struct ServiceExtraFD {
         int fd;
         char *fdname;
-};
+} ServiceExtraFD;
 
 struct Service {
         Unit meta;
index ba6f2fb9c5504e794f6c9bec2eeec3417cb8b1f2..4a9ff98ee94865267d60d50b7f2cc27595bcad52 100644 (file)
@@ -7,6 +7,7 @@
 #include "dbus-unit.h"
 #include "fd-util.h"
 #include "log.h"
+#include "manager.h"
 #include "serialize.h"
 #include "slice.h"
 #include "special.h"
index 37e1f700f8f5d3efca6a1478b7be684f260f156c..46faecc0307acf6dc46679f1cf703d35b2826cfa 100644 (file)
@@ -3,9 +3,7 @@
 
 #include "unit.h"
 
-typedef struct Slice Slice;
-
-struct Slice {
+typedef struct Slice {
         Unit meta;
 
         SliceState state, deserialized_state;
@@ -16,7 +14,7 @@ struct Slice {
         CGroupContext cgroup_context;
 
         CGroupRuntime *cgroup_runtime;
-};
+} Slice;
 
 extern const UnitVTable slice_vtable;
 
index 861aaba3d44c38192c76a374c3eb0512a0cfd402..bb1db8e90ea514b36d503a72c322ee1dcaac073b 100644 (file)
@@ -28,6 +28,7 @@
 #include "ip-protocol-list.h"
 #include "label-util.h"
 #include "log.h"
+#include "manager.h"
 #include "mkdir-label.h"
 #include "parse-util.h"
 #include "path-util.h"
index 51fc96280b98c44a13602bfc9d6957f92ef89321..240a9ac9658e5450a4f67594f37c93ff1d4b7339 100644 (file)
@@ -1,14 +1,13 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-typedef struct Socket Socket;
-typedef struct SocketPeer SocketPeer;
-
-#include "mount.h"
 #include "pidref.h"
 #include "socket-util.h"
 #include "unit.h"
 
+typedef struct Socket Socket;
+typedef struct SocketPeer SocketPeer;
+
 typedef enum SocketExecCommand {
         SOCKET_EXEC_START_PRE,
         SOCKET_EXEC_START_CHOWN,
index cc5a21ee7809aa7c9bf79548dd0a1827fb830451..a8549699ffe65eceedd853dedc2a197fcf92288f 100644 (file)
@@ -17,6 +17,7 @@
 #include "fd-util.h"
 #include "format-util.h"
 #include "fstab-util.h"
+#include "manager.h"
 #include "parse-util.h"
 #include "path-util.h"
 #include "process-util.h"
index d9bbd377f0e947208510af7b78e8c06d0e043b15..fce7ea5e56affec5c3bbb2833e80758da9ca976d 100644 (file)
@@ -10,8 +10,6 @@
 #include "pidref.h"
 #include "unit.h"
 
-typedef struct Swap Swap;
-
 typedef enum SwapExecCommand {
         SWAP_EXEC_ACTIVATE,
         SWAP_EXEC_DEACTIVATE,
@@ -38,7 +36,7 @@ typedef struct SwapParameters {
         bool priority_set;
 } SwapParameters;
 
-struct Swap {
+typedef struct Swap {
         Unit meta;
 
         char *what;
@@ -85,7 +83,7 @@ struct Swap {
         devices for the same swap. We chain them up here. */
 
         LIST_FIELDS(struct Swap, same_devnode);
-};
+} Swap;
 
 extern const UnitVTable swap_vtable;
 
index bb909d664f278f91b77380f205f0260f68626c51..9e7c77c027eab78130dc0a6452ce6dedf8a87f99 100644 (file)
@@ -3,13 +3,11 @@
 
 #include "unit.h"
 
-typedef struct Target Target;
-
-struct Target {
+typedef struct Target {
         Unit meta;
 
         TargetState state, deserialized_state;
-};
+} Target;
 
 extern const UnitVTable target_vtable;
 
index b37a67f3107e4f26ee2c0083d774336194d3ca25..d69e2299229d544a98bfadead67ed07551658511 100644 (file)
@@ -12,6 +12,7 @@
 #include "dbus-timer.h"
 #include "dbus-unit.h"
 #include "fs-util.h"
+#include "manager.h"
 #include "parse-util.h"
 #include "random-util.h"
 #include "serialize.h"
index 14a9931dffe5775092a215fd46d9519febbb9dc9..90f19a7cf4e1319d3c87ba3f4ef4003cbe253f37 100644 (file)
@@ -1,9 +1,6 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-typedef struct Timer Timer;
-typedef struct ActivationDetailsTimer ActivationDetailsTimer;
-
 #include "calendarspec.h"
 #include "unit.h"
 
@@ -37,7 +34,7 @@ typedef enum TimerResult {
         _TIMER_RESULT_INVALID = -EINVAL,
 } TimerResult;
 
-struct Timer {
+typedef struct Timer {
         Unit meta;
 
         usec_t accuracy_usec;
@@ -64,12 +61,12 @@ struct Timer {
         bool defer_reactivation;
 
         char *stamp_path;
-};
+} Timer;
 
-struct ActivationDetailsTimer {
+typedef struct ActivationDetailsTimer {
         ActivationDetails meta;
         dual_timestamp last_trigger;
-};
+} ActivationDetailsTimer;
 
 #define TIMER_MONOTONIC_CLOCK(t) ((t)->wake_system ? CLOCK_BOOTTIME_ALARM : CLOCK_MONOTONIC)
 
index 07fd612d918f767f05344e4a85da635906333abd..6d0d7e73beff0bb959df65edf293c73d861a661d 100644 (file)
@@ -8,6 +8,7 @@
 #include "bus-common-errors.h"
 #include "bus-error.h"
 #include "dbus-unit.h"
+#include "manager.h"
 #include "slice.h"
 #include "strv.h"
 #include "terminal-util.h"
index b6728a35d7b43f48bef7a21d51534ed03ec0797d..1f58fcebccf8570ad9ede2dc8ae3fb621e90e400 100644 (file)
@@ -1,20 +1,15 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-typedef struct Transaction Transaction;
-typedef enum TransactionAddFlags TransactionAddFlags;
-
 #include "hashmap.h"
 #include "job.h"
-#include "manager.h"
-#include "unit.h"
 
-struct Transaction {
+typedef struct Transaction {
         /* Jobs to be added */
         Hashmap *jobs;        /* Unit object => Job object list 1:1 */
         Job *anchor_job;      /* The job the user asked for */
         bool irreversible;
-};
+} Transaction;
 
 Transaction* transaction_new(bool irreversible);
 Transaction* transaction_free(Transaction *tr);
index f25e2e39861b7f0bda1416caa1fa18bfe53ec6c1..0bdacfc3c08fb31ab5dc1e3de54a0dce3ab910d7 100644 (file)
@@ -4,6 +4,7 @@
 #include "cgroup-util.h"
 #include "format-util.h"
 #include "macro.h"
+#include "manager.h"
 #include "sd-path.h"
 #include "specifier.h"
 #include "string-util.h"
index 13aea615dd677eafbc755c35914b9b4c6f431aca..a38b38590a84dc507845fdf24c67ff5a9f2c5d77 100644 (file)
@@ -10,6 +10,7 @@
 #include "parse-util.h"
 #include "serialize.h"
 #include "string-table.h"
+#include "unit.h"
 #include "unit-serialize.h"
 #include "user-util.h"
 
index ab8a8e3be904138bbc03a599ce28341649a595bc..a7ac03cf823580dbdc5924150a704358bc0bd313 100644 (file)
@@ -1,11 +1,13 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
+#include <stdbool.h>
 #include <stdio.h>
 
-#include "unit.h"
 #include "fdset.h"
 
+typedef struct Unit Unit;
+
 /* These functions serialize state for our own usage, i.e.: across a reload/reexec, rather than for being
  * passed to a child process. */
 
index c25777671df0f79d5b48b3ac78c968d97f3b1398..db142976227b961164ded041915738f2464766bc 100644 (file)
@@ -24,6 +24,7 @@
 #include "dbus-unit.h"
 #include "dbus.h"
 #include "dropin.h"
+#include "dynamic-user.h"
 #include "env-util.h"
 #include "escape.h"
 #include "exec-credential.h"
@@ -6810,6 +6811,14 @@ static const char* const unit_mount_dependency_type_table[_UNIT_MOUNT_DEPENDENCY
 
 DEFINE_STRING_TABLE_LOOKUP(unit_mount_dependency_type, UnitMountDependencyType);
 
+static const char* const oom_policy_table[_OOM_POLICY_MAX] = {
+        [OOM_CONTINUE] = "continue",
+        [OOM_STOP]     = "stop",
+        [OOM_KILL]     = "kill",
+};
+
+DEFINE_STRING_TABLE_LOOKUP(oom_policy, OOMPolicy);
+
 UnitDependency unit_mount_dependency_type_to_dependency_type(UnitMountDependencyType t) {
         switch (t) {
 
index 6a46cbda0a22322006fd1e79ccd86959bb15b7d1..5bf52f5f6d21d02b137362ea2f5bfcfb854ed2d8 100644 (file)
@@ -9,26 +9,28 @@
 
 #include "sd-id128.h"
 
-/* Circular dependency with manager.h, needs to be defined before local includes */
-typedef enum UnitMountDependencyType {
-        UNIT_MOUNT_WANTS,
-        UNIT_MOUNT_REQUIRES,
-        _UNIT_MOUNT_DEPENDENCY_TYPE_MAX,
-        _UNIT_MOUNT_DEPENDENCY_TYPE_INVALID = -EINVAL,
-} UnitMountDependencyType;
-
 #include "cgroup.h"
 #include "condition.h"
 #include "emergency-action.h"
+#include "execute.h"
 #include "install.h"
+#include "job.h"
 #include "list.h"
 #include "log-context.h"
 #include "mount-util.h"
 #include "pidref.h"
+#include "ratelimit.h"
 #include "unit-file.h"
 
 typedef struct UnitRef UnitRef;
 
+typedef enum UnitMountDependencyType {
+        UNIT_MOUNT_WANTS,
+        UNIT_MOUNT_REQUIRES,
+        _UNIT_MOUNT_DEPENDENCY_TYPE_MAX,
+        _UNIT_MOUNT_DEPENDENCY_TYPE_INVALID = -EINVAL,
+} UnitMountDependencyType;
+
 typedef enum KillOperation {
         KILL_TERMINATE,
         KILL_TERMINATE_AND_LOG,
@@ -46,6 +48,21 @@ typedef enum CollectMode {
         _COLLECT_MODE_INVALID = -EINVAL,
 } CollectMode;
 
+typedef enum OOMPolicy {
+        OOM_CONTINUE,          /* The kernel or systemd-oomd kills the process it wants to kill, and that's it */
+        OOM_STOP,              /* The kernel or systemd-oomd kills the process it wants to kill, and we stop the unit */
+        OOM_KILL,              /* The kernel or systemd-oomd kills the process it wants to kill, and all others in the unit, and we stop the unit */
+        _OOM_POLICY_MAX,
+        _OOM_POLICY_INVALID = -EINVAL,
+} OOMPolicy;
+
+typedef enum StatusType {
+        STATUS_TYPE_EPHEMERAL,
+        STATUS_TYPE_NORMAL,
+        STATUS_TYPE_NOTICE,
+        STATUS_TYPE_EMERGENCY,
+} StatusType;
+
 static inline bool UNIT_IS_ACTIVE_OR_RELOADING(UnitActiveState t) {
         return IN_SET(t, UNIT_ACTIVE, UNIT_RELOADING, UNIT_REFRESHING);
 }
@@ -200,8 +217,6 @@ static inline void* UNIT_DEPENDENCY_TO_PTR(UnitDependency d) {
         return INT_TO_PTR(d);
 }
 
-#include "job.h"
-
 struct UnitRef {
         /* Keeps tracks of references to a unit. This is useful so
          * that we can merge two units if necessary and correct all
@@ -1061,6 +1076,9 @@ UnitMountDependencyType unit_mount_dependency_type_from_string(const char *s) _c
 const char* unit_mount_dependency_type_to_string(UnitMountDependencyType t) _const_;
 UnitDependency unit_mount_dependency_type_to_dependency_type(UnitMountDependencyType t) _pure_;
 
+const char* oom_policy_to_string(OOMPolicy i) _const_;
+OOMPolicy oom_policy_from_string(const char *s) _pure_;
+
 /* Macros which append UNIT= or USER_UNIT= to the message */
 
 #define log_unit_full_errno_zerook(unit, level, error, ...)             \