[CRIU] [PATCH v4 02/19] sfds: Kill SELF_STDIN_OFF via fdstore

Kirill Tkhai ktkhai at virtuozzo.com
Wed Jan 10 17:00:39 MSK 2018


Place stdin in fdstore. Kill SELF_STDIN_OFF.

v4: New

Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
 criu/files.c             |    1 -
 criu/include/servicefd.h |    1 -
 criu/include/tty.h       |    1 -
 criu/tty.c               |   15 ++++++---------
 4 files changed, 6 insertions(+), 12 deletions(-)

diff --git a/criu/files.c b/criu/files.c
index 705fecf5f..9d1663d78 100644
--- a/criu/files.c
+++ b/criu/files.c
@@ -1323,7 +1323,6 @@ int prepare_fds(struct pstree_item *me)
 	if (rsti(me)->fdt)
 		futex_inc_and_wake(&rsti(me)->fdt->fdt_lock);
 out:
-	tty_fini_fds();
 	return ret;
 }
 
diff --git a/criu/include/servicefd.h b/criu/include/servicefd.h
index 175e53023..0c4d6c102 100644
--- a/criu/include/servicefd.h
+++ b/criu/include/servicefd.h
@@ -10,7 +10,6 @@ enum sfd_type {
 	IMG_FD_OFF,
 	PROC_FD_OFF,	/* fd with /proc for all proc_ calls */
 	PROC_PID_FD_OFF,
-	SELF_STDIN_OFF,
 	CR_PROC_FD_OFF, /* some other's proc fd.
 			 *  For dump -- target ns' proc
 			 *  For restore -- CRIU ns' proc
diff --git a/criu/include/tty.h b/criu/include/tty.h
index 25fa1c42c..95ced8396 100644
--- a/criu/include/tty.h
+++ b/criu/include/tty.h
@@ -32,7 +32,6 @@ struct mount_info;
 extern int devpts_restore(struct mount_info *pm);
 
 extern int tty_prep_fds(void);
-extern void tty_fini_fds(void);
 
 extern int devpts_check_bindmount(struct mount_info *m);
 
diff --git a/criu/tty.c b/criu/tty.c
index 9ef60d224..1c8cf678a 100644
--- a/criu/tty.c
+++ b/criu/tty.c
@@ -125,6 +125,7 @@ struct tty_dump_info {
 static bool stdin_isatty = false;
 static LIST_HEAD(collected_ttys);
 static LIST_HEAD(all_ttys);
+static int self_stdin_fdid = -1;
 
 /*
  * Usually an application has not that many ttys opened.
@@ -1000,9 +1001,9 @@ static int pty_open_unpaired_slave(struct file_desc *d, struct tty_info *slave)
 			return -1;
 		}
 
-		fd = dup(get_service_fd(SELF_STDIN_OFF));
+		fd = fdstore_get(self_stdin_fdid);
 		if (fd < 0) {
-			pr_perror("Can't dup SELF_STDIN_OFF");
+			pr_err("Can't get self_stdin_fdid\n");
 			return -1;
 		}
 
@@ -2330,19 +2331,15 @@ int tty_prep_fds(void)
 	else
 		stdin_isatty = true;
 
-	if (install_service_fd(SELF_STDIN_OFF, STDIN_FILENO) < 0) {
-		pr_err("Can't dup stdin to SELF_STDIN_OFF\n");
+	self_stdin_fdid = fdstore_add(STDIN_FILENO);
+	if (self_stdin_fdid < 0) {
+		pr_err("Can't place stdin fd to fdstore\n");
 		return -1;
 	}
 
 	return 0;
 }
 
-void tty_fini_fds(void)
-{
-	close_service_fd(SELF_STDIN_OFF);
-}
-
 static int open_pty(void *arg, int flags)
 {
 	int dfd = (unsigned long) arg;



More information about the CRIU mailing list