slice.c revision 8e2af478402414f060bbc16e1b4bbe7de1779c13
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
/***
This file is part of systemd.
Copyright 2013 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 "slice.h"
#include "load-fragment.h"
#include "log.h"
#include "dbus-slice.h"
#include "special.h"
#include "unit-name.h"
[SLICE_DEAD] = UNIT_INACTIVE,
};
static void slice_init(Unit *u) {
assert(u);
}
static void slice_done(Unit *u) {
assert(u);
}
assert(t);
log_debug("%s changed %s -> %s",
}
static int slice_add_parent_slice(Slice *s) {
char *a, *dash;
int r;
assert(s);
return 0;
return 0;
if (dash)
else
a = (char*) SPECIAL_ROOT_SLICE;
if (r < 0)
return r;
return 0;
}
static int slice_add_default_dependencies(Slice *s) {
int r;
assert(s);
/* Make sure slices are unloaded on shutdown */
if (r < 0)
return r;
return 0;
}
static int slice_verify(Slice *s) {
assert(s);
return 0;
char *a, *dash;
if (dash)
else
a = (char*) SPECIAL_ROOT_SLICE;
return -EINVAL;
}
}
return 0;
}
static int slice_load(Unit *u) {
int r;
assert(s);
if (r < 0)
return r;
/* This is a new unit? Then let's add in some extras */
if (u->load_state == UNIT_LOADED) {
r = slice_add_parent_slice(s);
if (r < 0)
return r;
if (u->default_dependencies) {
r = slice_add_default_dependencies(s);
if (r < 0)
return r;
}
}
return slice_verify(s);
}
static int slice_coldplug(Unit *u) {
assert(t);
if (t->deserialized_state != t->state)
slice_set_state(t, t->deserialized_state);
return 0;
}
assert(t);
assert(f);
fprintf(f,
"%sSlice State: %s\n",
}
static int slice_start(Unit *u) {
assert(t);
return 0;
}
static int slice_stop(Unit *u) {
assert(t);
/* We do not need to destroy the cgroup explicitly,
* unit_notify() will do that for us anyway. */
return 0;
}
}
assert(s);
assert(f);
return 0;
}
assert(u);
if (state < 0)
else
s->deserialized_state = state;
} else
return 0;
}
assert(u);
}
assert(u);
}
static const char* const slice_state_table[_SLICE_STATE_MAX] = {
[SLICE_DEAD] = "dead",
[SLICE_ACTIVE] = "active"
};
const UnitVTable slice_vtable = {
.object_size = sizeof(Slice),
.sections =
"Unit\0"
"Slice\0"
"Install\0",
.private_section = "Slice",
.no_alias = true,
.no_instances = true,
.init = slice_init,
.load = slice_load,
.done = slice_done,
.dump = slice_dump,
.start = slice_start,
.stop = slice_stop,
.kill = slice_kill,
.bus_interface = "org.freedesktop.systemd1.Slice",
.finished_start_job = {
[JOB_DONE] = "Created slice %s.",
[JOB_DEPENDENCY] = "Dependency failed for %s.",
},
.finished_stop_job = {
[JOB_DONE] = "Removed slice %s.",
},
},
};