[CRIU] [PATCH v4 28/33] files: Move ctty fixup to open_fd()

Kirill Tkhai ktkhai at virtuozzo.com
Tue Dec 13 07:08:19 PST 2016


Fixup ctty right after it's open. It'll need for
merging tty files in single fds list: set ctty
before next fle in list is processed. See next
patch for the details.

v4: New

Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
 criu/files.c |   21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/criu/files.c b/criu/files.c
index 0a86851..95f3912 100644
--- a/criu/files.c
+++ b/criu/files.c
@@ -992,9 +992,7 @@ static int open_fd(int pid, struct fdinfo_list_entry *fle)
 		ret = receive_fd(pid, fle);
 		if (ret != ORV_OK)
 			return ret;
-
-		fle->stage = FLE_RESTORED;
-		return ORV_OK;
+		goto fixup_ctty;
 	}
 
 	ret = d->ops->open(d, &new_fd);
@@ -1003,8 +1001,16 @@ static int open_fd(int pid, struct fdinfo_list_entry *fle)
 			return ORV_ERR;
 	}
 
-	if (ret == ORV_OK)
+fixup_ctty:
+	if (ret == ORV_OK) {
+		if (fle->fe->fd == get_service_fd(CTL_TTY_OFF)) {
+			ret = tty_restore_ctl_terminal(fle->desc, fle->fe->fd);
+			if (ret == ORV_ERR)
+				return ret;
+		}
+
 		fle->stage = FLE_RESTORED;
+	}
 	return ret;
 }
 
@@ -1031,7 +1037,7 @@ static int receive_fd(int pid, struct fdinfo_list_entry *fle)
 
 static int open_fdinfos(int pid, struct list_head *list)
 {
-	struct fdinfo_list_entry *fle, *tmp, *service_fle = NULL;
+	struct fdinfo_list_entry *fle, *tmp;
 	LIST_HEAD(completed);
 	bool progress, again;
 	int st, ret = 0;
@@ -1058,8 +1064,6 @@ static int open_fdinfos(int pid, struct list_head *list)
 			}
 			if (ret == ORV_AGAIN)
 			       again = true;
-			if (fle->fe->fd == get_service_fd(CTL_TTY_OFF))
-				service_fle = fle;
 		}
 		if (!progress && again)
 			wait_fds_event();
@@ -1069,9 +1073,6 @@ static int open_fdinfos(int pid, struct list_head *list)
 splice:
 	list_splice(&completed, list);
 
-	if (ret == ORV_OK && service_fle)
-		ret = tty_restore_ctl_terminal(service_fle->desc, service_fle->fe->fd);
-
 	return ret;
 }
 



More information about the CRIU mailing list