[08/12] files: Add file_desc_ops::receive method

Submitted by Kirill Tkhai on April 29, 2016, 2:36 p.m.

Details

Message ID 146194061534.9179.8744765626787652632.stgit@pro
State Rejected
Series "Support for packet's msg_name in receive queue of promiscous DGRAM sockets"
Headers show

Commit Message

Kirill Tkhai April 29, 2016, 2:36 p.m.
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@virtuozzo.com>
---
 criu/files.c         |    3 ++-
 criu/include/files.h |   10 +++++++++-
 2 files changed, 11 insertions(+), 2 deletions(-)

Patch hide | download patch | download mbox

diff --git a/criu/files.c b/criu/files.c
index 67c6721..fd5c61d 100644
--- a/criu/files.c
+++ b/criu/files.c
@@ -979,12 +979,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 5db6ab1..472cc45 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);
 	/*