2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-09-05 08:45:49 +00:00

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: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
This commit is contained in:
Tycho Andersen
2016-03-04 23:55:00 +03:00
committed by Pavel Emelyanov
parent 8b33970e51
commit b4ffeeeba2
2 changed files with 5 additions and 3 deletions

View File

@@ -1604,12 +1604,12 @@ static int rewrite_cgsets(CgroupEntry *cge, char **controllers, int n_controller
*/
if (!set_from) {
set_from = true;
/* -2 because cgns_prefix includes leading and trailing /'s */
*from = xsprintf("%s%s", to, (*from) + cg->cgns_prefix - 2);
/* -1 because cgns_prefix includes leading / */
*from = xsprintf("%s%s", to, (*from) + cg->cgns_prefix - 1);
}
cg->path = xsprintf("%s%s", to, cg->path +
cg->cgns_prefix - 1);
cg->cgns_prefix);
cg->cgns_prefix = strlen(to);
} else {
/* otherwise, use the old rewriting strategy */

View File

@@ -2283,6 +2283,8 @@ int parse_task_cgroup(int pid, struct parasite_dump_cgroup_args *args, struct li
}
ext->cgns_prefix = pos - ext->path;
if (ext->path[ext->cgns_prefix-1] == '/')
ext->cgns_prefix--;
}
}