| 413 | } |
| 414 | |
| 415 | static int ifwi_repack(void) |
| 416 | { |
| 417 | if (!ifwi.repack) |
| 418 | return 0; |
| 419 | |
| 420 | struct buffer output_buff; |
| 421 | const size_t size = ifwi.file_end_offset; |
| 422 | struct buffer bpdt_buff; |
| 423 | |
| 424 | if (buffer_create(&output_buff, size, "Output IFWI")) { |
| 425 | ERROR("Unable to allocate output buff!\n"); |
| 426 | return -1; |
| 427 | } |
| 428 | |
| 429 | buffer_clone(&bpdt_buff, &output_buff); |
| 430 | |
| 431 | ifwi.bpdt_ops->update_checksum(ifwi.bpdt_hdr, &ifwi.bpdt_entries[0]); |
| 432 | |
| 433 | if (ifwi.bpdt_ops->write_hdr(&bpdt_buff, ifwi.bpdt_hdr)) |
| 434 | return -1; |
| 435 | |
| 436 | if (write_bpdt_entries(&bpdt_buff)) |
| 437 | return -1; |
| 438 | |
| 439 | subpart_write(&output_buff); |
| 440 | |
| 441 | if (buffer_write_file(&output_buff, params.image_name)) { |
| 442 | ERROR("File write error!\n"); |
| 443 | return -1; |
| 444 | } |
| 445 | |
| 446 | printf("Image written successfully to %s.\n", params.image_name); |
| 447 | return 0; |
| 448 | } |
| 449 | |
| 450 | static bool should_process_partition(int type) |
| 451 | { |
no test coverage detected