4 This file is part of systemd.
6 Copyright 2010 Lennart Poettering
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.
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.
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/>.
26 #define UNIT_NAME_MAX 256
28 typedef enum UnitType
{
42 _UNIT_TYPE_INVALID
= -1
45 typedef enum UnitLoadState
{
53 _UNIT_LOAD_STATE_INVALID
= -1
56 typedef enum UnitActiveState
{
63 _UNIT_ACTIVE_STATE_MAX
,
64 _UNIT_ACTIVE_STATE_INVALID
= -1
67 typedef enum AutomountState
{
73 _AUTOMOUNT_STATE_INVALID
= -1
76 typedef enum BusNameState
{
86 _BUSNAME_STATE_INVALID
= -1
89 /* We simply watch devices, we cannot plug/unplug them. That
90 * simplifies the state engine greatly */
91 typedef enum DeviceState
{
93 DEVICE_TENTATIVE
, /* mounted or swapped, but not (yet) announced by udev */
94 DEVICE_PLUGGED
, /* announced by udev */
96 _DEVICE_STATE_INVALID
= -1
99 typedef enum MountState
{
101 MOUNT_MOUNTING
, /* /usr/bin/mount is running, but the mount is not done yet. */
102 MOUNT_MOUNTING_DONE
, /* /usr/bin/mount is running, and the mount is done. */
106 MOUNT_MOUNTING_SIGTERM
,
107 MOUNT_MOUNTING_SIGKILL
,
108 MOUNT_REMOUNTING_SIGTERM
,
109 MOUNT_REMOUNTING_SIGKILL
,
110 MOUNT_UNMOUNTING_SIGTERM
,
111 MOUNT_UNMOUNTING_SIGKILL
,
114 _MOUNT_STATE_INVALID
= -1
117 typedef enum PathState
{
123 _PATH_STATE_INVALID
= -1
126 typedef enum ScopeState
{
134 _SCOPE_STATE_INVALID
= -1
137 typedef enum ServiceState
{
143 SERVICE_EXITED
, /* Nothing is running anymore, but RemainAfterExit is true hence this is OK */
145 SERVICE_STOP
, /* No STOP_PRE state, instead just register multiple STOP executables */
146 SERVICE_STOP_SIGABRT
, /* Watchdog timeout */
147 SERVICE_STOP_SIGTERM
,
148 SERVICE_STOP_SIGKILL
,
150 SERVICE_FINAL_SIGTERM
, /* In case the STOP_POST executable hangs, we shoot that down, too */
151 SERVICE_FINAL_SIGKILL
,
153 SERVICE_AUTO_RESTART
,
155 _SERVICE_STATE_INVALID
= -1
158 typedef enum SliceState
{
162 _SLICE_STATE_INVALID
= -1
165 typedef enum SocketState
{
173 SOCKET_STOP_PRE_SIGTERM
,
174 SOCKET_STOP_PRE_SIGKILL
,
176 SOCKET_FINAL_SIGTERM
,
177 SOCKET_FINAL_SIGKILL
,
180 _SOCKET_STATE_INVALID
= -1
183 typedef enum SwapState
{
185 SWAP_ACTIVATING
, /* /sbin/swapon is running, but the swap not yet enabled. */
186 SWAP_ACTIVATING_DONE
, /* /sbin/swapon is running, and the swap is done. */
189 SWAP_ACTIVATING_SIGTERM
,
190 SWAP_ACTIVATING_SIGKILL
,
191 SWAP_DEACTIVATING_SIGTERM
,
192 SWAP_DEACTIVATING_SIGKILL
,
195 _SWAP_STATE_INVALID
= -1
198 typedef enum TargetState
{
202 _TARGET_STATE_INVALID
= -1
205 typedef enum TimerState
{
212 _TIMER_STATE_INVALID
= -1
215 typedef enum UnitDependency
{
216 /* Positive dependencies */
223 /* Inverse of the above */
224 UNIT_REQUIRED_BY
, /* inverse of 'requires' is 'required_by' */
225 UNIT_REQUISITE_OF
, /* inverse of 'requisite' is 'requisite_of' */
226 UNIT_WANTED_BY
, /* inverse of 'wants' */
227 UNIT_BOUND_BY
, /* inverse of 'binds_to' */
228 UNIT_CONSISTS_OF
, /* inverse of 'part_of' */
230 /* Negative dependencies */
231 UNIT_CONFLICTS
, /* inverse of 'conflicts' is 'conflicted_by' */
235 UNIT_BEFORE
, /* inverse of 'before' is 'after' and vice versa */
241 /* Triggers (i.e. a socket triggers a service) */
245 /* Propagate reloads */
246 UNIT_PROPAGATES_RELOAD_TO
,
247 UNIT_RELOAD_PROPAGATED_FROM
,
249 /* Joins namespace of */
250 UNIT_JOINS_NAMESPACE_OF
,
252 /* Reference information for GC logic */
253 UNIT_REFERENCES
, /* Inverse of 'references' is 'referenced_by' */
256 _UNIT_DEPENDENCY_MAX
,
257 _UNIT_DEPENDENCY_INVALID
= -1
260 typedef enum NotifyAccess
{
266 _NOTIFY_ACCESS_INVALID
= -1
269 typedef enum UnitNameFlags
{
270 UNIT_NAME_PLAIN
= 1, /* Allow foo.service */
271 UNIT_NAME_INSTANCE
= 2, /* Allow foo@bar.service */
272 UNIT_NAME_TEMPLATE
= 4, /* Allow foo@.service */
273 UNIT_NAME_ANY
= UNIT_NAME_PLAIN
|UNIT_NAME_INSTANCE
|UNIT_NAME_TEMPLATE
,
276 bool unit_name_is_valid(const char *n
, UnitNameFlags flags
) _pure_
;
277 bool unit_prefix_is_valid(const char *p
) _pure_
;
278 bool unit_instance_is_valid(const char *i
) _pure_
;
279 bool unit_suffix_is_valid(const char *s
) _pure_
;
281 static inline int unit_prefix_and_instance_is_valid(const char *p
) {
282 /* For prefix+instance and instance the same rules apply */
283 return unit_instance_is_valid(p
);
286 int unit_name_to_prefix(const char *n
, char **prefix
);
287 int unit_name_to_instance(const char *n
, char **instance
);
288 int unit_name_to_prefix_and_instance(const char *n
, char **ret
);
290 UnitType
unit_name_to_type(const char *n
) _pure_
;
292 int unit_name_change_suffix(const char *n
, const char *suffix
, char **ret
);
294 int unit_name_build(const char *prefix
, const char *instance
, const char *suffix
, char **ret
);
296 char *unit_name_escape(const char *f
);
297 int unit_name_unescape(const char *f
, char **ret
);
298 int unit_name_path_escape(const char *f
, char **ret
);
299 int unit_name_path_unescape(const char *f
, char **ret
);
301 int unit_name_replace_instance(const char *f
, const char *i
, char **ret
);
303 int unit_name_template(const char *f
, char **ret
);
305 int unit_name_from_path(const char *path
, const char *suffix
, char **ret
);
306 int unit_name_from_path_instance(const char *prefix
, const char *path
, const char *suffix
, char **ret
);
307 int unit_name_to_path(const char *name
, char **ret
);
309 char *unit_dbus_path_from_name(const char *name
);
310 int unit_name_from_dbus_path(const char *path
, char **name
);
312 const char* unit_dbus_interface_from_type(UnitType t
);
313 const char *unit_dbus_interface_from_name(const char *name
);
315 typedef enum UnitNameMangle
{
320 int unit_name_mangle_with_suffix(const char *name
, UnitNameMangle allow_globs
, const char *suffix
, char **ret
);
322 static inline int unit_name_mangle(const char *name
, UnitNameMangle allow_globs
, char **ret
) {
323 return unit_name_mangle_with_suffix(name
, allow_globs
, ".service", ret
);
326 int slice_build_parent_slice(const char *slice
, char **ret
);
327 int slice_build_subslice(const char *slice
, const char*name
, char **subslice
);
328 bool slice_name_is_valid(const char *name
);
330 const char *unit_type_to_string(UnitType i
) _const_
;
331 UnitType
unit_type_from_string(const char *s
) _pure_
;
333 const char *unit_load_state_to_string(UnitLoadState i
) _const_
;
334 UnitLoadState
unit_load_state_from_string(const char *s
) _pure_
;
336 const char *unit_active_state_to_string(UnitActiveState i
) _const_
;
337 UnitActiveState
unit_active_state_from_string(const char *s
) _pure_
;
339 const char* automount_state_to_string(AutomountState i
) _const_
;
340 AutomountState
automount_state_from_string(const char *s
) _pure_
;
342 const char* busname_state_to_string(BusNameState i
) _const_
;
343 BusNameState
busname_state_from_string(const char *s
) _pure_
;
345 const char* device_state_to_string(DeviceState i
) _const_
;
346 DeviceState
device_state_from_string(const char *s
) _pure_
;
348 const char* mount_state_to_string(MountState i
) _const_
;
349 MountState
mount_state_from_string(const char *s
) _pure_
;
351 const char* path_state_to_string(PathState i
) _const_
;
352 PathState
path_state_from_string(const char *s
) _pure_
;
354 const char* scope_state_to_string(ScopeState i
) _const_
;
355 ScopeState
scope_state_from_string(const char *s
) _pure_
;
357 const char* service_state_to_string(ServiceState i
) _const_
;
358 ServiceState
service_state_from_string(const char *s
) _pure_
;
360 const char* slice_state_to_string(SliceState i
) _const_
;
361 SliceState
slice_state_from_string(const char *s
) _pure_
;
363 const char* socket_state_to_string(SocketState i
) _const_
;
364 SocketState
socket_state_from_string(const char *s
) _pure_
;
366 const char* swap_state_to_string(SwapState i
) _const_
;
367 SwapState
swap_state_from_string(const char *s
) _pure_
;
369 const char* target_state_to_string(TargetState i
) _const_
;
370 TargetState
target_state_from_string(const char *s
) _pure_
;
372 const char *timer_state_to_string(TimerState i
) _const_
;
373 TimerState
timer_state_from_string(const char *s
) _pure_
;
375 const char *unit_dependency_to_string(UnitDependency i
) _const_
;
376 UnitDependency
unit_dependency_from_string(const char *s
) _pure_
;
378 const char* notify_access_to_string(NotifyAccess i
) _const_
;
379 NotifyAccess
notify_access_from_string(const char *s
) _pure_
;