[07/18] tty: Generate unique ID for satellite regfile entry

Submitted by Pavel Emelianov on July 10, 2017, 9:39 a.m.

Details

Message ID f6b62d6a-b5e7-3b7e-18dd-5426b116d4b2@virtuozzo.com
State Accepted
Series "Support descriptors sent over unix sockets"
Commit 47279341f882b379d81da79e1d2db84311cb0466
Headers show

Commit Message

Pavel Emelianov July 10, 2017, 9:39 a.m.
Same thing as for fifo-s.

Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
---
 criu/tty.c       | 18 ++++++++++++++----
 images/tty.proto |  1 +
 2 files changed, 15 insertions(+), 4 deletions(-)

Patch hide | download patch | download mbox

diff --git a/criu/tty.c b/criu/tty.c
index a967ee3..b42e54a 100644
--- a/criu/tty.c
+++ b/criu/tty.c
@@ -1619,7 +1619,8 @@  static int collect_one_tty(void *obj, ProtobufCMessage *msg, struct cr_img *i)
 	 * reg file rectord because they are inherited from
 	 * command line on restore.
 	 */
-	info->reg_d = try_collect_special_file(info->tfe->id, 1);
+	info->reg_d = try_collect_special_file( info->tfe->has_regf_id ?
+			info->tfe->regf_id : info->tfe->id, 1);
 	if (!info->reg_d) {
 		if (info->driver->type != TTY_TYPE__EXT_TTY) {
 			if (!deprecated_ok("TTY w/o regfile"))
@@ -1908,14 +1909,23 @@  static int dump_one_tty(int lfd, u32 id, const struct fd_parms *p)
 		return -1;
 	}
 
-	if (driver->type != TTY_TYPE__EXT_TTY && dump_one_reg_file(lfd, id, p))
-		return -1;
-
 	e.id		= id;
 	e.tty_info_id	= tty_gen_id(driver, index);
 	e.flags		= p->flags;
 	e.fown		= (FownEntry *)&p->fown;
 
+	if (driver->type != TTY_TYPE__EXT_TTY) {
+		u32 rf_id;
+
+		fd_id_generate_special(NULL, &rf_id);
+		if (dump_one_reg_file(lfd, rf_id, p))
+			return -1;
+
+		e.has_regf_id = true;
+		e.regf_id = rf_id;
+	}
+
+
 	/*
 	 * FIXME
 	 *
diff --git a/images/tty.proto b/images/tty.proto
index 8ae804a..12c6166 100644
--- a/images/tty.proto
+++ b/images/tty.proto
@@ -87,4 +87,5 @@  message tty_file_entry {
 	required fown_entry		fown		= 4;
 
 	// optional sint32		mnt_id		= 5 [default = 0];
+	optional uint32			regf_id		= 6;
 }