static int install_variables(const char *esp_path, uint32_t part, uint64_t pstart, uint64_t psize, sd_id128_t uuid, const char *path, bool first) { char *p = NULL; uint16_t *options = NULL; uint16_t slot; int r; if (!is_efi_boot()) { fprintf(stderr, "Not booted with EFI, skipping EFI variable setup.\n"); return 0; } if (asprintf(&p, "%s%s", esp_path, path) < 0) { fprintf(stderr, "Out of memory.\n"); return -ENOMEM; } if (access(p, F_OK) < 0) { if (errno == ENOENT) r = 0; else r = -errno; goto finish; } r = find_slot(uuid, path, &slot); if (r < 0) { if (r == -ENOENT) fprintf(stderr, "Failed to access EFI variables. Is the \"efivarfs\" filesystem mounted?\n"); else fprintf(stderr, "Failed to determine current boot order: %s\n", strerror(-r)); goto finish; } if (first || r == false) { r = efi_add_boot_option(slot, "Linux Boot Manager", part, pstart, psize, uuid, path); if (r < 0) { fprintf(stderr, "Failed to create EFI Boot variable entry: %s\n", strerror(-r)); goto finish; } fprintf(stderr, "Created EFI boot entry \"Linux Boot Manager\".\n"); } insert_into_order(slot, first); finish: free(p); free(options); return r; }
static int install_variables(const char *esp_path, uint32_t part, uint64_t pstart, uint64_t psize, sd_id128_t uuid, const char *path, bool first) { char *p; uint16_t slot; int r; if (!is_efi_boot()) { log_warning("Not booted with EFI, skipping EFI variable setup."); return 0; } p = strjoina(esp_path, path); if (access(p, F_OK) < 0) { if (errno == ENOENT) return 0; else return log_error_errno(errno, "Cannot access \"%s\": %m", p); } r = find_slot(uuid, path, &slot); if (r < 0) return log_error_errno(r, r == -ENOENT ? "Failed to access EFI variables. Is the \"efivarfs\" filesystem mounted?" : "Failed to determine current boot order: %m"); if (first || r == false) { r = efi_add_boot_option(slot, "Linux Boot Manager", part, pstart, psize, uuid, path); if (r < 0) return log_error_errno(r, "Failed to create EFI Boot variable entry: %m"); log_info("Created EFI boot entry \"Linux Boot Manager\"."); } return insert_into_order(slot, first); }