#include <unistd.h>
#include "alloc-util.h"
+#include "efivars.h"
#include "env-util.h"
#include "extract-word.h"
#include "fd-util.h"
return 1;
}
+int vconsole_keymap_from_efi(char **ret) {
+ int r;
+
+ assert(ret);
+
+ if (!is_efi_boot()) {
+ *ret = NULL;
+ return 0;
+ }
+
+ _cleanup_free_ char *tag = NULL;
+ r = efi_get_variable_string(EFI_LOADER_VARIABLE_STR("LoaderKeyboardLayout"), &tag);
+ if (r == -ENOENT) {
+ *ret = NULL;
+ return 0;
+ }
+ if (r < 0)
+ return log_debug_errno(r, "Failed to read LoaderKeyboardLayout EFI variable: %m");
+
+ r = find_vconsole_keymap_for_bcp47(tag, ret);
+ if (r < 0)
+ return log_debug_errno(r, "Failed to look up vconsole keymap for firmware tag '%s': %m", tag);
+
+ return r;
+}
+
int vconsole_serialize(const VCContext *vc, const X11Context *xc, char ***env) {
int r;
int x11_convert_to_vconsole(const X11Context *xc, VCContext *ret);
int find_vconsole_keymap_for_bcp47(const char *tag, char **ret);
+int vconsole_keymap_from_efi(char **ret);
int vconsole_serialize(const VCContext *vc, const X11Context *xc, char ***env);
#include "alloc-util.h"
#include "creds-util.h"
-#include "efivars.h"
#include "env-file.h"
#include "errno-util.h"
#include "fd-util.h"
static int context_read_efi(Context *c) {
_cleanup_(context_done) Context v = {};
- _cleanup_free_ char *tag = NULL;
int r;
assert(c);
- if (!is_efi_boot())
- return 0;
-
- r = efi_get_variable_string(EFI_LOADER_VARIABLE_STR("LoaderKeyboardLayout"), &tag);
- if (r == -ENOENT)
- return 0;
+ r = vconsole_keymap_from_efi(&v.keymap);
if (r < 0)
- return log_debug_errno(r, "Failed to read LoaderKeyboardLayout EFI variable, ignoring: %m");
-
- r = find_vconsole_keymap_for_bcp47(tag, &v.keymap);
- if (r < 0)
- return log_debug_errno(r, "Failed to look up vconsole keymap for firmware tag '%s', ignoring: %m", tag);
+ return r;
if (r == 0) {
- log_debug("No vconsole keymap matches firmware-provided keyboard layout '%s', ignoring.", tag);
+ log_debug("No vconsole keymap matches firmware-provided keyboard layout, ignoring.");
return 0;
}