size_t s;
int r;
+ if (!is_efi_boot()) /* If this is not an EFI boot, assume the queried flags are zero */
+ return 0;
+
r = efi_get_variable(EFI_VENDOR_GLOBAL, varname, NULL, &v, &s);
if (r < 0)
return r;
sd_id128_t p_uuid = SD_ID128_NULL;
int r;
+ if (!is_efi_boot())
+ return -EOPNOTSUPP;
+
xsprintf(boot_id, "Boot%04X", id);
r = efi_get_variable(EFI_VENDOR_GLOBAL, boot_id, NULL, (void **)&buf, &l);
if (r < 0)
return s;
}
-int efi_add_boot_option(uint16_t id, const char *title,
- uint32_t part, uint64_t pstart, uint64_t psize,
- sd_id128_t part_uuid, const char *path) {
- char boot_id[9];
- size_t size;
- size_t title_len;
- size_t path_len;
+int efi_add_boot_option(
+ uint16_t id,
+ const char *title,
+ uint32_t part,
+ uint64_t pstart,
+ uint64_t psize,
+ sd_id128_t part_uuid,
+ const char *path) {
+
+ size_t size, title_len, path_len;
+ _cleanup_free_ char *buf = NULL;
struct boot_option *option;
struct device_path *devicep;
- _cleanup_free_ char *buf = NULL;
+ char boot_id[9];
+
+ if (!is_efi_boot())
+ return -EOPNOTSUPP;
title_len = (strlen(title)+1) * 2;
path_len = (strlen(path)+1) * 2;
int efi_remove_boot_option(uint16_t id) {
char boot_id[9];
+ if (!is_efi_boot())
+ return -EOPNOTSUPP;
+
xsprintf(boot_id, "Boot%04X", id);
return efi_set_variable(EFI_VENDOR_GLOBAL, boot_id, NULL, 0);
}
size_t l;
int r;
+ if (!is_efi_boot())
+ return -EOPNOTSUPP;
+
r = efi_get_variable(EFI_VENDOR_GLOBAL, "BootOrder", NULL, &buf, &l);
if (r < 0)
return r;
}
int efi_set_boot_order(uint16_t *order, size_t n) {
+
+ if (!is_efi_boot())
+ return -EOPNOTSUPP;
+
return efi_set_variable(EFI_VENDOR_GLOBAL, "BootOrder", order, n * sizeof(uint16_t));
}
assert(options);
+ if (!is_efi_boot())
+ return -EOPNOTSUPP;
+
dir = opendir("/sys/firmware/efi/efivars/");
if (!dir)
return -errno;
assert(firmware);
assert(loader);
+ if (!is_efi_boot())
+ return -EOPNOTSUPP;
+
r = read_usec(EFI_VENDOR_LOADER, "LoaderTimeInitUSec", &x);
if (r < 0)
return r;
_cleanup_free_ char *p = NULL;
int r, parsed[16];
+ if (!is_efi_boot())
+ return -EOPNOTSUPP;
+
r = efi_get_variable_string(EFI_VENDOR_LOADER, "LoaderDevicePartUUID", &p);
if (r < 0)
return r;
r = efi_loader_get_boot_usec(&loader_start, &loader_exit);
if (r < 0) {
- bool ok = r == -ENOENT || (getuid() != 0 && r == -EACCES);
+ bool ok = r == -ENOENT || (getuid() != 0 && r == -EACCES) || r == -EOPNOTSUPP;
log_full_errno(ok ? LOG_DEBUG : LOG_ERR,
r, "Failed to read EFI loader data: %m");
r = boot_timestamps(NULL, &fw, &l);
if (r < 0) {
- bool ok = r == -ENOENT || (getuid() != 0 && r == -EACCES);
+ bool ok = r == -ENOENT || (getuid() != 0 && r == -EACCES) || r == -EOPNOTSUPP;
log_full_errno(ok ? LOG_DEBUG : LOG_ERR,
r, "Failed to read variables: %m");