target.c revision c69182961b00707d977957cf81d5c41cfbeab429
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
/***
This file is part of systemd.
Copyright 2010 Lennart Poettering
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include <errno.h>
#include <signal.h>
#include <unistd.h>
#include "unit.h"
#include "target.h"
#include "load-fragment.h"
#include "log.h"
#include "dbus-target.h"
#include "special.h"
#include "unit-name.h"
[TARGET_DEAD] = UNIT_INACTIVE,
};
assert(t);
log_debug("%s changed %s -> %s",
}
static int target_add_default_dependencies(Target *t) {
static const UnitDependency deps[] = {
};
Iterator i;
int r;
unsigned k;
assert(t);
/* Imply ordering for requirement dependencies on target
* units. Note that when the user created a contradicting
* ordering manually we won't add anything in here to make
* sure we don't create a loop. */
for (k = 0; k < ELEMENTSOF(deps); k++)
return r;
/* Make sure targets are unloaded on shutdown */
}
static int target_load(Unit *u) {
int r;
assert(t);
if ((r = unit_load_fragment_and_dropin(u)) < 0)
return r;
/* This is a new unit? Then let's add in some extras */
if (u->load_state == UNIT_LOADED) {
if (u->default_dependencies)
if ((r = target_add_default_dependencies(t)) < 0)
return r;
}
return 0;
}
static int target_coldplug(Unit *u) {
assert(t);
if (t->deserialized_state != t->state)
target_set_state(t, t->deserialized_state);
return 0;
}
assert(t);
assert(f);
fprintf(f,
"%sTarget State: %s\n",
}
static int target_start(Unit *u) {
assert(t);
return 0;
}
static int target_stop(Unit *u) {
assert(t);
return 0;
}
assert(s);
assert(f);
return 0;
}
assert(u);
else
s->deserialized_state = state;
} else
return 0;
}
assert(u);
}
static const char *target_sub_state_to_string(Unit *u) {
assert(u);
}
static const char* const target_state_table[_TARGET_STATE_MAX] = {
[TARGET_DEAD] = "dead",
[TARGET_ACTIVE] = "active"
};
const UnitVTable target_vtable = {
.suffix = ".target",
.object_size = sizeof(Target),
.sections =
"Unit\0"
"Target\0"
"Install\0",
.load = target_load,
.dump = target_dump,
.start = target_start,
.stop = target_stop,
.bus_interface = "org.freedesktop.systemd1.Target",
.finished_start_job = {
[JOB_DONE] = "Reached target %s.",
[JOB_DEPENDENCY] = "Dependency failed for %s.",
},
.finished_stop_job = {
[JOB_DONE] = "Stopped target %s.",
},
},
};