unit.h revision d0bfe5243aa6fd9ccdd33fe3c9dfa0a08026d1ab
1a14a53cfded6e78c6e8dfb73fdff0039971d642Lennart Poettering/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
1a14a53cfded6e78c6e8dfb73fdff0039971d642Lennart Poettering
1a14a53cfded6e78c6e8dfb73fdff0039971d642Lennart Poettering#ifndef foounithfoo
1a14a53cfded6e78c6e8dfb73fdff0039971d642Lennart Poettering#define foounithfoo
1a14a53cfded6e78c6e8dfb73fdff0039971d642Lennart Poettering
1a14a53cfded6e78c6e8dfb73fdff0039971d642Lennart Poettering/***
1a14a53cfded6e78c6e8dfb73fdff0039971d642Lennart Poettering This file is part of systemd.
1a14a53cfded6e78c6e8dfb73fdff0039971d642Lennart Poettering
1a14a53cfded6e78c6e8dfb73fdff0039971d642Lennart Poettering Copyright 2010 Lennart Poettering
1a14a53cfded6e78c6e8dfb73fdff0039971d642Lennart Poettering
1a14a53cfded6e78c6e8dfb73fdff0039971d642Lennart Poettering systemd is free software; you can redistribute it and/or modify it
1a14a53cfded6e78c6e8dfb73fdff0039971d642Lennart Poettering under the terms of the GNU Lesser General Public License as published by
1a14a53cfded6e78c6e8dfb73fdff0039971d642Lennart Poettering the Free Software Foundation; either version 2.1 of the License, or
1a14a53cfded6e78c6e8dfb73fdff0039971d642Lennart Poettering (at your option) any later version.
1a14a53cfded6e78c6e8dfb73fdff0039971d642Lennart Poettering
1a14a53cfded6e78c6e8dfb73fdff0039971d642Lennart Poettering systemd is distributed in the hope that it will be useful, but
1a14a53cfded6e78c6e8dfb73fdff0039971d642Lennart Poettering WITHOUT ANY WARRANTY; without even the implied warranty of
1a14a53cfded6e78c6e8dfb73fdff0039971d642Lennart Poettering MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1a14a53cfded6e78c6e8dfb73fdff0039971d642Lennart Poettering Lesser General Public License for more details.
1a14a53cfded6e78c6e8dfb73fdff0039971d642Lennart Poettering
1a14a53cfded6e78c6e8dfb73fdff0039971d642Lennart Poettering You should have received a copy of the GNU Lesser General Public License
1a14a53cfded6e78c6e8dfb73fdff0039971d642Lennart Poettering along with systemd; If not, see <http://www.gnu.org/licenses/>.
1a14a53cfded6e78c6e8dfb73fdff0039971d642Lennart Poettering***/
1a14a53cfded6e78c6e8dfb73fdff0039971d642Lennart Poettering
96115cdfe0241ae9b4e7177cd3874c0a93d00b39Thomas Hindoe Paaboel Andersen#include <stdbool.h>
1a14a53cfded6e78c6e8dfb73fdff0039971d642Lennart Poettering#include <stdlib.h>
1af7211984a8dba3c5ba40fae794c4c55f5e6bd3Lennart Poettering
1af7211984a8dba3c5ba40fae794c4c55f5e6bd3Lennart Poetteringtypedef struct Unit Unit;
1a14a53cfded6e78c6e8dfb73fdff0039971d642Lennart Poetteringtypedef struct UnitVTable UnitVTable;
1a14a53cfded6e78c6e8dfb73fdff0039971d642Lennart Poetteringtypedef enum UnitActiveState UnitActiveState;
1a14a53cfded6e78c6e8dfb73fdff0039971d642Lennart Poetteringtypedef enum UnitDependency UnitDependency;
1a14a53cfded6e78c6e8dfb73fdff0039971d642Lennart Poetteringtypedef struct UnitRef UnitRef;
1ca208fb4f93e5869704af1812cbff7130a2fc03Zbigniew Jędrzejewski-Szmektypedef struct UnitStatusMessageFormats UnitStatusMessageFormats;
1a14a53cfded6e78c6e8dfb73fdff0039971d642Lennart Poettering
1a14a53cfded6e78c6e8dfb73fdff0039971d642Lennart Poettering#include "set.h"
9a5cb1371b6d8b0a04bd08665bcf9b06cb40c64cZbigniew Jędrzejewski-Szmek#include "util.h"
e48fdd84432bbf9c2ecc339183258c7c33116032Lennart Poettering#include "list.h"
e48fdd84432bbf9c2ecc339183258c7c33116032Lennart Poettering#include "socket-util.h"
1af7211984a8dba3c5ba40fae794c4c55f5e6bd3Lennart Poettering#include "execute.h"
73b80ec2d999c45ce13f3e034704249d80829f7eLennart Poettering#include "condition.h"
1b9e5b126359a2a2ec37de1f94f046093abc74b8Lennart Poettering#include "install.h"
f9ac15442e4132f00eca5495d53c17062aae13e0Lennart Poettering#include "unit-name.h"
1a14a53cfded6e78c6e8dfb73fdff0039971d642Lennart Poettering
1a14a53cfded6e78c6e8dfb73fdff0039971d642Lennart Poetteringenum UnitActiveState {
73b80ec2d999c45ce13f3e034704249d80829f7eLennart Poettering UNIT_ACTIVE,
73b80ec2d999c45ce13f3e034704249d80829f7eLennart Poettering UNIT_RELOADING,
73b80ec2d999c45ce13f3e034704249d80829f7eLennart Poettering UNIT_INACTIVE,
1a14a53cfded6e78c6e8dfb73fdff0039971d642Lennart Poettering UNIT_FAILED,
cca1dfddd4ce4357113663532696488427cc54e4Lennart Poettering UNIT_ACTIVATING,
1af7211984a8dba3c5ba40fae794c4c55f5e6bd3Lennart Poettering UNIT_DEACTIVATING,
1af7211984a8dba3c5ba40fae794c4c55f5e6bd3Lennart Poettering _UNIT_ACTIVE_STATE_MAX,
1af7211984a8dba3c5ba40fae794c4c55f5e6bd3Lennart Poettering _UNIT_ACTIVE_STATE_INVALID = -1
1af7211984a8dba3c5ba40fae794c4c55f5e6bd3Lennart Poettering};
1af7211984a8dba3c5ba40fae794c4c55f5e6bd3Lennart Poettering
1af7211984a8dba3c5ba40fae794c4c55f5e6bd3Lennart Poetteringstatic inline bool UNIT_IS_ACTIVE_OR_RELOADING(UnitActiveState t) {
1af7211984a8dba3c5ba40fae794c4c55f5e6bd3Lennart Poettering return t == UNIT_ACTIVE || t == UNIT_RELOADING;
1af7211984a8dba3c5ba40fae794c4c55f5e6bd3Lennart Poettering}
1af7211984a8dba3c5ba40fae794c4c55f5e6bd3Lennart Poettering
7410616cd9dbbec97cf98d75324da5cda2b2f7a2Lennart Poetteringstatic inline bool UNIT_IS_ACTIVE_OR_ACTIVATING(UnitActiveState t) {
7410616cd9dbbec97cf98d75324da5cda2b2f7a2Lennart Poettering return t == UNIT_ACTIVE || t == UNIT_ACTIVATING || t == UNIT_RELOADING;
7410616cd9dbbec97cf98d75324da5cda2b2f7a2Lennart Poettering}
1af7211984a8dba3c5ba40fae794c4c55f5e6bd3Lennart Poettering
1af7211984a8dba3c5ba40fae794c4c55f5e6bd3Lennart Poetteringstatic inline bool UNIT_IS_INACTIVE_OR_DEACTIVATING(UnitActiveState t) {
1af7211984a8dba3c5ba40fae794c4c55f5e6bd3Lennart Poettering return t == UNIT_INACTIVE || t == UNIT_FAILED || t == UNIT_DEACTIVATING;
1af7211984a8dba3c5ba40fae794c4c55f5e6bd3Lennart Poettering}
1af7211984a8dba3c5ba40fae794c4c55f5e6bd3Lennart Poettering
7410616cd9dbbec97cf98d75324da5cda2b2f7a2Lennart Poetteringstatic inline bool UNIT_IS_INACTIVE_OR_FAILED(UnitActiveState t) {
7410616cd9dbbec97cf98d75324da5cda2b2f7a2Lennart Poettering return t == UNIT_INACTIVE || t == UNIT_FAILED;
7410616cd9dbbec97cf98d75324da5cda2b2f7a2Lennart Poettering}
1af7211984a8dba3c5ba40fae794c4c55f5e6bd3Lennart Poettering
1af7211984a8dba3c5ba40fae794c4c55f5e6bd3Lennart Poetteringenum UnitDependency {
821b2e792159e237a1e5a1ea4bb6ae2e55d64be5Lukas Nykryn /* Positive dependencies */
1af7211984a8dba3c5ba40fae794c4c55f5e6bd3Lennart Poettering UNIT_REQUIRES,
1af7211984a8dba3c5ba40fae794c4c55f5e6bd3Lennart Poettering UNIT_REQUIRES_OVERRIDABLE,
1af7211984a8dba3c5ba40fae794c4c55f5e6bd3Lennart Poettering UNIT_REQUISITE,
4a62c710b62a5a3c7a8a278b810b9d5b5a0c8f4fMichal Schmidt UNIT_REQUISITE_OVERRIDABLE,
4a62c710b62a5a3c7a8a278b810b9d5b5a0c8f4fMichal Schmidt UNIT_WANTS,
1af7211984a8dba3c5ba40fae794c4c55f5e6bd3Lennart Poettering UNIT_BINDS_TO,
1af7211984a8dba3c5ba40fae794c4c55f5e6bd3Lennart Poettering
1af7211984a8dba3c5ba40fae794c4c55f5e6bd3Lennart Poettering /* Inverse of the above */
1af7211984a8dba3c5ba40fae794c4c55f5e6bd3Lennart Poettering UNIT_REQUIRED_BY, /* inverse of 'requires' and 'requisite' is 'required_by' */
1af7211984a8dba3c5ba40fae794c4c55f5e6bd3Lennart Poettering UNIT_REQUIRED_BY_OVERRIDABLE, /* inverse of 'requires_overridable' and 'requisite_overridable' is 'soft_required_by' */
c3834f9b881f2b1a68dc7d797c134f0b66b47b57Lennart Poettering UNIT_WANTED_BY, /* inverse of 'wants' */
1af7211984a8dba3c5ba40fae794c4c55f5e6bd3Lennart Poettering UNIT_BOUND_BY, /* inverse of 'binds_to' */
1af7211984a8dba3c5ba40fae794c4c55f5e6bd3Lennart Poettering
1af7211984a8dba3c5ba40fae794c4c55f5e6bd3Lennart Poettering /* Negative dependencies */
1af7211984a8dba3c5ba40fae794c4c55f5e6bd3Lennart Poettering UNIT_CONFLICTS, /* inverse of 'conflicts' is 'conflicted_by' */
1af7211984a8dba3c5ba40fae794c4c55f5e6bd3Lennart Poettering UNIT_CONFLICTED_BY,
1af7211984a8dba3c5ba40fae794c4c55f5e6bd3Lennart Poettering
1af7211984a8dba3c5ba40fae794c4c55f5e6bd3Lennart Poettering /* Order */
1af7211984a8dba3c5ba40fae794c4c55f5e6bd3Lennart Poettering UNIT_BEFORE, /* inverse of 'before' is 'after' and vice versa */
1af7211984a8dba3c5ba40fae794c4c55f5e6bd3Lennart Poettering UNIT_AFTER,
1af7211984a8dba3c5ba40fae794c4c55f5e6bd3Lennart Poettering
cca1dfddd4ce4357113663532696488427cc54e4Lennart Poettering /* On Failure */
1af7211984a8dba3c5ba40fae794c4c55f5e6bd3Lennart Poettering UNIT_ON_FAILURE,
1af7211984a8dba3c5ba40fae794c4c55f5e6bd3Lennart Poettering
cca1dfddd4ce4357113663532696488427cc54e4Lennart Poettering /* Triggers (i.e. a socket triggers a service) */
1af7211984a8dba3c5ba40fae794c4c55f5e6bd3Lennart Poettering UNIT_TRIGGERS,
1af7211984a8dba3c5ba40fae794c4c55f5e6bd3Lennart Poettering UNIT_TRIGGERED_BY,
dacd6cee76a08331b8c8616c5f30f70ee49aa2f9Lennart Poettering
dacd6cee76a08331b8c8616c5f30f70ee49aa2f9Lennart Poettering /* Propagate reloads */
dacd6cee76a08331b8c8616c5f30f70ee49aa2f9Lennart Poettering UNIT_PROPAGATES_RELOAD_TO,
1af7211984a8dba3c5ba40fae794c4c55f5e6bd3Lennart Poettering UNIT_RELOAD_PROPAGATED_FROM,
63c372cb9df3bee01e3bf8cd7f96f336bddda846Lennart Poettering
1af7211984a8dba3c5ba40fae794c4c55f5e6bd3Lennart Poettering /* Reference information for GC logic */
1af7211984a8dba3c5ba40fae794c4c55f5e6bd3Lennart Poettering UNIT_REFERENCES, /* Inverse of 'references' is 'referenced_by' */
1af7211984a8dba3c5ba40fae794c4c55f5e6bd3Lennart Poettering UNIT_REFERENCED_BY,
1af7211984a8dba3c5ba40fae794c4c55f5e6bd3Lennart Poettering
1af7211984a8dba3c5ba40fae794c4c55f5e6bd3Lennart Poettering _UNIT_DEPENDENCY_MAX,
1af7211984a8dba3c5ba40fae794c4c55f5e6bd3Lennart Poettering _UNIT_DEPENDENCY_INVALID = -1
4a62c710b62a5a3c7a8a278b810b9d5b5a0c8f4fMichal Schmidt};
4a62c710b62a5a3c7a8a278b810b9d5b5a0c8f4fMichal Schmidt
1af7211984a8dba3c5ba40fae794c4c55f5e6bd3Lennart Poettering#include "manager.h"
1af7211984a8dba3c5ba40fae794c4c55f5e6bd3Lennart Poettering#include "job.h"
1af7211984a8dba3c5ba40fae794c4c55f5e6bd3Lennart Poettering#include "cgroup.h"
1af7211984a8dba3c5ba40fae794c4c55f5e6bd3Lennart Poettering#include "cgroup-attr.h"
1af7211984a8dba3c5ba40fae794c4c55f5e6bd3Lennart Poettering
1af7211984a8dba3c5ba40fae794c4c55f5e6bd3Lennart Poetteringstruct Unit {
1af7211984a8dba3c5ba40fae794c4c55f5e6bd3Lennart Poettering Manager *manager;
4a62c710b62a5a3c7a8a278b810b9d5b5a0c8f4fMichal Schmidt
4a62c710b62a5a3c7a8a278b810b9d5b5a0c8f4fMichal Schmidt UnitType type;
1af7211984a8dba3c5ba40fae794c4c55f5e6bd3Lennart Poettering UnitLoadState load_state;
1af7211984a8dba3c5ba40fae794c4c55f5e6bd3Lennart Poettering Unit *merged_into;
1af7211984a8dba3c5ba40fae794c4c55f5e6bd3Lennart Poettering
1af7211984a8dba3c5ba40fae794c4c55f5e6bd3Lennart Poettering char *id; /* One name is special because we use it for identification. Points to an entry in the names set */
1af7211984a8dba3c5ba40fae794c4c55f5e6bd3Lennart Poettering char *instance;
1af7211984a8dba3c5ba40fae794c4c55f5e6bd3Lennart Poettering
1af7211984a8dba3c5ba40fae794c4c55f5e6bd3Lennart Poettering Set *names;
4a62c710b62a5a3c7a8a278b810b9d5b5a0c8f4fMichal Schmidt Set *dependencies[_UNIT_DEPENDENCY_MAX];
4a62c710b62a5a3c7a8a278b810b9d5b5a0c8f4fMichal Schmidt
1af7211984a8dba3c5ba40fae794c4c55f5e6bd3Lennart Poettering char **requires_mounts_for;
1af7211984a8dba3c5ba40fae794c4c55f5e6bd3Lennart Poettering
1af7211984a8dba3c5ba40fae794c4c55f5e6bd3Lennart Poettering char *description;
1af7211984a8dba3c5ba40fae794c4c55f5e6bd3Lennart Poettering char **documentation;
1af7211984a8dba3c5ba40fae794c4c55f5e6bd3Lennart Poettering
1af7211984a8dba3c5ba40fae794c4c55f5e6bd3Lennart Poettering char *fragment_path; /* if loaded from a config file this is the primary path to it */
1af7211984a8dba3c5ba40fae794c4c55f5e6bd3Lennart Poettering char *source_path; /* if converted, the source file */
1af7211984a8dba3c5ba40fae794c4c55f5e6bd3Lennart Poettering usec_t fragment_mtime;
1af7211984a8dba3c5ba40fae794c4c55f5e6bd3Lennart Poettering usec_t source_mtime;
1af7211984a8dba3c5ba40fae794c4c55f5e6bd3Lennart Poettering
4c1fc3e404d648c70bd2f50ac50aeac6ece8872eDaniel Mack /* If there is something to do with this unit, then this is the installed job for it */
4c1fc3e404d648c70bd2f50ac50aeac6ece8872eDaniel Mack Job *job;
23bbb0de4e3f85d9704a5c12a5afa2dfa0159e41Michal Schmidt
23bbb0de4e3f85d9704a5c12a5afa2dfa0159e41Michal Schmidt /* JOB_NOP jobs are special and can be installed without disturbing the real job. */
1af7211984a8dba3c5ba40fae794c4c55f5e6bd3Lennart Poettering Job *nop_job;
1af7211984a8dba3c5ba40fae794c4c55f5e6bd3Lennart Poettering
1af7211984a8dba3c5ba40fae794c4c55f5e6bd3Lennart Poettering usec_t job_timeout;
1af7211984a8dba3c5ba40fae794c4c55f5e6bd3Lennart Poettering
1af7211984a8dba3c5ba40fae794c4c55f5e6bd3Lennart Poettering /* References to this */
1af7211984a8dba3c5ba40fae794c4c55f5e6bd3Lennart Poettering LIST_HEAD(UnitRef, refs);
1af7211984a8dba3c5ba40fae794c4c55f5e6bd3Lennart Poettering
1af7211984a8dba3c5ba40fae794c4c55f5e6bd3Lennart Poettering /* Conditions to check */
1af7211984a8dba3c5ba40fae794c4c55f5e6bd3Lennart Poettering LIST_HEAD(Condition, conditions);
73b80ec2d999c45ce13f3e034704249d80829f7eLennart Poettering
73b80ec2d999c45ce13f3e034704249d80829f7eLennart Poettering dual_timestamp condition_timestamp;
73b80ec2d999c45ce13f3e034704249d80829f7eLennart Poettering
73b80ec2d999c45ce13f3e034704249d80829f7eLennart Poettering dual_timestamp inactive_exit_timestamp;
73b80ec2d999c45ce13f3e034704249d80829f7eLennart Poettering dual_timestamp active_enter_timestamp;
cca1dfddd4ce4357113663532696488427cc54e4Lennart Poettering dual_timestamp active_exit_timestamp;
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sievers dual_timestamp inactive_enter_timestamp;
73b80ec2d999c45ce13f3e034704249d80829f7eLennart Poettering
73b80ec2d999c45ce13f3e034704249d80829f7eLennart Poettering /* Counterparts in the cgroup filesystem */
73b80ec2d999c45ce13f3e034704249d80829f7eLennart Poettering CGroupBonding *cgroup_bondings;
1af7211984a8dba3c5ba40fae794c4c55f5e6bd3Lennart Poettering CGroupAttribute *cgroup_attributes;
1a14a53cfded6e78c6e8dfb73fdff0039971d642Lennart Poettering
e48fdd84432bbf9c2ecc339183258c7c33116032Lennart Poettering /* Per type list */
1a14a53cfded6e78c6e8dfb73fdff0039971d642Lennart Poettering LIST_FIELDS(Unit, units_by_type);
1af7211984a8dba3c5ba40fae794c4c55f5e6bd3Lennart Poettering
1af7211984a8dba3c5ba40fae794c4c55f5e6bd3Lennart Poettering /* All units which have requires_mounts_for set */
1af7211984a8dba3c5ba40fae794c4c55f5e6bd3Lennart Poettering LIST_FIELDS(Unit, has_requires_mounts_for);
1af7211984a8dba3c5ba40fae794c4c55f5e6bd3Lennart Poettering
1af7211984a8dba3c5ba40fae794c4c55f5e6bd3Lennart Poettering /* Load queue */
73b80ec2d999c45ce13f3e034704249d80829f7eLennart Poettering LIST_FIELDS(Unit, load_queue);
1a14a53cfded6e78c6e8dfb73fdff0039971d642Lennart Poettering
73b80ec2d999c45ce13f3e034704249d80829f7eLennart Poettering /* D-Bus queue */
1af7211984a8dba3c5ba40fae794c4c55f5e6bd3Lennart Poettering LIST_FIELDS(Unit, dbus_queue);
cca1dfddd4ce4357113663532696488427cc54e4Lennart Poettering
1af7211984a8dba3c5ba40fae794c4c55f5e6bd3Lennart Poettering /* Cleanup queue */
1af7211984a8dba3c5ba40fae794c4c55f5e6bd3Lennart Poettering LIST_FIELDS(Unit, cleanup_queue);
1af7211984a8dba3c5ba40fae794c4c55f5e6bd3Lennart Poettering
1af7211984a8dba3c5ba40fae794c4c55f5e6bd3Lennart Poettering /* GC queue */
1af7211984a8dba3c5ba40fae794c4c55f5e6bd3Lennart Poettering LIST_FIELDS(Unit, gc_queue);
1af7211984a8dba3c5ba40fae794c4c55f5e6bd3Lennart Poettering
1af7211984a8dba3c5ba40fae794c4c55f5e6bd3Lennart Poettering /* Used during GC sweeps */
7410616cd9dbbec97cf98d75324da5cda2b2f7a2Lennart Poettering unsigned gc_marker;
7410616cd9dbbec97cf98d75324da5cda2b2f7a2Lennart Poettering
7410616cd9dbbec97cf98d75324da5cda2b2f7a2Lennart Poettering /* When deserializing, temporarily store the job type for this
1a14a53cfded6e78c6e8dfb73fdff0039971d642Lennart Poettering * unit here, if there was a job scheduled.
e48fdd84432bbf9c2ecc339183258c7c33116032Lennart Poettering * Only for deserializing from a legacy version. New style uses full
e48fdd84432bbf9c2ecc339183258c7c33116032Lennart Poettering * serialized jobs. */
e48fdd84432bbf9c2ecc339183258c7c33116032Lennart Poettering int deserialized_job; /* This is actually of type JobType */
e48fdd84432bbf9c2ecc339183258c7c33116032Lennart Poettering
e48fdd84432bbf9c2ecc339183258c7c33116032Lennart Poettering /* Error code when we didn't manage to load the unit (negative) */
4a62c710b62a5a3c7a8a278b810b9d5b5a0c8f4fMichal Schmidt int load_error;
4a62c710b62a5a3c7a8a278b810b9d5b5a0c8f4fMichal Schmidt
1a14a53cfded6e78c6e8dfb73fdff0039971d642Lennart Poettering /* Cached unit file state */
1a14a53cfded6e78c6e8dfb73fdff0039971d642Lennart Poettering UnitFileState unit_file_state;
1a14a53cfded6e78c6e8dfb73fdff0039971d642Lennart Poettering
1a14a53cfded6e78c6e8dfb73fdff0039971d642Lennart Poettering /* Garbage collect us we nobody wants or requires us anymore */
c3834f9b881f2b1a68dc7d797c134f0b66b47b57Lennart Poettering bool stop_when_unneeded;
c3834f9b881f2b1a68dc7d797c134f0b66b47b57Lennart Poettering
e48fdd84432bbf9c2ecc339183258c7c33116032Lennart Poettering /* Create default dependencies */
e48fdd84432bbf9c2ecc339183258c7c33116032Lennart Poettering bool default_dependencies;
73b80ec2d999c45ce13f3e034704249d80829f7eLennart Poettering
73b80ec2d999c45ce13f3e034704249d80829f7eLennart Poettering /* Refuse manual starting, allow starting only indirectly via dependency. */
73b80ec2d999c45ce13f3e034704249d80829f7eLennart Poettering bool refuse_manual_start;
e48fdd84432bbf9c2ecc339183258c7c33116032Lennart Poettering
e48fdd84432bbf9c2ecc339183258c7c33116032Lennart Poettering /* Don't allow the user to stop this unit manually, allow stopping only indirectly via dependency. */
e48fdd84432bbf9c2ecc339183258c7c33116032Lennart Poettering bool refuse_manual_stop;
e48fdd84432bbf9c2ecc339183258c7c33116032Lennart Poettering
e48fdd84432bbf9c2ecc339183258c7c33116032Lennart Poettering /* Allow isolation requests */
e48fdd84432bbf9c2ecc339183258c7c33116032Lennart Poettering bool allow_isolate;
1a14a53cfded6e78c6e8dfb73fdff0039971d642Lennart Poettering
1a14a53cfded6e78c6e8dfb73fdff0039971d642Lennart Poettering /* Isolate OnFailure unit */
1af7211984a8dba3c5ba40fae794c4c55f5e6bd3Lennart Poettering bool on_failure_isolate;
1af7211984a8dba3c5ba40fae794c4c55f5e6bd3Lennart Poettering
1af7211984a8dba3c5ba40fae794c4c55f5e6bd3Lennart Poettering /* Ignore this unit when isolating */
73b80ec2d999c45ce13f3e034704249d80829f7eLennart Poettering bool ignore_on_isolate;
73b80ec2d999c45ce13f3e034704249d80829f7eLennart Poettering
73b80ec2d999c45ce13f3e034704249d80829f7eLennart Poettering /* Ignore this unit when snapshotting */
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sievers bool ignore_on_snapshot;
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sievers
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sievers /* Did the last condition check suceed? */
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sievers bool condition_result;
1a14a53cfded6e78c6e8dfb73fdff0039971d642Lennart Poettering
dacd6cee76a08331b8c8616c5f30f70ee49aa2f9Lennart Poettering bool in_load_queue:1;
dacd6cee76a08331b8c8616c5f30f70ee49aa2f9Lennart Poettering bool in_dbus_queue:1;
dacd6cee76a08331b8c8616c5f30f70ee49aa2f9Lennart Poettering bool in_cleanup_queue:1;
1a14a53cfded6e78c6e8dfb73fdff0039971d642Lennart Poettering bool in_gc_queue:1;
73b80ec2d999c45ce13f3e034704249d80829f7eLennart Poettering
73b80ec2d999c45ce13f3e034704249d80829f7eLennart Poettering bool sent_dbus_new_signal:1;
73b80ec2d999c45ce13f3e034704249d80829f7eLennart Poettering
73b80ec2d999c45ce13f3e034704249d80829f7eLennart Poettering bool no_gc:1;
1a14a53cfded6e78c6e8dfb73fdff0039971d642Lennart Poettering
73b80ec2d999c45ce13f3e034704249d80829f7eLennart Poettering bool in_audit:1;
4a62c710b62a5a3c7a8a278b810b9d5b5a0c8f4fMichal Schmidt};
4a62c710b62a5a3c7a8a278b810b9d5b5a0c8f4fMichal Schmidt
1a14a53cfded6e78c6e8dfb73fdff0039971d642Lennart Poetteringstruct UnitRef {
1a14a53cfded6e78c6e8dfb73fdff0039971d642Lennart Poettering /* Keeps tracks of references to a unit. This is useful so
1a14a53cfded6e78c6e8dfb73fdff0039971d642Lennart Poettering * that we can merge two units if necessary and correct all
1a14a53cfded6e78c6e8dfb73fdff0039971d642Lennart Poettering * references to them */
1a14a53cfded6e78c6e8dfb73fdff0039971d642Lennart Poettering
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sievers Unit* unit;
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sievers LIST_FIELDS(UnitRef, refs);
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sievers};
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sievers
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sieversstruct UnitStatusMessageFormats {
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sievers const char *starting_stopping[2];
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sievers const char *finished_start_job[_JOB_RESULT_MAX];
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sievers const char *finished_stop_job[_JOB_RESULT_MAX];
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sievers};
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sievers
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sievers#include "service.h"
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sievers#include "timer.h"
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sievers#include "socket.h"
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sievers#include "target.h"
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sievers#include "device.h"
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sievers#include "mount.h"
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sievers#include "automount.h"
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sievers#include "snapshot.h"
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sievers#include "swap.h"
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sievers#include "path.h"
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sievers
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sieversstruct UnitVTable {
61331eab0a53cd9b8446eab6d1ebf1a046d8efc1Lennart Poettering /* How much memory does an object of this unit type need */
61331eab0a53cd9b8446eab6d1ebf1a046d8efc1Lennart Poettering size_t object_size;
61331eab0a53cd9b8446eab6d1ebf1a046d8efc1Lennart Poettering
61331eab0a53cd9b8446eab6d1ebf1a046d8efc1Lennart Poettering /* Config file sections this unit type understands, separated
cca1dfddd4ce4357113663532696488427cc54e4Lennart Poettering * by NUL chars */
61331eab0a53cd9b8446eab6d1ebf1a046d8efc1Lennart Poettering const char *sections;
61331eab0a53cd9b8446eab6d1ebf1a046d8efc1Lennart Poettering
61331eab0a53cd9b8446eab6d1ebf1a046d8efc1Lennart Poettering /* This should reset all type-specific variables. This should
61331eab0a53cd9b8446eab6d1ebf1a046d8efc1Lennart Poettering * not allocate memory, and is called with zero-initialized
a0b1209c4a59754f428894e0485413542da50014Zbigniew Jędrzejewski-Szmek * data. It should hence only initialize variables that need
61331eab0a53cd9b8446eab6d1ebf1a046d8efc1Lennart Poettering * to be set != 0. */
61331eab0a53cd9b8446eab6d1ebf1a046d8efc1Lennart Poettering void (*init)(Unit *u);
61331eab0a53cd9b8446eab6d1ebf1a046d8efc1Lennart Poettering
61331eab0a53cd9b8446eab6d1ebf1a046d8efc1Lennart Poettering /* This should free all type-specific variables. It should be
61331eab0a53cd9b8446eab6d1ebf1a046d8efc1Lennart Poettering * idempotent. */
61331eab0a53cd9b8446eab6d1ebf1a046d8efc1Lennart Poettering void (*done)(Unit *u);
61331eab0a53cd9b8446eab6d1ebf1a046d8efc1Lennart Poettering
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sievers /* Actually load data from disk. This may fail, and should set
61331eab0a53cd9b8446eab6d1ebf1a046d8efc1Lennart Poettering * load_state to UNIT_LOADED, UNIT_MERGED or leave it at
61331eab0a53cd9b8446eab6d1ebf1a046d8efc1Lennart Poettering * UNIT_STUB if no configuration could be found. */
61331eab0a53cd9b8446eab6d1ebf1a046d8efc1Lennart Poettering int (*load)(Unit *u);
61331eab0a53cd9b8446eab6d1ebf1a046d8efc1Lennart Poettering
61331eab0a53cd9b8446eab6d1ebf1a046d8efc1Lennart Poettering /* If a a lot of units got created via enumerate(), this is
61331eab0a53cd9b8446eab6d1ebf1a046d8efc1Lennart Poettering * where to actually set the state and call unit_notify(). */
61331eab0a53cd9b8446eab6d1ebf1a046d8efc1Lennart Poettering int (*coldplug)(Unit *u);
61331eab0a53cd9b8446eab6d1ebf1a046d8efc1Lennart Poettering
61331eab0a53cd9b8446eab6d1ebf1a046d8efc1Lennart Poettering void (*dump)(Unit *u, FILE *f, const char *prefix);
61331eab0a53cd9b8446eab6d1ebf1a046d8efc1Lennart Poettering
61331eab0a53cd9b8446eab6d1ebf1a046d8efc1Lennart Poettering int (*start)(Unit *u);
61331eab0a53cd9b8446eab6d1ebf1a046d8efc1Lennart Poettering int (*stop)(Unit *u);
56f64d95763a799ba4475daf44d8e9f72a1bd474Michal Schmidt int (*reload)(Unit *u);
61331eab0a53cd9b8446eab6d1ebf1a046d8efc1Lennart Poettering
61331eab0a53cd9b8446eab6d1ebf1a046d8efc1Lennart Poettering int (*kill)(Unit *u, KillWho w, KillMode m, int signo, DBusError *error);
61331eab0a53cd9b8446eab6d1ebf1a046d8efc1Lennart Poettering
61331eab0a53cd9b8446eab6d1ebf1a046d8efc1Lennart Poettering bool (*can_reload)(Unit *u);
61331eab0a53cd9b8446eab6d1ebf1a046d8efc1Lennart Poettering
61331eab0a53cd9b8446eab6d1ebf1a046d8efc1Lennart Poettering /* Write all data that cannot be restored from other sources
61331eab0a53cd9b8446eab6d1ebf1a046d8efc1Lennart Poettering * away using unit_serialize_item() */
61331eab0a53cd9b8446eab6d1ebf1a046d8efc1Lennart Poettering int (*serialize)(Unit *u, FILE *f, FDSet *fds);
61331eab0a53cd9b8446eab6d1ebf1a046d8efc1Lennart Poettering
61331eab0a53cd9b8446eab6d1ebf1a046d8efc1Lennart Poettering /* Restore one item from the serialization */
a0b1209c4a59754f428894e0485413542da50014Zbigniew Jędrzejewski-Szmek int (*deserialize_item)(Unit *u, const char *key, const char *data, FDSet *fds);
a0b1209c4a59754f428894e0485413542da50014Zbigniew Jędrzejewski-Szmek
61331eab0a53cd9b8446eab6d1ebf1a046d8efc1Lennart Poettering /* Boils down the more complex internal state of this unit to
a0b1209c4a59754f428894e0485413542da50014Zbigniew Jędrzejewski-Szmek * a simpler one that the engine can understand */
a0b1209c4a59754f428894e0485413542da50014Zbigniew Jędrzejewski-Szmek UnitActiveState (*active_state)(Unit *u);
61331eab0a53cd9b8446eab6d1ebf1a046d8efc1Lennart Poettering
61331eab0a53cd9b8446eab6d1ebf1a046d8efc1Lennart Poettering /* Returns the substate specific to this unit type as
61331eab0a53cd9b8446eab6d1ebf1a046d8efc1Lennart Poettering * string. This is purely information so that we can give the
61331eab0a53cd9b8446eab6d1ebf1a046d8efc1Lennart Poettering * user a more fine grained explanation in which actual state a
61331eab0a53cd9b8446eab6d1ebf1a046d8efc1Lennart Poettering * unit is in. */
61331eab0a53cd9b8446eab6d1ebf1a046d8efc1Lennart Poettering const char* (*sub_state_to_string)(Unit *u);
cca1dfddd4ce4357113663532696488427cc54e4Lennart Poettering
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sievers /* Return true when there is reason to keep this entry around
61331eab0a53cd9b8446eab6d1ebf1a046d8efc1Lennart Poettering * even nothing references it and it isn't active in any
61331eab0a53cd9b8446eab6d1ebf1a046d8efc1Lennart Poettering * way */
61331eab0a53cd9b8446eab6d1ebf1a046d8efc1Lennart Poettering bool (*check_gc)(Unit *u);
61331eab0a53cd9b8446eab6d1ebf1a046d8efc1Lennart Poettering
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sievers /* Return true when this unit is suitable for snapshotting */
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sievers bool (*check_snapshot)(Unit *u);
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sievers
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sievers void (*fd_event)(Unit *u, int fd, uint32_t events, Watch *w);
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sievers void (*sigchld_event)(Unit *u, pid_t pid, int code, int status);
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sievers void (*timer_event)(Unit *u, uint64_t n_elapsed, Watch *w);
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sievers
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sievers /* Reset failed state if we are in failed state */
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sievers void (*reset_failed)(Unit *u);
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sievers
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sievers /* Called whenever any of the cgroups this unit watches for
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sievers * ran empty */
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sievers void (*cgroup_notify_empty)(Unit *u);
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sievers
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sievers /* Called whenever a process of this unit sends us a message */
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sievers void (*notify_message)(Unit *u, pid_t pid, char **tags);
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sievers
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sievers /* Called whenever a name thus Unit registered for comes or
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sievers * goes away. */
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sievers void (*bus_name_owner_change)(Unit *u, const char *name, const char *old_owner, const char *new_owner);
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sievers
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sievers /* Called whenever a bus PID lookup finishes */
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sievers void (*bus_query_pid_done)(Unit *u, const char *name, pid_t pid);
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sievers
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sievers /* Called for each message received on the bus */
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sievers DBusHandlerResult (*bus_message_handler)(Unit *u, DBusConnection *c, DBusMessage *message);
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sievers
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sievers /* Return the unit this unit is following */
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sievers Unit *(*following)(Unit *u);
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sievers
dacd6cee76a08331b8c8616c5f30f70ee49aa2f9Lennart Poettering /* Return the set of units that are following each other */
dacd6cee76a08331b8c8616c5f30f70ee49aa2f9Lennart Poettering int (*following_set)(Unit *u, Set **s);
dacd6cee76a08331b8c8616c5f30f70ee49aa2f9Lennart Poettering
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sievers /* This is called for each unit type and should be used to
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sievers * enumerate existing devices and load them. However,
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sievers * everything that is loaded here should still stay in
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sievers * inactive state. It is the job of the coldplug() call above
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sievers * to put the units into the initial state. */
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sievers int (*enumerate)(Manager *m);
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sievers
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sievers /* Type specific cleanups. */
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sievers void (*shutdown)(Manager *m);
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sievers
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sievers /* When sending out PropertiesChanged signal, which properties
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sievers * shall be invalidated? This is a NUL separated list of
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sievers * strings, to minimize relocations a little. */
7a1494aa4e4a131d73e866cf1e7eb7b6e47dbab8Tom Gundersen const char *bus_invalidating_properties;
7a1494aa4e4a131d73e866cf1e7eb7b6e47dbab8Tom Gundersen
7a1494aa4e4a131d73e866cf1e7eb7b6e47dbab8Tom Gundersen /* The interface name */
7a1494aa4e4a131d73e866cf1e7eb7b6e47dbab8Tom Gundersen const char *bus_interface;
7a1494aa4e4a131d73e866cf1e7eb7b6e47dbab8Tom Gundersen
7a1494aa4e4a131d73e866cf1e7eb7b6e47dbab8Tom Gundersen UnitStatusMessageFormats status_message_formats;
7a1494aa4e4a131d73e866cf1e7eb7b6e47dbab8Tom Gundersen
7a1494aa4e4a131d73e866cf1e7eb7b6e47dbab8Tom Gundersen /* Can units of this type have multiple names? */
7a1494aa4e4a131d73e866cf1e7eb7b6e47dbab8Tom Gundersen bool no_alias:1;
7a1494aa4e4a131d73e866cf1e7eb7b6e47dbab8Tom Gundersen
7a1494aa4e4a131d73e866cf1e7eb7b6e47dbab8Tom Gundersen /* Instances make no sense for this type */
7a1494aa4e4a131d73e866cf1e7eb7b6e47dbab8Tom Gundersen bool no_instances:1;
7a1494aa4e4a131d73e866cf1e7eb7b6e47dbab8Tom Gundersen
7a1494aa4e4a131d73e866cf1e7eb7b6e47dbab8Tom Gundersen /* Exclude from automatic gc */
7a1494aa4e4a131d73e866cf1e7eb7b6e47dbab8Tom Gundersen bool no_gc:1;
7a1494aa4e4a131d73e866cf1e7eb7b6e47dbab8Tom Gundersen};
7a1494aa4e4a131d73e866cf1e7eb7b6e47dbab8Tom Gundersen
7a1494aa4e4a131d73e866cf1e7eb7b6e47dbab8Tom Gundersenextern const UnitVTable * const unit_vtable[_UNIT_TYPE_MAX];
7a1494aa4e4a131d73e866cf1e7eb7b6e47dbab8Tom Gundersen
7a1494aa4e4a131d73e866cf1e7eb7b6e47dbab8Tom Gundersen#define UNIT_VTABLE(u) unit_vtable[(u)->type]
7a1494aa4e4a131d73e866cf1e7eb7b6e47dbab8Tom Gundersen
7a1494aa4e4a131d73e866cf1e7eb7b6e47dbab8Tom Gundersen/* For casting a unit into the various unit types */
7a1494aa4e4a131d73e866cf1e7eb7b6e47dbab8Tom Gundersen#define DEFINE_CAST(UPPERCASE, MixedCase) \
7a1494aa4e4a131d73e866cf1e7eb7b6e47dbab8Tom Gundersen static inline MixedCase* UPPERCASE(Unit *u) { \
7a1494aa4e4a131d73e866cf1e7eb7b6e47dbab8Tom Gundersen if (_unlikely_(!u || u->type != UNIT_##UPPERCASE)) \
7a1494aa4e4a131d73e866cf1e7eb7b6e47dbab8Tom Gundersen return NULL; \
7a1494aa4e4a131d73e866cf1e7eb7b6e47dbab8Tom Gundersen \
7a1494aa4e4a131d73e866cf1e7eb7b6e47dbab8Tom Gundersen return (MixedCase*) u; \
7a1494aa4e4a131d73e866cf1e7eb7b6e47dbab8Tom Gundersen }
7a1494aa4e4a131d73e866cf1e7eb7b6e47dbab8Tom Gundersen
7a1494aa4e4a131d73e866cf1e7eb7b6e47dbab8Tom Gundersen/* For casting the various unit types into a unit */
7a1494aa4e4a131d73e866cf1e7eb7b6e47dbab8Tom Gundersen#define UNIT(u) (&(u)->meta)
7a1494aa4e4a131d73e866cf1e7eb7b6e47dbab8Tom Gundersen
7a1494aa4e4a131d73e866cf1e7eb7b6e47dbab8Tom GundersenDEFINE_CAST(SOCKET, Socket);
7a1494aa4e4a131d73e866cf1e7eb7b6e47dbab8Tom GundersenDEFINE_CAST(TIMER, Timer);
7a1494aa4e4a131d73e866cf1e7eb7b6e47dbab8Tom GundersenDEFINE_CAST(SERVICE, Service);
7a1494aa4e4a131d73e866cf1e7eb7b6e47dbab8Tom GundersenDEFINE_CAST(TARGET, Target);
7a1494aa4e4a131d73e866cf1e7eb7b6e47dbab8Tom GundersenDEFINE_CAST(DEVICE, Device);
7a1494aa4e4a131d73e866cf1e7eb7b6e47dbab8Tom GundersenDEFINE_CAST(MOUNT, Mount);
7a1494aa4e4a131d73e866cf1e7eb7b6e47dbab8Tom GundersenDEFINE_CAST(AUTOMOUNT, Automount);
7a1494aa4e4a131d73e866cf1e7eb7b6e47dbab8Tom GundersenDEFINE_CAST(SNAPSHOT, Snapshot);
7a1494aa4e4a131d73e866cf1e7eb7b6e47dbab8Tom GundersenDEFINE_CAST(SWAP, Swap);
7a1494aa4e4a131d73e866cf1e7eb7b6e47dbab8Tom GundersenDEFINE_CAST(PATH, Path);
7a1494aa4e4a131d73e866cf1e7eb7b6e47dbab8Tom Gundersen
7a1494aa4e4a131d73e866cf1e7eb7b6e47dbab8Tom GundersenUnit *unit_new(Manager *m, size_t size);
7a1494aa4e4a131d73e866cf1e7eb7b6e47dbab8Tom Gundersenvoid unit_free(Unit *u);
7a1494aa4e4a131d73e866cf1e7eb7b6e47dbab8Tom Gundersen
7a1494aa4e4a131d73e866cf1e7eb7b6e47dbab8Tom Gundersenint unit_add_name(Unit *u, const char *name);
7a1494aa4e4a131d73e866cf1e7eb7b6e47dbab8Tom Gundersen
7a1494aa4e4a131d73e866cf1e7eb7b6e47dbab8Tom Gundersenint unit_add_dependency(Unit *u, UnitDependency d, Unit *other, bool add_reference);
7a1494aa4e4a131d73e866cf1e7eb7b6e47dbab8Tom Gundersenint unit_add_two_dependencies(Unit *u, UnitDependency d, UnitDependency e, Unit *other, bool add_reference);
7a1494aa4e4a131d73e866cf1e7eb7b6e47dbab8Tom Gundersen
7a1494aa4e4a131d73e866cf1e7eb7b6e47dbab8Tom Gundersenint unit_add_dependency_by_name(Unit *u, UnitDependency d, const char *name, const char *filename, bool add_reference);
7a1494aa4e4a131d73e866cf1e7eb7b6e47dbab8Tom Gundersenint unit_add_two_dependencies_by_name(Unit *u, UnitDependency d, UnitDependency e, const char *name, const char *path, bool add_reference);
7a1494aa4e4a131d73e866cf1e7eb7b6e47dbab8Tom Gundersen
7a1494aa4e4a131d73e866cf1e7eb7b6e47dbab8Tom Gundersenint unit_add_dependency_by_name_inverse(Unit *u, UnitDependency d, const char *name, const char *filename, bool add_reference);
7a1494aa4e4a131d73e866cf1e7eb7b6e47dbab8Tom Gundersenint unit_add_two_dependencies_by_name_inverse(Unit *u, UnitDependency d, UnitDependency e, const char *name, const char *path, bool add_reference);
7a1494aa4e4a131d73e866cf1e7eb7b6e47dbab8Tom Gundersen
7a1494aa4e4a131d73e866cf1e7eb7b6e47dbab8Tom Gundersenint unit_add_exec_dependencies(Unit *u, ExecContext *c);
7a1494aa4e4a131d73e866cf1e7eb7b6e47dbab8Tom Gundersen
7a1494aa4e4a131d73e866cf1e7eb7b6e47dbab8Tom Gundersenint unit_add_cgroup(Unit *u, CGroupBonding *b);
7a1494aa4e4a131d73e866cf1e7eb7b6e47dbab8Tom Gundersenint unit_add_cgroup_from_text(Unit *u, const char *name);
7a1494aa4e4a131d73e866cf1e7eb7b6e47dbab8Tom Gundersenint unit_add_default_cgroups(Unit *u);
7a1494aa4e4a131d73e866cf1e7eb7b6e47dbab8Tom GundersenCGroupBonding* unit_get_default_cgroup(Unit *u);
7a1494aa4e4a131d73e866cf1e7eb7b6e47dbab8Tom Gundersenint unit_add_cgroup_attribute(Unit *u, const char *controller, const char *name, const char *value, CGroupAttributeMapCallback map_callback);
7a1494aa4e4a131d73e866cf1e7eb7b6e47dbab8Tom Gundersen
7a1494aa4e4a131d73e866cf1e7eb7b6e47dbab8Tom Gundersenint unit_choose_id(Unit *u, const char *name);
7a1494aa4e4a131d73e866cf1e7eb7b6e47dbab8Tom Gundersenint unit_set_description(Unit *u, const char *description);
7a1494aa4e4a131d73e866cf1e7eb7b6e47dbab8Tom Gundersen
7a1494aa4e4a131d73e866cf1e7eb7b6e47dbab8Tom Gundersenbool unit_check_gc(Unit *u);
7a1494aa4e4a131d73e866cf1e7eb7b6e47dbab8Tom Gundersen
7a1494aa4e4a131d73e866cf1e7eb7b6e47dbab8Tom Gundersenvoid unit_add_to_load_queue(Unit *u);
7a1494aa4e4a131d73e866cf1e7eb7b6e47dbab8Tom Gundersenvoid unit_add_to_dbus_queue(Unit *u);
7a1494aa4e4a131d73e866cf1e7eb7b6e47dbab8Tom Gundersenvoid unit_add_to_cleanup_queue(Unit *u);
7a1494aa4e4a131d73e866cf1e7eb7b6e47dbab8Tom Gundersenvoid unit_add_to_gc_queue(Unit *u);
7a1494aa4e4a131d73e866cf1e7eb7b6e47dbab8Tom Gundersen
7a1494aa4e4a131d73e866cf1e7eb7b6e47dbab8Tom Gundersenint unit_merge(Unit *u, Unit *other);
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sieversint unit_merge_by_name(Unit *u, const char *other);
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sievers
59512f21d77d984cf1363fb0d1770218c5e17020Kay SieversUnit *unit_follow_merge(Unit *u);
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sievers
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sieversint unit_load_fragment_and_dropin(Unit *u);
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sieversint unit_load_fragment_and_dropin_optional(Unit *u);
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sieversint unit_load(Unit *unit);
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sievers
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sieversconst char *unit_description(Unit *u);
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sievers
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sieversbool unit_has_name(Unit *u, const char *name);
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sievers
59512f21d77d984cf1363fb0d1770218c5e17020Kay SieversUnitActiveState unit_active_state(Unit *u);
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sievers
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sieversconst char* unit_sub_state_to_string(Unit *u);
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sievers
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sieversvoid unit_dump(Unit *u, FILE *f, const char *prefix);
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sievers
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sieversbool unit_can_reload(Unit *u);
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sieversbool unit_can_start(Unit *u);
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sieversbool unit_can_isolate(Unit *u);
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sievers
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sieversint unit_start(Unit *u);
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sieversint unit_stop(Unit *u);
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sieversint unit_reload(Unit *u);
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sievers
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sieversint unit_kill(Unit *u, KillWho w, KillMode m, int signo, DBusError *error);
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sievers
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sieversvoid unit_notify(Unit *u, UnitActiveState os, UnitActiveState ns, bool reload_success);
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sievers
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sieversint unit_watch_fd(Unit *u, int fd, uint32_t events, Watch *w);
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sieversvoid unit_unwatch_fd(Unit *u, Watch *w);
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sievers
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sieversint unit_watch_pid(Unit *u, pid_t pid);
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sieversvoid unit_unwatch_pid(Unit *u, pid_t pid);
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sievers
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sieversint unit_watch_timer(Unit *u, usec_t delay, Watch *w);
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sieversvoid unit_unwatch_timer(Unit *u, Watch *w);
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sievers
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sieversint unit_watch_bus_name(Unit *u, const char *name);
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sieversvoid unit_unwatch_bus_name(Unit *u, const char *name);
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sievers
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sieversbool unit_job_is_applicable(Unit *u, JobType j);
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sievers
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sieversint set_unit_path(const char *p);
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sievers
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sieverschar *unit_dbus_path(Unit *u);
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sievers
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sieversint unit_load_related_unit(Unit *u, const char *type, Unit **_found);
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sieversint unit_get_related_unit(Unit *u, const char *type, Unit **_found);
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sievers
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sieverschar *unit_name_printf(Unit *u, const char* text);
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sieverschar *unit_full_printf(Unit *u, const char *text);
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sieverschar **unit_full_printf_strv(Unit *u, char **l);
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sievers
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sieversbool unit_can_serialize(Unit *u);
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sieversint unit_serialize(Unit *u, FILE *f, FDSet *fds);
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sieversvoid unit_serialize_item_format(Unit *u, FILE *f, const char *key, const char *value, ...) _printf_attr_(4,5);
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sieversvoid unit_serialize_item(Unit *u, FILE *f, const char *key, const char *value);
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sieversint unit_deserialize(Unit *u, FILE *f, FDSet *fds);
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sievers
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sieversint unit_add_node_link(Unit *u, const char *what, bool wants);
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sievers
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sieversint unit_coldplug(Unit *u);
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sievers
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sieversvoid unit_status_printf(Unit *u, const char *status, const char *format, ...);
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sievers
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sieversbool unit_need_daemon_reload(Unit *u);
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sievers
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sieversvoid unit_reset_failed(Unit *u);
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sievers
59512f21d77d984cf1363fb0d1770218c5e17020Kay SieversUnit *unit_following(Unit *u);
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sievers
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sieversbool unit_pending_inactive(Unit *u);
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sieversbool unit_pending_active(Unit *u);
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sievers
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sieversint unit_add_default_target_dependency(Unit *u, Unit *target);
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sievers
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sieversint unit_following_set(Unit *u, Set **s);
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sievers
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sieversvoid unit_trigger_on_failure(Unit *u);
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sievers
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sieversbool unit_condition_test(Unit *u);
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sievers
59512f21d77d984cf1363fb0d1770218c5e17020Kay SieversUnitFileState unit_get_unit_file_state(Unit *u);
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sievers
59512f21d77d984cf1363fb0d1770218c5e17020Kay SieversUnit* unit_ref_set(UnitRef *ref, Unit *u);
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sieversvoid unit_ref_unset(UnitRef *ref);
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sievers
7a1494aa4e4a131d73e866cf1e7eb7b6e47dbab8Tom Gundersen#define UNIT_DEREF(ref) ((ref).unit)
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sievers
7a1494aa4e4a131d73e866cf1e7eb7b6e47dbab8Tom Gundersenint unit_add_one_mount_link(Unit *u, Mount *m);
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sieversint unit_add_mount_links(Unit *u);
59512f21d77d984cf1363fb0d1770218c5e17020Kay Sievers
7a1494aa4e4a131d73e866cf1e7eb7b6e47dbab8Tom Gundersenconst char *unit_active_state_to_string(UnitActiveState i);
59512f21d77d984cf1363fb0d1770218c5e17020Kay SieversUnitActiveState unit_active_state_from_string(const char *s);
61331eab0a53cd9b8446eab6d1ebf1a046d8efc1Lennart Poettering
61331eab0a53cd9b8446eab6d1ebf1a046d8efc1Lennart Poetteringconst char *unit_dependency_to_string(UnitDependency i);
1ca208fb4f93e5869704af1812cbff7130a2fc03Zbigniew Jędrzejewski-SzmekUnitDependency unit_dependency_from_string(const char *s);
1ca208fb4f93e5869704af1812cbff7130a2fc03Zbigniew Jędrzejewski-Szmek
61331eab0a53cd9b8446eab6d1ebf1a046d8efc1Lennart Poettering#endif
61331eab0a53cd9b8446eab6d1ebf1a046d8efc1Lennart Poettering