]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/core/unit.h
core: add bus API and systemctl commands for altering cgroup parameters during runtime
[thirdparty/systemd.git] / src / core / unit.h
CommitLineData
03467c88 1/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
87f0e418 2
c2f1db8f 3#pragma once
87f0e418 4
a7334b09
LP
5/***
6 This file is part of systemd.
7
8 Copyright 2010 Lennart Poettering
9
10 systemd is free software; you can redistribute it and/or modify it
5430f7f2
LP
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
a7334b09
LP
13 (at your option) any later version.
14
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
5430f7f2 18 Lesser General Public License for more details.
a7334b09 19
5430f7f2 20 You should have received a copy of the GNU Lesser General Public License
a7334b09
LP
21 along with systemd; If not, see <http://www.gnu.org/licenses/>.
22***/
23
87f0e418
LP
24#include <stdbool.h>
25#include <stdlib.h>
26
ac155bb8 27typedef struct Unit Unit;
87f0e418 28typedef struct UnitVTable UnitVTable;
87f0e418
LP
29typedef enum UnitActiveState UnitActiveState;
30typedef enum UnitDependency UnitDependency;
57020a3a 31typedef struct UnitRef UnitRef;
c6918296 32typedef struct UnitStatusMessageFormats UnitStatusMessageFormats;
87f0e418 33
87f0e418
LP
34#include "set.h"
35#include "util.h"
36#include "list.h"
37#include "socket-util.h"
38#include "execute.h"
52661efd 39#include "condition.h"
a4375746 40#include "install.h"
0a9f8ed0 41#include "unit-name.h"
87f0e418 42
87f0e418
LP
43enum UnitActiveState {
44 UNIT_ACTIVE,
032ff4af 45 UNIT_RELOADING,
87f0e418 46 UNIT_INACTIVE,
fdf20a31 47 UNIT_FAILED,
87f0e418
LP
48 UNIT_ACTIVATING,
49 UNIT_DEACTIVATING,
94f04347
LP
50 _UNIT_ACTIVE_STATE_MAX,
51 _UNIT_ACTIVE_STATE_INVALID = -1
87f0e418
LP
52};
53
54static inline bool UNIT_IS_ACTIVE_OR_RELOADING(UnitActiveState t) {
032ff4af 55 return t == UNIT_ACTIVE || t == UNIT_RELOADING;
87f0e418
LP
56}
57
58static inline bool UNIT_IS_ACTIVE_OR_ACTIVATING(UnitActiveState t) {
032ff4af 59 return t == UNIT_ACTIVE || t == UNIT_ACTIVATING || t == UNIT_RELOADING;
87f0e418
LP
60}
61
62static inline bool UNIT_IS_INACTIVE_OR_DEACTIVATING(UnitActiveState t) {
fdf20a31 63 return t == UNIT_INACTIVE || t == UNIT_FAILED || t == UNIT_DEACTIVATING;
6124958c
LP
64}
65
fdf20a31
MM
66static inline bool UNIT_IS_INACTIVE_OR_FAILED(UnitActiveState t) {
67 return t == UNIT_INACTIVE || t == UNIT_FAILED;
87f0e418
LP
68}
69
70enum UnitDependency {
71 /* Positive dependencies */
72 UNIT_REQUIRES,
9e2f7c11 73 UNIT_REQUIRES_OVERRIDABLE,
87f0e418 74 UNIT_REQUISITE,
9e2f7c11
LP
75 UNIT_REQUISITE_OVERRIDABLE,
76 UNIT_WANTS,
7f2cddae 77 UNIT_BINDS_TO,
85e9a101 78 UNIT_PART_OF,
87f0e418
LP
79
80 /* Inverse of the above */
9e2f7c11 81 UNIT_REQUIRED_BY, /* inverse of 'requires' and 'requisite' is 'required_by' */
f14e15f8 82 UNIT_REQUIRED_BY_OVERRIDABLE, /* inverse of 'requires_overridable' and 'requisite_overridable' is 'soft_required_by' */
9e2f7c11 83 UNIT_WANTED_BY, /* inverse of 'wants' */
7f2cddae 84 UNIT_BOUND_BY, /* inverse of 'binds_to' */
85e9a101 85 UNIT_CONSISTS_OF, /* inverse of 'part_of' */
87f0e418
LP
86
87 /* Negative dependencies */
69dd2852
LP
88 UNIT_CONFLICTS, /* inverse of 'conflicts' is 'conflicted_by' */
89 UNIT_CONFLICTED_BY,
87f0e418
LP
90
91 /* Order */
701cc384 92 UNIT_BEFORE, /* inverse of 'before' is 'after' and vice versa */
87f0e418
LP
93 UNIT_AFTER,
94
5de9682c
LP
95 /* On Failure */
96 UNIT_ON_FAILURE,
97
57020a3a
LP
98 /* Triggers (i.e. a socket triggers a service) */
99 UNIT_TRIGGERS,
100 UNIT_TRIGGERED_BY,
101
4dcc1cb4 102 /* Propagate reloads */
7f2cddae
LP
103 UNIT_PROPAGATES_RELOAD_TO,
104 UNIT_RELOAD_PROPAGATED_FROM,
4dcc1cb4 105
701cc384
LP
106 /* Reference information for GC logic */
107 UNIT_REFERENCES, /* Inverse of 'references' is 'referenced_by' */
108 UNIT_REFERENCED_BY,
109
87f0e418
LP
110 _UNIT_DEPENDENCY_MAX,
111 _UNIT_DEPENDENCY_INVALID = -1
112};
113
ef734fd6
LP
114#include "manager.h"
115#include "job.h"
8e274523 116#include "cgroup.h"
ab1f0633 117#include "cgroup-attr.h"
ef734fd6 118
ac155bb8 119struct Unit {
87f0e418 120 Manager *manager;
23a177ef 121
87f0e418
LP
122 UnitType type;
123 UnitLoadState load_state;
23a177ef 124 Unit *merged_into;
87f0e418
LP
125
126 char *id; /* One name is special because we use it for identification. Points to an entry in the names set */
9e2f7c11 127 char *instance;
87f0e418
LP
128
129 Set *names;
130 Set *dependencies[_UNIT_DEPENDENCY_MAX];
131
7c8fa05c
LP
132 char **requires_mounts_for;
133
87f0e418 134 char *description;
49dbfa7b 135 char **documentation;
faf919f1 136
6be1e7d5 137 char *fragment_path; /* if loaded from a config file this is the primary path to it */
1b64d026 138 char *source_path; /* if converted, the source file */
45fb0699 139 usec_t fragment_mtime;
1b64d026 140 usec_t source_mtime;
87f0e418 141
e0209d83 142 /* If there is something to do with this unit, then this is the installed job for it */
87f0e418
LP
143 Job *job;
144
e0209d83
MS
145 /* JOB_NOP jobs are special and can be installed without disturbing the real job. */
146 Job *nop_job;
147
faf919f1
LP
148 usec_t job_timeout;
149
57020a3a
LP
150 /* References to this */
151 LIST_HEAD(UnitRef, refs);
152
52661efd
LP
153 /* Conditions to check */
154 LIST_HEAD(Condition, conditions);
155
90bbc946
LP
156 dual_timestamp condition_timestamp;
157
63983207
LP
158 dual_timestamp inactive_exit_timestamp;
159 dual_timestamp active_enter_timestamp;
160 dual_timestamp active_exit_timestamp;
161 dual_timestamp inactive_enter_timestamp;
87f0e418 162
8e274523
LP
163 /* Counterparts in the cgroup filesystem */
164 CGroupBonding *cgroup_bondings;
ab1f0633 165 CGroupAttribute *cgroup_attributes;
8e274523 166
ef734fd6 167 /* Per type list */
ac155bb8 168 LIST_FIELDS(Unit, units_by_type);
c1e1601e 169
7c8fa05c
LP
170 /* All units which have requires_mounts_for set */
171 LIST_FIELDS(Unit, has_requires_mounts_for);
172
701cc384 173 /* Load queue */
ac155bb8 174 LIST_FIELDS(Unit, load_queue);
701cc384 175
c1e1601e 176 /* D-Bus queue */
ac155bb8 177 LIST_FIELDS(Unit, dbus_queue);
23a177ef
LP
178
179 /* Cleanup queue */
ac155bb8 180 LIST_FIELDS(Unit, cleanup_queue);
9d58f1db 181
701cc384 182 /* GC queue */
ac155bb8 183 LIST_FIELDS(Unit, gc_queue);
701cc384
LP
184
185 /* Used during GC sweeps */
eced69b3 186 unsigned gc_marker;
701cc384 187
7fab9d01 188 /* When deserializing, temporarily store the job type for this
39a18c60
MS
189 * unit here, if there was a job scheduled.
190 * Only for deserializing from a legacy version. New style uses full
191 * serialized jobs. */
7fab9d01
LP
192 int deserialized_job; /* This is actually of type JobType */
193
8821a00f
LP
194 /* Error code when we didn't manage to load the unit (negative) */
195 int load_error;
196
a4375746
LP
197 /* Cached unit file state */
198 UnitFileState unit_file_state;
199
9d58f1db
LP
200 /* Garbage collect us we nobody wants or requires us anymore */
201 bool stop_when_unneeded;
202
35b8ca3a 203 /* Create default dependencies */
a40eb732
LP
204 bool default_dependencies;
205
b5e9dba8
LP
206 /* Refuse manual starting, allow starting only indirectly via dependency. */
207 bool refuse_manual_start;
208
209 /* Don't allow the user to stop this unit manually, allow stopping only indirectly via dependency. */
210 bool refuse_manual_stop;
211
2528a7a6
LP
212 /* Allow isolation requests */
213 bool allow_isolate;
214
222ae6a8
LP
215 /* Isolate OnFailure unit */
216 bool on_failure_isolate;
217
c8f4d764
LP
218 /* Ignore this unit when isolating */
219 bool ignore_on_isolate;
220
7a6000a6
LP
221 /* Ignore this unit when snapshotting */
222 bool ignore_on_snapshot;
223
49f43d5f 224 /* Did the last condition check succeed? */
90bbc946
LP
225 bool condition_result;
226
9d58f1db
LP
227 bool in_load_queue:1;
228 bool in_dbus_queue:1;
229 bool in_cleanup_queue:1;
701cc384
LP
230 bool in_gc_queue:1;
231
9d58f1db 232 bool sent_dbus_new_signal:1;
6c073082
LP
233
234 bool no_gc:1;
cd6d0a45
LP
235
236 bool in_audit:1;
87f0e418
LP
237};
238
57020a3a
LP
239struct UnitRef {
240 /* Keeps tracks of references to a unit. This is useful so
241 * that we can merge two units if necessary and correct all
242 * references to them */
243
244 Unit* unit;
245 LIST_FIELDS(UnitRef, refs);
246};
247
c6918296
MS
248struct UnitStatusMessageFormats {
249 const char *starting_stopping[2];
250 const char *finished_start_job[_JOB_RESULT_MAX];
251 const char *finished_stop_job[_JOB_RESULT_MAX];
252};
253
87f0e418
LP
254#include "service.h"
255#include "timer.h"
256#include "socket.h"
257#include "target.h"
258#include "device.h"
259#include "mount.h"
260#include "automount.h"
261#include "snapshot.h"
07b0b134 262#include "swap.h"
01f78473 263#include "path.h"
87f0e418 264
87f0e418 265struct UnitVTable {
7d17cfbc
MS
266 /* How much memory does an object of this unit type need */
267 size_t object_size;
268
3ef63c31
LP
269 /* If greater than 0, the offset into the object where
270 * ExecContext is found, if the unit type has that */
271 size_t exec_context_offset;
272
f975e971
LP
273 /* Config file sections this unit type understands, separated
274 * by NUL chars */
275 const char *sections;
276
e537352b 277 /* This should reset all type-specific variables. This should
a16e1123
LP
278 * not allocate memory, and is called with zero-initialized
279 * data. It should hence only initialize variables that need
280 * to be set != 0. */
e537352b
LP
281 void (*init)(Unit *u);
282
a16e1123
LP
283 /* This should free all type-specific variables. It should be
284 * idempotent. */
285 void (*done)(Unit *u);
286
e537352b
LP
287 /* Actually load data from disk. This may fail, and should set
288 * load_state to UNIT_LOADED, UNIT_MERGED or leave it at
289 * UNIT_STUB if no configuration could be found. */
290 int (*load)(Unit *u);
291
c5315881 292 /* If a lot of units got created via enumerate(), this is
e537352b 293 * where to actually set the state and call unit_notify(). */
f50e0a01 294 int (*coldplug)(Unit *u);
87f0e418
LP
295
296 void (*dump)(Unit *u, FILE *f, const char *prefix);
297
298 int (*start)(Unit *u);
299 int (*stop)(Unit *u);
300 int (*reload)(Unit *u);
301
c74f17d9 302 int (*kill)(Unit *u, KillWho w, int signo, DBusError *error);
8a0867d6 303
87f0e418
LP
304 bool (*can_reload)(Unit *u);
305
a16e1123
LP
306 /* Write all data that cannot be restored from other sources
307 * away using unit_serialize_item() */
308 int (*serialize)(Unit *u, FILE *f, FDSet *fds);
309
310 /* Restore one item from the serialization */
311 int (*deserialize_item)(Unit *u, const char *key, const char *data, FDSet *fds);
312
01e10de3
LP
313 /* Try to match up fds with what we need for this unit */
314 int (*distribute_fds)(Unit *u, FDSet *fds);
315
87f0e418
LP
316 /* Boils down the more complex internal state of this unit to
317 * a simpler one that the engine can understand */
318 UnitActiveState (*active_state)(Unit *u);
319
10a94420
LP
320 /* Returns the substate specific to this unit type as
321 * string. This is purely information so that we can give the
35b8ca3a 322 * user a more fine grained explanation in which actual state a
10a94420
LP
323 * unit is in. */
324 const char* (*sub_state_to_string)(Unit *u);
325
701cc384
LP
326 /* Return true when there is reason to keep this entry around
327 * even nothing references it and it isn't active in any
328 * way */
329 bool (*check_gc)(Unit *u);
330
331 /* Return true when this unit is suitable for snapshotting */
332 bool (*check_snapshot)(Unit *u);
333
acbb0225 334 void (*fd_event)(Unit *u, int fd, uint32_t events, Watch *w);
87f0e418 335 void (*sigchld_event)(Unit *u, pid_t pid, int code, int status);
acbb0225 336 void (*timer_event)(Unit *u, uint64_t n_elapsed, Watch *w);
7824bbeb 337
fdf20a31
MM
338 /* Reset failed state if we are in failed state */
339 void (*reset_failed)(Unit *u);
5632e374 340
05e343b7
LP
341 /* Called whenever any of the cgroups this unit watches for
342 * ran empty */
8e274523
LP
343 void (*cgroup_notify_empty)(Unit *u);
344
8c47c732 345 /* Called whenever a process of this unit sends us a message */
c952c6ec 346 void (*notify_message)(Unit *u, pid_t pid, char **tags);
8c47c732 347
05e343b7
LP
348 /* Called whenever a name thus Unit registered for comes or
349 * goes away. */
350 void (*bus_name_owner_change)(Unit *u, const char *name, const char *old_owner, const char *new_owner);
351
352 /* Called whenever a bus PID lookup finishes */
353 void (*bus_query_pid_done)(Unit *u, const char *name, pid_t pid);
354
4139c1b2 355 /* Called for each message received on the bus */
5e8d1c9a 356 DBusHandlerResult (*bus_message_handler)(Unit *u, DBusConnection *c, DBusMessage *message);
4139c1b2 357
a7f241db
LP
358 /* Return the unit this unit is following */
359 Unit *(*following)(Unit *u);
360
6210e7fc
LP
361 /* Return the set of units that are following each other */
362 int (*following_set)(Unit *u, Set **s);
363
8742514c
LP
364 /* Called whenever CLOCK_REALTIME made a jump */
365 void (*time_change)(Unit *u);
366
f50e0a01
LP
367 /* This is called for each unit type and should be used to
368 * enumerate existing devices and load them. However,
369 * everything that is loaded here should still stay in
370 * inactive state. It is the job of the coldplug() call above
371 * to put the units into the initial state. */
7824bbeb 372 int (*enumerate)(Manager *m);
f50e0a01
LP
373
374 /* Type specific cleanups. */
7824bbeb 375 void (*shutdown)(Manager *m);
9d58f1db 376
c4e2ceae 377 /* When sending out PropertiesChanged signal, which properties
96d4ce01 378 * shall be invalidated? This is a NUL separated list of
c4e2ceae
LP
379 * strings, to minimize relocations a little. */
380 const char *bus_invalidating_properties;
381
382 /* The interface name */
383 const char *bus_interface;
384
c6918296
MS
385 UnitStatusMessageFormats status_message_formats;
386
9d58f1db
LP
387 /* Can units of this type have multiple names? */
388 bool no_alias:1;
389
9d58f1db
LP
390 /* Instances make no sense for this type */
391 bool no_instances:1;
392
701cc384
LP
393 /* Exclude from automatic gc */
394 bool no_gc:1;
87f0e418
LP
395};
396
397extern const UnitVTable * const unit_vtable[_UNIT_TYPE_MAX];
398
ac155bb8 399#define UNIT_VTABLE(u) unit_vtable[(u)->type]
87f0e418
LP
400
401/* For casting a unit into the various unit types */
402#define DEFINE_CAST(UPPERCASE, MixedCase) \
403 static inline MixedCase* UPPERCASE(Unit *u) { \
ac155bb8 404 if (_unlikely_(!u || u->type != UNIT_##UPPERCASE)) \
87f0e418
LP
405 return NULL; \
406 \
407 return (MixedCase*) u; \
408 }
409
410/* For casting the various unit types into a unit */
ac155bb8 411#define UNIT(u) (&(u)->meta)
87f0e418
LP
412
413DEFINE_CAST(SOCKET, Socket);
414DEFINE_CAST(TIMER, Timer);
415DEFINE_CAST(SERVICE, Service);
416DEFINE_CAST(TARGET, Target);
417DEFINE_CAST(DEVICE, Device);
418DEFINE_CAST(MOUNT, Mount);
419DEFINE_CAST(AUTOMOUNT, Automount);
420DEFINE_CAST(SNAPSHOT, Snapshot);
07b0b134 421DEFINE_CAST(SWAP, Swap);
01f78473 422DEFINE_CAST(PATH, Path);
87f0e418 423
7d17cfbc 424Unit *unit_new(Manager *m, size_t size);
87f0e418
LP
425void unit_free(Unit *u);
426
427int unit_add_name(Unit *u, const char *name);
9e2f7c11 428
701cc384 429int unit_add_dependency(Unit *u, UnitDependency d, Unit *other, bool add_reference);
2c966c03
LP
430int unit_add_two_dependencies(Unit *u, UnitDependency d, UnitDependency e, Unit *other, bool add_reference);
431
701cc384 432int unit_add_dependency_by_name(Unit *u, UnitDependency d, const char *name, const char *filename, bool add_reference);
2c966c03
LP
433int unit_add_two_dependencies_by_name(Unit *u, UnitDependency d, UnitDependency e, const char *name, const char *path, bool add_reference);
434
701cc384 435int unit_add_dependency_by_name_inverse(Unit *u, UnitDependency d, const char *name, const char *filename, bool add_reference);
2c966c03 436int unit_add_two_dependencies_by_name_inverse(Unit *u, UnitDependency d, UnitDependency e, const char *name, const char *path, bool add_reference);
0ae97ec1 437
23a177ef
LP
438int unit_add_exec_dependencies(Unit *u, ExecContext *c);
439
8e274523 440int unit_add_cgroup(Unit *u, CGroupBonding *b);
246aa6dd 441int unit_add_cgroup_from_text(Unit *u, const char *name, bool overwrite, CGroupBonding **ret);
d686d8a9 442int unit_add_default_cgroups(Unit *u);
8e274523 443CGroupBonding* unit_get_default_cgroup(Unit *u);
246aa6dd 444int unit_add_cgroup_attribute(Unit *u, const char *controller, const char *name, const char *value, CGroupAttributeMapCallback map_callback, CGroupAttribute **ret);
8e274523 445
0ae97ec1 446int unit_choose_id(Unit *u, const char *name);
f50e0a01 447int unit_set_description(Unit *u, const char *description);
87f0e418 448
701cc384
LP
449bool unit_check_gc(Unit *u);
450
87f0e418 451void unit_add_to_load_queue(Unit *u);
c1e1601e 452void unit_add_to_dbus_queue(Unit *u);
23a177ef 453void unit_add_to_cleanup_queue(Unit *u);
701cc384 454void unit_add_to_gc_queue(Unit *u);
87f0e418
LP
455
456int unit_merge(Unit *u, Unit *other);
23a177ef
LP
457int unit_merge_by_name(Unit *u, const char *other);
458
459Unit *unit_follow_merge(Unit *u);
87f0e418 460
e537352b
LP
461int unit_load_fragment_and_dropin(Unit *u);
462int unit_load_fragment_and_dropin_optional(Unit *u);
87f0e418
LP
463int unit_load(Unit *unit);
464
87f0e418
LP
465const char *unit_description(Unit *u);
466
f278026d
LP
467bool unit_has_name(Unit *u, const char *name);
468
87f0e418
LP
469UnitActiveState unit_active_state(Unit *u);
470
10a94420
LP
471const char* unit_sub_state_to_string(Unit *u);
472
87f0e418
LP
473void unit_dump(Unit *u, FILE *f, const char *prefix);
474
475bool unit_can_reload(Unit *u);
476bool unit_can_start(Unit *u);
2528a7a6 477bool unit_can_isolate(Unit *u);
87f0e418
LP
478
479int unit_start(Unit *u);
480int unit_stop(Unit *u);
481int unit_reload(Unit *u);
482
c74f17d9 483int unit_kill(Unit *u, KillWho w, int signo, DBusError *error);
8a0867d6 484
e2f3b44c 485void unit_notify(Unit *u, UnitActiveState os, UnitActiveState ns, bool reload_success);
87f0e418 486
acbb0225
LP
487int unit_watch_fd(Unit *u, int fd, uint32_t events, Watch *w);
488void unit_unwatch_fd(Unit *u, Watch *w);
87f0e418
LP
489
490int unit_watch_pid(Unit *u, pid_t pid);
491void unit_unwatch_pid(Unit *u, pid_t pid);
492
36697dc0 493int unit_watch_timer(Unit *u, clockid_t, bool relative, usec_t usec, Watch *w);
acbb0225 494void unit_unwatch_timer(Unit *u, Watch *w);
87f0e418 495
05e343b7
LP
496int unit_watch_bus_name(Unit *u, const char *name);
497void unit_unwatch_bus_name(Unit *u, const char *name);
498
87f0e418
LP
499bool unit_job_is_applicable(Unit *u, JobType j);
500
0301abf4
LP
501int set_unit_path(const char *p);
502
50159e6a
LP
503char *unit_dbus_path(Unit *u);
504
f6ff8c29 505int unit_load_related_unit(Unit *u, const char *type, Unit **_found);
a16e1123 506int unit_get_related_unit(Unit *u, const char *type, Unit **_found);
f6ff8c29 507
a16e1123 508bool unit_can_serialize(Unit *u);
6b78f9b4 509int unit_serialize(Unit *u, FILE *f, FDSet *fds, bool serialize_jobs);
93a46b0b 510void unit_serialize_item_format(Unit *u, FILE *f, const char *key, const char *value, ...) _printf_attr_(4,5);
a16e1123
LP
511void unit_serialize_item(Unit *u, FILE *f, const char *key, const char *value);
512int unit_deserialize(Unit *u, FILE *f, FDSet *fds);
513
6e2ef85b
LP
514int unit_add_node_link(Unit *u, const char *what, bool wants);
515
cca098b0
LP
516int unit_coldplug(Unit *u);
517
5831e9b7 518void unit_status_printf(Unit *u, const char *status, const char *format, ...);
9e58ff9c 519
45fb0699
LP
520bool unit_need_daemon_reload(Unit *u);
521
fdf20a31 522void unit_reset_failed(Unit *u);
5632e374 523
a7f241db
LP
524Unit *unit_following(Unit *u);
525
18ffdfda 526bool unit_pending_inactive(Unit *u);
f976f3f6 527bool unit_pending_active(Unit *u);
18ffdfda 528
bba34eed
LP
529int unit_add_default_target_dependency(Unit *u, Unit *target);
530
41f9172f
LP
531char *unit_default_cgroup_path(Unit *u);
532
6210e7fc
LP
533int unit_following_set(Unit *u, Set **s);
534
c0daa706
LP
535void unit_trigger_on_failure(Unit *u);
536
90bbc946
LP
537bool unit_condition_test(Unit *u);
538
a4375746
LP
539UnitFileState unit_get_unit_file_state(Unit *u);
540
57020a3a
LP
541Unit* unit_ref_set(UnitRef *ref, Unit *u);
542void unit_ref_unset(UnitRef *ref);
543
544#define UNIT_DEREF(ref) ((ref).unit)
545
7c8fa05c
LP
546int unit_add_one_mount_link(Unit *u, Mount *m);
547int unit_add_mount_links(Unit *u);
548
cba6e062 549int unit_exec_context_defaults(Unit *u, ExecContext *c);
e06c73cc 550
3ef63c31
LP
551ExecContext *unit_get_exec_context(Unit *u);
552
94f04347
LP
553const char *unit_active_state_to_string(UnitActiveState i);
554UnitActiveState unit_active_state_from_string(const char *s);
555
556const char *unit_dependency_to_string(UnitDependency i);
557UnitDependency unit_dependency_from_string(const char *s);
fdf9f9bb
ZJS
558
559#define log_full_unit(level, unit, ...) log_meta_object(level, __FILE__, __LINE__, __func__, "UNIT=", unit, __VA_ARGS__)
560#define log_debug_unit(unit, ...) log_full_unit(LOG_DEBUG, unit, __VA_ARGS__)
561#define log_info_unit(unit, ...) log_full_unit(LOG_INFO, unit, __VA_ARGS__)
562#define log_notice_unit(unit, ...) log_full_unit(LOG_NOTICE, unit, __VA_ARGS__)
563#define log_warning_unit(unit, ...) log_full_unit(LOG_WARNING, unit, __VA_ARGS__)
564#define log_error_unit(unit, ...) log_full_unit(LOG_ERR, unit, __VA_ARGS__)