1 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
6 This file is part of systemd.
8 Copyright 2010 Lennart Poettering
10 systemd is free software; you can redistribute it and/or modify it
11 under the terms of the GNU Lesser General Public License as published by
12 the Free Software Foundation; either version 2.1 of the License, or
13 (at your option) any later version.
15 systemd is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 Lesser General Public License for more details.
20 You should have received a copy of the GNU Lesser General Public License
21 along with systemd; If not, see <http://www.gnu.org/licenses/>.
28 #define UNIT_NAME_MAX 256
30 typedef enum UnitType {
45 _UNIT_TYPE_INVALID = -1
48 /// UNNEEDED by elogind
50 typedef enum UnitLoadState {
58 _UNIT_LOAD_STATE_INVALID = -1
61 typedef enum UnitActiveState {
68 _UNIT_ACTIVE_STATE_MAX,
69 _UNIT_ACTIVE_STATE_INVALID = -1
72 typedef enum AutomountState {
78 _AUTOMOUNT_STATE_INVALID = -1
81 typedef enum BusNameState {
91 _BUSNAME_STATE_INVALID = -1
94 /* We simply watch devices, we cannot plug/unplug them. That
95 * simplifies the state engine greatly */
96 typedef enum DeviceState {
98 DEVICE_TENTATIVE, /* mounted or swapped, but not (yet) announced by udev */
99 DEVICE_PLUGGED, /* announced by udev */
101 _DEVICE_STATE_INVALID = -1
104 typedef enum MountState {
106 MOUNT_MOUNTING, /* /usr/bin/mount is running, but the mount is not done yet. */
107 MOUNT_MOUNTING_DONE, /* /usr/bin/mount is running, and the mount is done. */
111 MOUNT_MOUNTING_SIGTERM,
112 MOUNT_MOUNTING_SIGKILL,
113 MOUNT_REMOUNTING_SIGTERM,
114 MOUNT_REMOUNTING_SIGKILL,
115 MOUNT_UNMOUNTING_SIGTERM,
116 MOUNT_UNMOUNTING_SIGKILL,
119 _MOUNT_STATE_INVALID = -1
122 typedef enum PathState {
128 _PATH_STATE_INVALID = -1
131 typedef enum ScopeState {
139 _SCOPE_STATE_INVALID = -1
142 typedef enum ServiceState {
148 SERVICE_EXITED, /* Nothing is running anymore, but RemainAfterExit is true hence this is OK */
150 SERVICE_STOP, /* No STOP_PRE state, instead just register multiple STOP executables */
151 SERVICE_STOP_SIGABRT, /* Watchdog timeout */
152 SERVICE_STOP_SIGTERM,
153 SERVICE_STOP_SIGKILL,
155 SERVICE_FINAL_SIGTERM, /* In case the STOP_POST executable hangs, we shoot that down, too */
156 SERVICE_FINAL_SIGKILL,
158 SERVICE_AUTO_RESTART,
160 _SERVICE_STATE_INVALID = -1
163 typedef enum SliceState {
167 _SLICE_STATE_INVALID = -1
170 typedef enum SnapshotState {
174 _SNAPSHOT_STATE_INVALID = -1
177 typedef enum SocketState {
185 SOCKET_STOP_PRE_SIGTERM,
186 SOCKET_STOP_PRE_SIGKILL,
188 SOCKET_FINAL_SIGTERM,
189 SOCKET_FINAL_SIGKILL,
192 _SOCKET_STATE_INVALID = -1
195 typedef enum SwapState {
197 SWAP_ACTIVATING, /* /sbin/swapon is running, but the swap not yet enabled. */
198 SWAP_ACTIVATING_DONE, /* /sbin/swapon is running, and the swap is done. */
201 SWAP_ACTIVATING_SIGTERM,
202 SWAP_ACTIVATING_SIGKILL,
203 SWAP_DEACTIVATING_SIGTERM,
204 SWAP_DEACTIVATING_SIGKILL,
207 _SWAP_STATE_INVALID = -1
211 typedef enum TargetState {
215 _TARGET_STATE_INVALID = -1
218 typedef enum TimerState {
225 _TIMER_STATE_INVALID = -1
228 typedef enum UnitDependency {
229 /* Positive dependencies */
231 UNIT_REQUIRES_OVERRIDABLE,
233 UNIT_REQUISITE_OVERRIDABLE,
238 /* Inverse of the above */
239 UNIT_REQUIRED_BY, /* inverse of 'requires' is 'required_by' */
240 UNIT_REQUIRED_BY_OVERRIDABLE, /* inverse of 'requires_overridable' is 'required_by_overridable' */
241 UNIT_REQUISITE_OF, /* inverse of 'requisite' is 'requisite_of' */
242 UNIT_REQUISITE_OF_OVERRIDABLE,/* inverse of 'requisite_overridable' is 'requisite_of_overridable' */
243 UNIT_WANTED_BY, /* inverse of 'wants' */
244 UNIT_BOUND_BY, /* inverse of 'binds_to' */
245 UNIT_CONSISTS_OF, /* inverse of 'part_of' */
247 /* Negative dependencies */
248 UNIT_CONFLICTS, /* inverse of 'conflicts' is 'conflicted_by' */
252 UNIT_BEFORE, /* inverse of 'before' is 'after' and vice versa */
258 /* Triggers (i.e. a socket triggers a service) */
262 /* Propagate reloads */
263 UNIT_PROPAGATES_RELOAD_TO,
264 UNIT_RELOAD_PROPAGATED_FROM,
266 /* Joins namespace of */
267 UNIT_JOINS_NAMESPACE_OF,
269 /* Reference information for GC logic */
270 UNIT_REFERENCES, /* Inverse of 'references' is 'referenced_by' */
273 _UNIT_DEPENDENCY_MAX,
274 _UNIT_DEPENDENCY_INVALID = -1
278 typedef enum UnitNameFlags {
279 UNIT_NAME_PLAIN = 1, /* Allow foo.service */
280 UNIT_NAME_INSTANCE = 2, /* Allow foo@bar.service */
281 UNIT_NAME_TEMPLATE = 4, /* Allow foo@.service */
282 UNIT_NAME_ANY = UNIT_NAME_PLAIN|UNIT_NAME_INSTANCE|UNIT_NAME_TEMPLATE,
285 bool unit_name_is_valid(const char *n, UnitNameFlags flags) _pure_;
286 bool unit_prefix_is_valid(const char *p) _pure_;
287 bool unit_instance_is_valid(const char *i) _pure_;
288 bool unit_suffix_is_valid(const char *s) _pure_;
290 /// UNNEEDED by elogind
292 static inline int unit_prefix_and_instance_is_valid(const char *p) {
293 /* For prefix+instance and instance the same rules apply */
294 return unit_instance_is_valid(p);
298 // UNNEEDED int unit_name_to_prefix(const char *n, char **prefix);
299 // UNNEEDED int unit_name_to_instance(const char *n, char **instance);
300 // UNNEEDED int unit_name_to_prefix_and_instance(const char *n, char **ret);
302 // UNNEEDED UnitType unit_name_to_type(const char *n) _pure_;
304 // UNNEEDED int unit_name_change_suffix(const char *n, const char *suffix, char **ret);
306 int unit_name_build(const char *prefix, const char *instance, const char *suffix, char **ret);
308 // UNNEEDED char *unit_name_escape(const char *f);
309 // UNNEEDED int unit_name_unescape(const char *f, char **ret);
310 // UNNEEDED int unit_name_path_escape(const char *f, char **ret);
311 // UNNEEDED int unit_name_path_unescape(const char *f, char **ret);
313 // UNNEEDED int unit_name_replace_instance(const char *f, const char *i, char **ret);
315 // UNNEEDED int unit_name_template(const char *f, char **ret);
317 // UNNEEDED int unit_name_from_path(const char *path, const char *suffix, char **ret);
318 // UNNEEDED int unit_name_from_path_instance(const char *prefix, const char *path, const char *suffix, char **ret);
319 // UNNEEDED int unit_name_to_path(const char *name, char **ret);
321 // UNNEEDED char *unit_dbus_path_from_name(const char *name);
322 // UNNEEDED int unit_name_from_dbus_path(const char *path, char **name);
324 // UNNEEDED const char* unit_dbus_interface_from_type(UnitType t);
325 // UNNEEDED const char *unit_dbus_interface_from_name(const char *name);
327 /// UNNEEDED by elogind
329 typedef enum UnitNameMangle {
334 int unit_name_mangle_with_suffix(const char *name, UnitNameMangle allow_globs, const char *suffix, char **ret);
336 static inline int unit_name_mangle(const char *name, UnitNameMangle allow_globs, char **ret) {
337 return unit_name_mangle_with_suffix(name, allow_globs, ".service", ret);
341 // UNNEEDED int slice_build_parent_slice(const char *slice, char **ret);
342 int slice_build_subslice(const char *slice, const char*name, char **subslice);
343 bool slice_name_is_valid(const char *name);
345 const char *unit_type_to_string(UnitType i) _const_;
346 UnitType unit_type_from_string(const char *s) _pure_;
348 // UNNEEDED const char *unit_load_state_to_string(UnitLoadState i) _const_;
349 // UNNEEDED UnitLoadState unit_load_state_from_string(const char *s) _pure_;
351 // UNNEEDED const char *unit_active_state_to_string(UnitActiveState i) _const_;
352 // UNNEEDED UnitActiveState unit_active_state_from_string(const char *s) _pure_;
354 // UNNEEDED const char* automount_state_to_string(AutomountState i) _const_;
355 // UNNEEDED AutomountState automount_state_from_string(const char *s) _pure_;
357 // UNNEEDED const char* busname_state_to_string(BusNameState i) _const_;
358 // UNNEEDED BusNameState busname_state_from_string(const char *s) _pure_;
360 // UNNEEDED const char* device_state_to_string(DeviceState i) _const_;
361 // UNNEEDED DeviceState device_state_from_string(const char *s) _pure_;
363 // UNNEEDED const char* mount_state_to_string(MountState i) _const_;
364 // UNNEEDED MountState mount_state_from_string(const char *s) _pure_;
366 // UNNEEDED const char* path_state_to_string(PathState i) _const_;
367 // UNNEEDED PathState path_state_from_string(const char *s) _pure_;
369 // UNNEEDED const char* scope_state_to_string(ScopeState i) _const_;
370 // UNNEEDED ScopeState scope_state_from_string(const char *s) _pure_;
372 // UNNEEDED const char* service_state_to_string(ServiceState i) _const_;
373 // UNNEEDED ServiceState service_state_from_string(const char *s) _pure_;
375 // UNNEEDED const char* slice_state_to_string(SliceState i) _const_;
376 // UNNEEDED SliceState slice_state_from_string(const char *s) _pure_;
378 // UNNEEDED const char* snapshot_state_to_string(SnapshotState i) _const_;
379 // UNNEEDED SnapshotState snapshot_state_from_string(const char *s) _pure_;
381 // UNNEEDED const char* socket_state_to_string(SocketState i) _const_;
382 // UNNEEDED SocketState socket_state_from_string(const char *s) _pure_;
384 // UNNEEDED const char* swap_state_to_string(SwapState i) _const_;
385 // UNNEEDED SwapState swap_state_from_string(const char *s) _pure_;
387 // UNNEEDED const char* target_state_to_string(TargetState i) _const_;
388 // UNNEEDED TargetState target_state_from_string(const char *s) _pure_;
390 // UNNEEDED const char *timer_state_to_string(TimerState i) _const_;
391 // UNNEEDED TimerState timer_state_from_string(const char *s) _pure_;
393 // UNNEEDED const char *unit_dependency_to_string(UnitDependency i) _const_;
394 // UNNEEDED UnitDependency unit_dependency_from_string(const char *s) _pure_;