unit.c revision 3b6fdb5b5afebc49a7e987e3e3bf7aa2615d1671
/*-*- Mode: C; c-basic-offset: 8 -*-*/
/***
This file is part of systemd.
Copyright 2010 Lennart Poettering
under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
systemd is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include <assert.h>
#include <errno.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include "set.h"
#include "unit.h"
#include "macro.h"
#include "strv.h"
#include "load-fragment.h"
#include "load-dropin.h"
#include "log.h"
#include "unit-name.h"
#include "specifier.h"
#include "dbus-unit.h"
#include "special.h"
#include "cgroup-util.h"
[UNIT_SERVICE] = &service_vtable,
[UNIT_TIMER] = &timer_vtable,
[UNIT_SOCKET] = &socket_vtable,
[UNIT_TARGET] = &target_vtable,
[UNIT_DEVICE] = &device_vtable,
[UNIT_MOUNT] = &mount_vtable,
[UNIT_SNAPSHOT] = &snapshot_vtable,
[UNIT_SWAP] = &swap_vtable,
[UNIT_PATH] = &path_vtable
};
Unit *u;
assert(m);
return NULL;
free(u);
return NULL;
}
u->meta.default_dependencies = true;
return u;
}
assert(u);
}
UnitType t;
int r;
assert(u);
if (unit_name_is_template(text)) {
return -EINVAL;
} else
if (!s)
return -ENOMEM;
if (!unit_name_is_valid(s)) {
r = -EINVAL;
goto fail;
}
assert_se((t = unit_name_to_type(s)) >= 0);
r = -EINVAL;
goto fail;
}
if ((r = unit_name_to_instance(s, &i)) < 0)
goto fail;
if (i && unit_vtable[t]->no_instances)
goto fail;
r = -EINVAL;
goto fail;
}
if (unit_vtable[t]->no_alias &&
r = -EEXIST;
goto fail;
}
r = -E2BIG;
goto fail;
}
if (r == -EEXIST)
r = 0;
goto fail;
}
goto fail;
}
if (UNIT_VTABLE(u)->init)
UNIT_VTABLE(u)->init(u);
} else
free(i);
return 0;
fail:
free(s);
free(i);
return r;
}
char *s, *t = NULL;
assert(u);
if (unit_name_is_template(name)) {
return -EINVAL;
return -ENOMEM;
name = t;
}
/* Selects one of the names of this unit as the id */
free(t);
if (!s)
return -ENOENT;
return 0;
}
char *s;
assert(u);
if (!(s = strdup(description)))
return -ENOMEM;
u->meta.description = s;
return 0;
}
bool unit_check_gc(Unit *u) {
assert(u);
return true;
if (UNIT_VTABLE(u)->no_gc)
return true;
return true;
if (unit_active_state(u) != UNIT_INACTIVE)
return true;
if (UNIT_VTABLE(u)->check_gc)
if (UNIT_VTABLE(u)->check_gc(u))
return true;
return false;
}
void unit_add_to_load_queue(Unit *u) {
assert(u);
return;
u->meta.in_load_queue = true;
}
void unit_add_to_cleanup_queue(Unit *u) {
assert(u);
if (u->meta.in_cleanup_queue)
return;
u->meta.in_cleanup_queue = true;
}
void unit_add_to_gc_queue(Unit *u) {
assert(u);
return;
if (unit_check_gc(u))
return;
u->meta.in_gc_queue = true;
}
void unit_add_to_dbus_queue(Unit *u) {
assert(u);
return;
/* Shortcut things if nobody cares */
u->meta.sent_dbus_new_signal = true;
return;
}
u->meta.in_dbus_queue = true;
}
Iterator i;
assert(u);
/* Frees the set and makes sure we are dropped from the
* inverse pointers */
SET_FOREACH(other, s, i) {
for (d = 0; d < _UNIT_DEPENDENCY_MAX; d++)
}
set_free(s);
}
Iterator i;
char *t;
assert(u);
if (UNIT_VTABLE(u)->done)
UNIT_VTABLE(u)->done(u);
for (d = 0; d < _UNIT_DEPENDENCY_MAX; d++)
if (u->meta.in_load_queue)
if (u->meta.in_dbus_queue)
if (u->meta.in_cleanup_queue)
if (u->meta.in_gc_queue) {
}
free(u);
}
assert(u);
return unit_active_state(unit_follow_merge(u));
/* After a reload it might happen that a unit is not correctly
* loaded but still has a process around. That's why we won't
* shortcut failed loading to UNIT_INACTIVE_MAINTENANCE. */
return UNIT_VTABLE(u)->active_state(u);
}
const char* unit_sub_state_to_string(Unit *u) {
assert(u);
return UNIT_VTABLE(u)->sub_state_to_string(u);
}
assert(s);
if (!*other)
return;
if (*s)
else {
*s = *other;
}
}
char *t;
Iterator i;
assert(u);
}
Iterator i;
int r;
assert(u);
assert(d < _UNIT_DEPENDENCY_MAX);
for (k = 0; k < _UNIT_DEPENDENCY_MAX; k++)
if (r == -EEXIST)
else
}
}
}
assert(u);
if (other == u)
return 0;
return -EINVAL;
return -EINVAL;
return -EEXIST;
return -EEXIST;
return -EEXIST;
/* Merge names */
merge_names(u, other);
/* Merge dependencies */
for (d = 0; d < _UNIT_DEPENDENCY_MAX; d++)
merge_dependencies(u, other, d);
/* If there is still some data attached to the other node, we
* don't need it anymore, and can free it. */
return 0;
}
int r;
char *s = NULL;
assert(u);
if (unit_name_is_template(name)) {
return -EINVAL;
return -ENOMEM;
name = s;
}
r = unit_add_name(u, name);
else
r = unit_merge(u, other);
free(s);
return r;
}
assert(u);
return u;
}
int r;
assert(u);
assert(c);
if (c->std_output != EXEC_OUTPUT_KMSG &&
c->std_output != EXEC_OUTPUT_SYSLOG &&
c->std_error != EXEC_OUTPUT_KMSG &&
c->std_error != EXEC_OUTPUT_SYSLOG)
return 0;
/* If syslog or kernel logging is requested, make sure our own
* logging daemon is run first. */
return r;
return r;
return 0;
}
const char *unit_description(Unit *u) {
assert(u);
if (u->meta.description)
return u->meta.description;
}
char *t;
Iterator i;
char *p2;
const char *prefix2;
CGroupBonding *b;
char
assert(u);
if (!prefix)
prefix = "";
fprintf(f,
"%s-> Unit %s:\n"
"%s\tDescription: %s\n"
"%s\tInstance: %s\n"
"%s\tUnit Load State: %s\n"
"%s\tUnit Active State: %s\n"
"%s\tInactive Exit Timestamp: %s\n"
"%s\tActive Enter Timestamp: %s\n"
"%s\tActive Exit Timestamp: %s\n"
"%s\tInactive Enter Timestamp: %s\n"
"%s\tGC Check Good: %s\n",
prefix, unit_description(u),
prefix, strna(format_timestamp(timestamp1, sizeof(timestamp1), u->meta.inactive_exit_timestamp.realtime)),
prefix, strna(format_timestamp(timestamp2, sizeof(timestamp2), u->meta.active_enter_timestamp.realtime)),
prefix, strna(format_timestamp(timestamp3, sizeof(timestamp3), u->meta.active_exit_timestamp.realtime)),
prefix, strna(format_timestamp(timestamp4, sizeof(timestamp4), u->meta.inactive_enter_timestamp.realtime)),
if (u->meta.fragment_path)
for (d = 0; d < _UNIT_DEPENDENCY_MAX; d++) {
}
fprintf(f,
"%s\tRecursive Stop: %s\n"
"%s\tStopWhenUnneeded: %s\n"
"%s\tOnlyByDependency: %s\n"
"%s\tDefaultDependencies: %s\n"
"%s\tIgnoreDependencyFailure: %s\n",
fprintf(f, "%s\tControlGroup: %s:%s\n",
if (UNIT_VTABLE(u)->dump)
fprintf(f,
"%s\tMerged into: %s\n",
}
/* Common implementation for multiple backends */
int unit_load_fragment_and_dropin(Unit *u) {
int r;
assert(u);
/* Load a .service file */
if ((r = unit_load_fragment(u)) < 0)
return r;
return -ENOENT;
/* Load drop-in directory data */
if ((r = unit_load_dropin(unit_follow_merge(u))) < 0)
return r;
return 0;
}
/* Common implementation for multiple backends */
int unit_load_fragment_and_dropin_optional(Unit *u) {
int r;
assert(u);
/* Same as unit_load_fragment_and_dropin(), but whether
* something can be loaded or not doesn't matter. */
/* Load a .service file */
if ((r = unit_load_fragment(u)) < 0)
return r;
/* Load drop-in directory data */
if ((r = unit_load_dropin(unit_follow_merge(u))) < 0)
return r;
return 0;
}
/* Common implementation for multiple backends */
int unit_load_nop(Unit *u) {
assert(u);
return 0;
}
int r;
assert(u);
if (u->meta.in_load_queue) {
u->meta.in_load_queue = false;
}
return -EINVAL;
return 0;
if (UNIT_VTABLE(u)->load)
if ((r = UNIT_VTABLE(u)->load(u)) < 0)
goto fail;
r = -ENOENT;
goto fail;
}
return 0;
fail:
return r;
}
/* Errors:
* -EBADR: This unit type does not support starting.
* -EALREADY: Unit is already started.
* -EAGAIN: An operation is already in progress. Retry later.
* -ECANCELED: Too many requests for now.
*/
int unit_start(Unit *u) {
assert(u);
return -EINVAL;
/* If this is already (being) started, then this will
* succeed. Note that this will even succeed if this unit is
* not startable by the user. This is relied on to detect when
* we need to wait for units and when waiting is finished. */
state = unit_active_state(u);
return -EALREADY;
/* If it is stopped, but we cannot start it, then fail */
if (!UNIT_VTABLE(u)->start)
return -EBADR;
/* We don't suppress calls to ->start() here when we are
* already starting, to allow this request to be used as a
* "hurry up" call, for example when the unit is in some "auto
* restart" state where it waits for a holdoff timer to elapse
* before it will start again. */
return UNIT_VTABLE(u)->start(u);
}
bool unit_can_start(Unit *u) {
assert(u);
return !!UNIT_VTABLE(u)->start;
}
/* Errors:
* -EBADR: This unit type does not support stopping.
* -EALREADY: Unit is already stopped.
* -EAGAIN: An operation is already in progress. Retry later.
*/
assert(u);
state = unit_active_state(u);
return -EALREADY;
if (!UNIT_VTABLE(u)->stop)
return -EBADR;
return UNIT_VTABLE(u)->stop(u);
}
/* Errors:
* -EBADR: This unit type does not support reloading.
* -ENOEXEC: Unit is not started.
* -EAGAIN: An operation is already in progress. Retry later.
*/
int unit_reload(Unit *u) {
assert(u);
return -EINVAL;
if (!unit_can_reload(u))
return -EBADR;
state = unit_active_state(u);
if (unit_active_state(u) == UNIT_RELOADING)
return -EALREADY;
if (unit_active_state(u) != UNIT_ACTIVE)
return -ENOEXEC;
return UNIT_VTABLE(u)->reload(u);
}
bool unit_can_reload(Unit *u) {
assert(u);
if (!UNIT_VTABLE(u)->reload)
return false;
if (!UNIT_VTABLE(u)->can_reload)
return true;
return UNIT_VTABLE(u)->can_reload(u);
}
static void unit_check_uneeded(Unit *u) {
Iterator i;
assert(u);
/* If this service shall be shut down when unneeded then do
* so. */
if (!u->meta.stop_when_unneeded)
return;
return;
return;
return;
return;
/* Ok, nobody needs us anymore. Sniff. Then let's commit suicide */
}
static void retroactively_start_dependencies(Unit *u) {
Iterator i;
assert(u);
}
static void retroactively_stop_dependencies(Unit *u) {
Iterator i;
assert(u);
if (u->meta.recursive_stop) {
/* Pull down units need us recursively if enabled */
}
/* Garbage collect services that might not be needed anymore, if enabled */
}
assert(u);
/* Note that this is called for all low-level state changes,
* even if they might map to the same high-level
* UnitActiveState! That means that ns == os is OK an expected
* behaviour here. For example: if a mount point is remounted
* this function will be called too and the utmp code below
* relies on that! */
timer_unit_notify(u, ns);
path_unit_notify(u, ns);
bool unexpected = false;
/* So we reached a different state for this
* job. Let's see if we can run it now if it
* failed previously due to EAGAIN. */
/* Let's check whether this state change constitutes a
* finished job, or maybe cotradicts a running job and
* hence needs to invalidate jobs. */
case JOB_START:
case JOB_VERIFY_ACTIVE:
unexpected = true;
}
break;
case JOB_RELOAD:
case JOB_RELOAD_OR_START:
if (ns == UNIT_ACTIVE)
unexpected = true;
}
}
break;
case JOB_STOP:
case JOB_RESTART:
case JOB_TRY_RESTART:
unexpected = true;
}
break;
default:
assert_not_reached("Job type unknown");
}
/* If this state change happened without being
* requested by a job, then let's retroactively start
* or stop dependencies */
if (unexpected) {
}
}
/* Some names are special */
if (UNIT_IS_ACTIVE_OR_RELOADING(ns)) {
if (unit_has_name(u, SPECIAL_DBUS_SERVICE)) {
/* The bus just might have become available,
* hence try to connect to it, if we aren't
* yet connected. */
}
if (unit_has_name(u, SPECIAL_SYSLOG_SERVICE))
/* The syslog daemon just might have become
* available, hence try to connect to it, if
* we aren't yet connected. */
log_open();
/* Another directory became available, let's
* check if that is enough to write our utmp
* entry. */
/* A target got activated, maybe this is a runlevel? */
} else if (!UNIT_IS_ACTIVE_OR_RELOADING(ns)) {
if (unit_has_name(u, SPECIAL_SYSLOG_SERVICE))
/* The syslog daemon might just have
* terminated, hence try to disconnect from
* it. */
/* We don't care about D-Bus here, since we'll get an
* asynchronous notification for it anyway. */
}
/* Maybe we finished startup and are now ready for being
* stopped because unneeded? */
}
struct epoll_event ev;
assert(u);
assert(w);
fd,
&ev) < 0)
return -errno;
return 0;
}
assert(u);
assert(w);
if (w->type == WATCH_INVALID)
return;
w->fd = -1;
w->type = WATCH_INVALID;
}
assert(u);
/* Watch a specific PID. We only support one unit watching
* each PID for now. */
}
assert(u);
}
struct itimerspec its;
bool ours;
assert(u);
assert(w);
/* This will try to reuse the old timer if there is one */
if (w->type == WATCH_TIMER) {
ours = false;
} else {
ours = true;
return -errno;
}
if (delay <= 0) {
/* Set absolute time in the past, but not 0, since we
* don't want to disarm the timer */
} else {
flags = 0;
}
/* This will also flush the elapse counter */
goto fail;
if (w->type == WATCH_INVALID) {
struct epoll_event ev;
goto fail;
}
w->type = WATCH_TIMER;
return 0;
fail:
if (ours)
return -errno;
}
assert(u);
assert(w);
if (w->type == WATCH_INVALID)
return;
close_nointr_nofail(w->fd);
w->fd = -1;
w->type = WATCH_INVALID;
}
assert(u);
assert(j >= 0 && j < _JOB_TYPE_MAX);
switch (j) {
case JOB_VERIFY_ACTIVE:
case JOB_START:
return true;
case JOB_STOP:
case JOB_RESTART:
case JOB_TRY_RESTART:
return unit_can_start(u);
case JOB_RELOAD:
return unit_can_reload(u);
case JOB_RELOAD_OR_START:
return unit_can_reload(u) && unit_can_start(u);
default:
assert_not_reached("Invalid job type");
}
}
[UNIT_WANTS] = UNIT_WANTED_BY,
[UNIT_BEFORE] = UNIT_AFTER,
[UNIT_AFTER] = UNIT_BEFORE,
};
int r, q = 0, v = 0, w = 0;
assert(u);
assert(d >= 0 && d < _UNIT_DEPENDENCY_MAX);
/* We won't allow dependencies on ourselves. We will not
* consider them an error however. */
if (u == other)
return 0;
if (UNIT_VTABLE(u)->no_requires &&
(d == UNIT_REQUIRES ||
d == UNIT_REQUIRES_OVERRIDABLE ||
d == UNIT_REQUISITE ||
d == UNIT_REQUISITE_OVERRIDABLE)) {
return -EINVAL;
}
if ((r = set_ensure_allocated(&u->meta.dependencies[d], trivial_hash_func, trivial_compare_func)) < 0 ||
(r = set_ensure_allocated(&other->meta.dependencies[inverse_table[d]], trivial_hash_func, trivial_compare_func)) < 0)
return r;
if (add_reference)
if ((r = set_ensure_allocated(&u->meta.dependencies[UNIT_REFERENCES], trivial_hash_func, trivial_compare_func)) < 0 ||
(r = set_ensure_allocated(&other->meta.dependencies[UNIT_REFERENCED_BY], trivial_hash_func, trivial_compare_func)) < 0)
return r;
return q;
r = v;
goto fail;
}
if (add_reference) {
r = w;
goto fail;
}
goto fail;
}
return 0;
fail:
if (q > 0)
if (v > 0)
if (w > 0)
return r;
}
int unit_add_two_dependencies(Unit *u, UnitDependency d, UnitDependency e, Unit *other, bool add_reference) {
int r;
assert(u);
return r;
return r;
return 0;
}
char *s;
assert(u);
if (!name)
if (!unit_name_is_template(name)) {
*p = NULL;
return name;
}
else {
char *i;
return NULL;
s = unit_name_replace_instance(name, i);
free(i);
}
if (!s)
return NULL;
*p = s;
return s;
}
int unit_add_dependency_by_name(Unit *u, UnitDependency d, const char *name, const char *path, bool add_reference) {
int r;
char *s;
assert(u);
return -ENOMEM;
goto finish;
free(s);
return r;
}
int unit_add_two_dependencies_by_name(Unit *u, UnitDependency d, UnitDependency e, const char *name, const char *path, bool add_reference) {
int r;
char *s;
assert(u);
return -ENOMEM;
goto finish;
free(s);
return r;
}
int unit_add_dependency_by_name_inverse(Unit *u, UnitDependency d, const char *name, const char *path, bool add_reference) {
int r;
char *s;
assert(u);
return -ENOMEM;
goto finish;
free(s);
return r;
}
int unit_add_two_dependencies_by_name_inverse(Unit *u, UnitDependency d, UnitDependency e, const char *name, const char *path, bool add_reference) {
int r;
char *s;
assert(u);
return -ENOMEM;
goto finish;
goto finish;
free(s);
return r;
}
int set_unit_path(const char *p) {
char *cwd, *c;
int r;
/* This is mostly for debug purposes */
if (path_is_absolute(p)) {
if (!(c = strdup(p)))
return -ENOMEM;
} else {
if (!(cwd = get_current_dir_name()))
return -errno;
if (r < 0)
return -ENOMEM;
}
if (setenv("SYSTEMD_UNIT_PATH", c, 0) < 0) {
r = -errno;
free(c);
return r;
}
return 0;
}
char *unit_dbus_path(Unit *u) {
char *p, *e;
assert(u);
return NULL;
if (asprintf(&p, "/org/freedesktop/systemd1/unit/%s", e) < 0) {
free(e);
return NULL;
}
free(e);
return p;
}
CGroupBonding *l;
int r;
assert(u);
assert(b);
/* Ensure this hasn't been added yet */
return r;
}
b->unit = u;
return 0;
}
static char *default_cgroup_path(Unit *u) {
char *p;
int r;
assert(u);
char *t;
return NULL;
free(t);
} else
return r < 0 ? NULL : p;
}
size_t n;
CGroupBonding *b = NULL;
int r;
assert(u);
/* Detect controller name */
if (name[n] == 0 ||
/* Only controller name, no path? */
if (!(path = default_cgroup_path(u)))
return -ENOMEM;
} else {
const char *p;
/* Controller name, and path. */
p = name+n+1;
if (!path_is_absolute(p))
return -EINVAL;
return -ENOMEM;
}
if (n > 0)
else
if (!controller) {
r = -ENOMEM;
goto fail;
}
r = -EEXIST;
goto fail;
}
r = -ENOMEM;
goto fail;
}
b->controller = controller;
b->only_us = false;
b->clean_up = false;
if ((r = unit_add_cgroup(u, b)) < 0)
goto fail;
return 0;
fail:
free(b);
return r;
}
int unit_add_default_cgroup(Unit *u) {
CGroupBonding *b;
int r = -ENOMEM;
assert(u);
/* Adds in the default cgroup data, if it wasn't specified yet */
if (unit_get_default_cgroup(u))
return 0;
return -ENOMEM;
goto fail;
if (!(b->path = default_cgroup_path(u)))
goto fail;
b->clean_up = true;
b->only_us = true;
if ((r = unit_add_cgroup(u, b)) < 0)
goto fail;
return 0;
fail:
free(b->controller);
free(b);
return r;
}
assert(u);
}
char *t;
int r;
assert(u);
return -ENOMEM;
assert(!unit_has_name(u, t));
free(t);
return r;
}
char *t;
assert(u);
return -ENOMEM;
assert(!unit_has_name(u, t));
free(t);
if (!found)
return -ENOENT;
return 0;
}
assert(u);
}
assert(u);
}
char *p, *r;
assert(u);
return NULL;
r = unit_name_unescape(p);
free(p);
return r;
}
assert(u);
return strdup("");
}
/*
* This will use the passed string as format string and
* replace the following specifiers:
*
* %n: the full id of the unit (foo@bar.waldo)
* %N: the id of the unit without the suffix (foo@bar)
* %p: the prefix (foo)
* %i: the instance (bar)
*/
};
assert(u);
}
/* This is similar to unit_name_printf() but also supports
* unescaping */
};
assert(u);
}
char **unit_full_printf_strv(Unit *u, char **l) {
size_t n;
char **r, **i, **j;
/* Applies unit_full_printf to every entry in l */
assert(u);
n = strv_length(l);
if (!(r = new(char*, n+1)))
return NULL;
for (i = l, j = r; *i; i++, j++)
if (!(*j = unit_full_printf(u, *i)))
goto fail;
*j = NULL;
return r;
fail:
j--;
while (j >= r)
free(*j);
free(r);
return NULL;
}
assert(u);
/* Watch a specific name on the bus. We only support one unit
* watching each name for now. */
}
assert(u);
}
bool unit_can_serialize(Unit *u) {
assert(u);
}
int r;
assert(u);
assert(f);
if (!unit_can_serialize(u))
return 0;
return r;
/* End marker */
fputc('\n', f);
return 0;
}
assert(u);
assert(f);
fputc('=', f);
fputc('\n', f);
}
assert(u);
assert(f);
}
int r;
assert(u);
assert(f);
if (!unit_can_serialize(u))
return 0;
for (;;) {
char line[1024], *l, *v;
size_t k;
if (feof(f))
return 0;
return -errno;
}
/* End marker */
if (l[0] == 0)
return 0;
k = strcspn(l, "=");
if (l[k] == '=') {
l[k] = 0;
v = l+k+1;
} else
v = l+k;
if (streq(l, "job")) {
if ((type = job_type_from_string(v)) < 0)
log_debug("Failed to parse job type value %s", v);
else
continue;
}
return r;
}
}
char *e;
int r;
assert(u);
if (!what)
return 0;
/* Adds in links to the device node that this unit is based on */
if (!is_device_path(what))
return 0;
return -ENOMEM;
free(e);
if (r < 0)
return r;
return r;
if (wants)
return r;
return 0;
}
int unit_coldplug(Unit *u) {
int r;
assert(u);
if (UNIT_VTABLE(u)->coldplug)
if ((r = UNIT_VTABLE(u)->coldplug(u)) < 0)
return r;
if (u->meta.deserialized_job >= 0) {
if ((r = manager_add_job(u->meta.manager, u->meta.deserialized_job, u, JOB_FAIL, false, NULL, NULL)) < 0)
return r;
}
return 0;
}
assert(u);
if (!UNIT_VTABLE(u)->show_status)
return;
return;
return;
return;
}
static const char* const unit_type_table[_UNIT_TYPE_MAX] = {
[UNIT_SERVICE] = "service",
[UNIT_TIMER] = "timer",
[UNIT_SOCKET] = "socket",
[UNIT_TARGET] = "target",
[UNIT_DEVICE] = "device",
[UNIT_MOUNT] = "mount",
[UNIT_AUTOMOUNT] = "automount",
[UNIT_SNAPSHOT] = "snapshot",
[UNIT_SWAP] = "swap"
};
static const char* const unit_load_state_table[_UNIT_LOAD_STATE_MAX] = {
[UNIT_STUB] = "stub",
[UNIT_LOADED] = "loaded",
[UNIT_FAILED] = "failed",
[UNIT_MERGED] = "merged"
};
static const char* const unit_active_state_table[_UNIT_ACTIVE_STATE_MAX] = {
[UNIT_ACTIVE] = "active",
[UNIT_RELOADING] = "reloading",
[UNIT_INACTIVE] = "inactive",
[UNIT_MAINTENANCE] = "maintenance",
[UNIT_ACTIVATING] = "activating",
[UNIT_DEACTIVATING] = "deactivating"
};
static const char* const unit_dependency_table[_UNIT_DEPENDENCY_MAX] = {
[UNIT_REQUIRES] = "Requires",
[UNIT_REQUIRES_OVERRIDABLE] = "RequiresOverridable",
[UNIT_WANTS] = "Wants",
[UNIT_REQUISITE] = "Requisite",
[UNIT_REQUISITE_OVERRIDABLE] = "RequisiteOverridable",
[UNIT_REQUIRED_BY] = "RequiredBy",
[UNIT_REQUIRED_BY_OVERRIDABLE] = "RequiredByOverridable",
[UNIT_WANTED_BY] = "WantedBy",
[UNIT_CONFLICTS] = "Conflicts",
[UNIT_BEFORE] = "Before",
[UNIT_AFTER] = "After",
[UNIT_REFERENCES] = "References",
[UNIT_REFERENCED_BY] = "ReferencedBy"
};
static const char* const kill_mode_table[_KILL_MODE_MAX] = {
[KILL_CONTROL_GROUP] = "control-group",
[KILL_PROCESS_GROUP] = "process-group",
[KILL_PROCESS] = "process",
[KILL_NONE] = "none"
};