slice.c revision 598459cebac7cc93089769a992e7b03287f77e12
03831d35f7499c87d51205817c93e9a8d42c4baestevel/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
03831d35f7499c87d51205817c93e9a8d42c4baestevel This file is part of systemd.
03831d35f7499c87d51205817c93e9a8d42c4baestevel Copyright 2013 Lennart Poettering
03831d35f7499c87d51205817c93e9a8d42c4baestevel systemd is free software; you can redistribute it and/or modify it
03831d35f7499c87d51205817c93e9a8d42c4baestevel under the terms of the GNU Lesser General Public License as published by
03831d35f7499c87d51205817c93e9a8d42c4baestevel the Free Software Foundation; either version 2.1 of the License, or
03831d35f7499c87d51205817c93e9a8d42c4baestevel (at your option) any later version.
03831d35f7499c87d51205817c93e9a8d42c4baestevel systemd is distributed in the hope that it will be useful, but
03831d35f7499c87d51205817c93e9a8d42c4baestevel WITHOUT ANY WARRANTY; without even the implied warranty of
03831d35f7499c87d51205817c93e9a8d42c4baestevel MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
03831d35f7499c87d51205817c93e9a8d42c4baestevel Lesser General Public License for more details.
03831d35f7499c87d51205817c93e9a8d42c4baestevel You should have received a copy of the GNU Lesser General Public License
03831d35f7499c87d51205817c93e9a8d42c4baestevel along with systemd; If not, see <http://www.gnu.org/licenses/>.
03831d35f7499c87d51205817c93e9a8d42c4baestevelstatic const UnitActiveState state_translation_table[_SLICE_STATE_MAX] = {
03831d35f7499c87d51205817c93e9a8d42c4baestevelstatic void slice_set_state(Slice *t, SliceState state) {
03831d35f7499c87d51205817c93e9a8d42c4baestevel unit_notify(UNIT(t), state_translation_table[old_state], state_translation_table[state], true);
03831d35f7499c87d51205817c93e9a8d42c4baestevel r = manager_load_unit(UNIT(s)->manager, a, NULL, NULL, &parent);
03831d35f7499c87d51205817c93e9a8d42c4baestevel /* Make sure slices are unloaded on shutdown */
03831d35f7499c87d51205817c93e9a8d42c4baestevel "%s located outside its parent slice. Refusing.", UNIT(s)->id);
03831d35f7499c87d51205817c93e9a8d42c4baestevel /* This is a new unit? Then let's add in some extras */
03831d35f7499c87d51205817c93e9a8d42c4baestevelstatic void slice_dump(Unit *u, FILE *f, const char *prefix) {
03831d35f7499c87d51205817c93e9a8d42c4baestevel "%sSlice State: %s\n",
03831d35f7499c87d51205817c93e9a8d42c4baestevel /* We do not need to destroy the cgroup explicitly,
03831d35f7499c87d51205817c93e9a8d42c4baestevel * unit_notify() will do that for us anyway. */
03831d35f7499c87d51205817c93e9a8d42c4baestevelstatic int slice_kill(Unit *u, KillWho who, int signo, sd_bus_error *error) {
03831d35f7499c87d51205817c93e9a8d42c4baestevel return unit_kill_common(u, who, signo, -1, -1, error);
03831d35f7499c87d51205817c93e9a8d42c4baestevelstatic int slice_serialize(Unit *u, FILE *f, FDSet *fds) {
03831d35f7499c87d51205817c93e9a8d42c4baestevel unit_serialize_item(u, f, "state", slice_state_to_string(s->state));
03831d35f7499c87d51205817c93e9a8d42c4baestevelstatic int slice_deserialize_item(Unit *u, const char *key, const char *value, FDSet *fds) {
03831d35f7499c87d51205817c93e9a8d42c4baestevel_pure_ static UnitActiveState slice_active_state(Unit *u) {
03831d35f7499c87d51205817c93e9a8d42c4baestevel_pure_ static const char *slice_sub_state_to_string(Unit *u) {
03831d35f7499c87d51205817c93e9a8d42c4baestevelstatic const char* const slice_state_table[_SLICE_STATE_MAX] = {
03831d35f7499c87d51205817c93e9a8d42c4baestevel .cgroup_context_offset = offsetof(Slice, cgroup_context),
03831d35f7499c87d51205817c93e9a8d42c4baestevel "Install\0",