[PATCH v3 2/6] efi_loader: Support for file renaming
Daniel Venzin
Daniel.Venzin at mt.com
Fri Feb 7 13:45:19 CET 2025
File renaming is necessary for features like systemd-boot
bootcounting.
Signed-off-by: Daniel Venzin <Daniel.Venzin at mt.com>
---
(no changes since v2)
Changes in v2:
- Use EFI_ACCESS_DENIED for unsuccessful renames
- Avoid using of "== 0"
- Move the call to set_blk_dev earlier in the sequence
lib/efi_loader/efi_file.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/lib/efi_loader/efi_file.c b/lib/efi_loader/efi_file.c
index 201fa5f8f3c..9a5a345bfc0 100644
--- a/lib/efi_loader/efi_file.c
+++ b/lib/efi_loader/efi_file.c
@@ -969,6 +969,10 @@ static efi_status_t EFIAPI efi_file_setinfo(struct efi_file_handle *file,
ret = EFI_ACCESS_DENIED;
goto out;
}
+ if (set_blk_dev(fh)) {
+ ret = EFI_DEVICE_ERROR;
+ goto out;
+ }
/* Check for renaming */
new_file_name = malloc(utf16_utf8_strlen(info->file_name) + 1);
if (!new_file_name) {
@@ -978,10 +982,11 @@ static efi_status_t EFIAPI efi_file_setinfo(struct efi_file_handle *file,
pos = new_file_name;
utf16_utf8_strcpy(&pos, info->file_name);
if (strcmp(new_file_name, filename)) {
- /* TODO: we do not support renaming */
- EFI_PRINT("Renaming not supported\n");
+ if (fs_rename(fh->path, new_file_name) != 0)
+ ret = EFI_ACCESS_DENIED;
+ else
+ ret = EFI_SUCCESS;
free(new_file_name);
- ret = EFI_ACCESS_DENIED;
goto out;
}
free(new_file_name);
--
2.39.5
More information about the U-Boot
mailing list