busname.c revision ff975efb2e88dcd5221a2f0d76c4c87e85b821a8
84e51726a38e133ca42d2f30f0668d3921b210cbLennart Poettering/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
84e51726a38e133ca42d2f30f0668d3921b210cbLennart Poettering This file is part of systemd.
84e51726a38e133ca42d2f30f0668d3921b210cbLennart Poettering Copyright 2013 Lennart Poettering
84e51726a38e133ca42d2f30f0668d3921b210cbLennart Poettering systemd is free software; you can redistribute it and/or modify it
84e51726a38e133ca42d2f30f0668d3921b210cbLennart Poettering under the terms of the GNU Lesser General Public License as published by
84e51726a38e133ca42d2f30f0668d3921b210cbLennart Poettering the Free Software Foundation; either version 2.1 of the License, or
84e51726a38e133ca42d2f30f0668d3921b210cbLennart Poettering (at your option) any later version.
84e51726a38e133ca42d2f30f0668d3921b210cbLennart Poettering systemd is distributed in the hope that it will be useful, but
84e51726a38e133ca42d2f30f0668d3921b210cbLennart Poettering WITHOUT ANY WARRANTY; without even the implied warranty of
84e51726a38e133ca42d2f30f0668d3921b210cbLennart Poettering MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
84e51726a38e133ca42d2f30f0668d3921b210cbLennart Poettering Lesser General Public License for more details.
84e51726a38e133ca42d2f30f0668d3921b210cbLennart Poettering You should have received a copy of the GNU Lesser General Public License
84e51726a38e133ca42d2f30f0668d3921b210cbLennart Poettering along with systemd; If not, see <http://www.gnu.org/licenses/>.
84e51726a38e133ca42d2f30f0668d3921b210cbLennart Poetteringstatic const UnitActiveState state_translation_table[_BUSNAME_STATE_MAX] = {
84e51726a38e133ca42d2f30f0668d3921b210cbLennart Poetteringstatic int busname_dispatch_io(sd_event_source *source, int fd, uint32_t revents, void *userdata);
assert(u);
assert(u);
if (n->starter_fd >= 0) {
assert(n);
r = unit_add_two_dependencies_by_name(UNIT(n), UNIT_AFTER, UNIT_REQUIRES, SPECIAL_SYSINIT_TARGET, NULL, true);
return unit_add_two_dependencies_by_name(UNIT(n), UNIT_BEFORE, UNIT_CONFLICTS, SPECIAL_SHUTDOWN_TARGET, NULL, true);
assert(n);
if (!n->name) {
if (!n->name)
return -ENOMEM;
if (!u->description) {
Unit *x;
if (u->default_dependencies) {
assert(n);
log_error_unit(UNIT(n)->id, "%s's Name= setting is not a valid service name Refusing.", UNIT(n)->id);
return -EINVAL;
return -EINVAL;
assert(u);
r = unit_load_fragment_and_dropin(u);
r = busname_add_extras(n);
return busname_verify(n);
assert(n);
assert(f);
fprintf(f,
assert(n);
if (n->event_source) {
assert(n);
if (n->starter_fd <= 0)
assert(n);
if (n->starter_fd < 0)
if (n->event_source)
r = sd_event_add_io(UNIT(n)->manager->event, n->starter_fd, EPOLLIN, busname_dispatch_io, n, &n->event_source);
assert(n);
if (n->starter_fd >= 0)
n->starter_fd = bus_kernel_create_starter(UNIT(n)->manager->running_as == SYSTEMD_SYSTEM ? "system" : "user", n->name);
if (n->starter_fd < 0) {
return n->starter_fd;
assert(n);
busname_close_fd(n);
assert(n);
r = busname_open_fd(n);
r = busname_watch_fd(n);
assert(n);
if (f != BUSNAME_SUCCESS)
n->result = f;
assert(n);
r = busname_open_fd(n);
goto fail;
r = busname_watch_fd(n);
goto fail;
fail:
bool pending = false;
Iterator i;
assert(n);
log_debug_unit(UNIT(n)->id, "Suppressing activation request on %s since unit stop is scheduled.", UNIT(n)->id);
pending = true;
if (!pending) {
r = manager_add_job(UNIT(n)->manager, JOB_START, UNIT_DEREF(n->service), JOB_REPLACE, true, &error, NULL);
goto fail;
fail:
log_warning_unit(UNIT(n)->id, "%s failed to queue service startup job: %s", UNIT(n)->id, bus_error_message(&error, r));
assert(n);
return -ENOENT;
assert(n);
assert(n);
assert(f);
if (n->starter_fd >= 0) {
int copy;
if (copy < 0)
return copy;
assert(n);
if (state < 0)
else if (f != BUSNAME_SUCCESS)
n->result = f;
int fd;
if (n->starter_fd >= 0)
assert(u);
assert(u);
assert(n);
goto fail;
fail:
assert(n);
Service *s;
assert(n);
.sections =
.finished_start_job = {
.finished_stop_job = {