[CRIU] [PATCH 1/2] criu: tty -- Add dumping of queued data
Cyrill Gorcunov
gorcunov at openvz.org
Tue Mar 15 12:18:35 PDT 2016
This is new ioctl code which is not present
on old kernels.
Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
criu/tty.c | 16 ++++++++++++++++
images/tty.proto | 1 +
2 files changed, 17 insertions(+)
diff --git a/criu/tty.c b/criu/tty.c
index ba44af6e033a..869d6593a150 100644
--- a/criu/tty.c
+++ b/criu/tty.c
@@ -1514,6 +1514,12 @@ int dump_verify_tty_sids(void)
return ret;
}
+#define N_TTY_BUF_SIZE 4096
+
+#ifndef TIOCPEEKRAW
+# define TIOCPEEKRAW _IOR('T', 0x41, char)
+#endif
+
static int dump_tty_info(int lfd, u32 id, const struct fd_parms *p, struct tty_driver *driver, int index)
{
TtyInfoEntry info = TTY_INFO_ENTRY__INIT;
@@ -1524,6 +1530,9 @@ static int dump_tty_info(int lfd, u32 id, const struct fd_parms *p, struct tty_d
struct parasite_tty_args *pti;
struct tty_dump_info *dinfo;
+ unsigned char qdata[N_TTY_BUF_SIZE];
+ ssize_t qdata_size;
+
struct termios t;
struct winsize w;
@@ -1621,6 +1630,13 @@ static int dump_tty_info(int lfd, u32 id, const struct fd_parms *p, struct tty_d
}
winsize_copy(&winsize, &w);
+ qdata_size = ioctl(lfd, TIOCPEEKRAW, qdata);
+ if (qdata_size > 0) {
+ info.has_qdata = true;
+ info.qdata.len = qdata_size;
+ info.qdata.data = qdata;
+ }
+
ret = pb_write_one(img_from_set(glob_imgset, CR_FD_TTY_INFO), &info, PB_TTY_INFO);
out:
xfree(termios.c_cc);
diff --git a/images/tty.proto b/images/tty.proto
index 4b5a70c20a88..a846e72b1807 100644
--- a/images/tty.proto
+++ b/images/tty.proto
@@ -62,6 +62,7 @@ message tty_info_entry {
*/
optional tty_pty_entry pty = 12;
optional uint32 dev = 13;
+ optional bytes qdata = 14;
};
message tty_file_entry {
--
2.5.0
More information about the CRIU
mailing list