Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(381)

Unified Diff: src/platform/vboot_reference/vfirmware/firmware_image.c

Issue 1525032: Add a --vblock option to firmware_utility to only output the verification block. (Closed)
Patch Set: fix typo Created 10 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/platform/vboot_reference/vfirmware/firmware_image.c
diff --git a/src/platform/vboot_reference/vfirmware/firmware_image.c b/src/platform/vboot_reference/vfirmware/firmware_image.c
index b633d1a7c73d0b2cb5000ae531aaace8b7f5049a..84e37341cf9bf43d07c24aa6eaae67c9b9c1c3b9 100644
--- a/src/platform/vboot_reference/vfirmware/firmware_image.c
+++ b/src/platform/vboot_reference/vfirmware/firmware_image.c
@@ -258,8 +258,10 @@ uint8_t* GetFirmwareBlob(const FirmwareImage* image, uint64_t* blob_len) {
}
int WriteFirmwareImage(const char* input_file,
- const FirmwareImage* image) {
+ const FirmwareImage* image,
+ int is_only_vblock) {
int fd;
+ int success = 1;
uint8_t* firmware_blob;
uint64_t blob_len;
@@ -275,15 +277,23 @@ int WriteFirmwareImage(const char* input_file,
debug("Couldn't create firmware blob from FirmwareImage.\n");
return 0;
}
- if (blob_len != write(fd, firmware_blob, blob_len)) {
- debug("Couldn't write Firmware Image to file: %s\n", input_file);
- Free(firmware_blob);
- close(fd);
- return 0;
+ if (!is_only_vblock) {
+ if (blob_len != write(fd, firmware_blob, blob_len)) {
+ debug("Couldn't write Firmware Image to file: %s\n", input_file);
+ success = 0;
+ }
+ } else {
+ /* Exclude the firmware_data. */
+ int vblock_len = blob_len - image->firmware_len;
+ if (vblock_len != write(fd, firmware_blob, vblock_len)) {
+ debug("Couldn't write Firmware Image verifcation block to file: %s\n",
+ input_file);
+ success = 0;
+ }
}
Free(firmware_blob);
close(fd);
- return 1;
+ return success;
}
void PrintFirmwareImage(const FirmwareImage* image) {

Powered by Google App Engine
This is Rietveld 408576698