From c0e929abc55d5a9c8831035f1e0985bc3746c62c Mon Sep 17 00:00:00 2001 From: Pavel Emelyanov Date: Mon, 10 Jul 2017 12:39:05 +0300 Subject: [PATCH] fifo: Generate unique ID for satellite regfile entry The plan is to have all file entries have unique ID. Fifo generates a reg file entry to reuse the whole reg-files c/r-ing engine (ghosts, open-by-path, etc.) and right now ID for this entry is the same as for fifo entry. Reviewed-by: Kirill Tkhai Signed-off-by: Pavel Emelyanov Signed-off-by: Andrei Vagin --- criu/fifo.c | 14 +++++++++++--- images/fifo.proto | 1 + 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/criu/fifo.c b/criu/fifo.c index d0728e1b0..a26934319 100644 --- a/criu/fifo.c +++ b/criu/fifo.c @@ -8,6 +8,7 @@ #include "image.h" #include "files.h" #include "files-reg.h" +#include "file-ids.h" #include "pipes.h" #include "fifo.h" @@ -43,13 +44,16 @@ static int dump_one_fifo(int lfd, u32 id, const struct fd_parms *p) struct cr_img *img = img_from_set(glob_imgset, CR_FD_FILES); FileEntry fe = FILE_ENTRY__INIT; FifoEntry e = FIFO_ENTRY__INIT; + u32 rf_id; + + fd_id_generate_special(NULL, &rf_id); /* * It's a trick here, we use regular files dumping * code to save path to a fifo, then we reuse it * on restore. */ - if (dump_one_reg_file(lfd, id, p)) + if (dump_one_reg_file(lfd, rf_id, p)) return -1; pr_info("Dumping fifo %d with id %#x pipe_id %#x\n", @@ -57,6 +61,8 @@ static int dump_one_fifo(int lfd, u32 id, const struct fd_parms *p) e.id = id; e.pipe_id = pipe_id(p); + e.has_regf_id = true; + e.regf_id = rf_id; fe.type = FD_TYPES__FIFO; fe.id = e.id; @@ -116,8 +122,10 @@ static int open_fifo_fd(struct file_desc *d, int *new_fd) struct file_desc *reg_d; int fd; - reg_d = find_file_desc_raw(FD_TYPES__REG, info->fe->id); - BUG_ON(!reg_d); + reg_d = collect_special_file(info->fe->has_regf_id ? + info->fe->regf_id : info->fe->id); + if (!reg_d) + return -1; fd = open_path(reg_d, do_open_fifo, info); if (fd < 0) diff --git a/images/fifo.proto b/images/fifo.proto index 9d5b9538b..f5b3283ff 100644 --- a/images/fifo.proto +++ b/images/fifo.proto @@ -3,4 +3,5 @@ syntax = "proto2"; message fifo_entry { required uint32 id = 1; required uint32 pipe_id = 2; + optional uint32 regf_id = 3; }