login
Header Space

 
 

Re: Fix VT canonical input in UTF-8 mode [Was: UTF-8 fixes in comments]

Previous thread: 2.6.25-git WARNING: at arch/x86/kernel/genapic_64.c:86 read_apic_id+0x2e/0x46() by Kevin Winchester on Tuesday, April 29, 2008 - 7:59 pm. (3 messages)

Next thread: [PATCH] Account for user time when updating memory integrals by Jonathan Lim on Tuesday, April 29, 2008 - 8:48 pm. (1 message)
To: <linux-kernel@...>
Date: Tuesday, April 29, 2008 - 8:08 pm

Confirmed.

Try init=/bin/stty -a, that will show

-iutf8

So there is little wonder that canonical mode does not work as expected.

Try init=/bin/sh, from that shell run stty iutf8. Then things will work
fine.  The fix is thus just to make the VT's tty initial iutf8 setup
follow vt.default_utf8.

Samuel
--
To: Samuel Thibault <samuel.thibault@...>, <linux-kernel@...>
Date: Wednesday, April 30, 2008 - 3:49 pm

Will try that on a more recent install. Mine's stty does not support
this option. Your analysis makes quite a lot of sense, and such a fix
would wipe part of my annoyances/anger with this recent change.

Thanks,
Willy

--
To: Willy Tarreau <w@...>
Cc: <linux-kernel@...>, <akpm@...>
Date: Saturday, May 3, 2008 - 7:50 pm

Hello,


Can you give the patch below a try?
Dynamic per-VT utf-8 switch should also work, provided that you reopen
the VT (i.e. log out).

Samuel



Set IUTF8 as appropriate on VT tty open.

Signed-off-by: Samuel Thibault &lt;samuel.thibault@ens-lyon.org&gt;

--- linux/drivers/char/vt.c.orig	2008-05-04 00:37:50.000000000 +0100
+++ linux/drivers/char/vt.c	2008-05-04 00:47:39.000000000 +0100
@@ -2723,6 +2723,10 @@ static int con_open(struct tty_struct *t
 				tty-&gt;winsize.ws_row = vc_cons[currcons].d-&gt;vc_rows;
 				tty-&gt;winsize.ws_col = vc_cons[currcons].d-&gt;vc_cols;
 			}
+			if (vc-&gt;vc_utf)
+				tty-&gt;termios-&gt;c_iflag |= IUTF8;
+			else
+				tty-&gt;termios-&gt;c_iflag &amp;= ~IUTF8;
 			release_console_sem();
 			vcs_make_sysfs(tty);
 			return ret;
@@ -2899,6 +2903,8 @@ int __init vty_init(void)
 	console_driver-&gt;minor_start = 1;
 	console_driver-&gt;type = TTY_DRIVER_TYPE_CONSOLE;
 	console_driver-&gt;init_termios = tty_std_termios;
+	if (default_utf8)
+		console_driver-&gt;init_termios.c_iflag |= IUTF8;
 	console_driver-&gt;flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_RESET_TERMIOS;
 	tty_set_operations(console_driver, &amp;con_ops);
 	if (tty_register_driver(console_driver))
--
To: Willy Tarreau <w@...>, <linux-kernel@...>, <akpm@...>, <stable@...>
Date: Sunday, May 4, 2008 - 6:25 am

I guess this is suitable for the stable trees of 2.6.24 and 2.6.25
(where UTF-8 is by default now).




Set IUTF8 as appropriate on VT tty open.

Signed-off-by: Samuel Thibault &lt;samuel.thibault@ens-lyon.org&gt;

--- linux/drivers/char/vt.c.orig	2008-05-04 00:37:50.000000000 +0100
+++ linux/drivers/char/vt.c	2008-05-04 00:47:39.000000000 +0100
@@ -2723,6 +2723,10 @@ static int con_open(struct tty_struct *t
 				tty-&gt;winsize.ws_row = vc_cons[currcons].d-&gt;vc_rows;
 				tty-&gt;winsize.ws_col = vc_cons[currcons].d-&gt;vc_cols;
 			}
+			if (vc-&gt;vc_utf)
+				tty-&gt;termios-&gt;c_iflag |= IUTF8;
+			else
+				tty-&gt;termios-&gt;c_iflag &amp;= ~IUTF8;
 			release_console_sem();
 			vcs_make_sysfs(tty);
 			return ret;
@@ -2899,6 +2903,8 @@ int __init vty_init(void)
 	console_driver-&gt;minor_start = 1;
 	console_driver-&gt;type = TTY_DRIVER_TYPE_CONSOLE;
 	console_driver-&gt;init_termios = tty_std_termios;
+	if (default_utf8)
+		console_driver-&gt;init_termios.c_iflag |= IUTF8;
 	console_driver-&gt;flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_RESET_TERMIOS;
 	tty_set_operations(console_driver, &amp;con_ops);
 	if (tty_register_driver(console_driver))

--
To: Samuel Thibault <samuel.thibault@...>
Cc: <w@...>, <linux-kernel@...>, <stable@...>
Date: Monday, May 5, 2008 - 7:00 pm

On Sun, 4 May 2008 11:25:54 +0100

That changelog is pretty darn terse :(  I'll often go through
the email ladder and try to extract the missing information
but this time I don't really see it there.

Things like: what is the kernel's current behaviour, why does
it behave that way, how does the patch fix it?

Thanks.
--
To: Andrew Morton <akpm@...>
Cc: <w@...>, <linux-kernel@...>, <stable@...>
Date: Monday, May 5, 2008 - 7:54 pm

Well, it's more an implementation than a fix. Let's try again:



For e.g. proper TTY canonical support, IUTF8 termios flag has to be set
as appropriate.  Linux used to not care about setting that flag for VT
TTYs.

This patch fixes that by activating it according to the current mode
of the VT, and sets the default value according to the vt.default_utf8
parameter.



Samuel
--
To: Samuel Thibault <samuel.thibault@...>, <linux-kernel@...>, <akpm@...>, <stable@...>
Date: Sunday, May 4, 2008 - 7:03 am

You should have added:  CC: stable@kernel.org here so that the stable
team automatically gets notified when it's merged into mainline.

Thanks!
Willy

--
To: Samuel Thibault <samuel.thibault@...>, <linux-kernel@...>, <akpm@...>
Date: Sunday, May 4, 2008 - 4:55 am

Hi Samuel,


I confirm that your patch works perfectly for me. Now backspace correctly
removes multi-byte characters. My bash is still fooled though but as Alan
explained it, it's readline which has to be upgraded now.

Thanks!
Willy

--
To: <linux-kernel@...>
Cc: <cmadams@...>, Willy Tarreau <w@...>, Alan Cox <alan@...>, Helge Hafting <helge.hafting@...>, Adrian Bunk <bunk@...>, H. Peter Anvin <hpa@...>
Date: Wednesday, April 30, 2008 - 5:38 am

Yes of course, but here the purpose was _not_ programs like bash, but
the canonical mode (i.e. programs like cat etc.), for which the LANG
variable has no effect, only iutf8 has.

Samuel
--
To: Samuel Thibault <samuel.thibault@...>, <linux-kernel@...>, <cmadams@...>, Alan Cox <alan@...>, Helge Hafting <helge.hafting@...>, Adrian Bunk <bunk@...>, H. Peter Anvin <hpa@...>
Date: Wednesday, April 30, 2008 - 3:45 pm

exactly, thanks for understanding my problem Samuel :-)

Willy
--
To: <linux-kernel@...>
Date: Tuesday, April 29, 2008 - 11:38 pm

You may also need to select a UTF-8 locale (e.g. LANG="en_US.UTF-8") for
programs like bash to handle this correctly.

-- 
Chris Adams &lt;cmadams@hiwaay.net&gt;
Systems and Network Administrator - HiWAAY Internet Services
I don't speak for anybody but myself - that's enough trouble.
--
Previous thread: 2.6.25-git WARNING: at arch/x86/kernel/genapic_64.c:86 read_apic_id+0x2e/0x46() by Kevin Winchester on Tuesday, April 29, 2008 - 7:59 pm. (3 messages)

Next thread: [PATCH] Account for user time when updating memory integrals by Jonathan Lim on Tuesday, April 29, 2008 - 8:48 pm. (1 message)
speck-geostationary