All of lore.kernel.org
 help / color / mirror / Atom feed
* C/R of termios
@ 2010-12-09  1:28 Sukadev Bhattiprolu
       [not found] ` <20101209012820.GA10001-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: Sukadev Bhattiprolu @ 2010-12-09  1:28 UTC (permalink / raw)
  To: Oren Laadan; +Cc: Containers

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.

---
diff --git a/arch/x86/include/asm/checkpoint_hdr.h b/arch/x86/include/asm/checkpoint_hdr.h
index 0505329..2778aed 100644
--- a/arch/x86/include/asm/checkpoint_hdr.h
+++ b/arch/x86/include/asm/checkpoint_hdr.h
@@ -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__ */
 
 
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c
index 3a2c770..2b3f001 100644
--- a/drivers/char/tty_io.c
+++ b/drivers/char/tty_io.c
@@ -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;
diff --git a/include/linux/checkpoint_hdr.h b/include/linux/checkpoint_hdr.h
index 4303235..e432b04 100644
--- a/include/linux/checkpoint_hdr.h
+++ b/include/linux/checkpoint_hdr.h
@@ -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 */

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: C/R of termios
       [not found] ` <20101209012820.GA10001-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
@ 2010-12-13 14:38   ` Serge E. Hallyn
  2010-12-13 14:54   ` Oren Laadan
  1 sibling, 0 replies; 5+ messages in thread
From: Serge E. Hallyn @ 2010-12-13 14:38 UTC (permalink / raw)
  To: Sukadev Bhattiprolu; +Cc: Containers

Quoting Sukadev Bhattiprolu (sukadev-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org):
> 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.

Looks reasonable to me.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: C/R of termios
       [not found] ` <20101209012820.GA10001-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
  2010-12-13 14:38   ` Serge E. Hallyn
@ 2010-12-13 14:54   ` Oren Laadan
       [not found]     ` <4D063396.3090207-eQaUEPhvms7ENvBUuze7eA@public.gmane.org>
  1 sibling, 1 reply; 5+ messages in thread
From: Oren Laadan @ 2010-12-13 14:54 UTC (permalink / raw)
  To: Sukadev Bhattiprolu; +Cc: Containers

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.

On 12/08/2010 08:28 PM, Sukadev Bhattiprolu wrote:
> 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.
>
> ---
> diff --git a/arch/x86/include/asm/checkpoint_hdr.h b/arch/x86/include/asm/checkpoint_hdr.h
> index 0505329..2778aed 100644
> --- a/arch/x86/include/asm/checkpoint_hdr.h
> +++ b/arch/x86/include/asm/checkpoint_hdr.h
> @@ -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__ */
>
>
> diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c
> index 3a2c770..2b3f001 100644
> --- a/drivers/char/tty_io.c
> +++ b/drivers/char/tty_io.c
> @@ -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;
> diff --git a/include/linux/checkpoint_hdr.h b/include/linux/checkpoint_hdr.h
> index 4303235..e432b04 100644
> --- a/include/linux/checkpoint_hdr.h
> +++ b/include/linux/checkpoint_hdr.h
> @@ -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 */
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: C/R of termios
       [not found]     ` <4D063396.3090207-eQaUEPhvms7ENvBUuze7eA@public.gmane.org>
@ 2010-12-13 18:27       ` Sukadev Bhattiprolu
       [not found]         ` <20101213182706.GC2035-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: Sukadev Bhattiprolu @ 2010-12-13 18:27 UTC (permalink / raw)
  To: Oren Laadan; +Cc: Containers


Oren Laadan [orenl-eQaUEPhvms7ENvBUuze7eA@public.gmane.org] 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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: C/R of termios
       [not found]         ` <20101213182706.GC2035-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
@ 2010-12-13 19:21           ` Oren Laadan
  0 siblings, 0 replies; 5+ messages in thread
From: Oren Laadan @ 2010-12-13 19:21 UTC (permalink / raw)
  To: Sukadev Bhattiprolu; +Cc: Containers


Ok, thanks.

On 12/13/2010 01:27 PM, Sukadev Bhattiprolu wrote:
>
> Oren Laadan [orenl-eQaUEPhvms7ENvBUuze7eA@public.gmane.org] 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
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2010-12-13 19:21 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-12-09  1:28 C/R of termios Sukadev Bhattiprolu
     [not found] ` <20101209012820.GA10001-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2010-12-13 14:38   ` Serge E. Hallyn
2010-12-13 14:54   ` Oren Laadan
     [not found]     ` <4D063396.3090207-eQaUEPhvms7ENvBUuze7eA@public.gmane.org>
2010-12-13 18:27       ` Sukadev Bhattiprolu
     [not found]         ` <20101213182706.GC2035-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2010-12-13 19:21           ` Oren Laadan

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.