unit.c revision 92ab323c824300683efb11fd43c9d834cea9b9e6
1N/A along with systemd; If not, see <http://www.gnu.org/licenses/>.
1N/A#include "load-fragment.h"
1N/A#include "load-dropin.h"
1N/A#include "unit-name.h"
1N/A#include "specifier.h"
1N/A#include "dbus-unit.h"
1N/A#include "cgroup-util.h"
1N/A if (!unit_name_is_valid(s, false)) {
1N/A if ((r = unit_name_to_instance(s, &i)) < 0)
1N/A if ((r = unit_name_to_instance(s, &i)) < 0)
assert(u);
assert(u);
assert(u);
if (unit_check_gc(u))
assert(u);
Iterator i;
assert(u);
for (d = 0; d < _UNIT_DEPENDENCY_MAX; d++)
set_free(s);
Iterator i;
assert(u);
for (d = 0; d < _UNIT_DEPENDENCY_MAX; d++)
free(u);
assert(u);
assert(u);
assert(s);
if (!*other)
*s = *other;
Iterator i;
assert(u);
Iterator i;
assert(u);
for (k = 0; k < _UNIT_DEPENDENCY_MAX; k++)
if (r == -EEXIST)
assert(u);
if (other == u)
return -EINVAL;
return -EINVAL;
return -EEXIST;
return -EEXIST;
return -EEXIST;
for (d = 0; d < _UNIT_DEPENDENCY_MAX; d++)
char *s = NULL;
assert(u);
return -EINVAL;
return -ENOMEM;
name = s;
free(s);
assert(u);
assert(u);
assert(c);
assert(u);
Iterator i;
char *p2;
const char *prefix2;
CGroupBonding *b;
assert(u);
if (!prefix)
fprintf(f,
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)),
fprintf(f, "%s\tJob Timeout: %s\n", prefix, format_timespan(timespan, sizeof(timespan), u->meta.job_timeout));
for (d = 0; d < _UNIT_DEPENDENCY_MAX; d++) {
fprintf(f,
fprintf(f,
assert(u);
if ((r = unit_load_fragment(u)) < 0)
return -ENOENT;
assert(u);
if ((r = unit_load_fragment(u)) < 0)
assert(u);
Iterator i;
assert(u);
assert(u);
return -EINVAL;
goto fail;
r = -ENOENT;
goto fail;
if ((r = unit_add_default_dependencies(u)) < 0)
goto fail;
fail:
assert(u);
return -EINVAL;
return -EALREADY;
return -EALREADY;
return -EBADR;
assert(u);
assert(u);
return unit_can_start(u) &&
assert(u);
return -EALREADY;
return -EBADR;
assert(u);
return -EINVAL;
if (!unit_can_reload(u))
return -EBADR;
return -EALREADY;
return -ENOEXEC;
assert(u);
Iterator i;
assert(u);
Iterator i;
assert(u);
Iterator i;
assert(u);
bool unexpected;
assert(u);
unexpected = false;
case JOB_START:
case JOB_VERIFY_ACTIVE:
unexpected = true;
case JOB_RELOAD:
case JOB_RELOAD_OR_START:
unexpected = true;
case JOB_STOP:
case JOB_RESTART:
case JOB_TRY_RESTART:
unexpected = true;
unexpected = true;
Iterator i;
log_open();
assert(u);
assert(w);
fd,
&ev) < 0)
return -errno;
assert(u);
assert(w);
assert(u);
assert(u);
bool ours;
assert(u);
assert(w);
ours = false;
ours = true;
return -errno;
if (delay <= 0) {
flags = 0;
goto fail;
goto fail;
fail:
if (ours)
return -errno;
assert(u);
assert(w);
assert(u);
case JOB_VERIFY_ACTIVE:
case JOB_START:
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:
assert(u);
u = unit_follow_merge(u);
if (u == other)
(d == UNIT_REQUIRES ||
d == UNIT_REQUIRES_OVERRIDABLE ||
d == UNIT_REQUISITE ||
d == UNIT_REQUISITE_OVERRIDABLE ||
d == UNIT_BIND_TO)) {
return -EINVAL;
if ((r = set_ensure_allocated(&u->meta.dependencies[d], trivial_hash_func, trivial_compare_func)) < 0)
if ((r = set_ensure_allocated(&other->meta.dependencies[inverse_table[d]], trivial_hash_func, trivial_compare_func)) < 0)
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)
goto fail;
if (add_reference) {
goto fail;
goto fail;
fail:
int unit_add_two_dependencies(Unit *u, UnitDependency d, UnitDependency e, Unit *other, bool add_reference) {
assert(u);
assert(u);
if (!name)
*p = NULL;
return name;
return NULL;
free(i);
return NULL;
int unit_add_dependency_by_name(Unit *u, UnitDependency d, const char *name, const char *path, bool add_reference) {
assert(u);
return -ENOMEM;
goto finish;
free(s);
int unit_add_two_dependencies_by_name(Unit *u, UnitDependency d, UnitDependency e, const char *name, const char *path, bool add_reference) {
assert(u);
return -ENOMEM;
goto finish;
free(s);
int unit_add_dependency_by_name_inverse(Unit *u, UnitDependency d, const char *name, const char *path, bool add_reference) {
assert(u);
return -ENOMEM;
goto finish;
free(s);
int unit_add_two_dependencies_by_name_inverse(Unit *u, UnitDependency d, UnitDependency e, const char *name, const char *path, bool add_reference) {
assert(u);
return -ENOMEM;
goto finish;
goto finish;
free(s);
int set_unit_path(const char *p) {
char *cwd, *c;
if (path_is_absolute(p)) {
if (!(c = strdup(p)))
return -ENOMEM;
return -errno;
return -ENOMEM;
r = -errno;
free(c);
assert(u);
return NULL;
return NULL;
free(e);
CGroupBonding *l;
assert(u);
assert(b);
if (!b->controller)
return -ENOMEM;
b->unit = u;
assert(u);
return NULL;
free(t);
return r < 0 ? NULL : p;
assert(u);
if (!path)
if (!controller)
return -ENOMEM;
r = -EEXIST;
goto fail;
r = -ENOMEM;
goto fail;
b->only_us = false;
b->clean_up = false;
if ((r = unit_add_cgroup(u, b)) < 0)
goto fail;
fail:
free(b);
CGroupBonding *b;
int r = -ENOMEM;
assert(u);
if (unit_get_default_cgroup(u))
return -ENOMEM;
goto fail;
b->clean_up = true;
b->only_us = true;
if ((r = unit_add_cgroup(u, b)) < 0)
goto fail;
fail:
free(b);
assert(u);
assert(u);
return -ENOMEM;
free(t);
assert(u);
return -ENOMEM;
free(t);
if (!found)
return -ENOENT;
assert(u);
assert(u);
assert(u);
return NULL;
r = unit_name_unescape(p);
free(p);
assert(u);
assert(u);
assert(u);
assert(u);
size_t n;
assert(u);
n = strv_length(l);
return NULL;
if (!(*j = unit_full_printf(u, *i)))
goto fail;
*j = NULL;
fail:
free(*j);
free(r);
return NULL;
assert(u);
assert(u);
assert(u);
assert(u);
assert(f);
if (!unit_can_serialize(u))
assert(u);
assert(f);
assert(u);
assert(f);
assert(u);
assert(f);
if (!unit_can_serialize(u))
size_t k;
if (feof(f))
return -errno;
assert(u);
if (!what)
return -ENOMEM;
free(e);
if (wants)
assert(u);
if ((r = manager_add_job(u->meta.manager, u->meta.deserialized_job, u, JOB_FAIL, false, NULL, NULL)) < 0)
assert(u);
assert(u);
assert(u);
assert(u);
return NULL;
assert(u);
assert(u);
UnitType t;
assert(n);
for (t = 0; t < _UNIT_TYPE_MAX; t++)
return _UNIT_TYPE_INVALID;
UnitType t;
t = unit_name_to_type(n);
if (t < 0 || t >= _UNIT_TYPE_MAX)
assert(u);
if (m == KILL_NONE)
return -ENOTSUP;