[CRIU] [PATCH 05/12] dump: files tree - merge pid+fd into one structure

Kinsbursky Stanislav skinsbursky at openvz.org
Fri Mar 23 12:23:38 EDT 2012


From: Stanislav Kinsbursky <skinsbursky at openvz.org>

This is a precursor patch. Will be usefull on restore stage later in the series.

Signed-off-by: Stanislav Kinsbursky <skinsbursky at openvz.org>
---
 file-ids.c         |    6 +++---
 include/file-ids.h |    8 ++++++--
 2 files changed, 9 insertions(+), 5 deletions(-)
-------------- next part --------------
diff --git a/file-ids.c b/file-ids.c
index 9d2608f..9bb7b96 100644
--- a/file-ids.c
+++ b/file-ids.c
@@ -71,8 +71,8 @@ static struct fd_id_entry *alloc_fd_id_entry(u32 genid, pid_t pid, int fd)
 
 	e->u.key.subid	= fd_id_entries_subid++;
 	e->u.key.genid	= genid;
-	e->pid		= pid;
-	e->fd		= fd;
+	e->info.pid	= pid;
+	e->info.fd	= fd;
 
 	/* Make sure no overflow here */
 	BUG_ON(!e->u.key.subid);
@@ -95,7 +95,7 @@ lookup_alloc_subtree(struct fd_id_entry *e, u32 genid, pid_t pid, int fd)
 
 	while (node) {
 		struct fd_id_entry *this = rb_entry(node, struct fd_id_entry, subtree_node);
-		int ret = sys_kcmp(this->pid, pid, KCMP_FILE, this->fd, fd);
+		int ret = sys_kcmp(this->info.pid, pid, KCMP_FILE, this->info.fd, fd);
 
 		parent = *new;
 		if (ret < 0)
diff --git a/include/file-ids.h b/include/file-ids.h
index 3001f80..dc36cbc 100644
--- a/include/file-ids.h
+++ b/include/file-ids.h
@@ -8,6 +8,11 @@
 #define FD_ID_INVALID		(-1UL)
 #define FD_PID_INVALID		((int)-2UL)
 
+struct file_info {
+	int			fd;
+	int			pid;
+};
+
 struct fd_id_entry {
 	struct rb_node	node;
 
@@ -22,8 +27,7 @@ struct fd_id_entry {
 		u64			id;
 	} u;
 
-	pid_t		pid;
-	int		fd;
+	struct file_info	info;
 } __aligned(sizeof(long));
 
 #define MAKE_FD_GENID(dev, ino, pos) \


More information about the CRIU mailing list