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

Kirill Tkhai ktkhai at virtuozzo.com
Tue Dec 29 06:05:28 PST 2015


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 19c7358..2f41a84 100644
--- a/files-reg.c
+++ b/files-reg.c
@@ -434,17 +434,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;
@@ -457,7 +458,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;
@@ -469,7 +469,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;
 
@@ -499,9 +499,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