The UNIT() macro upcasts from specific unit types to the base Unit.
Use it everywhere, rather than accessing the 'meta' member directly.
a->directory_mode = 0755;
- a->meta.ignore_on_isolate = true;
+ UNIT(a)->ignore_on_isolate = true;
}
static void repeat_unmout(const char *path) {
/* If we reload/reexecute things we keep the mount point
* around */
if (a->where &&
- (a->meta.manager->exit_code != MANAGER_RELOAD &&
- a->meta.manager->exit_code != MANAGER_REEXECUTE))
+ (UNIT(a)->manager->exit_code != MANAGER_RELOAD &&
+ UNIT(a)->manager->exit_code != MANAGER_REEXECUTE))
repeat_unmout(a->where);
}
assert(a);
assert(m);
- if (a->meta.load_state != UNIT_LOADED ||
- m->meta.load_state != UNIT_LOADED)
+ if (UNIT(a)->load_state != UNIT_LOADED ||
+ UNIT(m)->load_state != UNIT_LOADED)
return 0;
if (!path_startswith(a->where, m->where))
assert(a);
- LIST_FOREACH(units_by_type, other, a->meta.manager->units_by_type[UNIT_MOUNT])
+ LIST_FOREACH(units_by_type, other, UNIT(a)->manager->units_by_type[UNIT_MOUNT])
if ((r = automount_add_one_mount_link(a, (Mount*) other)) < 0)
return r;
assert(a);
- if (a->meta.manager->running_as == MANAGER_SYSTEM) {
+ if (UNIT(a)->manager->running_as == MANAGER_SYSTEM) {
if ((r = unit_add_dependency_by_name(UNIT(a), UNIT_BEFORE, SPECIAL_BASIC_TARGET, NULL, true)) < 0)
return r;
char *e;
assert(a);
- if (a->meta.load_state != UNIT_LOADED)
+ if (UNIT(a)->load_state != UNIT_LOADED)
return 0;
if (path_equal(a->where, "/")) {
free(e);
if (!b) {
- log_error("%s's Where setting doesn't match unit name. Refusing.", a->meta.id);
+ log_error("%s's Where setting doesn't match unit name. Refusing.", UNIT(a)->id);
return -EINVAL;
}
if (r < 0)
return r;
- if (a->meta.default_dependencies)
+ if (UNIT(a)->default_dependencies)
if ((r = automount_add_default_dependencies(a)) < 0)
return r;
}
if (state != old_state)
log_debug("%s changed %s -> %s",
- a->meta.id,
+ UNIT(a)->id,
automount_state_to_string(old_state),
automount_state_to_string(state));
if (set_isempty(a->tokens))
return 0;
- if ((ioctl_fd = open_ioctl_fd(a->meta.manager->dev_autofs_fd, a->where, a->dev_id)) < 0) {
+ if ((ioctl_fd = open_ioctl_fd(UNIT(a)->manager->dev_autofs_fd, a->where, a->dev_id)) < 0) {
r = ioctl_fd;
goto fail;
}
* if you pass a positive status code here, the kernel will
* freeze! Yay! */
- if ((k = autofs_send_ready(a->meta.manager->dev_autofs_fd,
+ if ((k = autofs_send_ready(UNIT(a)->manager->dev_autofs_fd,
ioctl_fd,
token,
status)) < 0)
if (a->tokens)
set_clear(a->tokens);
- if ((dev_autofs_fd = open_dev_autofs(a->meta.manager)) < 0) {
+ if ((dev_autofs_fd = open_dev_autofs(UNIT(a)->manager)) < 0) {
r = dev_autofs_fd;
goto fail;
}
/* We don't take mount requests anymore if we are supposed to
* shut down anyway */
if (unit_pending_inactive(UNIT(a))) {
- log_debug("Suppressing automount request on %s since unit stop is scheduled.", a->meta.id);
+ log_debug("Suppressing automount request on %s since unit stop is scheduled.", UNIT(a)->id);
automount_send_ready(a, -EHOSTDOWN);
return;
}
/* Before we do anything, let's see if somebody is playing games with us? */
if (lstat(a->where, &st) < 0) {
- log_warning("%s failed to stat automount point: %m", a->meta.id);
+ log_warning("%s failed to stat automount point: %m", UNIT(a)->id);
goto fail;
}
if (!S_ISDIR(st.st_mode) || st.st_dev != a->dev_id)
- log_info("%s's automount point already active?", a->meta.id);
- else if ((r = manager_add_job(a->meta.manager, JOB_START, UNIT_DEREF(a->mount), JOB_REPLACE, true, &error, NULL)) < 0) {
- log_warning("%s failed to queue mount startup job: %s", a->meta.id, bus_error(&error, r));
+ log_info("%s's automount point already active?", UNIT(a)->id);
+ else if ((r = manager_add_job(UNIT(a)->manager, JOB_START, UNIT_DEREF(a->mount), JOB_REPLACE, true, &error, NULL)) < 0) {
+ log_warning("%s failed to queue mount startup job: %s", UNIT(a)->id, bus_error(&error, r));
goto fail;
}
/* Remove this unit from the chain of devices which share the
* same sysfs path. */
- first = hashmap_get(d->meta.manager->devices_by_sysfs, d->sysfs);
+ first = hashmap_get(UNIT(d)->manager->devices_by_sysfs, d->sysfs);
LIST_REMOVE(Device, same_sysfs, first, d);
if (first)
- hashmap_remove_and_replace(d->meta.manager->devices_by_sysfs, d->sysfs, first->sysfs, first);
+ hashmap_remove_and_replace(UNIT(d)->manager->devices_by_sysfs, d->sysfs, first->sysfs, first);
else
- hashmap_remove(d->meta.manager->devices_by_sysfs, d->sysfs);
+ hashmap_remove(UNIT(d)->manager->devices_by_sysfs, d->sysfs);
free(d->sysfs);
d->sysfs = NULL;
Device *d = DEVICE(u);
assert(d);
- assert(d->meta.load_state == UNIT_STUB);
+ assert(UNIT(d)->load_state == UNIT_STUB);
/* In contrast to all other unit types we timeout jobs waiting
* for devices by default. This is because they otherwise wait
* indefinitely for plugged in devices, something which cannot
* happen for the other units since their operations time out
* anyway. */
- d->meta.job_timeout = DEFAULT_TIMEOUT_USEC;
+ UNIT(d)->job_timeout = DEFAULT_TIMEOUT_USEC;
- d->meta.ignore_on_isolate = true;
- d->meta.ignore_on_snapshot = true;
+ UNIT(d)->ignore_on_isolate = true;
+ UNIT(d)->ignore_on_snapshot = true;
}
static void device_done(Unit *u) {
if (state != old_state)
log_debug("%s changed %s -> %s",
- d->meta.id,
+ UNIT(d)->id,
device_state_to_string(old_state),
device_state_to_string(state));
/* Make everybody follow the unit that's named after the sysfs path */
for (other = d->same_sysfs_next; other; other = other->same_sysfs_next)
- if (startswith(other->meta.id, "sys-"))
+ if (startswith(UNIT(other)->id, "sys-"))
return UNIT(other);
for (other = d->same_sysfs_prev; other; other = other->same_sysfs_prev) {
- if (startswith(other->meta.id, "sys-"))
+ if (startswith(UNIT(other)->id, "sys-"))
return UNIT(other);
first = other;
return 0;
}
- r = manager_load_unit(t->meta.manager, rvalue, NULL, NULL, &u);
+ r = manager_load_unit(UNIT(t)->manager, rvalue, NULL, NULL, &u);
if (r < 0) {
log_error("[%s:%u] Failed to load unit %s, ignoring: %s", filename, line, rvalue, bus_error(&error, r));
dbus_error_free(&error);
return 0;
}
- if ((r = manager_load_unit(t->meta.manager, rvalue, NULL, &error, &u)) < 0) {
+ if ((r = manager_load_unit(UNIT(t)->manager, rvalue, NULL, &error, &u)) < 0) {
log_error("[%s:%u] Failed to load unit %s, ignoring: %s", filename, line, rvalue, bus_error(&error, r));
dbus_error_free(&error);
return 0;
return 0;
}
- r = manager_load_unit(s->meta.manager, rvalue, NULL, &error, &x);
+ r = manager_load_unit(UNIT(s)->manager, rvalue, NULL, &error, &x);
if (r < 0) {
log_error("[%s:%u] Failed to load unit %s, ignoring: %s", filename, line, rvalue, bus_error(&error, r));
dbus_error_free(&error);
m->control_command_id = _MOUNT_EXEC_COMMAND_INVALID;
- m->meta.ignore_on_isolate = true;
+ UNIT(m)->ignore_on_isolate = true;
}
static void mount_unwatch_control_pid(Mount *m) {
/* Adds in links to other mount points that might lie below or
* above us in the hierarchy */
- LIST_FOREACH(units_by_type, other, m->meta.manager->units_by_type[UNIT_MOUNT]) {
+ LIST_FOREACH(units_by_type, other, UNIT(m)->manager->units_by_type[UNIT_MOUNT]) {
Mount *n = (Mount*) other;
MountParameters *pn;
if (n == m)
continue;
- if (n->meta.load_state != UNIT_LOADED)
+ if (UNIT(n)->load_state != UNIT_LOADED)
continue;
pn = get_mount_parameters_configured(n);
assert(m);
- LIST_FOREACH(units_by_type, other, m->meta.manager->units_by_type[UNIT_SWAP])
+ LIST_FOREACH(units_by_type, other, UNIT(m)->manager->units_by_type[UNIT_SWAP])
if ((r = swap_add_one_mount_link((Swap*) other, m)) < 0)
return r;
assert(m);
- LIST_FOREACH(units_by_type, other, m->meta.manager->units_by_type[UNIT_PATH])
+ LIST_FOREACH(units_by_type, other, UNIT(m)->manager->units_by_type[UNIT_PATH])
if ((r = path_add_one_mount_link((Path*) other, m)) < 0)
return r;
assert(m);
- LIST_FOREACH(units_by_type, other, m->meta.manager->units_by_type[UNIT_AUTOMOUNT])
+ LIST_FOREACH(units_by_type, other, UNIT(m)->manager->units_by_type[UNIT_AUTOMOUNT])
if ((r = automount_add_one_mount_link((Automount*) other, m)) < 0)
return r;
assert(m);
- LIST_FOREACH(units_by_type, other, m->meta.manager->units_by_type[UNIT_SOCKET])
+ LIST_FOREACH(units_by_type, other, UNIT(m)->manager->units_by_type[UNIT_SOCKET])
if ((r = socket_add_one_mount_link((Socket*) other, m)) < 0)
return r;
assert(m);
- if (m->meta.manager->running_as != MANAGER_SYSTEM)
+ if (UNIT(m)->manager->running_as != MANAGER_SYSTEM)
return 0;
if (!(p = get_mount_parameters_configured(m)))
automount ||
mount_test_option(p->options, "comment=systemd.mount") ||
mount_test_option(p->options, "x-systemd-mount") ||
- m->meta.manager->mount_auto;
+ UNIT(m)->manager->mount_auto;
if (mount_is_network(p)) {
target = SPECIAL_REMOTE_FS_TARGET;
after = SPECIAL_LOCAL_FS_PRE_TARGET;
}
- if ((r = manager_load_unit(m->meta.manager, target, NULL, NULL, &tu)) < 0)
+ if ((r = manager_load_unit(UNIT(m)->manager, target, NULL, NULL, &tu)) < 0)
return r;
if (after)
if (!(name = unit_name_from_path_instance("fsck", p->what, ".service")))
return -ENOMEM;
- if ((r = manager_load_unit_prepare(m->meta.manager, name, NULL, NULL, &fsck)) < 0) {
+ if ((r = manager_load_unit_prepare(UNIT(m)->manager, name, NULL, NULL, &fsck)) < 0) {
log_warning("Failed to prepare unit %s: %s", name, strerror(-r));
free(name);
return r;
assert(m);
- if (m->meta.manager->running_as != MANAGER_SYSTEM)
+ if (UNIT(m)->manager->running_as != MANAGER_SYSTEM)
return 0;
p = get_mount_parameters_configured(m);
return r;
}
- SET_FOREACH(other, m->meta.dependencies[UNIT_AFTER], i) {
+ SET_FOREACH(other, UNIT(m)->dependencies[UNIT_AFTER], i) {
if (other->type != UNIT_DEVICE)
continue;
char *e;
assert(m);
- if (m->meta.load_state != UNIT_LOADED)
+ if (UNIT(m)->load_state != UNIT_LOADED)
return 0;
if (!m->from_etc_fstab && !m->from_fragment && !m->from_proc_self_mountinfo)
free(e);
if (!b) {
- log_error("%s's Where setting doesn't match unit name. Refusing.", m->meta.id);
+ log_error("%s's Where setting doesn't match unit name. Refusing.", UNIT(m)->id);
return -EINVAL;
}
return -EINVAL;
}
- if (m->meta.fragment_path && !m->parameters_fragment.what) {
- log_error("%s's What setting is missing. Refusing.", m->meta.id);
+ if (UNIT(m)->fragment_path && !m->parameters_fragment.what) {
+ log_error("%s's What setting is missing. Refusing.", UNIT(m)->id);
return -EBADMSG;
}
if (m->exec_context.pam_name && m->exec_context.kill_mode != KILL_CONTROL_GROUP) {
- log_error("%s has PAM enabled. Kill mode must be set to 'control-group'. Refusing.", m->meta.id);
+ log_error("%s has PAM enabled. Kill mode must be set to 'control-group'. Refusing.", UNIT(m)->id);
return -EINVAL;
}
if ((r = unit_add_exec_dependencies(u, &m->exec_context)) < 0)
return r;
- if (m->meta.fragment_path)
+ if (UNIT(m)->fragment_path)
m->from_fragment = true;
if (!m->where)
path_kill_slashes(m->where);
- if (!m->meta.description)
+ if (!UNIT(m)->description)
if ((r = unit_set_description(u, m->where)) < 0)
return r;
if ((r = mount_add_fstab_links(m)) < 0)
return r;
- if (m->meta.default_dependencies)
+ if (UNIT(m)->default_dependencies)
if ((r = mount_add_default_dependencies(m)) < 0)
return r;
assert(m);
- SET_FOREACH(p, m->meta.dependencies[UNIT_TRIGGERED_BY], i)
+ SET_FOREACH(p, UNIT(m)->dependencies[UNIT_TRIGGERED_BY], i)
if (p->type == UNIT_AUTOMOUNT) {
r = automount_send_ready(AUTOMOUNT(p), status);
if (r < 0)
if (state != old_state)
log_debug("%s changed %s -> %s",
- m->meta.id,
+ UNIT(m)->id,
mount_state_to_string(old_state),
mount_state_to_string(state));
NULL,
&m->exec_context,
NULL, 0,
- m->meta.manager->environment,
+ UNIT(m)->manager->environment,
true,
true,
true,
- m->meta.manager->confirm_spawn,
- m->meta.cgroup_bondings,
- m->meta.cgroup_attributes,
+ UNIT(m)->manager->confirm_spawn,
+ UNIT(m)->cgroup_bondings,
+ UNIT(m)->cgroup_attributes,
&pid)) < 0)
goto fail;
if ((r = set_put(pid_set, LONG_TO_PTR(m->control_pid))) < 0)
goto fail;
- if ((r = cgroup_bonding_kill_list(m->meta.cgroup_bondings, sig, true, pid_set)) < 0) {
+ if ((r = cgroup_bonding_kill_list(UNIT(m)->cgroup_bondings, sig, true, pid_set)) < 0) {
if (r != -EAGAIN && r != -ESRCH && r != -ENOENT)
log_warning("Failed to kill control group: %s", strerror(-r));
} else if (r > 0)
return;
fail:
- log_warning("%s failed to kill processes: %s", m->meta.id, strerror(-r));
+ log_warning("%s failed to kill processes: %s", UNIT(m)->id, strerror(-r));
if (state == MOUNT_REMOUNTING_SIGTERM || state == MOUNT_REMOUNTING_SIGKILL)
mount_enter_mounted(m, false);
return;
fail:
- log_warning("%s failed to run 'umount' task: %s", m->meta.id, strerror(-r));
+ log_warning("%s failed to run 'umount' task: %s", UNIT(m)->id, strerror(-r));
mount_enter_mounted(m, false);
}
return;
fail:
- log_warning("%s failed to run 'mount' task: %s", m->meta.id, strerror(-r));
+ log_warning("%s failed to run 'mount' task: %s", UNIT(m)->id, strerror(-r));
mount_enter_dead(m, false);
}
return;
fail:
- log_warning("%s failed to run 'remount' task: %s", m->meta.id, strerror(-r));
+ log_warning("%s failed to run 'remount' task: %s", UNIT(m)->id, strerror(-r));
m->reload_failure = true;
mount_enter_mounted(m, true);
}
goto finish;
}
- if ((q = cgroup_bonding_kill_list(m->meta.cgroup_bondings, signo, false, pid_set)) < 0)
+ if ((q = cgroup_bonding_kill_list(UNIT(m)->cgroup_bondings, signo, false, pid_set)) < 0)
if (q != -EAGAIN && q != -ESRCH && q != -ENOENT)
r = q;
}
assert(p);
assert(m);
- if (p->meta.load_state != UNIT_LOADED ||
- m->meta.load_state != UNIT_LOADED)
+ if (UNIT(p)->load_state != UNIT_LOADED ||
+ UNIT(m)->load_state != UNIT_LOADED)
return 0;
LIST_FOREACH(spec, s, p->specs) {
assert(p);
- LIST_FOREACH(units_by_type, other, p->meta.manager->units_by_type[UNIT_MOUNT])
+ LIST_FOREACH(units_by_type, other, UNIT(p)->manager->units_by_type[UNIT_MOUNT])
if ((r = path_add_one_mount_link(p, (Mount*) other)) < 0)
return r;
static int path_verify(Path *p) {
assert(p);
- if (p->meta.load_state != UNIT_LOADED)
+ if (UNIT(p)->load_state != UNIT_LOADED)
return 0;
if (!p->specs) {
- log_error("%s lacks path setting. Refusing.", p->meta.id);
+ log_error("%s lacks path setting. Refusing.", UNIT(p)->id);
return -EINVAL;
}
assert(p);
- if (p->meta.manager->running_as == MANAGER_SYSTEM) {
+ if (UNIT(p)->manager->running_as == MANAGER_SYSTEM) {
if ((r = unit_add_dependency_by_name(UNIT(p), UNIT_BEFORE, SPECIAL_BASIC_TARGET, NULL, true)) < 0)
return r;
if ((r = path_add_mount_links(p)) < 0)
return r;
- if (p->meta.default_dependencies)
+ if (UNIT(p)->default_dependencies)
if ((r = path_add_default_dependencies(p)) < 0)
return r;
}
if (state != old_state)
log_debug("%s changed %s -> %s",
- p->meta.id,
+ UNIT(p)->id,
path_state_to_string(old_state),
path_state_to_string(state));
dbus_error_init(&error);
/* Don't start job if we are supposed to go down */
- if (p->meta.job && p->meta.job->type == JOB_STOP)
+ if (UNIT(p)->job && UNIT(p)->job->type == JOB_STOP)
return;
- if ((r = manager_add_job(p->meta.manager, JOB_START, UNIT_DEREF(p->unit), JOB_REPLACE, true, &error, NULL)) < 0)
+ if ((r = manager_add_job(UNIT(p)->manager, JOB_START, UNIT_DEREF(p->unit), JOB_REPLACE, true, &error, NULL)) < 0)
goto fail;
p->inotify_triggered = false;
return;
fail:
- log_warning("%s failed to queue unit startup job: %s", p->meta.id, bus_error(&error, r));
+ log_warning("%s failed to queue unit startup job: %s", UNIT(p)->id, bus_error(&error, r));
path_enter_dead(p, false);
dbus_error_free(&error);
if (recheck)
if (path_check_good(p, initial)) {
- log_debug("%s got triggered.", p->meta.id);
+ log_debug("%s got triggered.", UNIT(p)->id);
path_enter_running(p);
return;
}
if (recheck)
if (path_check_good(p, false)) {
- log_debug("%s got triggered.", p->meta.id);
+ log_debug("%s got triggered.", UNIT(p)->id);
path_enter_running(p);
return;
}
return;
fail:
- log_warning("%s failed to enter waiting state: %s", p->meta.id, strerror(-r));
+ log_warning("%s failed to enter waiting state: %s", UNIT(p)->id, strerror(-r));
path_enter_dead(p, false);
}
p = PATH(k);
if (p->state == PATH_RUNNING && new_state == UNIT_INACTIVE) {
- log_debug("%s got notified about unit deactivation.", p->meta.id);
+ log_debug("%s got notified about unit deactivation.", UNIT(p)->id);
/* Hmm, so inotify was triggered since the
* last activation, so I guess we need to
if (get_parent_of_pid(pid, &ppid) >= 0 && ppid != getpid()) {
log_warning("%s: Supervising process %lu which is not our child. We'll most likely not notice when it exits.",
- s->meta.id, (unsigned long) pid);
+ UNIT(s)->id, (unsigned long) pid);
s->main_pid_alien = true;
} else
/* For each pair of services where at least one lacks a LSB
* header, we use the start priority value to order things. */
- LIST_FOREACH(units_by_type, other, s->meta.manager->units_by_type[UNIT_SERVICE]) {
+ LIST_FOREACH(units_by_type, other, UNIT(s)->manager->units_by_type[UNIT_SERVICE]) {
Service *t;
UnitDependency d;
bool special_s, special_t;
if (s == t)
continue;
- if (t->meta.load_state != UNIT_LOADED)
+ if (UNIT(t)->load_state != UNIT_LOADED)
continue;
if (t->sysv_start_priority < 0)
/* If both units have modern headers we don't care
* about the priorities */
- if ((s->meta.fragment_path || s->sysv_has_lsb) &&
- (t->meta.fragment_path || t->sysv_has_lsb))
+ if ((UNIT(s)->fragment_path || s->sysv_has_lsb) &&
+ (UNIT(t)->fragment_path || t->sysv_has_lsb))
continue;
special_s = s->sysv_runlevels && !chars_intersect(RUNLEVELS_UP, s->sysv_runlevels);
* needed for early boot) and don't create any links
* to it. */
- s->meta.default_dependencies = false;
+ UNIT(s)->default_dependencies = false;
/* Don't timeout special services during boot (like fsck) */
s->timeout_usec = 0;
s->guess_main_pid = false;
s->restart = SERVICE_RESTART_NO;
- if (s->meta.manager->sysv_console)
+ if (UNIT(s)->manager->sysv_console)
s->exec_context.std_output = EXEC_OUTPUT_JOURNAL_AND_CONSOLE;
s->exec_context.kill_mode = KILL_PROCESS;
return -ENOENT;
#endif
- STRV_FOREACH(p, s->meta.manager->lookup_paths.sysvinit_path) {
+ STRV_FOREACH(p, UNIT(s)->manager->lookup_paths.sysvinit_path) {
char *path;
int r;
r = service_load_sysv_path(s, path);
#if defined(TARGET_DEBIAN) || defined(TARGET_UBUNTU) || defined(TARGET_ANGSTROM)
- if (r >= 0 && s->meta.load_state == UNIT_STUB) {
+ if (r >= 0 && UNIT(s)->load_state == UNIT_STUB) {
/* Try Debian style *.sh source'able init scripts */
strcat(path, ".sh");
r = service_load_sysv_path(s, path);
free(path);
#ifdef TARGET_SUSE
- if (r >= 0 && s->meta.load_state == UNIT_STUB) {
+ if (r >= 0 && UNIT(s)->load_state == UNIT_STUB) {
/* Try SUSE style boot.* init scripts */
path = join(*p, "/boot.", name, NULL);
#endif
#ifdef TARGET_FRUGALWARE
- if (r >= 0 && s->meta.load_state == UNIT_STUB) {
+ if (r >= 0 && UNIT(s)->load_state == UNIT_STUB) {
/* Try Frugalware style rc.* init scripts */
path = join(*p, "/rc.", name, NULL);
if (r < 0)
return r;
- if ((s->meta.load_state != UNIT_STUB))
+ if ((UNIT(s)->load_state != UNIT_STUB))
break;
}
/* Load service data from SysV init scripts, preferably with
* LSB headers ... */
- if (strv_isempty(s->meta.manager->lookup_paths.sysvinit_path))
+ if (strv_isempty(UNIT(s)->manager->lookup_paths.sysvinit_path))
return 0;
- if ((t = s->meta.id))
+ if ((t = UNIT(s)->id))
if ((r = service_load_sysv_name(s, t)) < 0)
return r;
- if (s->meta.load_state == UNIT_STUB)
- SET_FOREACH(t, s->meta.names, i) {
- if (t == s->meta.id)
+ if (UNIT(s)->load_state == UNIT_STUB)
+ SET_FOREACH(t, UNIT(s)->names, i) {
+ if (t == UNIT(s)->id)
continue;
if ((r = service_load_sysv_name(s, t)) < 0)
return r;
- if (s->meta.load_state != UNIT_STUB)
+ if (UNIT(s)->load_state != UNIT_STUB)
break;
}
/* For each pair of services where both have an fsck priority
* we order things based on it. */
- LIST_FOREACH(units_by_type, other, s->meta.manager->units_by_type[UNIT_SERVICE]) {
+ LIST_FOREACH(units_by_type, other, UNIT(s)->manager->units_by_type[UNIT_SERVICE]) {
Service *t;
UnitDependency d;
if (s == t)
continue;
- if (t->meta.load_state != UNIT_LOADED)
+ if (UNIT(t)->load_state != UNIT_LOADED)
continue;
if (t->fsck_passno <= 0)
static int service_verify(Service *s) {
assert(s);
- if (s->meta.load_state != UNIT_LOADED)
+ if (UNIT(s)->load_state != UNIT_LOADED)
return 0;
if (!s->exec_command[SERVICE_EXEC_START]) {
- log_error("%s lacks ExecStart setting. Refusing.", s->meta.id);
+ log_error("%s lacks ExecStart setting. Refusing.", UNIT(s)->id);
return -EINVAL;
}
if (s->type != SERVICE_ONESHOT &&
s->exec_command[SERVICE_EXEC_START]->command_next) {
- log_error("%s has more than one ExecStart setting, which is only allowed for Type=oneshot services. Refusing.", s->meta.id);
+ log_error("%s has more than one ExecStart setting, which is only allowed for Type=oneshot services. Refusing.", UNIT(s)->id);
return -EINVAL;
}
if (s->type == SERVICE_ONESHOT &&
s->exec_command[SERVICE_EXEC_RELOAD]) {
- log_error("%s has an ExecReload setting, which is not allowed for Type=oneshot services. Refusing.", s->meta.id);
+ log_error("%s has an ExecReload setting, which is not allowed for Type=oneshot services. Refusing.", UNIT(s)->id);
return -EINVAL;
}
if (s->type == SERVICE_DBUS && !s->bus_name) {
- log_error("%s is of type D-Bus but no D-Bus service name has been specified. Refusing.", s->meta.id);
+ log_error("%s is of type D-Bus but no D-Bus service name has been specified. Refusing.", UNIT(s)->id);
return -EINVAL;
}
if (s->exec_context.pam_name && s->exec_context.kill_mode != KILL_CONTROL_GROUP) {
- log_error("%s has PAM enabled. Kill mode must be set to 'control-group'. Refusing.", s->meta.id);
+ log_error("%s has PAM enabled. Kill mode must be set to 'control-group'. Refusing.", UNIT(s)->id);
return -EINVAL;
}
* majority of services. */
/* First, pull in base system */
- if (s->meta.manager->running_as == MANAGER_SYSTEM) {
+ if (UNIT(s)->manager->running_as == MANAGER_SYSTEM) {
if ((r = unit_add_two_dependencies_by_name(UNIT(s), UNIT_AFTER, UNIT_REQUIRES, SPECIAL_BASIC_TARGET, NULL, true)) < 0)
return r;
- } else if (s->meta.manager->running_as == MANAGER_USER) {
+ } else if (UNIT(s)->manager->running_as == MANAGER_USER) {
if ((r = unit_add_two_dependencies_by_name(UNIT(s), UNIT_AFTER, UNIT_REQUIRES, SPECIAL_SOCKETS_TARGET, NULL, true)) < 0)
return r;
if (s->exec_context.std_error == EXEC_OUTPUT_INHERIT &&
s->exec_context.std_output == EXEC_OUTPUT_INHERIT &&
s->exec_context.std_input == EXEC_INPUT_NULL)
- s->exec_context.std_error = s->meta.manager->default_std_error;
+ s->exec_context.std_error = UNIT(s)->manager->default_std_error;
if (s->exec_context.std_output == EXEC_OUTPUT_INHERIT &&
s->exec_context.std_input == EXEC_INPUT_NULL)
- s->exec_context.std_output = s->meta.manager->default_std_output;
+ s->exec_context.std_output = UNIT(s)->manager->default_std_output;
}
static int service_load(Unit *u) {
if ((r = unit_add_two_dependencies_by_name(u, UNIT_AFTER, UNIT_REQUIRES, SPECIAL_DBUS_SOCKET, NULL, true)) < 0)
return r;
- if (s->meta.default_dependencies)
+ if (UNIT(s)->default_dependencies)
if ((r = service_add_default_dependencies(s)) < 0)
return r;
}
assert(s->main_pid <= 0);
- if ((pid = cgroup_bonding_search_main_pid_list(s->meta.cgroup_bondings)) <= 0)
+ if ((pid = cgroup_bonding_search_main_pid_list(UNIT(s)->cgroup_bondings)) <= 0)
return -ENOENT;
log_debug("Main PID guessed: %lu", (unsigned long) pid);
if (s->socket_fd >= 0)
return;
- SET_FOREACH(u, s->meta.dependencies[UNIT_TRIGGERED_BY], i)
+ SET_FOREACH(u, UNIT(s)->dependencies[UNIT_TRIGGERED_BY], i)
if (u->type == UNIT_SOCKET)
socket_notify_service_dead(SOCKET(u));
if (!s->pid_file_pathspec)
return;
- log_debug("Stopping watch for %s's PID file %s", s->meta.id, s->pid_file_pathspec->path);
+ log_debug("Stopping watch for %s's PID file %s", UNIT(s)->id, s->pid_file_pathspec->path);
path_spec_unwatch(s->pid_file_pathspec, UNIT(s));
path_spec_done(s->pid_file_pathspec);
free(s->pid_file_pathspec);
state != SERVICE_STOP_POST &&
state != SERVICE_FINAL_SIGTERM &&
state != SERVICE_FINAL_SIGKILL &&
- !(state == SERVICE_DEAD && s->meta.job)) {
+ !(state == SERVICE_DEAD && UNIT(s)->job)) {
service_close_socket_fd(s);
service_connection_unref(s);
}
/* For the inactive states unit_notify() will trim the cgroup,
* but for exit we have to do that ourselves... */
- if (state == SERVICE_EXITED && s->meta.manager->n_reloading <= 0)
- cgroup_bonding_trim_list(s->meta.cgroup_bondings, true);
+ if (state == SERVICE_EXITED && UNIT(s)->manager->n_reloading <= 0)
+ cgroup_bonding_trim_list(UNIT(s)->cgroup_bondings, true);
if (old_state != state)
- log_debug("%s changed %s -> %s", s->meta.id, service_state_to_string(old_state), service_state_to_string(state));
+ log_debug("%s changed %s -> %s", UNIT(s)->id, service_state_to_string(old_state), service_state_to_string(state));
unit_notify(UNIT(s), state_translation_table[old_state], state_translation_table[state], !s->reload_failure);
s->reload_failure = false;
if (s->socket_fd >= 0)
return 0;
- SET_FOREACH(u, s->meta.dependencies[UNIT_TRIGGERED_BY], i) {
+ SET_FOREACH(u, UNIT(s)->dependencies[UNIT_TRIGGERED_BY], i) {
int *cfds;
unsigned cn_fds;
Socket *sock;
}
if (set_notify_socket)
- if (asprintf(our_env + n_env++, "NOTIFY_SOCKET=%s", s->meta.manager->notify_socket) < 0) {
+ if (asprintf(our_env + n_env++, "NOTIFY_SOCKET=%s", UNIT(s)->manager->notify_socket) < 0) {
r = -ENOMEM;
goto fail;
}
}
if (!(final_env = strv_env_merge(2,
- s->meta.manager->environment,
+ UNIT(s)->manager->environment,
our_env,
NULL))) {
r = -ENOMEM;
apply_permissions,
apply_chroot,
apply_tty_stdin,
- s->meta.manager->confirm_spawn,
- s->meta.cgroup_bondings,
- s->meta.cgroup_attributes,
+ UNIT(s)->manager->confirm_spawn,
+ UNIT(s)->cgroup_bondings,
+ UNIT(s)->cgroup_attributes,
&pid);
if (r < 0)
assert(s);
- if ((r = cgroup_bonding_is_empty_list(s->meta.cgroup_bondings)) < 0)
+ if ((r = cgroup_bonding_is_empty_list(UNIT(s)->cgroup_bondings)) < 0)
return r;
return !r;
return;
fail:
- log_warning("%s failed to run install restart timer: %s", s->meta.id, strerror(-r));
+ log_warning("%s failed to run install restart timer: %s", UNIT(s)->id, strerror(-r));
service_enter_dead(s, false, false);
}
return;
fail:
- log_warning("%s failed to run 'stop-post' task: %s", s->meta.id, strerror(-r));
+ log_warning("%s failed to run 'stop-post' task: %s", UNIT(s)->id, strerror(-r));
service_enter_signal(s, SERVICE_FINAL_SIGTERM, false);
}
if ((r = set_put(pid_set, LONG_TO_PTR(s->control_pid))) < 0)
goto fail;
- if ((r = cgroup_bonding_kill_list(s->meta.cgroup_bondings, sig, true, pid_set)) < 0) {
+ if ((r = cgroup_bonding_kill_list(UNIT(s)->cgroup_bondings, sig, true, pid_set)) < 0) {
if (r != -EAGAIN && r != -ESRCH && r != -ENOENT)
log_warning("Failed to kill control group: %s", strerror(-r));
} else if (r > 0)
return;
fail:
- log_warning("%s failed to kill processes: %s", s->meta.id, strerror(-r));
+ log_warning("%s failed to kill processes: %s", UNIT(s)->id, strerror(-r));
if (state == SERVICE_STOP_SIGTERM || state == SERVICE_STOP_SIGKILL)
service_enter_stop_post(s, false);
return;
fail:
- log_warning("%s failed to run 'stop' task: %s", s->meta.id, strerror(-r));
+ log_warning("%s failed to run 'stop' task: %s", UNIT(s)->id, strerror(-r));
service_enter_signal(s, SERVICE_STOP_SIGTERM, false);
}
return;
fail:
- log_warning("%s failed to run 'start-post' task: %s", s->meta.id, strerror(-r));
+ log_warning("%s failed to run 'start-post' task: %s", UNIT(s)->id, strerror(-r));
service_enter_stop(s, false);
}
/* We want to ensure that nobody leaks processes from
* START_PRE here, so let's go on a killing spree, People
* should not spawn long running processes from START_PRE. */
- cgroup_bonding_kill_list(s->meta.cgroup_bondings, SIGKILL, true, NULL);
+ cgroup_bonding_kill_list(UNIT(s)->cgroup_bondings, SIGKILL, true, NULL);
if (s->type == SERVICE_FORKING) {
s->control_command_id = SERVICE_EXEC_START;
return;
fail:
- log_warning("%s failed to run 'start' task: %s", s->meta.id, strerror(-r));
+ log_warning("%s failed to run 'start' task: %s", UNIT(s)->id, strerror(-r));
service_enter_signal(s, SERVICE_FINAL_SIGTERM, false);
}
/* Before we start anything, let's clear up what might
* be left from previous runs. */
- cgroup_bonding_kill_list(s->meta.cgroup_bondings, SIGKILL, true, NULL);
+ cgroup_bonding_kill_list(UNIT(s)->cgroup_bondings, SIGKILL, true, NULL);
s->control_command_id = SERVICE_EXEC_START_PRE;
return;
fail:
- log_warning("%s failed to run 'start-pre' task: %s", s->meta.id, strerror(-r));
+ log_warning("%s failed to run 'start-pre' task: %s", UNIT(s)->id, strerror(-r));
service_enter_dead(s, false, true);
}
assert(s);
dbus_error_init(&error);
- if (s->meta.job) {
+ if (UNIT(s)->job) {
log_info("Job pending for unit, delaying automatic restart.");
if ((r = unit_watch_timer(UNIT(s), s->restart_usec, &s->timer_watch)) < 0)
service_enter_dead(s, true, false);
- if ((r = manager_add_job(s->meta.manager, JOB_START, UNIT(s), JOB_FAIL, false, &error, NULL)) < 0)
+ if ((r = manager_add_job(UNIT(s)->manager, JOB_START, UNIT(s), JOB_FAIL, false, &error, NULL)) < 0)
goto fail;
- log_debug("%s scheduled restart job.", s->meta.id);
+ log_debug("%s scheduled restart job.", UNIT(s)->id);
return;
fail:
- log_warning("%s failed to schedule restart job: %s", s->meta.id, bus_error(&error, -r));
+ log_warning("%s failed to schedule restart job: %s", UNIT(s)->id, bus_error(&error, -r));
service_enter_dead(s, false, false);
dbus_error_free(&error);
return;
fail:
- log_warning("%s failed to run 'reload' task: %s", s->meta.id, strerror(-r));
+ log_warning("%s failed to run 'reload' task: %s", UNIT(s)->id, strerror(-r));
s->reload_failure = true;
service_enter_running(s, true);
}
return;
fail:
- log_warning("%s failed to run next control task: %s", s->meta.id, strerror(-r));
+ log_warning("%s failed to run next control task: %s", UNIT(s)->id, strerror(-r));
if (s->state == SERVICE_START_PRE)
service_enter_signal(s, SERVICE_FINAL_SIGTERM, false);
return;
fail:
- log_warning("%s failed to run next main task: %s", s->meta.id, strerror(-r));
+ log_warning("%s failed to run next main task: %s", UNIT(s)->id, strerror(-r));
service_enter_stop(s, false);
}
static int service_watch_pid_file(Service *s) {
int r;
- log_debug("Setting watch for %s's PID file %s", s->meta.id, s->pid_file_pathspec->path);
+ log_debug("Setting watch for %s's PID file %s", UNIT(s)->id, s->pid_file_pathspec->path);
r = path_spec_watch(s->pid_file_pathspec, UNIT(s));
if (r < 0)
goto fail;
return 0;
fail:
log_error("Failed to set a watch for %s's PID file %s: %s",
- s->meta.id, s->pid_file_pathspec->path, strerror(-r));
+ UNIT(s)->id, s->pid_file_pathspec->path, strerror(-r));
service_unwatch_pid_file(s);
return r;
}
assert(s);
assert(pid >= 0);
- if (!s->meta.fragment_path)
+ if (!UNIT(s)->fragment_path)
success = is_clean_exit_lsb(code, status);
else
success = is_clean_exit(code, status);
/* If we were hoping for the daemon to write its PID file,
* we can give up now. */
if (s->pid_file_pathspec) {
- log_warning("%s never wrote its PID file. Failing.", s->meta.id);
+ log_warning("%s never wrote its PID file. Failing.", UNIT(s)->id);
service_unwatch_pid_file(s);
if (s->state == SERVICE_START)
service_enter_signal(s, SERVICE_FINAL_SIGTERM, false);
* service for a stream socket and the socket needs to be
* configured. */
- if (s->meta.load_state != UNIT_LOADED)
+ if (UNIT(s)->load_state != UNIT_LOADED)
return -EINVAL;
if (s->socket_fd >= 0)
goto finish;
}
- if ((q = cgroup_bonding_kill_list(s->meta.cgroup_bondings, signo, false, pid_set)) < 0)
+ if ((q = cgroup_bonding_kill_list(UNIT(s)->cgroup_bondings, signo, false, pid_set)) < 0)
if (q != -EAGAIN && q != -ESRCH && q != -ENOENT)
r = q;
}
Snapshot *s = SNAPSHOT(u);
assert(s);
- assert(s->meta.load_state == UNIT_STUB);
+ assert(UNIT(s)->load_state == UNIT_STUB);
- s->meta.ignore_on_isolate = true;
- s->meta.ignore_on_snapshot = true;
+ UNIT(s)->ignore_on_isolate = true;
+ UNIT(s)->ignore_on_snapshot = true;
}
static void snapshot_set_state(Snapshot *s, SnapshotState state) {
if (state != old_state)
log_debug("%s changed %s -> %s",
- s->meta.id,
+ UNIT(s)->id,
snapshot_state_to_string(old_state),
snapshot_state_to_string(state));
/* Make sure that only snapshots created via snapshot_create()
* can be loaded */
- if (!s->by_snapshot_create && s->meta.manager->n_reloading <= 0)
+ if (!s->by_snapshot_create && UNIT(s)->manager->n_reloading <= 0)
return -ENOENT;
u->load_state = UNIT_LOADED;
assert(s->accept);
- if (!(prefix = unit_name_to_prefix(s->meta.id)))
+ if (!(prefix = unit_name_to_prefix(UNIT(s)->id)))
return -ENOMEM;
r = asprintf(&name, "%s@%u.service", prefix, s->n_accepted);
if (r < 0)
return -ENOMEM;
- r = manager_load_unit(s->meta.manager, name, NULL, NULL, &u);
+ r = manager_load_unit(UNIT(s)->manager, name, NULL, NULL, &u);
free(name);
if (r < 0)
static int socket_verify(Socket *s) {
assert(s);
- if (s->meta.load_state != UNIT_LOADED)
+ if (UNIT(s)->load_state != UNIT_LOADED)
return 0;
if (!s->ports) {
- log_error("%s lacks Listen setting. Refusing.", s->meta.id);
+ log_error("%s lacks Listen setting. Refusing.", UNIT(s)->id);
return -EINVAL;
}
if (s->accept && have_non_accept_socket(s)) {
- log_error("%s configured for accepting sockets, but sockets are non-accepting. Refusing.", s->meta.id);
+ log_error("%s configured for accepting sockets, but sockets are non-accepting. Refusing.", UNIT(s)->id);
return -EINVAL;
}
if (s->accept && s->max_connections <= 0) {
- log_error("%s's MaxConnection setting too small. Refusing.", s->meta.id);
+ log_error("%s's MaxConnection setting too small. Refusing.", UNIT(s)->id);
return -EINVAL;
}
if (s->accept && UNIT_DEREF(s->service)) {
- log_error("Explicit service configuration for accepting sockets not supported on %s. Refusing.", s->meta.id);
+ log_error("Explicit service configuration for accepting sockets not supported on %s. Refusing.", UNIT(s)->id);
return -EINVAL;
}
if (s->exec_context.pam_name && s->exec_context.kill_mode != KILL_CONTROL_GROUP) {
- log_error("%s has PAM enabled. Kill mode must be set to 'control-group'. Refusing.", s->meta.id);
+ log_error("%s has PAM enabled. Kill mode must be set to 'control-group'. Refusing.", UNIT(s)->id);
return -EINVAL;
}
assert(s);
assert(m);
- if (s->meta.load_state != UNIT_LOADED ||
- m->meta.load_state != UNIT_LOADED)
+ if (UNIT(s)->load_state != UNIT_LOADED ||
+ UNIT(m)->load_state != UNIT_LOADED)
return 0;
if (!socket_needs_mount(s, m->where))
assert(s);
- LIST_FOREACH(units_by_type, other, s->meta.manager->units_by_type[UNIT_MOUNT])
+ LIST_FOREACH(units_by_type, other, UNIT(s)->manager->units_by_type[UNIT_MOUNT])
if ((r = socket_add_one_mount_link(s, (Mount*) other)) < 0)
return r;
int r;
assert(s);
- if (s->meta.manager->running_as == MANAGER_SYSTEM) {
+ if (UNIT(s)->manager->running_as == MANAGER_SYSTEM) {
if ((r = unit_add_dependency_by_name(UNIT(s), UNIT_BEFORE, SPECIAL_SOCKETS_TARGET, NULL, true)) < 0)
return r;
if ((r = unit_add_default_cgroups(u)) < 0)
return r;
- if (s->meta.default_dependencies)
+ if (UNIT(s)->default_dependencies)
if ((r = socket_add_default_dependencies(s)) < 0)
return r;
}
if (state != old_state)
log_debug("%s changed %s -> %s",
- s->meta.id,
+ UNIT(s)->id,
socket_state_to_string(old_state),
socket_state_to_string(state));
argv,
&s->exec_context,
NULL, 0,
- s->meta.manager->environment,
+ UNIT(s)->manager->environment,
true,
true,
true,
- s->meta.manager->confirm_spawn,
- s->meta.cgroup_bondings,
- s->meta.cgroup_attributes,
+ UNIT(s)->manager->confirm_spawn,
+ UNIT(s)->cgroup_bondings,
+ UNIT(s)->cgroup_attributes,
&pid);
strv_free(argv);
return;
fail:
- log_warning("%s failed to run 'stop-post' task: %s", s->meta.id, strerror(-r));
+ log_warning("%s failed to run 'stop-post' task: %s", UNIT(s)->id, strerror(-r));
socket_enter_signal(s, SOCKET_FINAL_SIGTERM, false);
}
if ((r = set_put(pid_set, LONG_TO_PTR(s->control_pid))) < 0)
goto fail;
- if ((r = cgroup_bonding_kill_list(s->meta.cgroup_bondings, sig, true, pid_set)) < 0) {
+ if ((r = cgroup_bonding_kill_list(UNIT(s)->cgroup_bondings, sig, true, pid_set)) < 0) {
if (r != -EAGAIN && r != -ESRCH && r != -ENOENT)
log_warning("Failed to kill control group: %s", strerror(-r));
} else if (r > 0)
return;
fail:
- log_warning("%s failed to kill processes: %s", s->meta.id, strerror(-r));
+ log_warning("%s failed to kill processes: %s", UNIT(s)->id, strerror(-r));
if (state == SOCKET_STOP_PRE_SIGTERM || state == SOCKET_STOP_PRE_SIGKILL)
socket_enter_stop_post(s, false);
return;
fail:
- log_warning("%s failed to run 'stop-pre' task: %s", s->meta.id, strerror(-r));
+ log_warning("%s failed to run 'stop-pre' task: %s", UNIT(s)->id, strerror(-r));
socket_enter_stop_post(s, false);
}
assert(s);
if ((r = socket_watch_fds(s)) < 0) {
- log_warning("%s failed to watch sockets: %s", s->meta.id, strerror(-r));
+ log_warning("%s failed to watch sockets: %s", UNIT(s)->id, strerror(-r));
goto fail;
}
assert(s);
if ((r = socket_open_fds(s)) < 0) {
- log_warning("%s failed to listen on sockets: %s", s->meta.id, strerror(-r));
+ log_warning("%s failed to listen on sockets: %s", UNIT(s)->id, strerror(-r));
goto fail;
}
if ((s->control_command = s->exec_command[SOCKET_EXEC_START_POST])) {
if ((r = socket_spawn(s, s->control_command, &s->control_pid)) < 0) {
- log_warning("%s failed to run 'start-post' task: %s", s->meta.id, strerror(-r));
+ log_warning("%s failed to run 'start-post' task: %s", UNIT(s)->id, strerror(-r));
goto fail;
}
return;
fail:
- log_warning("%s failed to run 'start-pre' task: %s", s->meta.id, strerror(-r));
+ log_warning("%s failed to run 'start-pre' task: %s", UNIT(s)->id, strerror(-r));
socket_enter_dead(s, false);
}
/* We don't take connections anymore if we are supposed to
* shut down anyway */
if (unit_pending_inactive(UNIT(s))) {
- log_debug("Suppressing connection request on %s since unit stop is scheduled.", s->meta.id);
+ log_debug("Suppressing connection request on %s since unit stop is scheduled.", UNIT(s)->id);
if (cfd >= 0)
close_nointr_nofail(cfd);
socket_close_fds(s);
if ((r = socket_watch_fds(s)) < 0) {
- log_warning("%s failed to watch sockets: %s", s->meta.id, strerror(-r));
+ log_warning("%s failed to watch sockets: %s", UNIT(s)->id, strerror(-r));
socket_enter_stop_pre(s, false);
}
}
/* If there's already a start pending don't bother to
* do anything */
- SET_FOREACH(u, s->meta.dependencies[UNIT_TRIGGERS], i)
+ SET_FOREACH(u, UNIT(s)->dependencies[UNIT_TRIGGERS], i)
if (unit_pending_active(u)) {
pending = true;
break;
}
if (!pending)
- if ((r = manager_add_job(s->meta.manager, JOB_START, UNIT_DEREF(s->service), JOB_REPLACE, true, &error, NULL)) < 0)
+ if ((r = manager_add_job(UNIT(s)->manager, JOB_START, UNIT_DEREF(s->service), JOB_REPLACE, true, &error, NULL)) < 0)
goto fail;
socket_set_state(s, SOCKET_RUNNING);
if ((r = instance_from_socket(cfd, s->n_accepted, &instance)) < 0)
goto fail;
- if (!(prefix = unit_name_to_prefix(s->meta.id))) {
+ if (!(prefix = unit_name_to_prefix(UNIT(s)->id))) {
free(instance);
r = -ENOMEM;
goto fail;
unit_ref_unset(&s->service);
s->n_accepted ++;
- service->meta.no_gc = false;
+ UNIT(service)->no_gc = false;
unit_choose_id(UNIT(service), name);
free(name);
cfd = -1;
s->n_connections ++;
- if ((r = manager_add_job(s->meta.manager, JOB_START, UNIT(service), JOB_REPLACE, true, &error, NULL)) < 0)
+ if ((r = manager_add_job(UNIT(s)->manager, JOB_START, UNIT(service), JOB_REPLACE, true, &error, NULL)) < 0)
goto fail;
/* Notify clients about changed counters */
return;
fail:
- log_warning("%s failed to queue socket startup job: %s", s->meta.id, bus_error(&error, r));
+ log_warning("%s failed to queue socket startup job: %s", UNIT(s)->id, bus_error(&error, r));
socket_enter_stop_pre(s, false);
if (cfd >= 0)
return;
fail:
- log_warning("%s failed to run next task: %s", s->meta.id, strerror(-r));
+ log_warning("%s failed to run next task: %s", UNIT(s)->id, strerror(-r));
if (s->state == SOCKET_START_POST)
socket_enter_stop_pre(s, false);
service = SERVICE(UNIT_DEREF(s->service));
- if (service->meta.load_state != UNIT_LOADED) {
- log_error("Socket service %s not loaded, refusing.", service->meta.id);
+ if (UNIT(service)->load_state != UNIT_LOADED) {
+ log_error("Socket service %s not loaded, refusing.", UNIT(service)->id);
return -ENOENT;
}
if (service->state != SERVICE_DEAD &&
service->state != SERVICE_FAILED &&
service->state != SERVICE_AUTO_RESTART) {
- log_error("Socket service %s already active, refusing.", service->meta.id);
+ log_error("Socket service %s already active, refusing.", UNIT(service)->id);
return -EBUSY;
}
* services. */
if (s->state == SOCKET_RUNNING) {
- log_debug("%s got notified about service death.", s->meta.id);
+ log_debug("%s got notified about service death.", UNIT(s)->id);
socket_enter_listening(s);
}
}
assert(s->n_connections > 0);
s->n_connections--;
- log_debug("%s: One connection closed, %u left.", s->meta.id, s->n_connections);
+ log_debug("%s: One connection closed, %u left.", UNIT(s)->id, s->n_connections);
}
static void socket_reset_failed(Unit *u) {
goto finish;
}
- if ((q = cgroup_bonding_kill_list(s->meta.cgroup_bondings, signo, false, pid_set)) < 0)
+ if ((q = cgroup_bonding_kill_list(UNIT(s)->cgroup_bondings, signo, false, pid_set)) < 0)
if (q != -EAGAIN && q != -ESRCH && q != -ENOENT)
r = q;
}
/* Remove this unit from the chain of swaps which share the
* same kernel swap device. */
- first = hashmap_get(s->meta.manager->swaps_by_proc_swaps, s->parameters_proc_swaps.what);
+ first = hashmap_get(UNIT(s)->manager->swaps_by_proc_swaps, s->parameters_proc_swaps.what);
LIST_REMOVE(Swap, same_proc_swaps, first, s);
if (first)
- hashmap_remove_and_replace(s->meta.manager->swaps_by_proc_swaps, s->parameters_proc_swaps.what, first->parameters_proc_swaps.what, first);
+ hashmap_remove_and_replace(UNIT(s)->manager->swaps_by_proc_swaps, s->parameters_proc_swaps.what, first->parameters_proc_swaps.what, first);
else
- hashmap_remove(s->meta.manager->swaps_by_proc_swaps, s->parameters_proc_swaps.what);
+ hashmap_remove(UNIT(s)->manager->swaps_by_proc_swaps, s->parameters_proc_swaps.what);
free(s->parameters_proc_swaps.what);
s->parameters_proc_swaps.what = NULL;
Swap *s = SWAP(u);
assert(s);
- assert(s->meta.load_state == UNIT_STUB);
+ assert(UNIT(s)->load_state == UNIT_STUB);
s->timeout_usec = DEFAULT_TIMEOUT_USEC;
s->control_command_id = _MOUNT_EXEC_COMMAND_INVALID;
- s->meta.ignore_on_isolate = true;
+ UNIT(s)->ignore_on_isolate = true;
}
static void swap_unwatch_control_pid(Swap *s) {
assert(s);
assert(m);
- if (s->meta.load_state != UNIT_LOADED ||
- m->meta.load_state != UNIT_LOADED)
+ if (UNIT(s)->load_state != UNIT_LOADED ||
+ UNIT(m)->load_state != UNIT_LOADED)
return 0;
if (is_device_path(s->what))
assert(s);
- LIST_FOREACH(units_by_type, other, s->meta.manager->units_by_type[UNIT_MOUNT])
+ LIST_FOREACH(units_by_type, other, UNIT(s)->manager->units_by_type[UNIT_MOUNT])
if ((r = swap_add_one_mount_link(s, (Mount*) other)) < 0)
return r;
else
return 0;
- if ((r = manager_load_unit(s->meta.manager, SPECIAL_SWAP_TARGET, NULL, NULL, &tu)) < 0)
+ if ((r = manager_load_unit(UNIT(s)->manager, SPECIAL_SWAP_TARGET, NULL, NULL, &tu)) < 0)
return r;
if (!p->noauto &&
!p->nofail &&
- (p->handle || s->meta.manager->swap_auto) &&
+ (p->handle || UNIT(s)->manager->swap_auto) &&
s->from_etc_fstab &&
- s->meta.manager->running_as == MANAGER_SYSTEM)
+ UNIT(s)->manager->running_as == MANAGER_SYSTEM)
if ((r = unit_add_dependency(tu, UNIT_WANTS, UNIT(s), true)) < 0)
return r;
if (is_device_path(s->what))
return unit_add_node_link(UNIT(s), s->what,
!p->noauto && p->nofail &&
- s->meta.manager->running_as == MANAGER_SYSTEM);
+ UNIT(s)->manager->running_as == MANAGER_SYSTEM);
else
/* File based swap devices need to be ordered after
* remount-rootfs.service, since they might need a
assert(s);
- if (s->meta.manager->running_as == MANAGER_SYSTEM) {
+ if (UNIT(s)->manager->running_as == MANAGER_SYSTEM) {
if ((r = unit_add_two_dependencies_by_name(UNIT(s), UNIT_BEFORE, UNIT_CONFLICTS, SPECIAL_UMOUNT_TARGET, NULL, true)) < 0)
return r;
bool b;
char *e;
- if (s->meta.load_state != UNIT_LOADED)
+ if (UNIT(s)->load_state != UNIT_LOADED)
return 0;
if (!(e = unit_name_from_path(s->what, ".swap")))
free(e);
if (!b) {
- log_error("%s: Value of \"What\" and unit name do not match, not loading.\n", s->meta.id);
+ log_error("%s: Value of \"What\" and unit name do not match, not loading.\n", UNIT(s)->id);
return -EINVAL;
}
if (s->exec_context.pam_name && s->exec_context.kill_mode != KILL_CONTROL_GROUP) {
- log_error("%s has PAM enabled. Kill mode must be set to 'control-group'. Refusing.", s->meta.id);
+ log_error("%s has PAM enabled. Kill mode must be set to 'control-group'. Refusing.", UNIT(s)->id);
return -EINVAL;
}
if ((r = unit_add_exec_dependencies(u, &s->exec_context)) < 0)
return r;
- if (s->meta.fragment_path)
+ if (UNIT(s)->fragment_path)
s->from_fragment = true;
if (!s->what) {
path_kill_slashes(s->what);
- if (!s->meta.description)
+ if (!UNIT(s)->description)
if ((r = unit_set_description(u, s->what)) < 0)
return r;
if ((r = unit_add_default_cgroups(u)) < 0)
return r;
- if (s->meta.default_dependencies)
+ if (UNIT(s)->default_dependencies)
if ((r = swap_add_default_dependencies(s)) < 0)
return r;
}
if (state != old_state)
log_debug("%s changed %s -> %s",
- s->meta.id,
+ UNIT(s)->id,
swap_state_to_string(old_state),
swap_state_to_string(state));
NULL,
&s->exec_context,
NULL, 0,
- s->meta.manager->environment,
+ UNIT(s)->manager->environment,
true,
true,
true,
- s->meta.manager->confirm_spawn,
- s->meta.cgroup_bondings,
- s->meta.cgroup_attributes,
+ UNIT(s)->manager->confirm_spawn,
+ UNIT(s)->cgroup_bondings,
+ UNIT(s)->cgroup_attributes,
&pid)) < 0)
goto fail;
if ((r = set_put(pid_set, LONG_TO_PTR(s->control_pid))) < 0)
goto fail;
- if ((r = cgroup_bonding_kill_list(s->meta.cgroup_bondings, sig, true, pid_set)) < 0) {
+ if ((r = cgroup_bonding_kill_list(UNIT(s)->cgroup_bondings, sig, true, pid_set)) < 0) {
if (r != -EAGAIN && r != -ESRCH && r != -ENOENT)
log_warning("Failed to kill control group: %s", strerror(-r));
} else if (r > 0)
return;
fail:
- log_warning("%s failed to kill processes: %s", s->meta.id, strerror(-r));
+ log_warning("%s failed to kill processes: %s", UNIT(s)->id, strerror(-r));
swap_enter_dead(s, false);
return;
fail:
- log_warning("%s failed to run 'swapon' task: %s", s->meta.id, strerror(-r));
+ log_warning("%s failed to run 'swapon' task: %s", UNIT(s)->id, strerror(-r));
swap_enter_dead(s, false);
}
return;
fail:
- log_warning("%s failed to run 'swapoff' task: %s", s->meta.id, strerror(-r));
+ log_warning("%s failed to run 'swapoff' task: %s", UNIT(s)->id, strerror(-r));
swap_enter_active(s, false);
}
goto finish;
}
- if ((q = cgroup_bonding_kill_list(s->meta.cgroup_bondings, signo, false, pid_set)) < 0)
+ if ((q = cgroup_bonding_kill_list(UNIT(s)->cgroup_bondings, signo, false, pid_set)) < 0)
if (q != -EAGAIN && q != -ESRCH && q != -ENOENT)
r = q;
}
if (state != old_state)
log_debug("%s changed %s -> %s",
- t->meta.id,
+ UNIT(t)->id,
target_state_to_string(old_state),
target_state_to_string(state));
* sure we don't create a loop. */
for (k = 0; k < ELEMENTSOF(deps); k++)
- SET_FOREACH(other, t->meta.dependencies[deps[k]], i)
+ SET_FOREACH(other, UNIT(t)->dependencies[deps[k]], i)
if ((r = unit_add_default_target_dependency(other, UNIT(t))) < 0)
return r;
static int timer_verify(Timer *t) {
assert(t);
- if (t->meta.load_state != UNIT_LOADED)
+ if (UNIT(t)->load_state != UNIT_LOADED)
return 0;
if (!t->values) {
- log_error("%s lacks value setting. Refusing.", t->meta.id);
+ log_error("%s lacks value setting. Refusing.", UNIT(t)->id);
return -EINVAL;
}
assert(t);
- if (t->meta.manager->running_as == MANAGER_SYSTEM) {
+ if (UNIT(t)->manager->running_as == MANAGER_SYSTEM) {
if ((r = unit_add_dependency_by_name(UNIT(t), UNIT_BEFORE, SPECIAL_BASIC_TARGET, NULL, true)) < 0)
return r;
if (r < 0)
return r;
- if (t->meta.default_dependencies)
+ if (UNIT(t)->default_dependencies)
if ((r = timer_add_default_dependencies(t)) < 0)
return r;
}
if (state != old_state)
log_debug("%s changed %s -> %s",
- t->meta.id,
+ UNIT(t)->id,
timer_state_to_string(old_state),
timer_state_to_string(state));
case TIMER_ACTIVE:
if (state_translation_table[t->state] == UNIT_ACTIVE)
- base = t->meta.inactive_exit_timestamp.monotonic;
+ base = UNIT(t)->inactive_exit_timestamp.monotonic;
else
base = n;
break;
break;
case TIMER_STARTUP:
- base = t->meta.manager->startup_timestamp.monotonic;
+ base = UNIT(t)->manager->startup_timestamp.monotonic;
break;
case TIMER_UNIT_ACTIVE:
return;
fail:
- log_warning("%s failed to enter waiting state: %s", t->meta.id, strerror(-r));
+ log_warning("%s failed to enter waiting state: %s", UNIT(t)->id, strerror(-r));
timer_enter_dead(t, false);
}
dbus_error_init(&error);
/* Don't start job if we are supposed to go down */
- if (t->meta.job && t->meta.job->type == JOB_STOP)
+ if (UNIT(t)->job && UNIT(t)->job->type == JOB_STOP)
return;
- if ((r = manager_add_job(t->meta.manager, JOB_START, UNIT_DEREF(t->unit), JOB_REPLACE, true, &error, NULL)) < 0)
+ if ((r = manager_add_job(UNIT(t)->manager, JOB_START, UNIT_DEREF(t->unit), JOB_REPLACE, true, &error, NULL)) < 0)
goto fail;
timer_set_state(t, TIMER_RUNNING);
return;
fail:
- log_warning("%s failed to queue unit startup job: %s", t->meta.id, bus_error(&error, r));
+ log_warning("%s failed to queue unit startup job: %s", UNIT(t)->id, bus_error(&error, r));
timer_enter_dead(t, false);
dbus_error_free(&error);
case TIMER_RUNNING:
if (UNIT_IS_INACTIVE_OR_FAILED(new_state)) {
- log_debug("%s got notified about unit deactivation.", t->meta.id);
+ log_debug("%s got notified about unit deactivation.", UNIT(t)->id);
timer_enter_waiting(t, false);
}