Skip to contentSkip to conversation

: Fix C/R of termios

PATCH In review Sukadev Bhattiprolu 2 participants 2 messages Dec 22, 2010 – Jan 11, 2011 1 message not in the archive

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 : Fix C/R of termios

From: Sukadev Bhattiprolu <[email protected]>
Date: Fri, 10 Dec 2010 18:36:34 -0800
Subject: [PATCH 1/1] Fix C/R of termios

The kernel uses 'struct ktermios' to represent the terminal attributes. We should checkpoint and restart the 'struct ktermios' object rather than the 'struct termio'.

---
 arch/powerpc/include/asm/checkpoint_hdr.h |    6 +++---
 arch/x86/include/asm/checkpoint_hdr.h     |    6 +++---
 drivers/char/tty_io.c                     |    8 ++++++--
 include/linux/checkpoint_hdr.h            |   14 ++++++++------
 kernel/checkpoint/checkpoint.c            |    2 +-
 kernel/checkpoint/restart.c               |    2 +-
 6 files changed, 22 insertions(+), 16 deletions(-)
arch/powerpc/include/asm/checkpoint_hdr.h +3 -3
index fbb1705..d2e6096 100644
@@ -5,7 +5,7 @@
 
 /* arch dependent constants */
 #define CKPT_ARCH_NSIG 64
-#define CKPT_TTY_NCC  10
+#define CKPT_TTY_NCCS  19
 
 #ifdef __KERNEL__
 
@@ -15,8 +15,8 @@
 #endif
 
 #include <linux/tty.h>
-#if CKPT_TTY_NCC != NCC
-#error CKPT_TTY_NCC size is wrong per asm-generic/termios.h
+#if CKPT_TTY_NCCS != NCCS
+#error CKPT_TTY_NCCS size is wrong per asm/termbits.h
 #endif
 
 #endif /* __KERNEL__ */
arch/x86/include/asm/checkpoint_hdr.h +3 -3
index 0505329..3ac9d29 100644
@@ -54,7 +54,7 @@ enum {
 
 /* arch dependent constants */
 #define CKPT_ARCH_NSIG  64
-#define CKPT_TTY_NCC  8
+#define CKPT_TTY_NCCS	19
 
 #ifdef __KERNEL__
 
@@ -64,8 +64,8 @@ enum {
 #endif
 
 #include <linux/tty.h>
-#if CKPT_TTY_NCC != NCC
-#error CKPT_TTY_NCC size is wrong per asm-generic/termios.h
+#if CKPT_TTY_NCCS != NCCS
+#error CKPT_TTY_NCCS size is wrong per asm-generic/termbits.h
 #endif
 
 #endif /* __KERNEL__ */
drivers/char/tty_io.c +6 -2
index 3a2c770..857d43a 100644
@@ -2882,7 +2882,9 @@ static int checkpoint_tty(struct ckpt_ctx *ctx, void *ptr)
 	h->termios.c_oflag = tty->termios->c_oflag;
 	h->termios.c_cflag = tty->termios->c_cflag;
 	h->termios.c_lflag = tty->termios->c_lflag;
-	memcpy(h->termios.c_cc, tty->termios->c_cc, NCC);
+	memcpy(h->termios.c_cc, tty->termios->c_cc, NCCS);
+	h->termios.c_ispeed = tty->termios->c_ispeed;
+	h->termios.c_ospeed = tty->termios->c_ospeed;
 	h->winsize.ws_row = tty->winsize.ws_row;
 	h->winsize.ws_col = tty->winsize.ws_col;
 	h->winsize.ws_ypixel = tty->winsize.ws_ypixel;
@@ -3099,7 +3101,9 @@ static struct tty_struct *do_restore_tty(struct ckpt_ctx *ctx)
 	tty->termios->c_oflag = h->termios.c_oflag;
 	tty->termios->c_cflag = h->termios.c_cflag;
 	tty->termios->c_lflag = h->termios.c_lflag;
-	memcpy(tty->termios->c_cc, h->termios.c_cc, NCC);
+	memcpy(tty->termios->c_cc, h->termios.c_cc, NCCS);
+	tty->termios->c_ispeed = h->termios.c_ispeed;
+	tty->termios->c_ospeed = h->termios.c_ospeed;
 	tty->winsize.ws_row = h->winsize.ws_row;
 	tty->winsize.ws_col = h->winsize.ws_col;
 	tty->winsize.ws_ypixel = h->winsize.ws_ypixel;
include/linux/checkpoint_hdr.h +8 -6
index 4303235..2f10011 100644
@@ -317,7 +317,7 @@ struct ckpt_const {
 	__u16 rlimit_nlimits;
 	/* tty */
 	__u16 n_tty_buf_size;
-	__u16 tty_termios_ncc;
+	__u16 tty_termios_nccs;
 } __attribute__((aligned(8)));
 
 /* checkpoint image header */
@@ -1138,12 +1138,14 @@ struct ckpt_hdr_tty {
 
 	/* termios */
 	struct {
-		__u16 c_iflag;
-		__u16 c_oflag;
-		__u16 c_cflag;
-		__u16 c_lflag;
+		__u32 c_iflag;
+		__u32 c_oflag;
+		__u32 c_cflag;
+		__u32 c_lflag;
 		__u8 c_line;
-		__u8 c_cc[CKPT_TTY_NCC];
+		__u8 c_cc[CKPT_TTY_NCCS];
+		__u32 c_ispeed;
+		__u32 c_ospeed;
 	} __attribute__((aligned(8))) termios;
 
 	/* winsize */
kernel/checkpoint/checkpoint.c +1 -1
index 55f4dc2..853de1b 100644
@@ -128,7 +128,7 @@ static void fill_kernel_const(struct ckpt_const *h)
 	h->rlimit_nlimits = RLIM_NLIMITS;
 	/* tty */
 	h->n_tty_buf_size = N_TTY_BUF_SIZE;
-	h->tty_termios_ncc = NCC;
+	h->tty_termios_nccs = NCCS;
 }
 
 /* write the checkpoint header */
kernel/checkpoint/restart.c +1 -1
index 17270b8..0e359c2 100644
@@ -593,7 +593,7 @@ static int check_kernel_const(struct ckpt_const *h)
 	/* tty */
 	if (h->n_tty_buf_size != N_TTY_BUF_SIZE)
 		return -EINVAL;
-	if (h->tty_termios_ncc != NCC)
+	if (h->tty_termios_nccs != NCCS)
 		return -EINVAL;
 
 	return 0;
Signature · 1 line
1.6.0.4

A message that is not in the archive (sent off-list or not yet received): 20101222091559.GA32053-r/[email protected]

#2 lore raw

Pulled and merged in v23-rc1, with a slight change: NCCS is known to userspace, so no need for CKPT_TTY_NCCS...

Thanks

Oren.

Quoted 151 lines · Sukadev Bhattiprolu

From: Sukadev Bhattiprolu <[email protected]>
Date: Fri, 10 Dec 2010 18:36:34 -0800
Subject: [PATCH 1/1] Fix C/R of termios

The kernel uses 'struct ktermios' to represent the terminal attributes. We should checkpoint and restart the 'struct ktermios' object rather than the 'struct termio'.

---
 arch/powerpc/include/asm/checkpoint_hdr.h |    6 +++---
 arch/x86/include/asm/checkpoint_hdr.h     |    6 +++---
 drivers/char/tty_io.c                     |    8 ++++++--
 include/linux/checkpoint_hdr.h            |   14 ++++++++------
 kernel/checkpoint/checkpoint.c            |    2 +-
 kernel/checkpoint/restart.c               |    2 +-
 6 files changed, 22 insertions(+), 16 deletions(-)
arch/powerpc/include/asm/checkpoint_hdr.h +3 -3
index fbb1705..d2e6096 100644
@@ -5,7 +5,7 @@
 
 /* arch dependent constants */
 #define CKPT_ARCH_NSIG 64
-#define CKPT_TTY_NCC  10
+#define CKPT_TTY_NCCS  19
 
 #ifdef __KERNEL__
 
@@ -15,8 +15,8 @@
 #endif
 
 #include <linux/tty.h>
-#if CKPT_TTY_NCC != NCC
-#error CKPT_TTY_NCC size is wrong per asm-generic/termios.h
+#if CKPT_TTY_NCCS != NCCS
+#error CKPT_TTY_NCCS size is wrong per asm/termbits.h
 #endif
 
 #endif /* __KERNEL__ */
arch/x86/include/asm/checkpoint_hdr.h +3 -3
index 0505329..3ac9d29 100644
@@ -54,7 +54,7 @@ enum {
 
 /* arch dependent constants */
 #define CKPT_ARCH_NSIG  64
-#define CKPT_TTY_NCC  8
+#define CKPT_TTY_NCCS	19
 
 #ifdef __KERNEL__
 
@@ -64,8 +64,8 @@ enum {
 #endif
 
 #include <linux/tty.h>
-#if CKPT_TTY_NCC != NCC
-#error CKPT_TTY_NCC size is wrong per asm-generic/termios.h
+#if CKPT_TTY_NCCS != NCCS
+#error CKPT_TTY_NCCS size is wrong per asm-generic/termbits.h
 #endif
 
 #endif /* __KERNEL__ */
drivers/char/tty_io.c +6 -2
index 3a2c770..857d43a 100644
@@ -2882,7 +2882,9 @@ static int checkpoint_tty(struct ckpt_ctx *ctx, void *ptr)
 	h->termios.c_oflag = tty->termios->c_oflag;
 	h->termios.c_cflag = tty->termios->c_cflag;
 	h->termios.c_lflag = tty->termios->c_lflag;
-	memcpy(h->termios.c_cc, tty->termios->c_cc, NCC);
+	memcpy(h->termios.c_cc, tty->termios->c_cc, NCCS);
+	h->termios.c_ispeed = tty->termios->c_ispeed;
+	h->termios.c_ospeed = tty->termios->c_ospeed;
 	h->winsize.ws_row = tty->winsize.ws_row;
 	h->winsize.ws_col = tty->winsize.ws_col;
 	h->winsize.ws_ypixel = tty->winsize.ws_ypixel;
@@ -3099,7 +3101,9 @@ static struct tty_struct *do_restore_tty(struct ckpt_ctx *ctx)
 	tty->termios->c_oflag = h->termios.c_oflag;
 	tty->termios->c_cflag = h->termios.c_cflag;
 	tty->termios->c_lflag = h->termios.c_lflag;
-	memcpy(tty->termios->c_cc, h->termios.c_cc, NCC);
+	memcpy(tty->termios->c_cc, h->termios.c_cc, NCCS);
+	tty->termios->c_ispeed = h->termios.c_ispeed;
+	tty->termios->c_ospeed = h->termios.c_ospeed;
 	tty->winsize.ws_row = h->winsize.ws_row;
 	tty->winsize.ws_col = h->winsize.ws_col;
 	tty->winsize.ws_ypixel = h->winsize.ws_ypixel;
include/linux/checkpoint_hdr.h +8 -6
index 4303235..2f10011 100644
@@ -317,7 +317,7 @@ struct ckpt_const {
 	__u16 rlimit_nlimits;
 	/* tty */
 	__u16 n_tty_buf_size;
-	__u16 tty_termios_ncc;
+	__u16 tty_termios_nccs;
 } __attribute__((aligned(8)));
 
 /* checkpoint image header */
@@ -1138,12 +1138,14 @@ struct ckpt_hdr_tty {
 
 	/* termios */
 	struct {
-		__u16 c_iflag;
-		__u16 c_oflag;
-		__u16 c_cflag;
-		__u16 c_lflag;
+		__u32 c_iflag;
+		__u32 c_oflag;
+		__u32 c_cflag;
+		__u32 c_lflag;
 		__u8 c_line;
-		__u8 c_cc[CKPT_TTY_NCC];
+		__u8 c_cc[CKPT_TTY_NCCS];
+		__u32 c_ispeed;
+		__u32 c_ospeed;
 	} __attribute__((aligned(8))) termios;
 
 	/* winsize */
kernel/checkpoint/checkpoint.c +1 -1
index 55f4dc2..853de1b 100644
@@ -128,7 +128,7 @@ static void fill_kernel_const(struct ckpt_const *h)
 	h->rlimit_nlimits = RLIM_NLIMITS;
 	/* tty */
 	h->n_tty_buf_size = N_TTY_BUF_SIZE;
-	h->tty_termios_ncc = NCC;
+	h->tty_termios_nccs = NCCS;
 }
 
 /* write the checkpoint header */
kernel/checkpoint/restart.c +1 -1
index 17270b8..0e359c2 100644
@@ -593,7 +593,7 @@ static int check_kernel_const(struct ckpt_const *h)
 	/* tty */
 	if (h->n_tty_buf_size != N_TTY_BUF_SIZE)
 		return -EINVAL;
-	if (h->tty_termios_ncc != NCC)
+	if (h->tty_termios_nccs != NCCS)
 		return -EINVAL;
 
 	return 0;