mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-02-03 13:47:04 +03:00
core: undo the dependency inversion between unit.h and all unit types
This commit is contained in:
parent
90a8f0b9a9
commit
57b7a260c2
@ -8,6 +8,7 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "all-units.h"
|
||||
#include "analyze-verify.h"
|
||||
#include "bus-error.h"
|
||||
#include "bus-util.h"
|
||||
|
14
src/core/all-units.h
Normal file
14
src/core/all-units.h
Normal file
@ -0,0 +1,14 @@
|
||||
#pragma once
|
||||
|
||||
#include "unit.h"
|
||||
|
||||
#include "automount.h"
|
||||
#include "device.h"
|
||||
#include "path.h"
|
||||
#include "scope.h"
|
||||
#include "service.h"
|
||||
#include "slice.h"
|
||||
#include "socket.h"
|
||||
#include "swap.h"
|
||||
#include "target.h"
|
||||
#include "timer.h"
|
@ -45,3 +45,5 @@ extern const UnitVTable automount_vtable;
|
||||
|
||||
const char* automount_result_to_string(AutomountResult i) _const_;
|
||||
AutomountResult automount_result_from_string(const char *s) _pure_;
|
||||
|
||||
DEFINE_CAST(AUTOMOUNT, Automount);
|
||||
|
@ -9,7 +9,7 @@
|
||||
|
||||
#include "sd-bus.h"
|
||||
|
||||
#include "unit.h"
|
||||
#include "scope.h"
|
||||
|
||||
extern const sd_bus_vtable bus_scope_vtable[];
|
||||
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include "mkdir.h"
|
||||
#include "process-util.h"
|
||||
#include "selinux-access.h"
|
||||
#include "service.h"
|
||||
#include "special.h"
|
||||
#include "string-util.h"
|
||||
#include "strv.h"
|
||||
|
@ -7,6 +7,8 @@
|
||||
Copyright 2010 Lennart Poettering
|
||||
***/
|
||||
|
||||
#include "unit.h"
|
||||
|
||||
typedef struct Device Device;
|
||||
|
||||
typedef enum DeviceFound {
|
||||
@ -37,3 +39,5 @@ extern const UnitVTable device_vtable;
|
||||
|
||||
int device_found_node(Manager *m, const char *node, bool add, DeviceFound found, bool now);
|
||||
bool device_shall_be_bound_by(Unit *device, Unit *u);
|
||||
|
||||
DEFINE_CAST(DEVICE, Device);
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include "io-util.h"
|
||||
#include "parse-util.h"
|
||||
#include "random-util.h"
|
||||
#include "socket-util.h"
|
||||
#include "stdio-util.h"
|
||||
#include "string-util.h"
|
||||
#include "user-util.h"
|
||||
|
@ -86,6 +86,7 @@
|
||||
#include "selinux-util.h"
|
||||
#include "signal-util.h"
|
||||
#include "smack-util.h"
|
||||
#include "socket-util.h"
|
||||
#include "special.h"
|
||||
#include "stat-util.h"
|
||||
#include "string-table.h"
|
||||
|
@ -6,6 +6,8 @@ _Pragma("GCC diagnostic ignored \"-Wimplicit-fallthrough\"")
|
||||
#include "conf-parser.h"
|
||||
#include "load-fragment.h"
|
||||
#include "missing.h"
|
||||
|
||||
#include "all-units.h"
|
||||
%}
|
||||
struct ConfigPerfItem;
|
||||
%null_strings
|
||||
|
@ -20,6 +20,7 @@
|
||||
|
||||
#include "af-list.h"
|
||||
#include "alloc-util.h"
|
||||
#include "all-units.h"
|
||||
#include "bus-error.h"
|
||||
#include "bus-internal.h"
|
||||
#include "bus-util.h"
|
||||
@ -57,7 +58,6 @@
|
||||
#include "strv.h"
|
||||
#include "unit-name.h"
|
||||
#include "unit-printf.h"
|
||||
#include "unit.h"
|
||||
#include "user-util.h"
|
||||
#include "utf8.h"
|
||||
#include "web-util.h"
|
||||
|
@ -40,6 +40,7 @@
|
||||
#include "def.h"
|
||||
#include "emergency-action.h"
|
||||
#include "env-util.h"
|
||||
#include "exit-status.h"
|
||||
#include "fd-util.h"
|
||||
#include "fdset.h"
|
||||
#include "fileio.h"
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include "sd-path.h"
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "all-units.h"
|
||||
#include "audit-fd.h"
|
||||
#include "boot-timestamps.h"
|
||||
#include "bus-common-errors.h"
|
||||
@ -65,6 +66,7 @@
|
||||
#include "ratelimit.h"
|
||||
#include "rm-rf.h"
|
||||
#include "signal-util.h"
|
||||
#include "socket-util.h"
|
||||
#include "special.h"
|
||||
#include "stat-util.h"
|
||||
#include "string-table.h"
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "ratelimit.h"
|
||||
|
||||
struct libmnt_monitor;
|
||||
typedef struct Unit Unit;
|
||||
|
||||
/* Enforce upper limit how many names we allow */
|
||||
#define MANAGER_MAX_NAMES 131072 /* 128K */
|
||||
|
@ -16,6 +16,7 @@
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "dbus-mount.h"
|
||||
#include "device.h"
|
||||
#include "escape.h"
|
||||
#include "exit-status.h"
|
||||
#include "format-util.h"
|
||||
|
@ -11,6 +11,7 @@ typedef struct Mount Mount;
|
||||
|
||||
#include "kill.h"
|
||||
#include "dynamic-user.h"
|
||||
#include "unit.h"
|
||||
|
||||
typedef enum MountExecCommand {
|
||||
MOUNT_EXEC_MOUNT,
|
||||
@ -97,3 +98,5 @@ MountExecCommand mount_exec_command_from_string(const char *s) _pure_;
|
||||
|
||||
const char* mount_result_to_string(MountResult i) _const_;
|
||||
MountResult mount_result_from_string(const char *s) _pure_;
|
||||
|
||||
DEFINE_CAST(MOUNT, Mount);
|
||||
|
@ -79,3 +79,5 @@ PathType path_type_from_string(const char *s) _pure_;
|
||||
|
||||
const char* path_result_to_string(PathResult i) _const_;
|
||||
PathResult path_result_from_string(const char *s) _pure_;
|
||||
|
||||
DEFINE_CAST(PATH, Path);
|
||||
|
@ -46,3 +46,5 @@ int scope_abandon(Scope *s);
|
||||
|
||||
const char* scope_result_to_string(ScopeResult i) _const_;
|
||||
ScopeResult scope_result_from_string(const char *s) _pure_;
|
||||
|
||||
DEFINE_CAST(SCOPE, Scope);
|
||||
|
@ -14,6 +14,8 @@ typedef struct ServiceFDStore ServiceFDStore;
|
||||
#include "kill.h"
|
||||
#include "path.h"
|
||||
#include "ratelimit.h"
|
||||
#include "socket.h"
|
||||
#include "unit.h"
|
||||
|
||||
typedef enum ServiceRestart {
|
||||
SERVICE_RESTART_NO,
|
||||
@ -204,3 +206,5 @@ NotifyState notify_state_from_string(const char *s) _pure_;
|
||||
|
||||
const char* service_result_to_string(ServiceResult i) _const_;
|
||||
ServiceResult service_result_from_string(const char *s) _pure_;
|
||||
|
||||
DEFINE_CAST(SERVICE, Service);
|
||||
|
@ -7,6 +7,8 @@
|
||||
Copyright 2013 Lennart Poettering
|
||||
***/
|
||||
|
||||
#include "unit.h"
|
||||
|
||||
typedef struct Slice Slice;
|
||||
|
||||
struct Slice {
|
||||
@ -18,3 +20,5 @@ struct Slice {
|
||||
};
|
||||
|
||||
extern const UnitVTable slice_vtable;
|
||||
|
||||
DEFINE_CAST(SLICE, Slice);
|
||||
|
@ -13,6 +13,7 @@ typedef struct SocketPeer SocketPeer;
|
||||
#include "mount.h"
|
||||
#include "service.h"
|
||||
#include "socket-util.h"
|
||||
#include "unit.h"
|
||||
|
||||
typedef enum SocketExecCommand {
|
||||
SOCKET_EXEC_START_PRE,
|
||||
@ -182,3 +183,5 @@ SocketResult socket_result_from_string(const char *s) _pure_;
|
||||
|
||||
const char* socket_port_type_to_string(SocketPort *p) _pure_;
|
||||
SocketType socket_port_type_from_string(const char *p) _pure_;
|
||||
|
||||
DEFINE_CAST(SOCKET, Socket);
|
||||
|
@ -14,6 +14,7 @@
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "dbus-swap.h"
|
||||
#include "device.h"
|
||||
#include "escape.h"
|
||||
#include "exit-status.h"
|
||||
#include "fd-util.h"
|
||||
|
@ -9,6 +9,7 @@
|
||||
***/
|
||||
|
||||
#include "libudev.h"
|
||||
#include "unit.h"
|
||||
|
||||
typedef struct Swap Swap;
|
||||
|
||||
@ -95,3 +96,5 @@ SwapExecCommand swap_exec_command_from_string(const char *s) _pure_;
|
||||
|
||||
const char* swap_result_to_string(SwapResult i) _const_;
|
||||
SwapResult swap_result_from_string(const char *s) _pure_;
|
||||
|
||||
DEFINE_CAST(SWAP, Swap);
|
||||
|
@ -1,6 +1,8 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||
#pragma once
|
||||
|
||||
#include "unit.h"
|
||||
|
||||
/***
|
||||
This file is part of systemd.
|
||||
|
||||
@ -16,3 +18,5 @@ struct Target {
|
||||
};
|
||||
|
||||
extern const UnitVTable target_vtable;
|
||||
|
||||
DEFINE_CAST(TARGET, Target);
|
||||
|
@ -10,6 +10,7 @@
|
||||
typedef struct Timer Timer;
|
||||
|
||||
#include "calendarspec.h"
|
||||
#include "unit.h"
|
||||
|
||||
typedef enum TimerBase {
|
||||
TIMER_ACTIVE,
|
||||
@ -77,3 +78,5 @@ TimerBase timer_base_from_string(const char *s) _pure_;
|
||||
|
||||
const char* timer_result_to_string(TimerResult i) _const_;
|
||||
TimerResult timer_result_from_string(const char *s) _pure_;
|
||||
|
||||
DEFINE_CAST(TIMER, Timer);
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include "sd-messages.h"
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "all-units.h"
|
||||
#include "bus-common-errors.h"
|
||||
#include "bus-util.h"
|
||||
#include "cgroup-util.h"
|
||||
|
@ -11,11 +11,6 @@
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
typedef struct Unit Unit;
|
||||
typedef struct UnitVTable UnitVTable;
|
||||
typedef struct UnitRef UnitRef;
|
||||
typedef struct UnitStatusMessageFormats UnitStatusMessageFormats;
|
||||
|
||||
#include "bpf-program.h"
|
||||
#include "condition.h"
|
||||
#include "emergency-action.h"
|
||||
@ -24,6 +19,8 @@ typedef struct UnitStatusMessageFormats UnitStatusMessageFormats;
|
||||
#include "unit-name.h"
|
||||
#include "cgroup.h"
|
||||
|
||||
typedef struct UnitRef UnitRef;
|
||||
|
||||
typedef enum KillOperation {
|
||||
KILL_TERMINATE,
|
||||
KILL_TERMINATE_AND_LOG,
|
||||
@ -120,7 +117,7 @@ typedef enum UnitCGroupBPFState {
|
||||
UNIT_CGROUP_BPF_INVALIDATED = -1,
|
||||
} UnitCGroupBPFState;
|
||||
|
||||
struct Unit {
|
||||
typedef struct Unit {
|
||||
Manager *manager;
|
||||
|
||||
UnitType type;
|
||||
@ -358,13 +355,13 @@ struct Unit {
|
||||
/* When writing transient unit files, stores which section we stored last. If < 0, we didn't write any yet. If
|
||||
* == 0 we are in the [Unit] section, if > 0 we are in the unit type-specific section. */
|
||||
int last_section_private:2;
|
||||
};
|
||||
} Unit;
|
||||
|
||||
struct UnitStatusMessageFormats {
|
||||
typedef struct UnitStatusMessageFormats {
|
||||
const char *starting_stopping[2];
|
||||
const char *finished_start_job[_JOB_RESULT_MAX];
|
||||
const char *finished_stop_job[_JOB_RESULT_MAX];
|
||||
};
|
||||
} UnitStatusMessageFormats;
|
||||
|
||||
/* Flags used when writing drop-in files or transient unit files */
|
||||
typedef enum UnitWriteFlags {
|
||||
@ -387,17 +384,9 @@ typedef enum UnitWriteFlags {
|
||||
/* Returns true if neither persistent, nor runtime storage is requested, i.e. this is a check invocation only */
|
||||
#define UNIT_WRITE_FLAGS_NOOP(flags) (((flags) & (UNIT_RUNTIME|UNIT_PERSISTENT)) == 0)
|
||||
|
||||
#include "automount.h"
|
||||
#include "device.h"
|
||||
#include "path.h"
|
||||
#include "scope.h"
|
||||
#include "slice.h"
|
||||
#include "socket.h"
|
||||
#include "swap.h"
|
||||
#include "target.h"
|
||||
#include "timer.h"
|
||||
#include "kill.h"
|
||||
|
||||
struct UnitVTable {
|
||||
typedef struct UnitVTable {
|
||||
/* How much memory does an object of this unit type need */
|
||||
size_t object_size;
|
||||
|
||||
@ -566,7 +555,7 @@ struct UnitVTable {
|
||||
|
||||
/* True if queued jobs of this type should be GC'ed if no other job needs them anymore */
|
||||
bool gc_jobs:1;
|
||||
};
|
||||
} UnitVTable;
|
||||
|
||||
extern const UnitVTable * const unit_vtable[_UNIT_TYPE_MAX];
|
||||
|
||||
@ -590,18 +579,6 @@ extern const UnitVTable * const unit_vtable[_UNIT_TYPE_MAX];
|
||||
|
||||
#define UNIT_TRIGGER(u) ((Unit*) hashmap_first_key((u)->dependencies[UNIT_TRIGGERS]))
|
||||
|
||||
DEFINE_CAST(SERVICE, Service);
|
||||
DEFINE_CAST(SOCKET, Socket);
|
||||
DEFINE_CAST(TARGET, Target);
|
||||
DEFINE_CAST(DEVICE, Device);
|
||||
DEFINE_CAST(MOUNT, Mount);
|
||||
DEFINE_CAST(AUTOMOUNT, Automount);
|
||||
DEFINE_CAST(SWAP, Swap);
|
||||
DEFINE_CAST(TIMER, Timer);
|
||||
DEFINE_CAST(PATH, Path);
|
||||
DEFINE_CAST(SLICE, Slice);
|
||||
DEFINE_CAST(SCOPE, Scope);
|
||||
|
||||
Unit *unit_new(Manager *m, size_t size);
|
||||
void unit_free(Unit *u);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(Unit *, unit_free);
|
||||
|
@ -24,6 +24,7 @@
|
||||
#if HAVE_SECCOMP
|
||||
#include "seccomp-util.h"
|
||||
#endif
|
||||
#include "service.h"
|
||||
#include "stat-util.h"
|
||||
#include "test-helper.h"
|
||||
#include "tests.h"
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "all-units.h"
|
||||
#include "fd-util.h"
|
||||
#include "fs-util.h"
|
||||
#include "macro.h"
|
||||
|
@ -7,6 +7,7 @@
|
||||
|
||||
#include <sched.h>
|
||||
|
||||
#include "all-units.h"
|
||||
#include "macro.h"
|
||||
#include "manager.h"
|
||||
#include "rm-rf.h"
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include <unistd.h>
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "all-units.h"
|
||||
#include "capability-util.h"
|
||||
#include "fd-util.h"
|
||||
#include "fileio.h"
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "all-units.h"
|
||||
#include "glob-util.h"
|
||||
#include "hostname-util.h"
|
||||
#include "macro.h"
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include "log.h"
|
||||
#include "manager.h"
|
||||
#include "rm-rf.h"
|
||||
#include "service.h"
|
||||
#include "test-helper.h"
|
||||
#include "tests.h"
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user