[CRIU] [PATCH 1/2] files-reg: Add try_collect_special_file

Cyrill Gorcunov gorcunov at openvz.org
Fri Oct 17 05:52:09 PDT 2014


The idea is to be able to lookup for special id
which might be not present and we should not
yield the error.

Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
 files-reg.c         | 5 +++--
 include/files-reg.h | 4 +++-
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/files-reg.c b/files-reg.c
index 445f5cdf041c..47a79881a9b5 100644
--- a/files-reg.c
+++ b/files-reg.c
@@ -1127,7 +1127,7 @@ static struct file_desc_ops reg_desc_ops = {
 	.collect_fd = collect_reg_fd,
 };
 
-struct file_desc *collect_special_file(u32 id)
+struct file_desc *try_collect_special_file(u32 id, int optional)
 {
 	struct file_desc *fdesc;
 
@@ -1140,7 +1140,8 @@ struct file_desc *collect_special_file(u32 id)
 
 	fdesc = find_file_desc_raw(FD_TYPES__REG, id);
 	if (fdesc == NULL) {
-		pr_err("No entry for reg-file-ID %#x\n", id);
+		if (!optional)
+			pr_err("No entry for reg-file-ID %#x\n", id);
 		return NULL;
 	}
 
diff --git a/include/files-reg.h b/include/files-reg.h
index 706911447643..3d0e8569753f 100644
--- a/include/files-reg.h
+++ b/include/files-reg.h
@@ -40,7 +40,9 @@ extern int dump_one_reg_file(int lfd, u32 id, const struct fd_parms *p);
 
 extern struct file_remap *lookup_ghost_remap(u32 dev, u32 ino);
 extern void remap_put(struct file_remap *remap);
-extern struct file_desc *collect_special_file(u32 id);
+
+extern struct file_desc *try_collect_special_file(u32 id, int optional);
+#define collect_special_file(id)	try_collect_special_file(id, 0)
 
 extern struct collect_image_info reg_file_cinfo;
 extern struct collect_image_info remap_cinfo;
-- 
1.9.3



More information about the CRIU mailing list