Commit 8b88b3fc authored by Pavel Tikhomirov's avatar Pavel Tikhomirov Committed by Andrei Vagin

files: don't add double slash to path in create_ghost

Signed-off-by: 's avatarPavel Tikhomirov <ptikhomirov@virtuozzo.com>
Signed-off-by: 's avatarAndrei Vagin <avagin@virtuozzo.com>
parent 47bf04d2
...@@ -323,7 +323,13 @@ static int create_ghost(struct ghost_file *gf, GhostFileEntry *gfe, struct cr_im ...@@ -323,7 +323,13 @@ static int create_ghost(struct ghost_file *gf, GhostFileEntry *gfe, struct cr_im
goto err; goto err;
} }
snprintf(path + ret, sizeof(path) - ret, "/%s", gf->remap.rpath); /* Add a '/' only if we have no at the end */
if (path[root_len-1] != '/') {
path[root_len++] = '/';
path[root_len] = '\0';
}
snprintf(path + root_len, sizeof(path) - root_len, "%s", gf->remap.rpath);
ret = -1; ret = -1;
again: again:
if (S_ISFIFO(gfe->mode)) { if (S_ISFIFO(gfe->mode)) {
...@@ -358,7 +364,7 @@ again: ...@@ -358,7 +364,7 @@ again:
goto err; goto err;
} }
strcpy(gf->remap.rpath, path + root_len + 1); strcpy(gf->remap.rpath, path + root_len);
pr_debug("Remap rpath is %s\n", gf->remap.rpath); pr_debug("Remap rpath is %s\n", gf->remap.rpath);
ret = -1; ret = -1;
......
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