[10/18] fd: Helper for local fd dump

Submitted by Pavel Emelyanov on July 10, 2017, 9:40 a.m.

Details

Message ID 9ddd0e14-2c17-35c9-de0c-790ed3a7621e@virtuozzo.com
State Accepted
Series "Support descriptors sent over unix sockets"
Headers show

Commit Message

Pavel Emelyanov July 10, 2017, 9:40 a.m.
An aux code to dump the received file and report back its
ID and type.

Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
---
 criu/files.c         | 17 +++++++++++++++++
 criu/include/files.h |  1 +
 2 files changed, 18 insertions(+)

Patch hide | download patch | download mbox

diff --git a/criu/files.c b/criu/files.c
index a0e40f1..0387803 100644
--- a/criu/files.c
+++ b/criu/files.c
@@ -536,6 +536,23 @@  static int dump_one_file(struct pid *pid, int fd, int lfd, struct fd_opts *opts,
 	return dump_unsupp_fd(&p, lfd, "unknown", link.name + 1, e);
 }
 
+int dump_my_file(int lfd, u32 *id, int *type)
+{
+	struct pid me = {};
+	struct fd_opts fo = {};
+	FdinfoEntry e = FDINFO_ENTRY__INIT;
+
+	me.real = getpid();
+	me.ns[0].virt = -1; /* FIXME */
+
+	if (dump_one_file(&me, lfd, lfd, &fo, NULL, &e))
+		return -1;
+
+	*id = e.id;
+	*type = e.type;
+	return 0;
+}
+
 int dump_task_files_seized(struct parasite_ctl *ctl, struct pstree_item *item,
 		struct parasite_drain_fd *dfds)
 {
diff --git a/criu/include/files.h b/criu/include/files.h
index a96b744..3dc18df 100644
--- a/criu/include/files.h
+++ b/criu/include/files.h
@@ -131,6 +131,7 @@  struct fdtype_ops {
 
 struct cr_img;
 
+extern int dump_my_file(int lfd, u32 *, int *type);
 extern int do_dump_gen_file(struct fd_parms *p, int lfd,
 			    const struct fdtype_ops *ops,
 			    FdinfoEntry *e);