Commit dbb9d5eb authored by Kirill Tkhai's avatar Kirill Tkhai Committed by Pavel Emelyanov

files-reg: Make try_clean_ghost() use struct ghost_file ptr

This cleanup will be used in next patch.
Signed-off-by: 's avatarKirill Tkhai <ktkhai@virtuozzo.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
parent 78a0f8db
...@@ -432,17 +432,18 @@ int prepare_remaps(void) ...@@ -432,17 +432,18 @@ int prepare_remaps(void)
return ret; return ret;
} }
static void try_clean_ghost(struct remap_info *ri) static void try_clean_ghost(struct ghost_file *gf)
{ {
char path[PATH_MAX]; char path[PATH_MAX];
int mnt_id, ret; int mnt_id, ret;
mnt_id = ri->rfi->rfe->mnt_id; /* rirfirfe %) */ mnt_id = gf->remap.rmnt_id;
ret = rst_get_mnt_root(mnt_id, path, sizeof(path)); ret = rst_get_mnt_root(mnt_id, path, sizeof(path));
if (ret < 0) if (ret < 0)
return; return;
ghost_path(path + ret, sizeof(path) - 1, ri->rfi, ri->rfe); snprintf(path + ret, PATH_MAX - ret, "/%s", gf->remap.rpath);
if (!unlink(path)) { if (!unlink(path)) {
pr_info(" `- X [%s] ghost\n", path); pr_info(" `- X [%s] ghost\n", path);
return; return;
...@@ -455,7 +456,6 @@ static void try_clean_ghost(struct remap_info *ri) ...@@ -455,7 +456,6 @@ static void try_clean_ghost(struct remap_info *ri)
*/ */
if ((errno == EISDIR)) { if ((errno == EISDIR)) {
strncpy(path + ret, ri->rfi->path, sizeof(path) - 1);
if (!rmdir(path)) { if (!rmdir(path)) {
pr_info(" `- Xd [%s] ghost\n", path); pr_info(" `- Xd [%s] ghost\n", path);
return; return;
...@@ -467,7 +467,7 @@ static void try_clean_ghost(struct remap_info *ri) ...@@ -467,7 +467,7 @@ static void try_clean_ghost(struct remap_info *ri)
void try_clean_remaps(int ns_fd) void try_clean_remaps(int ns_fd)
{ {
struct remap_info *ri; struct ghost_file *gf;
int old_ns = -1; int old_ns = -1;
int cwd_fd = -1; int cwd_fd = -1;
...@@ -497,9 +497,8 @@ void try_clean_remaps(int ns_fd) ...@@ -497,9 +497,8 @@ void try_clean_remaps(int ns_fd)
} }
} }
list_for_each_entry(ri, &remaps, list) list_for_each_entry(gf, &ghost_files, list)
if (ri->rfe->remap_type == REMAP_TYPE__GHOST) try_clean_ghost(gf);
try_clean_ghost(ri);
if (old_ns >= 0) { if (old_ns >= 0) {
if (setns(old_ns, CLONE_NEWNS) < 0) if (setns(old_ns, CLONE_NEWNS) < 0)
......
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