Commit b4ffeeeb authored by Tycho Andersen's avatar Tycho Andersen Committed by Pavel Emelyanov

cgroup: don't include trailing / in cgns_prefix

We could do the math on the consuming side (and indeed, I tried), but it
seems much cleaner to just not include this in the first place so that all
consumers of it don't need to do the same thing.
Signed-off-by: 's avatarTycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
parent 8b33970e
...@@ -1604,12 +1604,12 @@ static int rewrite_cgsets(CgroupEntry *cge, char **controllers, int n_controller ...@@ -1604,12 +1604,12 @@ static int rewrite_cgsets(CgroupEntry *cge, char **controllers, int n_controller
*/ */
if (!set_from) { if (!set_from) {
set_from = true; set_from = true;
/* -2 because cgns_prefix includes leading and trailing /'s */ /* -1 because cgns_prefix includes leading / */
*from = xsprintf("%s%s", to, (*from) + cg->cgns_prefix - 2); *from = xsprintf("%s%s", to, (*from) + cg->cgns_prefix - 1);
} }
cg->path = xsprintf("%s%s", to, cg->path + cg->path = xsprintf("%s%s", to, cg->path +
cg->cgns_prefix - 1); cg->cgns_prefix);
cg->cgns_prefix = strlen(to); cg->cgns_prefix = strlen(to);
} else { } else {
/* otherwise, use the old rewriting strategy */ /* otherwise, use the old rewriting strategy */
......
...@@ -2283,6 +2283,8 @@ int parse_task_cgroup(int pid, struct parasite_dump_cgroup_args *args, struct li ...@@ -2283,6 +2283,8 @@ int parse_task_cgroup(int pid, struct parasite_dump_cgroup_args *args, struct li
} }
ext->cgns_prefix = pos - ext->path; ext->cgns_prefix = pos - ext->path;
if (ext->path[ext->cgns_prefix-1] == '/')
ext->cgns_prefix--;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment