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