diff mbox series

[v2] efi_loader: change the error message when storing EFI variables

Message ID 20240419094546.12653-1-ilias.apalodimas@linaro.org
State New
Headers show
Series [v2] efi_loader: change the error message when storing EFI variables | expand

Commit Message

Ilias Apalodimas April 19, 2024, 9:45 a.m. UTC
When we try to store EFI variables on a file, we need to use an ESP.
if an ESP is not found, variables will change in memory, but U-Boot
won't be able to restore them across reboots.

Adjust the error message so users can understand what's going on

Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
---
Changes since v1:
- print different messages if ESP is missing or write to file failed

 lib/efi_loader/efi_var_file.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

--
2.43.0

Comments

Ilias Apalodimas April 19, 2024, 9:49 a.m. UTC | #1
Heinrich

Please ignore this, I missed that we already report that in
efi_set_blk_dev_to_system_partition()

Apologies for the noise
/Ilias
On Fri, Apr 19, 2024 at 12:45:45PM +0300, Ilias Apalodimas wrote:
> When we try to store EFI variables on a file, we need to use an ESP.
> if an ESP is not found, variables will change in memory, but U-Boot
> won't be able to restore them across reboots.
>
> Adjust the error message so users can understand what's going on
>
> Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
> ---
> Changes since v1:
> - print different messages if ESP is missing or write to file failed
>
>  lib/efi_loader/efi_var_file.c | 10 +++++++---
>  1 file changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/lib/efi_loader/efi_var_file.c b/lib/efi_loader/efi_var_file.c
> index 413e1794e88c..d5d347d50f8d 100644
> --- a/lib/efi_loader/efi_var_file.c
> +++ b/lib/efi_loader/efi_var_file.c
> @@ -73,16 +73,20 @@ efi_status_t efi_var_to_file(void)
>  		goto error;
>
>  	ret = efi_set_blk_dev_to_system_partition();
> -	if (ret != EFI_SUCCESS)
> +	if (ret != EFI_SUCCESS) {
> +		log_err("ESP not found.");
>  		goto error;
> +	}
>
>  	r = fs_write(EFI_VAR_FILE_NAME, map_to_sysmem(buf), 0, len, &actlen);
> -	if (r || len != actlen)
> +	if (r || len != actlen) {
> +		log_err("Failed to store variables.");
>  		ret = EFI_DEVICE_ERROR;
> +	}
>
>  error:
>  	if (ret != EFI_SUCCESS)
> -		log_err("Failed to persist EFI variables\n");
> +		log_err(" UEFI variables won't persist reboot\n");
>  	free(buf);
>  	return ret;
>  #else
> --
> 2.43.0
>
diff mbox series

Patch

diff --git a/lib/efi_loader/efi_var_file.c b/lib/efi_loader/efi_var_file.c
index 413e1794e88c..d5d347d50f8d 100644
--- a/lib/efi_loader/efi_var_file.c
+++ b/lib/efi_loader/efi_var_file.c
@@ -73,16 +73,20 @@  efi_status_t efi_var_to_file(void)
 		goto error;

 	ret = efi_set_blk_dev_to_system_partition();
-	if (ret != EFI_SUCCESS)
+	if (ret != EFI_SUCCESS) {
+		log_err("ESP not found.");
 		goto error;
+	}

 	r = fs_write(EFI_VAR_FILE_NAME, map_to_sysmem(buf), 0, len, &actlen);
-	if (r || len != actlen)
+	if (r || len != actlen) {
+		log_err("Failed to store variables.");
 		ret = EFI_DEVICE_ERROR;
+	}

 error:
 	if (ret != EFI_SUCCESS)
-		log_err("Failed to persist EFI variables\n");
+		log_err(" UEFI variables won't persist reboot\n");
 	free(buf);
 	return ret;
 #else