![]() | |||||||||||
Messages in this thread Patch in this message |
This patch fixes a bug in the virtual terminal driver, whereby the UTF-8
mode is reset to "off" following a console reset, such as might be
delivered by mingetty, screen, vim, etc...
Rather than resetting to hardcoded "0", it gets reset on or off, as
determined by a new sysctl located in /proc/tty/vt/default_utf8_mode.
This patch is best accompanied with an addition of the following line to
the system's init scripts:
echo 1 >/proc/tty/vt/default_utf8_mode
Following this, all resets to the console will leave it with UTF-8 mode
on.
The default behaviour of this sysctl is as before, without the patch.
Namely, UTF-8 mode is switched off on reset. [I.e applying this patch
does not affect default behaviour].
Signed-off-by: Paul Evans <leonerd@leonerd.org.uk>
--- linux-2.6.11/drivers/char/vt.c 2005-05-04 02:01:08.000000000
+0100 +++ linux-2.6.11-utfswitch/drivers/char/vt.c 2005-05-07
22:41:58.000000000 +0100 @@ -93,6 +93,7 @@
#include <linux/pm.h>
#include <linux/font.h>
#include <linux/bitops.h>
+#include <linux/proc_fs.h>
#include <asm/io.h>
#include <asm/system.h>
@@ -162,6 +163,15 @@
static int blankinterval = 10*60*HZ;
static int vesa_off_interval;
+/*
+ * When resetting a console, do we start in UTF-8 mode or not?
+ * 0 = no, 1 = yes
+ */
+static int default_utf8_mode = 0;
+
+struct proc_dir_entry *proc_vt_dir;
+struct proc_dir_entry *proc_default_utf8_mode;
+
static DECLARE_WORK(console_work, console_callback, NULL);
/*
@@ -1472,7 +1482,7 @@
charset = 0;
need_wrap = 0;
report_mouse = 0;
- utf = 0;
+ utf = default_utf8_mode;
utf_count = 0;
disp_ctrl = 0;
@@ -2530,6 +2540,63 @@
reset_terminal(currcons, do_clear);
}
+static int proc_write_default_utf8_mode(struct file *file, const char
*buffer,
+ unsigned long count, void *data)
+{
+ char temp[16];
+ int len;
+
+ if (count > sizeof(temp)-1)
+ len = sizeof(temp)-1;
+ else
+ len = count;
+
+ if (copy_from_user(temp, buffer, len))
+ return -EFAULT;
+
+ temp[len] = 0;
+
+ /* No effect if empty or >1 character long */
+ if (temp[0] == 0 || (temp[1] != '\n' && temp[1] != 0)) {
+ return len;
+ }
+
+ /* No effect if outside the range 0<=x<=1 */
+ if (temp[0] < '0' || temp[0] > '1') {
+ return len;
+ }
+
+ default_utf8_mode = (temp[0] - '0');
+
+ return len;
+}
+
+static int proc_read_default_utf8_mode(char *page, char **start, off_t
off,
+ int count, int *eof, void *data)
+{
+ return sprintf(page, "default_utf8_mode = %d\n",
default_utf8_mode); +}
+
+static int init_proc(void)
+{
+ proc_vt_dir = proc_mkdir("tty/vt", NULL);
+
+ if (!proc_vt_dir)
+ return -ENOMEM;
+
+ proc_default_utf8_mode = create_proc_entry("default_utf8_mode",
0644, proc_vt_dir); +
+ if (!proc_default_utf8_mode)
+ return -ENOMEM;
+
+ proc_default_utf8_mode->owner = THIS_MODULE;
+ proc_default_utf8_mode->data = &default_utf8_mode;
+ proc_default_utf8_mode->write_proc =
proc_write_default_utf8_mode;
+ proc_default_utf8_mode->read_proc = proc_read_default_utf8_mode;
+
+ return 0;
+}
+
/*
* This routine initializes console interrupts, and does nothing
* else. If you want the screen to clear, call tty_write with
@@ -2612,6 +2679,8 @@
int __init vty_init(void)
{
+ int ret;
+
vcs_init();
console_driver = alloc_tty_driver(MAX_NR_CONSOLES);
@@ -2638,6 +2707,11 @@
#ifdef CONFIG_MDA_CONSOLE
mda_console_init();
#endif
+
+ ret = init_proc();
+ if (ret)
+ return ret;
+
return 0;
}
--
Paul "LeoNerd" Evans
leonerd@leonerd.org.uk
ICQ# 4135350 | Registered Linux# 179460
http://www.leonerd.org.uk/[unhandled content-type:application/pgp-signature] | ||||||||||
| Last update: 2005-05-18 04:12 [from the cache] ©2003-2008 | |||||||||||