|
|
9fc0f6 |
From a5236c816e1b8f7a56b2b4b0fa5ac2d5998e5b84 Mon Sep 17 00:00:00 2001
|
|
|
9fc0f6 |
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
|
|
|
9fc0f6 |
Date: Tue, 1 Jul 2014 22:20:11 -0400
|
|
|
9fc0f6 |
Subject: [PATCH] vconsole-setup: run setfont before loadkeys
|
|
|
9fc0f6 |
|
|
|
9fc0f6 |
https://bugs.freedesktop.org/show_bug.cgi?id=80685
|
|
|
9fc0f6 |
|
|
|
9fc0f6 |
(cherry picked from commit abee28c56d523e55751b0c007d0bf812cc285c00)
|
|
|
9fc0f6 |
|
|
|
9fc0f6 |
Conflicts:
|
|
|
9fc0f6 |
src/vconsole/vconsole-setup.c
|
|
|
9fc0f6 |
|
|
|
9fc0f6 |
Related: #1002450
|
|
|
9fc0f6 |
---
|
|
|
9fc0f6 |
src/vconsole/vconsole-setup.c | 49 ++++++++++++++++++++-----------------------
|
|
|
9fc0f6 |
1 file changed, 23 insertions(+), 26 deletions(-)
|
|
|
9fc0f6 |
|
|
|
9fc0f6 |
diff --git a/src/vconsole/vconsole-setup.c b/src/vconsole/vconsole-setup.c
|
|
|
9fc0f6 |
index 7196ddf..25d15af 100644
|
|
|
9fc0f6 |
--- a/src/vconsole/vconsole-setup.c
|
|
|
9fc0f6 |
+++ b/src/vconsole/vconsole-setup.c
|
|
|
9fc0f6 |
@@ -238,12 +238,10 @@ static void font_copy_to_all_vcs(int fd) {
|
|
|
9fc0f6 |
|
|
|
9fc0f6 |
int main(int argc, char **argv) {
|
|
|
9fc0f6 |
const char *vc;
|
|
|
9fc0f6 |
- char *vc_keymap = NULL;
|
|
|
9fc0f6 |
- char *vc_keymap_toggle = NULL;
|
|
|
9fc0f6 |
- char *vc_font = NULL;
|
|
|
9fc0f6 |
- char *vc_font_map = NULL;
|
|
|
9fc0f6 |
- char *vc_font_unimap = NULL;
|
|
|
9fc0f6 |
- int fd = -1;
|
|
|
9fc0f6 |
+ _cleanup_free_ char
|
|
|
9fc0f6 |
+ *vc_keymap = NULL, *vc_keymap_toggle = NULL,
|
|
|
9fc0f6 |
+ *vc_font = NULL, *vc_font_map = NULL, *vc_font_unimap = NULL;
|
|
|
9fc0f6 |
+ _cleanup_close_ int fd = -1;
|
|
|
9fc0f6 |
bool utf8;
|
|
|
9fc0f6 |
pid_t font_pid = 0, keymap_pid = 0;
|
|
|
9fc0f6 |
bool font_copy = false;
|
|
|
9fc0f6 |
@@ -265,12 +263,12 @@ int main(int argc, char **argv) {
|
|
|
9fc0f6 |
fd = open_terminal(vc, O_RDWR|O_CLOEXEC);
|
|
|
9fc0f6 |
if (fd < 0) {
|
|
|
9fc0f6 |
log_error("Failed to open %s: %m", vc);
|
|
|
9fc0f6 |
- goto finish;
|
|
|
9fc0f6 |
+ return EXIT_FAILURE;
|
|
|
9fc0f6 |
}
|
|
|
9fc0f6 |
|
|
|
9fc0f6 |
if (!is_vconsole(fd)) {
|
|
|
9fc0f6 |
log_error("Device %s is not a virtual console.", vc);
|
|
|
9fc0f6 |
- goto finish;
|
|
|
9fc0f6 |
+ return EXIT_FAILURE;
|
|
|
9fc0f6 |
}
|
|
|
9fc0f6 |
|
|
|
9fc0f6 |
utf8 = is_locale_utf8();
|
|
|
9fc0f6 |
@@ -305,28 +303,27 @@ int main(int argc, char **argv) {
|
|
|
9fc0f6 |
else
|
|
|
9fc0f6 |
disable_utf8(fd);
|
|
|
9fc0f6 |
|
|
|
9fc0f6 |
- r = EXIT_FAILURE;
|
|
|
9fc0f6 |
- if (keymap_load(vc, vc_keymap, vc_keymap_toggle, utf8, &keymap_pid) >= 0 &&
|
|
|
9fc0f6 |
- font_load(vc, vc_font, vc_font_map, vc_font_unimap, &font_pid) >= 0)
|
|
|
9fc0f6 |
- r = EXIT_SUCCESS;
|
|
|
9fc0f6 |
-
|
|
|
9fc0f6 |
-finish:
|
|
|
9fc0f6 |
- if (keymap_pid > 0)
|
|
|
9fc0f6 |
- wait_for_terminate_and_warn(KBD_LOADKEYS, keymap_pid);
|
|
|
9fc0f6 |
+ r = font_load(vc, vc_font, vc_font_map, vc_font_unimap, &font_pid);
|
|
|
9fc0f6 |
+ if (r < 0) {
|
|
|
9fc0f6 |
+ log_error("Failed to start " KBD_LOADKEYS ": %s", strerror(-r));
|
|
|
9fc0f6 |
+ return EXIT_FAILURE;
|
|
|
9fc0f6 |
+ }
|
|
|
9fc0f6 |
|
|
|
9fc0f6 |
- if (font_pid > 0) {
|
|
|
9fc0f6 |
+ if (font_pid > 0)
|
|
|
9fc0f6 |
wait_for_terminate_and_warn(KBD_SETFONT, font_pid);
|
|
|
9fc0f6 |
- if (font_copy)
|
|
|
9fc0f6 |
- font_copy_to_all_vcs(fd);
|
|
|
9fc0f6 |
+
|
|
|
9fc0f6 |
+ r = keymap_load(vc, vc_keymap, vc_keymap_toggle, utf8, &keymap_pid);
|
|
|
9fc0f6 |
+ if (r < 0) {
|
|
|
9fc0f6 |
+ log_error("Failed to start " KBD_SETFONT ": %s", strerror(-r));
|
|
|
9fc0f6 |
+ return EXIT_FAILURE;
|
|
|
9fc0f6 |
}
|
|
|
9fc0f6 |
|
|
|
9fc0f6 |
- free(vc_keymap);
|
|
|
9fc0f6 |
- free(vc_font);
|
|
|
9fc0f6 |
- free(vc_font_map);
|
|
|
9fc0f6 |
- free(vc_font_unimap);
|
|
|
9fc0f6 |
+ if (keymap_pid > 0)
|
|
|
9fc0f6 |
+ wait_for_terminate_and_warn(KBD_LOADKEYS, keymap_pid);
|
|
|
9fc0f6 |
|
|
|
9fc0f6 |
- if (fd >= 0)
|
|
|
9fc0f6 |
- close_nointr_nofail(fd);
|
|
|
9fc0f6 |
+ /* Only copy the font when we started setfont successfully */
|
|
|
9fc0f6 |
+ if (font_copy && font_pid > 0)
|
|
|
9fc0f6 |
+ font_copy_to_all_vcs(fd);
|
|
|
9fc0f6 |
|
|
|
9fc0f6 |
- return r;
|
|
|
9fc0f6 |
+ return EXIT_SUCCESS;
|
|
|
9fc0f6 |
}
|