Skip to content

Commit

Permalink
Save ESP file on write/delete operations
Browse files Browse the repository at this point in the history
It's required to keep updated the ESP file with every variable change.
Make sure to save those changes on every modify var operation.

Signed-off-by: Javier Tia <[email protected]>
  • Loading branch information
jetm committed Oct 6, 2024
1 parent 2734052 commit 50cc565
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/efivarfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,8 @@ efivarfs_del_variable(efi_guid_t guid, const char *name)
if (rc < 0)
efi_error("unlink failed");

efi_save_esp_filename();

__typeof__(errno) errno_value = errno;
free(path);
errno = errno_value;
Expand Down Expand Up @@ -442,6 +444,8 @@ efivarfs_set_variable(efi_guid_t guid, const char *name, const uint8_t *data,
goto err;
}

efi_save_esp_filename();

/* we're done */
ret = 0;

Expand Down
8 changes: 6 additions & 2 deletions src/vars.c
Original file line number Diff line number Diff line change
Expand Up @@ -435,8 +435,10 @@ vars_del_variable(efi_guid_t guid, const char *name)
}

rc = write(fd, buf, buf_size);
if (rc >= 0)
if (rc >= 0) {
efi_save_esp_filename();
ret = 0;
}
else
efi_error("write() failed");
err:
Expand Down Expand Up @@ -594,8 +596,10 @@ vars_set_variable(efi_guid_t guid, const char *name, const uint8_t *data,
rc = write(fd, &var32, sizeof(var32));
}

if (rc >= 0)
if (rc >= 0) {
efi_save_esp_filename();
ret = 0;
}
else
efi_error("write() failed");

Expand Down

0 comments on commit 50cc565

Please sign in to comment.