summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2017-06-14 20:20:33 -0400
committerLuke Shumaker <lukeshu@lukeshu.com>2017-06-16 17:06:57 -0400
commit4d2f5c684e80da14a38149d78134a0f3bf996d50 (patch)
tree4b522715b993c3774c9c26f4740b4b526ce1702c
parent9fa8446392a8dfdf7e941ad4d25b4e5543e554c8 (diff)
nspawn: mount_legacy_cgns_supported(): Rename variables to not lie
mount_legacy_cgns_supported() is very clearly meant to be a version of mount_legacy_cgns_unsupported() modified to cope with the fact that it has already chroot()ed, and thus can't look at the host /sys. So, the loops and such look similar. However, to cope with the fact that it can't look at /sys, it deals with hierarchies in the outermost loop, rather than controllers. Yet, it kept the list variable named "controllers". That's confusing.
-rw-r--r--src/nspawn/nspawn-cgroup.c36
1 files changed, 17 insertions, 19 deletions
diff --git a/src/nspawn/nspawn-cgroup.c b/src/nspawn/nspawn-cgroup.c
index 5afd2bd062..e939232b9e 100644
--- a/src/nspawn/nspawn-cgroup.c
+++ b/src/nspawn/nspawn-cgroup.c
@@ -204,10 +204,8 @@ int cgroup_setup(pid_t pid, CGroupUnified outer_cgver, CGroupUnified inner_cgver
/********************************************************************/
-/* Retrieve existing subsystems. This function is called in a new cgroup
- * namespace.
- */
-static int get_controllers(Set *subsystems) {
+/* Retrieve a list of cgroup v1 hierarchies. */
+static int get_v1_hierarchies(Set *subsystems) {
_cleanup_fclose_ FILE *f = NULL;
char line[LINE_MAX];
@@ -296,7 +294,7 @@ static int mount_legacy_cgroup_hierarchy(const char *dest, const char *controlle
static int mount_legacy_cgns_supported(
CGroupUnified outer_cgver, CGroupUnified inner_cgver, bool userns, uid_t uid_shift,
uid_t uid_range, const char *selinux_apifs_context) {
- _cleanup_set_free_free_ Set *controllers = NULL;
+ _cleanup_set_free_free_ Set *hierarchies = NULL;
const char *cgroup_root = "/sys/fs/cgroup", *c;
int r;
@@ -329,22 +327,22 @@ static int mount_legacy_cgns_supported(
if (outer_cgver >= CGROUP_UNIFIED_ALL)
goto skip_controllers;
- controllers = set_new(&string_hash_ops);
- if (!controllers)
+ hierarchies = set_new(&string_hash_ops);
+ if (!hierarchies)
return log_oom();
- r = get_controllers(controllers);
+ r = get_v1_hierarchies(hierarchies);
if (r < 0)
- return log_error_errno(r, "Failed to determine cgroup controllers: %m");
+ return log_error_errno(r, "Failed to determine cgroup hierarchies: %m");
for (;;) {
- _cleanup_free_ const char *controller = NULL;
+ _cleanup_free_ const char *hierarchy = NULL;
- controller = set_steal_first(controllers);
- if (!controller)
+ hierarchy = set_steal_first(hierarchies);
+ if (!hierarchy)
break;
- r = mount_legacy_cgroup_hierarchy("", controller, controller, inner_cgver, !userns);
+ r = mount_legacy_cgroup_hierarchy("", hierarchy, hierarchy, inner_cgver, !userns);
if (r < 0)
return r;
@@ -352,24 +350,24 @@ static int mount_legacy_cgns_supported(
* constituting individual hierarchies a symlink to the
* co-mount.
*/
- c = controller;
+ c = hierarchy;
for (;;) {
- _cleanup_free_ char *target = NULL, *tok = NULL;
+ _cleanup_free_ char *target = NULL, *controller = NULL;
- r = extract_first_word(&c, &tok, ",", 0);
+ r = extract_first_word(&c, &controller, ",", 0);
if (r < 0)
return log_error_errno(r, "Failed to extract co-mounted cgroup controller: %m");
if (r == 0)
break;
- target = prefix_root("/sys/fs/cgroup", tok);
+ target = prefix_root("/sys/fs/cgroup", controller);
if (!target)
return log_oom();
- if (streq(controller, tok))
+ if (streq(hierarchy, controller))
break;
- r = symlink_idempotent(controller, target);
+ r = symlink_idempotent(hierarchy, target);
if (r == -EINVAL)
return log_error_errno(r, "Invalid existing symlink for combined hierarchy: %m");
if (r < 0)