Commit 586eb55f authored by Pavel Emelyanov's avatar Pavel Emelyanov

cg: Trim proper prefix from ftw's path

After the commit that walks /proc/self/fd/N path instead of the temporary
one, the add_cgroup() started trimming first several bytes from the cgroup
path.

Test passed, since all cgroups were left as is after dump, so criu restore
didn't recreate them but got EEXIST on all mkdir-s.
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
Acked-by: 's avatarTycho Andersen <tycho.andersen@canonical.com>
parent dda742ec
......@@ -195,6 +195,7 @@ static bool cgroup_contains(char **controllers, unsigned int n_controllers, char
/* This is for use in add_cgroup() as additional arguments for the ftw()
* callback */
static struct cg_controller *current_controller;
static unsigned int path_pref_len;
#define EXACT_MATCH 0
#define PARENT_MATCH 1
......@@ -242,8 +243,8 @@ static int add_cgroup(const char *fpath, const struct stat *sb, int typeflag)
goto out;
}
/* chop off the first strlen(".criu.cgmounts.XXXXXX") */
ncd->path = xstrdup(fpath + 21);
/* chop off the first "/proc/self/fd/N" str */
ncd->path = xstrdup(fpath + path_pref_len);
if (!ncd->path) {
ret = -1;
goto out;
......@@ -316,7 +317,8 @@ static int collect_cgroups(struct list_head *ctls)
if (fd < 0)
return -1;
snprintf(path, PATH_MAX, "/proc/self/fd/%d/%s", fd, cc->path);
path_pref_len = snprintf(path, PATH_MAX, "/proc/self/fd/%d", fd);
snprintf(path + path_pref_len, PATH_MAX - path_pref_len, "%s", cc->path);
current_controller = NULL;
......
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