[CRIU] [PATCH v2 06/14] files: Count inh_fd_max

Kirill Tkhai ktkhai at virtuozzo.com
Thu Dec 28 16:09:38 MSK 2017


This patch counts maximum of inherited fds.
The value will be used in next patch.

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

diff --git a/criu/files.c b/criu/files.c
index 705fecf5f..d446a2393 100644
--- a/criu/files.c
+++ b/criu/files.c
@@ -1503,6 +1503,8 @@ struct inherit_fd {
 	dev_t inh_rdev;
 };
 
+int inh_fd_max = -1;
+
 /*
  * Return 1 if inherit fd has been closed or reused, 0 otherwise.
  *
@@ -1599,6 +1601,9 @@ int inherit_fd_add(int fd, char *key)
 	if (inh == NULL)
 		return -1;
 
+	if (fd > inh_fd_max)
+		inh_fd_max = fd;
+
 	inh->inh_id = key;
 	inh->inh_fd = fd;
 	inh->inh_dev = sbuf.st_dev;
diff --git a/criu/include/files.h b/criu/include/files.h
index 661a803e1..bd4ab8470 100644
--- a/criu/include/files.h
+++ b/criu/include/files.h
@@ -92,6 +92,8 @@ struct fdinfo_list_entry {
 	u8			fake:1;
 };
 
+extern int inh_fd_max;
+
 /* reports whether fd_a takes prio over fd_b */
 static inline int fdinfo_rst_prio(struct fdinfo_list_entry *fd_a, struct fdinfo_list_entry *fd_b)
 {



More information about the CRIU mailing list