[CRIU] [PATCH] cgroup: don't include trailing / in cgns_prefix
Tycho Andersen
tycho.andersen at canonical.com
Fri Mar 4 12:55:23 PST 2016
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 at canonical.com>
---
criu/cgroup.c | 6 +++---
criu/proc_parse.c | 2 ++
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/criu/cgroup.c b/criu/cgroup.c
index 609509c..9047aa5 100644
--- a/criu/cgroup.c
+++ b/criu/cgroup.c
@@ -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 */
diff --git a/criu/proc_parse.c b/criu/proc_parse.c
index a7e3b24..24a9154 100644
--- a/criu/proc_parse.c
+++ b/criu/proc_parse.c
@@ -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--;
}
}
--
2.7.0
More information about the CRIU
mailing list