]> git.proxmox.com Git - systemd.git/blame - src/basic/unit-def.h
New upstream version 240
[systemd.git] / src / basic / unit-def.h
CommitLineData
52ad194e
MB
1/* SPDX-License-Identifier: LGPL-2.1+ */
2#pragma once
3
52ad194e
MB
4#include <stdbool.h>
5
6#include "macro.h"
7
8typedef enum UnitType {
9 UNIT_SERVICE = 0,
10 UNIT_SOCKET,
11 UNIT_TARGET,
12 UNIT_DEVICE,
13 UNIT_MOUNT,
14 UNIT_AUTOMOUNT,
15 UNIT_SWAP,
16 UNIT_TIMER,
17 UNIT_PATH,
18 UNIT_SLICE,
19 UNIT_SCOPE,
20 _UNIT_TYPE_MAX,
21 _UNIT_TYPE_INVALID = -1
22} UnitType;
23
24typedef enum UnitLoadState {
25 UNIT_STUB = 0,
26 UNIT_LOADED,
b012e921
MB
27 UNIT_NOT_FOUND, /* error condition #1: unit file not found */
28 UNIT_BAD_SETTING, /* error condition #2: we couldn't parse some essential unit file setting */
29 UNIT_ERROR, /* error condition #3: other "system" error, catchall for the rest */
52ad194e
MB
30 UNIT_MERGED,
31 UNIT_MASKED,
32 _UNIT_LOAD_STATE_MAX,
33 _UNIT_LOAD_STATE_INVALID = -1
34} UnitLoadState;
35
36typedef enum UnitActiveState {
37 UNIT_ACTIVE,
38 UNIT_RELOADING,
39 UNIT_INACTIVE,
40 UNIT_FAILED,
41 UNIT_ACTIVATING,
42 UNIT_DEACTIVATING,
43 _UNIT_ACTIVE_STATE_MAX,
44 _UNIT_ACTIVE_STATE_INVALID = -1
45} UnitActiveState;
46
47typedef enum AutomountState {
48 AUTOMOUNT_DEAD,
49 AUTOMOUNT_WAITING,
50 AUTOMOUNT_RUNNING,
51 AUTOMOUNT_FAILED,
52 _AUTOMOUNT_STATE_MAX,
53 _AUTOMOUNT_STATE_INVALID = -1
54} AutomountState;
55
56/* We simply watch devices, we cannot plug/unplug them. That
57 * simplifies the state engine greatly */
58typedef enum DeviceState {
59 DEVICE_DEAD,
60 DEVICE_TENTATIVE, /* mounted or swapped, but not (yet) announced by udev */
61 DEVICE_PLUGGED, /* announced by udev */
62 _DEVICE_STATE_MAX,
63 _DEVICE_STATE_INVALID = -1
64} DeviceState;
65
66typedef enum MountState {
67 MOUNT_DEAD,
68 MOUNT_MOUNTING, /* /usr/bin/mount is running, but the mount is not done yet. */
69 MOUNT_MOUNTING_DONE, /* /usr/bin/mount is running, and the mount is done. */
70 MOUNT_MOUNTED,
71 MOUNT_REMOUNTING,
72 MOUNT_UNMOUNTING,
73 MOUNT_REMOUNTING_SIGTERM,
74 MOUNT_REMOUNTING_SIGKILL,
75 MOUNT_UNMOUNTING_SIGTERM,
76 MOUNT_UNMOUNTING_SIGKILL,
77 MOUNT_FAILED,
78 _MOUNT_STATE_MAX,
79 _MOUNT_STATE_INVALID = -1
80} MountState;
81
82typedef enum PathState {
83 PATH_DEAD,
84 PATH_WAITING,
85 PATH_RUNNING,
86 PATH_FAILED,
87 _PATH_STATE_MAX,
88 _PATH_STATE_INVALID = -1
89} PathState;
90
91typedef enum ScopeState {
92 SCOPE_DEAD,
93 SCOPE_RUNNING,
94 SCOPE_ABANDONED,
95 SCOPE_STOP_SIGTERM,
96 SCOPE_STOP_SIGKILL,
97 SCOPE_FAILED,
98 _SCOPE_STATE_MAX,
99 _SCOPE_STATE_INVALID = -1
100} ScopeState;
101
102typedef enum ServiceState {
103 SERVICE_DEAD,
104 SERVICE_START_PRE,
105 SERVICE_START,
106 SERVICE_START_POST,
107 SERVICE_RUNNING,
108 SERVICE_EXITED, /* Nothing is running anymore, but RemainAfterExit is true hence this is OK */
109 SERVICE_RELOAD,
110 SERVICE_STOP, /* No STOP_PRE state, instead just register multiple STOP executables */
6e866b33 111 SERVICE_STOP_WATCHDOG,
52ad194e
MB
112 SERVICE_STOP_SIGTERM,
113 SERVICE_STOP_SIGKILL,
114 SERVICE_STOP_POST,
115 SERVICE_FINAL_SIGTERM, /* In case the STOP_POST executable hangs, we shoot that down, too */
116 SERVICE_FINAL_SIGKILL,
117 SERVICE_FAILED,
118 SERVICE_AUTO_RESTART,
119 _SERVICE_STATE_MAX,
120 _SERVICE_STATE_INVALID = -1
121} ServiceState;
122
123typedef enum SliceState {
124 SLICE_DEAD,
125 SLICE_ACTIVE,
126 _SLICE_STATE_MAX,
127 _SLICE_STATE_INVALID = -1
128} SliceState;
129
130typedef enum SocketState {
131 SOCKET_DEAD,
132 SOCKET_START_PRE,
133 SOCKET_START_CHOWN,
134 SOCKET_START_POST,
135 SOCKET_LISTENING,
136 SOCKET_RUNNING,
137 SOCKET_STOP_PRE,
138 SOCKET_STOP_PRE_SIGTERM,
139 SOCKET_STOP_PRE_SIGKILL,
140 SOCKET_STOP_POST,
141 SOCKET_FINAL_SIGTERM,
142 SOCKET_FINAL_SIGKILL,
143 SOCKET_FAILED,
144 _SOCKET_STATE_MAX,
145 _SOCKET_STATE_INVALID = -1
146} SocketState;
147
148typedef enum SwapState {
149 SWAP_DEAD,
150 SWAP_ACTIVATING, /* /sbin/swapon is running, but the swap not yet enabled. */
151 SWAP_ACTIVATING_DONE, /* /sbin/swapon is running, and the swap is done. */
152 SWAP_ACTIVE,
153 SWAP_DEACTIVATING,
154 SWAP_DEACTIVATING_SIGTERM,
155 SWAP_DEACTIVATING_SIGKILL,
156 SWAP_FAILED,
157 _SWAP_STATE_MAX,
158 _SWAP_STATE_INVALID = -1
159} SwapState;
160
161typedef enum TargetState {
162 TARGET_DEAD,
163 TARGET_ACTIVE,
164 _TARGET_STATE_MAX,
165 _TARGET_STATE_INVALID = -1
166} TargetState;
167
168typedef enum TimerState {
169 TIMER_DEAD,
170 TIMER_WAITING,
171 TIMER_RUNNING,
172 TIMER_ELAPSED,
173 TIMER_FAILED,
174 _TIMER_STATE_MAX,
175 _TIMER_STATE_INVALID = -1
176} TimerState;
177
178typedef enum UnitDependency {
179 /* Positive dependencies */
180 UNIT_REQUIRES,
181 UNIT_REQUISITE,
182 UNIT_WANTS,
183 UNIT_BINDS_TO,
184 UNIT_PART_OF,
185
186 /* Inverse of the above */
187 UNIT_REQUIRED_BY, /* inverse of 'requires' is 'required_by' */
188 UNIT_REQUISITE_OF, /* inverse of 'requisite' is 'requisite_of' */
189 UNIT_WANTED_BY, /* inverse of 'wants' */
190 UNIT_BOUND_BY, /* inverse of 'binds_to' */
191 UNIT_CONSISTS_OF, /* inverse of 'part_of' */
192
193 /* Negative dependencies */
194 UNIT_CONFLICTS, /* inverse of 'conflicts' is 'conflicted_by' */
195 UNIT_CONFLICTED_BY,
196
197 /* Order */
198 UNIT_BEFORE, /* inverse of 'before' is 'after' and vice versa */
199 UNIT_AFTER,
200
201 /* On Failure */
202 UNIT_ON_FAILURE,
203
204 /* Triggers (i.e. a socket triggers a service) */
205 UNIT_TRIGGERS,
206 UNIT_TRIGGERED_BY,
207
208 /* Propagate reloads */
209 UNIT_PROPAGATES_RELOAD_TO,
210 UNIT_RELOAD_PROPAGATED_FROM,
211
212 /* Joins namespace of */
213 UNIT_JOINS_NAMESPACE_OF,
214
215 /* Reference information for GC logic */
216 UNIT_REFERENCES, /* Inverse of 'references' is 'referenced_by' */
217 UNIT_REFERENCED_BY,
218
219 _UNIT_DEPENDENCY_MAX,
220 _UNIT_DEPENDENCY_INVALID = -1
221} UnitDependency;
222
223typedef enum NotifyAccess {
224 NOTIFY_NONE,
225 NOTIFY_ALL,
226 NOTIFY_MAIN,
227 NOTIFY_EXEC,
228 _NOTIFY_ACCESS_MAX,
229 _NOTIFY_ACCESS_INVALID = -1
230} NotifyAccess;
231
232char *unit_dbus_path_from_name(const char *name);
233int unit_name_from_dbus_path(const char *path, char **name);
234
235const char* unit_dbus_interface_from_type(UnitType t);
236const char *unit_dbus_interface_from_name(const char *name);
237
238const char *unit_type_to_string(UnitType i) _const_;
239UnitType unit_type_from_string(const char *s) _pure_;
240
241const char *unit_load_state_to_string(UnitLoadState i) _const_;
242UnitLoadState unit_load_state_from_string(const char *s) _pure_;
243
244const char *unit_active_state_to_string(UnitActiveState i) _const_;
245UnitActiveState unit_active_state_from_string(const char *s) _pure_;
246
247const char* automount_state_to_string(AutomountState i) _const_;
248AutomountState automount_state_from_string(const char *s) _pure_;
249
250const char* device_state_to_string(DeviceState i) _const_;
251DeviceState device_state_from_string(const char *s) _pure_;
252
253const char* mount_state_to_string(MountState i) _const_;
254MountState mount_state_from_string(const char *s) _pure_;
255
256const char* path_state_to_string(PathState i) _const_;
257PathState path_state_from_string(const char *s) _pure_;
258
259const char* scope_state_to_string(ScopeState i) _const_;
260ScopeState scope_state_from_string(const char *s) _pure_;
261
262const char* service_state_to_string(ServiceState i) _const_;
263ServiceState service_state_from_string(const char *s) _pure_;
264
265const char* slice_state_to_string(SliceState i) _const_;
266SliceState slice_state_from_string(const char *s) _pure_;
267
268const char* socket_state_to_string(SocketState i) _const_;
269SocketState socket_state_from_string(const char *s) _pure_;
270
271const char* swap_state_to_string(SwapState i) _const_;
272SwapState swap_state_from_string(const char *s) _pure_;
273
274const char* target_state_to_string(TargetState i) _const_;
275TargetState target_state_from_string(const char *s) _pure_;
276
277const char *timer_state_to_string(TimerState i) _const_;
278TimerState timer_state_from_string(const char *s) _pure_;
279
280const char *unit_dependency_to_string(UnitDependency i) _const_;
281UnitDependency unit_dependency_from_string(const char *s) _pure_;
282
283const char* notify_access_to_string(NotifyAccess i) _const_;
284NotifyAccess notify_access_from_string(const char *s) _pure_;