[CRIU] [PATCH v4 12/19] files: Count inh_fd_max

Kirill Tkhai ktkhai at virtuozzo.com
Wed Jan 10 17:02:18 MSK 2018


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 16f9a9169..8f6d50e92 100644
--- a/criu/files.c
+++ b/criu/files.c
@@ -1504,6 +1504,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.
  *
@@ -1600,6 +1602,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