1
0
mirror of https://github.com/systemd/systemd.git synced 2024-10-31 16:21:26 +03:00

Merge pull request #8107 from sourcejedi/pedant

core: a couple of tidyups to synthesized units
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2018-02-06 10:17:05 +01:00 committed by GitHub
commit 81e19fa8c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 40 additions and 23 deletions

View File

@ -163,9 +163,6 @@ static int scope_load_init_scope(Unit *u) {
* synthesize it here, instead of relying on the unit file on disk. */ * synthesize it here, instead of relying on the unit file on disk. */
u->default_dependencies = false; u->default_dependencies = false;
u->ignore_on_isolate = true;
SCOPE(u)->kill_context.kill_signal = SIGRTMIN+14;
/* Prettify things, if we can. */ /* Prettify things, if we can. */
if (!u->description) if (!u->description)

View File

@ -137,7 +137,6 @@ static int slice_load_root_slice(Unit *u) {
* special semantics we synthesize it here, instead of relying on the unit file on disk. */ * special semantics we synthesize it here, instead of relying on the unit file on disk. */
u->default_dependencies = false; u->default_dependencies = false;
u->ignore_on_isolate = true;
if (!u->description) if (!u->description)
u->description = strdup("Root Slice"); u->description = strdup("Root Slice");
@ -147,6 +146,29 @@ static int slice_load_root_slice(Unit *u) {
return 1; return 1;
} }
static int slice_load_system_slice(Unit *u) {
assert(u);
if (!MANAGER_IS_SYSTEM(u->manager))
return 0;
if (!unit_has_name(u, SPECIAL_SYSTEM_SLICE))
return 0;
u->perpetual = true;
/* The system slice is a bit special. For example it is always running and cannot be terminated. Because of its
* special semantics we synthesize it here, instead of relying on the unit file on disk. */
u->default_dependencies = false;
if (!u->description)
u->description = strdup("System Slice");
if (!u->documentation)
u->documentation = strv_new("man:systemd.special(7)", NULL);
return 1;
}
static int slice_load(Unit *u) { static int slice_load(Unit *u) {
Slice *s = SLICE(u); Slice *s = SLICE(u);
int r; int r;
@ -157,6 +179,10 @@ static int slice_load(Unit *u) {
r = slice_load_root_slice(u); r = slice_load_root_slice(u);
if (r < 0) if (r < 0)
return r; return r;
r = slice_load_system_slice(u);
if (r < 0)
return r;
r = unit_load_fragment_and_dropin_optional(u); r = unit_load_fragment_and_dropin_optional(u);
if (r < 0) if (r < 0)
return r; return r;
@ -287,17 +313,17 @@ _pure_ static const char *slice_sub_state_to_string(Unit *u) {
return slice_state_to_string(SLICE(u)->state); return slice_state_to_string(SLICE(u)->state);
} }
static void slice_enumerate(Manager *m) { static void slice_enumerate_perpetual(Manager *m, const char *name) {
Unit *u; Unit *u;
int r; int r;
assert(m); assert(m);
u = manager_get_unit(m, SPECIAL_ROOT_SLICE); u = manager_get_unit(m, name);
if (!u) { if (!u) {
r = unit_new_for_name(m, sizeof(Slice), SPECIAL_ROOT_SLICE, &u); r = unit_new_for_name(m, sizeof(Slice), name, &u);
if (r < 0) { if (r < 0) {
log_error_errno(r, "Failed to allocate the special " SPECIAL_ROOT_SLICE " unit: %m"); log_error_errno(r, "Failed to allocate the special %s unit: %m", name);
return; return;
} }
} }
@ -309,6 +335,15 @@ static void slice_enumerate(Manager *m) {
unit_add_to_dbus_queue(u); unit_add_to_dbus_queue(u);
} }
static void slice_enumerate(Manager *m) {
assert(m);
slice_enumerate_perpetual(m, SPECIAL_ROOT_SLICE);
if (MANAGER_IS_SYSTEM(m))
slice_enumerate_perpetual(m, SPECIAL_SYSTEM_SLICE);
}
const UnitVTable slice_vtable = { const UnitVTable slice_vtable = {
.object_size = sizeof(Slice), .object_size = sizeof(Slice),
.cgroup_context_offset = offsetof(Slice, cgroup_context), .cgroup_context_offset = offsetof(Slice, cgroup_context),

View File

@ -91,7 +91,6 @@ units = [
['sysinit.target', ''], ['sysinit.target', ''],
['syslog.socket', ''], ['syslog.socket', ''],
['system-update.target', ''], ['system-update.target', ''],
['system.slice', ''],
['systemd-ask-password-console.path', '', ['systemd-ask-password-console.path', '',
'sysinit.target.wants/'], 'sysinit.target.wants/'],
['systemd-ask-password-wall.path', '', ['systemd-ask-password-wall.path', '',

View File

@ -1,14 +0,0 @@
# SPDX-License-Identifier: LGPL-2.1+
#
# This file is part of systemd.
#
# systemd is free software; you can redistribute it and/or modify it
# 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.
[Unit]
Description=System Slice
Documentation=man:systemd.special(7)
DefaultDependencies=no
Before=slices.target