if (streq(keymap, "@kernel"))
return 0;
+ if (access(KBD_LOADKEYS, X_OK) < 0) {
+ if (errno != ENOENT)
+ return log_error_errno(errno, "Failed to check if '" KBD_LOADKEYS "' is available: %m");
+
+ log_notice("'" KBD_LOADKEYS "' is not available, skipping keyboard mapping setup.");
+ return 0; /* Report that we skipped this */
+ }
+
args[i++] = KBD_LOADKEYS;
args[i++] = "-q";
args[i++] = "-C";
_exit(EXIT_FAILURE);
}
- return pidref_wait_for_terminate_and_check(KBD_LOADKEYS, &pidref, WAIT_LOG);
+ r = pidref_wait_for_terminate_and_check(KBD_LOADKEYS, &pidref, WAIT_LOG);
+ if (r < 0)
+ return r;
+ if (r != EXIT_SUCCESS)
+ return -EPROTO;
+
+ return 1; /* Report that we did something */
}
static int font_load_and_wait(const char *vc, Context *c) {
if (!font && !font_map && !font_unimap)
return 0;
+ if (access(KBD_SETFONT, X_OK) < 0) {
+ if (errno != ENOENT)
+ return log_error_errno(errno, "Failed to check if '" KBD_SETFONT "' is available: %m");
+
+ log_notice("'" KBD_SETFONT "' is not available, skipping console font setup.");
+ return 0; /* Report that we skipped this */
+ }
+
args[i++] = KBD_SETFONT;
args[i++] = "-C";
args[i++] = vc;
* things, but in particular lack of a graphical console. Let's be generous and not treat this as an
* error. */
r = pidref_wait_for_terminate_and_check(KBD_SETFONT, &pidref, WAIT_LOG_ABNORMAL);
- if (r == EX_OSERR)
+ if (r < 0)
+ return r; /* WAIT_LOG_ABNORMAL means we already have logged about these kinds of errors */
+ if (r == EX_OSERR) {
log_notice(KBD_SETFONT " failed with a \"system error\" (EX_OSERR), ignoring.");
- else if (r >= 0 && r != EXIT_SUCCESS)
- log_error(KBD_SETFONT " failed with exit status %i.", r);
+ return 0; /* Report that we skipped this */
+ }
+ if (r != EXIT_SUCCESS)
+ return log_error_errno(SYNTHETIC_ERRNO(EPROTO), KBD_SETFONT " failed with exit status %i.", r);
- return r;
+ return 1; /* Report that we did something */
}
/*
_cleanup_(context_done) Context c = {};
_cleanup_free_ char *vc = NULL;
_cleanup_close_ int fd = -EBADF, lock_fd = -EBADF;
- bool utf8, keyboard_ok;
+ bool utf8;
unsigned idx = 0;
- int r;
log_setup();
(void) toggle_utf8_vc(vc, fd, utf8);
- r = font_load_and_wait(vc, &c);
- keyboard_ok = keyboard_load_and_wait(vc, &c, utf8) == 0;
+ int setfont_status = font_load_and_wait(vc, &c);
+ int loadkeys_status = keyboard_load_and_wait(vc, &c, utf8);
if (idx > 0) {
- if (r == 0)
- setup_remaining_vcs(fd, idx, utf8);
+ if (setfont_status == 0)
+ log_notice("Configuration of first virtual console was skipped, ignoring remaining ones.");
+ else if (setfont_status < 0)
+ log_warning("Configuration of first virtual console failed, ignoring remaining ones.");
else
- log_full(r == EX_OSERR ? LOG_NOTICE : LOG_WARNING,
- "Configuration of first virtual console failed, ignoring remaining ones.");
+ setup_remaining_vcs(fd, idx, utf8);
}
- return IN_SET(r, 0, EX_OSERR) && keyboard_ok ? EXIT_SUCCESS : EXIT_FAILURE;
+ return (setfont_status >= 0 && loadkeys_status >= 0) ? EXIT_SUCCESS : EXIT_FAILURE;
}
DEFINE_MAIN_FUNCTION_WITH_POSITIVE_FAILURE(run);