return efi_set_variable(variable, u16, (char16_strlen(u16) + 1) * sizeof(char16_t));
}
+static int cache_efi_boot = -1;
+
+bool set_efi_boot(bool b) {
+ return (cache_efi_boot = b);
+}
+
bool is_efi_boot(void) {
- static int cache = -1;
+ if (cache_efi_boot >= 0)
+ return cache_efi_boot;
- if (cache < 0) {
- if (detect_container() > 0)
- cache = false;
- else {
- cache = access("/sys/firmware/efi/", F_OK) >= 0;
- if (!cache && errno != ENOENT)
- log_debug_errno(errno, "Unable to test whether /sys/firmware/efi/ exists, assuming EFI not available: %m");
- }
+ if (detect_container() > 0)
+ return (cache_efi_boot = false);
+
+ if (access("/sys/firmware/efi/", F_OK) < 0) {
+ if (errno != ENOENT)
+ log_debug_errno(errno, "Unable to test whether /sys/firmware/efi/ exists, assuming EFI not available: %m");
+ return (cache_efi_boot = false);
}
- return cache;
+ return (cache_efi_boot = true);
}
static int read_flag(const char *variable) {
int efi_set_variable(const char *variable, const void *value, size_t size) _nonnull_if_nonzero_(2, 3);
int efi_set_variable_string(const char *variable, const char *value);
+bool set_efi_boot(bool b);
bool is_efi_boot(void);
bool is_efi_secure_boot(void);
SecureBootMode efi_get_secure_boot_mode(void);
return -EOPNOTSUPP;
}
+static inline bool set_efi_boot(bool b) {
+ return false;
+}
+
static inline bool is_efi_boot(void) {
return false;
}