return r;
}
+static int enable_utf8(int fd) {
+ int r = 0, k;
+
+ if (ioctl(fd, KDSKBMODE, K_UNICODE) < 0)
+ r = -errno;
+
+ if (loop_write(fd, "\033%G", 3, false) < 0)
+ r = -errno;
+
+ k = write_one_line_file("/sys/module/vt/parameters/default_utf8", "1");
+ if (k < 0)
+ r = k;
+
+ if (r < 0)
+ log_warning("Failed to enable UTF-8: %s", strerror(-r));
+
+ return r;
+}
+
static int load_keymap(const char *vc, const char *map, const char *map_toggle, bool utf8, pid_t *_pid) {
const char *args[8];
int i = 0;
utf8 = is_locale_utf8();
- vc_keymap = strdup("us");
- vc_font = strdup(DEFAULT_FONT);
-
- if (!vc_keymap || !vc_font) {
- log_error("Failed to allocate strings.");
- goto finish;
- }
-
r = 0;
if (detect_container(NULL) <= 0) {
}
if (r <= 0) {
-#if defined(TARGET_FEDORA) || defined(TARGET_MEEGO)
- r = parse_env_file("/etc/sysconfig/i18n", NEWLINE,
- "SYSFONT", &vc_font,
- "SYSFONTACM", &vc_font_map,
- "UNIMAP", &vc_font_unimap,
- NULL);
- if (r < 0 && r != -ENOENT)
- log_warning("Failed to read /etc/sysconfig/i18n: %s", strerror(-r));
-
- r = parse_env_file("/etc/sysconfig/keyboard", NEWLINE,
- "KEYTABLE", &vc_keymap,
- "KEYMAP", &vc_keymap,
- NULL);
- if (r < 0 && r != -ENOENT)
- log_warning("Failed to read /etc/sysconfig/keyboard: %s", strerror(-r));
-
- if (access("/etc/sysconfig/console/default.kmap", F_OK) >= 0) {
- char *t;
-
- t = strdup("/etc/sysconfig/console/default.kmap");
- if (!t) {
- log_error("Out of memory.");
- goto finish;
- }
-
- free(vc_keymap);
- vc_keymap = t;
- }
-
-#elif defined(TARGET_SUSE)
+#if defined(TARGET_SUSE)
r = parse_env_file("/etc/sysconfig/keyboard", NEWLINE,
"KEYTABLE", &vc_keymap,
NULL);
free(vc_keytable);
if (!vc_keymap) {
- log_error("Out of memory.");
+ log_oom();
goto finish;
}
}
t = strdup("/etc/sysconfig/console/default.kmap");
if (!t) {
- log_error("Out of memory.");
+ log_oom();
goto finish;
}
r = EXIT_FAILURE;
- if (!utf8)
+ if (utf8)
+ enable_utf8(fd);
+ else
disable_utf8(fd);
+
if (load_keymap(vc, vc_keymap, vc_keymap_toggle, utf8, &keymap_pid) >= 0 &&
load_font(vc, vc_font, vc_font_map, vc_font_unimap, &font_pid) >= 0)
r = EXIT_SUCCESS;