C/R of termios
Subsystems (2)
Oren,
Any reason we only checkpoint/restore a 'struct termio' instead of a 'struct termios' ?
AFAICT, 'struct termios' seems to supersede 'struct termio' (i.e includes all fields of 'struct termio' plus more). The TCGETS ioctl and tcgetattr() interface return a 'struct termios' to user space.
The man page termio(7) says the 'struct termio' interface is obsolete.
The kernel uses 'struct ktermios' to represent the attributes internally. So shouldn't we checkpoint/restore the 'struct ktermios' object ?
If application uses legacy interface (TCGETA/TCSETA with 'struct termio') the kernel converts the 'struct ktermios' to the 'struct termio' in kernel_termios_to_user_termio(). So we should be fine if we C/R the ktermios object right ?
Here is a quick hack, just for reference. With this hack, I can C/R an app that does tcgetattr() of a pty before/after checkpoint.
---
arch/x86/include/asm/checkpoint_hdr.h +5 -0
@@ -55,6 +55,7 @@ enum {/* arch dependent constants */ #define CKPT_ARCH_NSIG 64#define CKPT_TTY_NCC 8 +#define CKPT_TTY_NCCS 19#ifdef __KERNEL__
@@ -68,6 +69,10 @@ enum {#error CKPT_TTY_NCC size is wrong per asm-generic/termios.h#endif +#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 +2 -2
@@ -2882,7 +2882,7 @@ 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->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 +3099,7 @@ 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->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 +3 -1
@@ -1143,7 +1143,9 @@ struct ckpt_hdr_tty {__u16 c_cflag;__u16 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 */
A message that is not in the archive (sent off-list or not yet received): 20101209012820.GA10001-r/[email protected]
Quoted 14 lines · Sukadev Bhattiprolu
Oren,
Any reason we only checkpoint/restore a 'struct termio' instead of a 'struct termios' ?
AFAICT, 'struct termios' seems to supersede 'struct termio' (i.e includes all fields of 'struct termio' plus more). The TCGETS ioctl and
tcgetattr()interface return a 'struct termios' to user space.The man page termio(7) says the 'struct termio' interface is obsolete.
The kernel uses 'struct ktermios' to represent the attributes internally. So shouldn't we checkpoint/restore the 'struct ktermios' object ?
Quoted 7 lines
If application uses legacy interface (TCGETA/TCSETA with 'struct termio') the kernel converts the 'struct ktermios' to the 'struct termio' in
kernel_termios_to_user_termio(). So we should be fine if we C/R the ktermios object right ?Here is a quick hack, just for reference. With this hack, I can C/R an app that does
tcgetattr()of a pty before/after checkpoint.
Looks reasonable to me.
Suka,
Yes, I overlooked it, thanks for pointing out. The patch looks fine - queued for inclusion. (I'll remove the now-unneeded define of CKPT_TTY_NCC)
Oren.
Quoted 84 lines · Sukadev Bhattiprolu
Oren,
Any reason we only checkpoint/restore a 'struct termio' instead of a 'struct termios' ?
AFAICT, 'struct termios' seems to supersede 'struct termio' (i.e includes all fields of 'struct termio' plus more). The TCGETS ioctl and
tcgetattr()interface return a 'struct termios' to user space.The man page termio(7) says the 'struct termio' interface is obsolete.
The kernel uses 'struct ktermios' to represent the attributes internally. So shouldn't we checkpoint/restore the 'struct ktermios' object ?
If application uses legacy interface (TCGETA/TCSETA with 'struct termio') the kernel converts the 'struct ktermios' to the 'struct termio' in
kernel_termios_to_user_termio(). So we should be fine if we C/R the ktermios object right ?Here is a quick hack, just for reference. With this hack, I can C/R an app that does
tcgetattr()of a pty before/after checkpoint.---
arch/x86/include/asm/checkpoint_hdr.h +5
-0@@ -55,6 +55,7 @@ enum {/* arch dependent constants */ #define CKPT_ARCH_NSIG 64#define CKPT_TTY_NCC 8 +#define CKPT_TTY_NCCS 19#ifdef __KERNEL__@@ -68,6 +69,10 @@ enum {#error CKPT_TTY_NCC size is wrong per asm-generic/termios.h#endif +#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 +2
-2@@ -2882,7 +2882,7 @@ 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->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 +3099,7 @@ 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->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 +3
-1@@ -1143,7 +1143,9 @@ struct ckpt_hdr_tty {__u16 c_cflag;__u16 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 */
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 5 lines · Oren Laadan [[email protected]] wrote:
Suka,
Yes, I overlooked it, thanks for pointing out. The patch looks fine - queued for inclusion. (I'll remove the now-unneeded define of
CKPT_TTY_NCC)
I can post a cleaner patch in a couple of days - one that works for other architectures too.
Thanks,
Sukadev
A message that is not in the archive (sent off-list or not yet received): 20101213182706.GC2035-r/[email protected]
Ok, thanks.
Quoted 15 lines · Sukadev Bhattiprolu
Quoted 5 lines · Oren Laadan [[email protected]] wrote:
Suka,
Yes, I overlooked it, thanks for pointing out. The patch looks fine - queued for inclusion. (I'll remove the now-unneeded define of
CKPT_TTY_NCC)I can post a cleaner patch in a couple of days - one that works for other architectures too.
Thanks,
Sukadev