tdecacqu / rpms / systemd

Forked from rpms/systemd 3 years ago
Clone
275528d
From 6b62bbbc7b53bee11778d27d18e9506d9b42d4ba Mon Sep 17 00:00:00 2001
275528d
From: Lennart Poettering <lennart@poettering.net>
275528d
Date: Sat, 11 Jul 2015 17:29:48 -0300
275528d
Subject: [PATCH 044/261] logind: some firmware implementations remove
275528d
 OsIndications if it is unset
275528d
275528d
We shouldn't fall over that, and just assume it is 0 in this case.
275528d
275528d
Fixes #499.
275528d
---
275528d
 src/shared/efivars.c | 14 +++++++++++++-
275528d
 1 file changed, 13 insertions(+), 1 deletion(-)
275528d
275528d
diff --git a/src/shared/efivars.c b/src/shared/efivars.c
275528d
index 0d6ecf5..347cd30 100644
275528d
--- a/src/shared/efivars.c
275528d
+++ b/src/shared/efivars.c
275528d
@@ -125,7 +125,19 @@ static int get_os_indications(uint64_t *os_indication) {
275528d
                 return r;
275528d
 
275528d
         r = efi_get_variable(EFI_VENDOR_GLOBAL, "OsIndications", NULL, &v, &s);
275528d
-        if (r < 0)
275528d
+        if (r == -ENOENT) {
275528d
+                /* Some firmware implementations that do support
275528d
+                 * OsIndications and report that with
275528d
+                 * OsIndicationsSupported will remove the
275528d
+                 * OsIndications variable when it is unset. Let's
275528d
+                 * pretend it's 0 then, to hide this implementation
275528d
+                 * detail. Note that this call will return -ENOENT
275528d
+                 * then only if the support for OsIndications is
275528d
+                 * missing entirely, as determined by
275528d
+                 * efi_reboot_to_firmware_supported() above. */
275528d
+                *os_indication = 0;
275528d
+                return 0;
275528d
+        } else if (r < 0)
275528d
                 return r;
275528d
         else if (s != sizeof(uint64_t))
275528d
                 return -EINVAL;
275528d
-- 
275528d
2.4.3
275528d