[21/28] files: Populate file_desc::setns_userns

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

Details

Message ID 149668359310.25229.13726243731453826763.stgit@localhost.localdomain
State Accepted
Series "Support sockets leaked to child user_ns task"
Commit 56c0cf2a7c0444ca7c5bcc7e244d552ef52da99f
Headers show

Commit Message

Kirill Tkhai June 5, 2017, 5:26 p.m.
Do it here once to use cached value later.

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

Patch hide | download patch | download mbox

diff --git a/criu/files.c b/criu/files.c
index ce52ebd86..eaa41d3a6 100644
--- a/criu/files.c
+++ b/criu/files.c
@@ -71,12 +71,17 @@  void file_desc_init(struct file_desc *d, u32 id, struct file_desc_ops *ops)
 
 	d->id	= id;
 	d->ops	= ops;
+	d->setns_userns = NULL;
 }
 
 int file_desc_add(struct file_desc *d, u32 id, struct file_desc_ops *ops)
 {
+	uint32_t file_user_ns;
 	file_desc_init(d, id, ops);
 	hlist_add_head(&d->hash, &file_desc_hash[id % FDESC_HASH_SIZE]);
+	if (d->ops->get_user_ns) {
+		d->ops->get_user_ns(d, &file_user_ns, &d->setns_userns);
+	}
 	return 0; /* this is to make tail-calls in collect_one_foo look nice */
 }
 
diff --git a/criu/include/files.h b/criu/include/files.h
index 2351e41c6..520abf668 100644
--- a/criu/include/files.h
+++ b/criu/include/files.h
@@ -117,6 +117,7 @@  struct file_desc {
 	struct hlist_node	hash;		/* Descriptor hashing and lookup */
 	struct list_head	fd_info_head;	/* Chain of fdinfo_list_entry-s with same ID and type but different pids */
 	struct file_desc_ops	*ops;		/* Associated operations */
+	struct ns_id		*setns_userns;	/* Minimal user_ns to be able to restore this file */
 };
 
 struct fdtype_ops {