]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/basic/unit-def.h
basic: split unit-name.[ch] into two (#7065)
[thirdparty/systemd.git] / src / basic / unit-def.h
1 #pragma once
2
3 /***
4 This file is part of systemd.
5
6 Copyright 2010 Lennart Poettering
7
8 systemd is free software; you can redistribute it and/or modify it
9 under the terms of the GNU Lesser General Public License as published by
10 the Free Software Foundation; either version 2.1 of the License, or
11 (at your option) any later version.
12
13 systemd is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Lesser General Public License for more details.
17
18 You should have received a copy of the GNU Lesser General Public License
19 along with systemd; If not, see <http://www.gnu.org/licenses/>.
20 ***/
21
22 #include <stdbool.h>
23
24 #include "macro.h"
25
26 typedef enum UnitType {
27 UNIT_SERVICE = 0,
28 UNIT_SOCKET,
29 UNIT_TARGET,
30 UNIT_DEVICE,
31 UNIT_MOUNT,
32 UNIT_AUTOMOUNT,
33 UNIT_SWAP,
34 UNIT_TIMER,
35 UNIT_PATH,
36 UNIT_SLICE,
37 UNIT_SCOPE,
38 _UNIT_TYPE_MAX,
39 _UNIT_TYPE_INVALID = -1
40 } UnitType;
41
42 typedef enum UnitLoadState {
43 UNIT_STUB = 0,
44 UNIT_LOADED,
45 UNIT_NOT_FOUND,
46 UNIT_ERROR,
47 UNIT_MERGED,
48 UNIT_MASKED,
49 _UNIT_LOAD_STATE_MAX,
50 _UNIT_LOAD_STATE_INVALID = -1
51 } UnitLoadState;
52
53 typedef enum UnitActiveState {
54 UNIT_ACTIVE,
55 UNIT_RELOADING,
56 UNIT_INACTIVE,
57 UNIT_FAILED,
58 UNIT_ACTIVATING,
59 UNIT_DEACTIVATING,
60 _UNIT_ACTIVE_STATE_MAX,
61 _UNIT_ACTIVE_STATE_INVALID = -1
62 } UnitActiveState;
63
64 typedef enum AutomountState {
65 AUTOMOUNT_DEAD,
66 AUTOMOUNT_WAITING,
67 AUTOMOUNT_RUNNING,
68 AUTOMOUNT_FAILED,
69 _AUTOMOUNT_STATE_MAX,
70 _AUTOMOUNT_STATE_INVALID = -1
71 } AutomountState;
72
73 /* We simply watch devices, we cannot plug/unplug them. That
74 * simplifies the state engine greatly */
75 typedef enum DeviceState {
76 DEVICE_DEAD,
77 DEVICE_TENTATIVE, /* mounted or swapped, but not (yet) announced by udev */
78 DEVICE_PLUGGED, /* announced by udev */
79 _DEVICE_STATE_MAX,
80 _DEVICE_STATE_INVALID = -1
81 } DeviceState;
82
83 typedef enum MountState {
84 MOUNT_DEAD,
85 MOUNT_MOUNTING, /* /usr/bin/mount is running, but the mount is not done yet. */
86 MOUNT_MOUNTING_DONE, /* /usr/bin/mount is running, and the mount is done. */
87 MOUNT_MOUNTED,
88 MOUNT_REMOUNTING,
89 MOUNT_UNMOUNTING,
90 MOUNT_REMOUNTING_SIGTERM,
91 MOUNT_REMOUNTING_SIGKILL,
92 MOUNT_UNMOUNTING_SIGTERM,
93 MOUNT_UNMOUNTING_SIGKILL,
94 MOUNT_FAILED,
95 _MOUNT_STATE_MAX,
96 _MOUNT_STATE_INVALID = -1
97 } MountState;
98
99 typedef enum PathState {
100 PATH_DEAD,
101 PATH_WAITING,
102 PATH_RUNNING,
103 PATH_FAILED,
104 _PATH_STATE_MAX,
105 _PATH_STATE_INVALID = -1
106 } PathState;
107
108 typedef enum ScopeState {
109 SCOPE_DEAD,
110 SCOPE_RUNNING,
111 SCOPE_ABANDONED,
112 SCOPE_STOP_SIGTERM,
113 SCOPE_STOP_SIGKILL,
114 SCOPE_FAILED,
115 _SCOPE_STATE_MAX,
116 _SCOPE_STATE_INVALID = -1
117 } ScopeState;
118
119 typedef enum ServiceState {
120 SERVICE_DEAD,
121 SERVICE_START_PRE,
122 SERVICE_START,
123 SERVICE_START_POST,
124 SERVICE_RUNNING,
125 SERVICE_EXITED, /* Nothing is running anymore, but RemainAfterExit is true hence this is OK */
126 SERVICE_RELOAD,
127 SERVICE_STOP, /* No STOP_PRE state, instead just register multiple STOP executables */
128 SERVICE_STOP_SIGABRT, /* Watchdog timeout */
129 SERVICE_STOP_SIGTERM,
130 SERVICE_STOP_SIGKILL,
131 SERVICE_STOP_POST,
132 SERVICE_FINAL_SIGTERM, /* In case the STOP_POST executable hangs, we shoot that down, too */
133 SERVICE_FINAL_SIGKILL,
134 SERVICE_FAILED,
135 SERVICE_AUTO_RESTART,
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,
161 _SOCKET_STATE_MAX,
162 _SOCKET_STATE_INVALID = -1
163 } SocketState;
164
165 typedef enum SwapState {
166 SWAP_DEAD,
167 SWAP_ACTIVATING, /* /sbin/swapon is running, but the swap not yet enabled. */
168 SWAP_ACTIVATING_DONE, /* /sbin/swapon is running, and the swap is done. */
169 SWAP_ACTIVE,
170 SWAP_DEACTIVATING,
171 SWAP_DEACTIVATING_SIGTERM,
172 SWAP_DEACTIVATING_SIGKILL,
173 SWAP_FAILED,
174 _SWAP_STATE_MAX,
175 _SWAP_STATE_INVALID = -1
176 } SwapState;
177
178 typedef enum TargetState {
179 TARGET_DEAD,
180 TARGET_ACTIVE,
181 _TARGET_STATE_MAX,
182 _TARGET_STATE_INVALID = -1
183 } TargetState;
184
185 typedef enum TimerState {
186 TIMER_DEAD,
187 TIMER_WAITING,
188 TIMER_RUNNING,
189 TIMER_ELAPSED,
190 TIMER_FAILED,
191 _TIMER_STATE_MAX,
192 _TIMER_STATE_INVALID = -1
193 } TimerState;
194
195 typedef enum UnitDependency {
196 /* Positive dependencies */
197 UNIT_REQUIRES,
198 UNIT_REQUISITE,
199 UNIT_WANTS,
200 UNIT_BINDS_TO,
201 UNIT_PART_OF,
202
203 /* Inverse of the above */
204 UNIT_REQUIRED_BY, /* inverse of 'requires' is 'required_by' */
205 UNIT_REQUISITE_OF, /* inverse of 'requisite' is 'requisite_of' */
206 UNIT_WANTED_BY, /* inverse of 'wants' */
207 UNIT_BOUND_BY, /* inverse of 'binds_to' */
208 UNIT_CONSISTS_OF, /* inverse of 'part_of' */
209
210 /* Negative dependencies */
211 UNIT_CONFLICTS, /* inverse of 'conflicts' is 'conflicted_by' */
212 UNIT_CONFLICTED_BY,
213
214 /* Order */
215 UNIT_BEFORE, /* inverse of 'before' is 'after' and vice versa */
216 UNIT_AFTER,
217
218 /* On Failure */
219 UNIT_ON_FAILURE,
220
221 /* Triggers (i.e. a socket triggers a service) */
222 UNIT_TRIGGERS,
223 UNIT_TRIGGERED_BY,
224
225 /* Propagate reloads */
226 UNIT_PROPAGATES_RELOAD_TO,
227 UNIT_RELOAD_PROPAGATED_FROM,
228
229 /* Joins namespace of */
230 UNIT_JOINS_NAMESPACE_OF,
231
232 /* Reference information for GC logic */
233 UNIT_REFERENCES, /* Inverse of 'references' is 'referenced_by' */
234 UNIT_REFERENCED_BY,
235
236 _UNIT_DEPENDENCY_MAX,
237 _UNIT_DEPENDENCY_INVALID = -1
238 } UnitDependency;
239
240 typedef enum NotifyAccess {
241 NOTIFY_NONE,
242 NOTIFY_ALL,
243 NOTIFY_MAIN,
244 NOTIFY_EXEC,
245 _NOTIFY_ACCESS_MAX,
246 _NOTIFY_ACCESS_INVALID = -1
247 } NotifyAccess;
248
249 char *unit_dbus_path_from_name(const char *name);
250 int unit_name_from_dbus_path(const char *path, char **name);
251
252 const char* unit_dbus_interface_from_type(UnitType t);
253 const char *unit_dbus_interface_from_name(const char *name);
254
255 const char *unit_type_to_string(UnitType i) _const_;
256 UnitType unit_type_from_string(const char *s) _pure_;
257
258 const char *unit_load_state_to_string(UnitLoadState i) _const_;
259 UnitLoadState unit_load_state_from_string(const char *s) _pure_;
260
261 const char *unit_active_state_to_string(UnitActiveState i) _const_;
262 UnitActiveState unit_active_state_from_string(const char *s) _pure_;
263
264 const char* automount_state_to_string(AutomountState i) _const_;
265 AutomountState automount_state_from_string(const char *s) _pure_;
266
267 const char* device_state_to_string(DeviceState i) _const_;
268 DeviceState device_state_from_string(const char *s) _pure_;
269
270 const char* mount_state_to_string(MountState i) _const_;
271 MountState mount_state_from_string(const char *s) _pure_;
272
273 const char* path_state_to_string(PathState i) _const_;
274 PathState path_state_from_string(const char *s) _pure_;
275
276 const char* scope_state_to_string(ScopeState i) _const_;
277 ScopeState scope_state_from_string(const char *s) _pure_;
278
279 const char* service_state_to_string(ServiceState i) _const_;
280 ServiceState service_state_from_string(const char *s) _pure_;
281
282 const char* slice_state_to_string(SliceState i) _const_;
283 SliceState slice_state_from_string(const char *s) _pure_;
284
285 const char* socket_state_to_string(SocketState i) _const_;
286 SocketState socket_state_from_string(const char *s) _pure_;
287
288 const char* swap_state_to_string(SwapState i) _const_;
289 SwapState swap_state_from_string(const char *s) _pure_;
290
291 const char* target_state_to_string(TargetState i) _const_;
292 TargetState target_state_from_string(const char *s) _pure_;
293
294 const char *timer_state_to_string(TimerState i) _const_;
295 TimerState timer_state_from_string(const char *s) _pure_;
296
297 const char *unit_dependency_to_string(UnitDependency i) _const_;
298 UnitDependency unit_dependency_from_string(const char *s) _pure_;
299
300 const char* notify_access_to_string(NotifyAccess i) _const_;
301 NotifyAccess notify_access_from_string(const char *s) _pure_;