[CRIU] [PATCH v3 11/15] files: Add file_desc_ops::receive method
Kirill Tkhai
ktkhai at virtuozzo.com
Wed Jun 1 08:12:58 PDT 2016
Currently, nothing is done for master files in receive_fd().
Add a receive method, which may be useful for subsystems,
which need it (for queuer-less dgram sockets, going in following
patches).
Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
criu/files.c | 3 ++-
criu/include/files.h | 10 +++++++++-
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/criu/files.c b/criu/files.c
index bb3b142..22668ec 100644
--- a/criu/files.c
+++ b/criu/files.c
@@ -1053,12 +1053,13 @@ static int open_fd(int pid, struct fdinfo_list_entry *fle)
static int receive_fd(int pid, struct fdinfo_list_entry *fle)
{
+ struct file_desc *d = fle->desc;
int tmp;
struct fdinfo_list_entry *flem;
flem = file_master(fle->desc);
if (flem->pid == pid)
- return 0;
+ return d->ops->receive ? d->ops->receive(d, fle->fe->fd) : 0;
pr_info("\tReceive fd for %d\n", fle->fe->fd);
diff --git a/criu/include/files.h b/criu/include/files.h
index 5e3d6dc..f0d5f23 100644
--- a/criu/include/files.h
+++ b/criu/include/files.h
@@ -90,7 +90,15 @@ struct file_desc_ops {
int (*open)(struct file_desc *d);
/*
* Called on a file when all files of that type are opened
- * and with the fd being the "restored" one.
+ * and with the fd being the "restored" one. This may be used
+ * to receive some additional file descriptors that are needed
+ * at post_open stage.
+ */
+ int (*receive)(struct file_desc *d, int fd);
+ /*
+ * Called on a file when all files of that type are opened
+ * and with the fd being the "restored" one and all data need
+ * to complete restore is received.
*/
int (*post_open)(struct file_desc *d, int fd);
/*
More information about the CRIU
mailing list