#include <stdio.h>
#include <stdlib.h>
#include <sys/ioctl.h>
+#include <sysexits.h>
#include <termios.h>
#include <unistd.h>
*vc_keymap = NULL, *vc_keymap_toggle = NULL,
*vc_font = NULL, *vc_font_map = NULL, *vc_font_unimap = NULL;
_cleanup_close_ int fd = -1;
- bool utf8, font_copy = false, font_ok, keyboard_ok;
- int r = EXIT_FAILURE;
+ bool utf8, font_copy = false, keyboard_ok;
+ int r;
log_set_target(LOG_TARGET_AUTO);
log_parse_environment();
"FONT_MAP", &vc_font_map,
"FONT_UNIMAP", &vc_font_unimap,
NULL);
-
if (r < 0 && r != -ENOENT)
log_warning_errno(r, "Failed to read /etc/vconsole.conf: %m");
"vconsole.font.map", &vc_font_map,
"vconsole.font.unimap", &vc_font_unimap,
NULL);
-
if (r < 0 && r != -ENOENT)
log_warning_errno(r, "Failed to read /proc/cmdline: %m");
}
toggle_utf8_sysfs(utf8);
toggle_utf8(vc, fd, utf8);
- font_ok = font_load_and_wait(vc, vc_font, vc_font_map, vc_font_unimap) == 0;
+
+ r = font_load_and_wait(vc, vc_font, vc_font_map, vc_font_unimap);
keyboard_ok = keyboard_load_and_wait(vc, vc_keymap, vc_keymap_toggle, utf8) == 0;
if (font_copy) {
- if (font_ok)
+ if (r == 0)
setup_remaining_vcs(fd, utf8);
+ else if (r == EX_OSERR)
+ /* setfont returns EX_OSERR when ioctl(KDFONTOP/PIO_FONTX/PIO_FONTX) fails.
+ * This might mean various things, but in particular lack of a graphical
+ * console. Let's be generous and not treat this as an error. */
+ log_notice("Setting fonts failed with a \"system error\", ignoring.");
else
log_warning("Setting source virtual console failed, ignoring remaining ones");
}
- return font_ok && keyboard_ok ? EXIT_SUCCESS : EXIT_FAILURE;
+ return IN_SET(r, 0, EX_OSERR) && keyboard_ok ? EXIT_SUCCESS : EXIT_FAILURE;
}