[CRIU] [PATCH v4 2/6] files-reg: Make try_clean_ghost() use struct ghost_file ptr

Kirill Tkhai ktkhai at virtuozzo.com
Mon Jan 25 08:39:44 PST 2016


This cleanup will be used in next patch.

Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
 files-reg.c |   15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/files-reg.c b/files-reg.c
index 735a15a..648c8d2 100644
--- a/files-reg.c
+++ b/files-reg.c
@@ -432,17 +432,18 @@ int prepare_remaps(void)
 	return ret;
 }
 
-static void try_clean_ghost(struct remap_info *ri)
+static void try_clean_ghost(struct ghost_file *gf)
 {
 	char path[PATH_MAX];
 	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));
 	if (ret < 0)
 		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)) {
 		pr_info(" `- X [%s] ghost\n", path);
 		return;
@@ -455,7 +456,6 @@ static void try_clean_ghost(struct remap_info *ri)
 	 */
 
 	if ((errno == EISDIR)) {
-		strncpy(path + ret, ri->rfi->path, sizeof(path) - 1);
 		if (!rmdir(path)) {
 			pr_info(" `- Xd [%s] ghost\n", path);
 			return;
@@ -467,7 +467,7 @@ static void try_clean_ghost(struct remap_info *ri)
 
 void try_clean_remaps(int ns_fd)
 {
-	struct remap_info *ri;
+	struct ghost_file *gf;
 	int old_ns = -1;
 	int cwd_fd = -1;
 
@@ -497,9 +497,8 @@ void try_clean_remaps(int ns_fd)
 		}
 	}
 
-	list_for_each_entry(ri, &remaps, list)
-		if (ri->rfe->remap_type == REMAP_TYPE__GHOST)
-			try_clean_ghost(ri);
+	list_for_each_entry(gf, &ghost_files, list)
+		try_clean_ghost(gf);
 
 	if (old_ns >= 0) {
 		if (setns(old_ns, CLONE_NEWNS) < 0)



More information about the CRIU mailing list