[CRIU] [PATCH v4 05/12] gc: implement link remaps show

Eugene Batalov eabatalov89 at gmail.com
Sun Sep 11 10:14:44 PDT 2016


Signed-off-by: Eugene Batalov <eabatalov89 at gmail.com>
---
 criu/files-reg.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/criu/files-reg.c b/criu/files-reg.c
index 07e9772..ad4a053 100644
--- a/criu/files-reg.c
+++ b/criu/files-reg.c
@@ -712,6 +712,23 @@ static void __rollback_link_remaps(bool do_unlink)
 void delete_link_remaps(void) { __rollback_link_remaps(true); }
 void free_link_remaps(void) { __rollback_link_remaps(false); }
 
+static void show_one_link_remap(struct remap_info *ri)
+{
+	/* Don't print " (deleted)" suffix if it exists */
+	const char DELETED_SUFFIX[] = " (deleted)";
+	size_t path_size = strlen(ri->rfi->path) + 1;
+
+	if (path_size >= sizeof(DELETED_SUFFIX)) {
+		char *path_no_suffix = ri->rfi->path + path_size
+			- sizeof(DELETED_SUFFIX);
+		if (!strcmp(path_no_suffix, DELETED_SUFFIX))
+			path_size -= sizeof(DELETED_SUFFIX) - 1;
+	}
+
+	pr_msg("Link remap: /%s -> /%.*s\n",
+			ri->rfi->remap->rpath, (int)path_size - 1, ri->rfi->path);
+}
+
 int gc_link_remaps(void)
 {
 	struct remap_info *ri;
@@ -721,6 +738,11 @@ int gc_link_remaps(void)
 		if (ri->rfe->remap_type != REMAP_TYPE__LINKED)
 			continue;
 
+		if (opts.show) {
+			show_one_link_remap(ri);
+			continue;
+		}
+
 		remap = ri->rfi->remap;
 		struct ns_id *remap_mntns = lookup_nsid_by_mnt_id(remap->rmnt_id);
 
-- 
1.9.1



More information about the CRIU mailing list