[17/28] files: Add task link to created fdinfo_list_entry and populate it

Submitted by Kirill Tkhai on June 5, 2017, 5:25 p.m.

Details

Message ID 149668355701.25229.14229859736244660638.stgit@localhost.localdomain
State Accepted
Series "Support sockets leaked to child user_ns task"
Commit 045cfb20fc1b90e9c919e5b8d360ad0e0433ae4f
Headers show

Commit Message

Kirill Tkhai June 5, 2017, 5:25 p.m.
This will be used in further to determine whether task's namespace
allows to restore file_desc.

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
---
 criu/files.c         |    6 ++++++
 criu/include/files.h |    1 +
 2 files changed, 7 insertions(+)

Patch hide | download patch | download mbox

diff --git a/criu/files.c b/criu/files.c
index eeb53271e..bbf3edae8 100644
--- a/criu/files.c
+++ b/criu/files.c
@@ -696,6 +696,12 @@  static struct fdinfo_list_entry *alloc_fle(int pid, FdinfoEntry *fe)
 	fle->fe = fe;
 	fle->received = 0;
 	fle->stage = FLE_INITIALIZED;
+	fle->task = pstree_item_by_virt(pid);
+	if (!fle->task) {
+		pr_err("Can't find task with pid %d\n", pid);
+		shfree_last(fle);
+		return NULL;
+	}
 
 	return fle;
 }
diff --git a/criu/include/files.h b/criu/include/files.h
index ef351b7e2..3fe3149f2 100644
--- a/criu/include/files.h
+++ b/criu/include/files.h
@@ -74,6 +74,7 @@  struct fdinfo_list_entry {
 	struct list_head	desc_list;	/* To chain on  @fd_info_head */
 	struct file_desc	*desc;		/* Associated file descriptor */
 	struct list_head	ps_list;	/* To chain  per-task files */
+	struct pstree_item	*task;
 	int			pid;
 	FdinfoEntry		*fe;
 	u8			received:1;