chiark / gitweb /
Add helper for fnmatch over strv
[elogind.git] / src / boot / boot-efi.c
index a0305ba77dc1afae99abe2af55ed3048dfd6b92a..bd0c59bd5aef936d95507eff0b77c7d6acc31c47 100644 (file)
 #include "efivars.h"
 #include "conf-files.h"
 
+static char *tilt_slashes(char *s) {
+        char *p;
+
+        if (!s)
+                return NULL;
+
+        for (p = s; *p; p++)
+                if (*p == '\\')
+                        *p = '/';
+        return s;
+}
+
 static int get_boot_entries(struct boot_info *info) {
-        uint16_t *list;
+        uint16_t *list = NULL;
         int i, n;
         int err = 0;
 
@@ -57,13 +69,19 @@ static int get_boot_entries(struct boot_info *info) {
                 info->fw_entries = e;
 
                 e = &info->fw_entries[info->fw_entries_count];
-                memset(e, 0, sizeof(struct boot_info_entry));
+                memzero(e, sizeof(struct boot_info_entry));
                 e->order = -1;
 
                 err = efi_get_boot_option(list[i], &e->title, &e->part_uuid, &e->path);
                 if (err < 0)
                         continue;
 
+                if (isempty(e->title)) {
+                        free(e->title);
+                        e->title = NULL;
+                }
+                tilt_slashes(e->path);
+
                 e->id = list[i];
                 info->fw_entries_count++;
         }
@@ -77,7 +95,7 @@ static int find_active_entry(struct boot_info *info) {
         void *buf;
         size_t l;
         size_t i;
-        int err = -ENOENT;
+        int err;
 
         err = efi_get_variable(EFI_VENDOR_GLOBAL, "BootCurrent", NULL, &buf, &l);
         if (err < 0)
@@ -140,6 +158,9 @@ int boot_info_query(struct boot_info *info) {
         char buf[64];
         char *loader_active = NULL;
 
+        info->fw_secure_boot = is_efi_secure_boot();
+        info->fw_secure_boot_setup_mode = is_efi_secure_boot_setup_mode();
+
         efi_get_variable_string(EFI_VENDOR_LOADER, "LoaderInfo", &info->loader);
 
         get_boot_entries(info);
@@ -152,7 +173,8 @@ int boot_info_query(struct boot_info *info) {
         efi_get_variable_string(EFI_VENDOR_LOADER, "LoaderFirmwareType", &info->fw_type);
         efi_get_variable_string(EFI_VENDOR_LOADER, "LoaderFirmwareInfo", &info->fw_info);
         efi_get_variable_string(EFI_VENDOR_LOADER, "LoaderImageIdentifier", &info->loader_image_path);
-        efi_get_loader_device_part_uuid(&info->loader_part_uuid);
+        tilt_slashes(info->loader_image_path);
+        efi_loader_get_device_part_uuid(&info->loader_part_uuid);
 
         boot_loader_read_entries(info);
         efi_get_variable_string(EFI_VENDOR_LOADER, "LoaderEntrySelected", &loader_active);