Skip to content

Commit

Permalink
cgroups/cgfsng: keep mountpoint intact
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
  • Loading branch information
Christian Brauner committed Nov 6, 2017
1 parent da3dcce commit 411ac6d
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/lxc/cgroups/cgfsng.c
Expand Up @@ -760,9 +760,10 @@ static char **get_controllers(char **klist, char **nlist, char *line)
{
/* the fourth field is /sys/fs/cgroup/comma-delimited-controller-list */
int i;
char *p = line, *p2, *tok, *saveptr = NULL;
char **aret = NULL;
char *dup, *p2, *tok;
bool is_cgroup_v2;
char *p = line, *saveptr = NULL;
char **aret = NULL;

/* handle cgroup v2 */
is_cgroup_v2 = is_cgroupfs_v2(line);
Expand Down Expand Up @@ -792,14 +793,24 @@ static char **get_controllers(char **klist, char **nlist, char *line)
/* cgroup v2 does not have separate mountpoints for controllers */
if (is_cgroup_v2) {
must_append_controller(klist, nlist, &aret, "cgroup2");
return aret;
return NULL;
}

/* strdup() here for v1 hierarchies. Otherwise strtok_r() will destroy
* mountpoints such as "/sys/fs/cgroup/cpu,cpuacct".
*/
dup = strdup(p);
if (!dup) {
SYSERROR("Failed to duplicate string");
return NULL;
}

for (tok = strtok_r(p, ",", &saveptr); tok;
for (tok = strtok_r(dup, ",", &saveptr); tok;
tok = strtok_r(NULL, ",", &saveptr)) {
must_append_controller(klist, nlist, &aret, tok);
}

free(dup);
return aret;
}

Expand Down

0 comments on commit 411ac6d

Please sign in to comment.