]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/shared/efivars.c
util-lib: introduce dirent-util.[ch] for directory entry calls
[thirdparty/systemd.git] / src / shared / efivars.c
index d34d977b9a2562f8cc6456a09a9ef6d0fdf843e9..6e8f156a688b3ae3804f16fb20fb577115aeea69 100644 (file)
 #include <string.h>
 #include <fcntl.h>
 
-#include "util.h"
+#include "dirent-util.h"
+#include "efivars.h"
+#include "fd-util.h"
+#include "io-util.h"
+#include "parse-util.h"
 #include "utf8.h"
+#include "util.h"
 #include "virt.h"
-#include "efivars.h"
 
 #ifdef ENABLE_EFI
 
@@ -101,7 +105,7 @@ int efi_reboot_to_firmware_supported(void) {
         uint64_t b;
         _cleanup_free_ void *v = NULL;
 
-        if (!is_efi_boot() || detect_container(NULL) > 0)
+        if (!is_efi_boot() || detect_container() > 0)
                 return -EOPNOTSUPP;
 
         r = efi_get_variable(EFI_VENDOR_GLOBAL, "OsIndicationsSupported", NULL, &v, &s);
@@ -125,7 +129,19 @@ static int get_os_indications(uint64_t *os_indication) {
                 return r;
 
         r = efi_get_variable(EFI_VENDOR_GLOBAL, "OsIndications", NULL, &v, &s);
-        if (r < 0)
+        if (r == -ENOENT) {
+                /* Some firmware implementations that do support
+                 * OsIndications and report that with
+                 * OsIndicationsSupported will remove the
+                 * OsIndications variable when it is unset. Let's
+                 * pretend it's 0 then, to hide this implementation
+                 * detail. Note that this call will return -ENOENT
+                 * then only if the support for OsIndications is
+                 * missing entirely, as determined by
+                 * efi_reboot_to_firmware_supported() above. */
+                *os_indication = 0;
+                return 0;
+        } else if (r < 0)
                 return r;
         else if (s != sizeof(uint64_t))
                 return -EINVAL;
@@ -483,7 +499,7 @@ int efi_add_boot_option(uint16_t id, const char *title,
         devicep->length = offsetof(struct device_path, drive) + sizeof(struct drive_path);
         devicep->drive.part_nr = part;
         devicep->drive.part_start = pstart;
-        devicep->drive.part_size =  psize;
+        devicep->drive.part_size = psize;
         devicep->drive.signature_type = SIGNATURE_TYPE_GUID;
         devicep->drive.mbr_type = MBR_TYPE_EFI_PARTITION_TABLE_HEADER;
         id128_to_efi_guid(part_uuid, devicep->drive.signature);