From: Paul LeoNerd Evans <leonerd@leonerd.org.uk>
To: linux-kernel@vger.kernel.org
Subject: [PATCH] Fix to virtual terminal UTF-8 mode handling
Date: Wed, 18 May 2005 03:05:13 +0100 [thread overview]
Message-ID: <20050518030513.7fe55ef1@nim.leo> (raw)
[-- Attachment #1: Type: text/plain, Size: 3723 bytes --]
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/
[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]
next reply other threads:[~2005-05-18 2:06 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-05-18 2:05 Paul LeoNerd Evans [this message]
2005-05-18 2:15 ` [PATCH] Fix to virtual terminal UTF-8 mode handling Paul LeoNerd Evans
2005-05-18 2:58 ` Andrew Morton
2005-05-18 3:10 ` Daniel Jacobowitz
2005-05-18 11:10 ` Paul LeoNerd Evans
2005-05-18 11:04 ` Paul LeoNerd Evans
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20050518030513.7fe55ef1@nim.leo \
--to=leonerd@leonerd.org.uk \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox