2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-09-02 23:35:21 +00:00

cg: use one path style throughout cg restore code

This commit is in preparation for the (hopefully last :) restore special cpuset
patch.

Previously, we installed the cgroup service fd after calling
prepare_cgroup_dirs, which meant that we had to carry around the temporary
directory name in order to put things in the right place. The
restore_cgroup_prop function uses the cg service fd instead of carrying around
the full path. This means that we can't sue restore_cgroup_prop, without first
sanitizing the path. Instead, we install the service fd before calling
prepare_cgroup_dirs, and all the code just references that instead of carrying
around the temporary path.

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
Tycho Andersen
2014-10-06 09:03:29 -05:00
committed by Pavel Emelyanov
parent 25e1997fde
commit de055b7992
3 changed files with 29 additions and 21 deletions

4
util.c
View File

@@ -687,7 +687,7 @@ struct vma_area *alloc_vma_area(void)
return p;
}
int mkdirp(const char *path)
int mkdirpat(int fd, const char *path)
{
size_t i;
char made_path[PATH_MAX], *pos;
@@ -707,7 +707,7 @@ int mkdirp(const char *path)
pos = strchr(made_path + i, '/');
if (pos)
*pos = '\0';
if (mkdir(made_path, 0755) < 0 && errno != EEXIST) {
if (mkdirat(fd, made_path, 0755) < 0 && errno != EEXIST) {
pr_perror("couldn't mkdirpat directory %s", made_path);
return -1;
}