1
0
mirror of https://review.coreboot.org/flashrom.git synced 2025-07-01 22:21:16 +02:00

cli_classic.c: add -x option for do_extract()

This change introduces a new option to extract all layout regions to
files with the name of each region (or with the provided filename via
-i region:file). It is implemented by mutating the flash layout to
include all regions and backfilling the entry->file with entry->name
(replacing spaces with underscores)

Signed-off-by: Daniel Campello <campello@chromium.org>
Change-Id: I8c69223fa92cf5b50abe070f1ab9f19d3b42f6ff
Reviewed-on: https://review.coreboot.org/c/flashrom/+/52450
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
This commit is contained in:
Daniel Campello
2021-04-16 15:26:42 -06:00
committed by Edward O'Callaghan
parent 0969e43b3f
commit ce983bccaa
5 changed files with 39 additions and 4 deletions

View File

@ -15,6 +15,7 @@
* GNU General Public License for more details.
*/
#include <ctype.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
@ -308,6 +309,24 @@ int normalize_romentries(const struct flashctx *flash)
return ret;
}
void prepare_layout_for_extraction(struct flashctx *flash)
{
const struct flashrom_layout *const l = get_layout(flash);
unsigned int i, j;
for (i = 0; i < l->num_entries; ++i) {
l->entries[i].included = true;
if (!l->entries[i].file)
l->entries[i].file = strdup(l->entries[i].name);
for (j = 0; l->entries[i].file[j]; j++) {
if (isspace(l->entries[i].file[j]))
l->entries[i].file[j] = '_';
}
}
}
const struct romentry *layout_next_included_region(
const struct flashrom_layout *const l, const chipoff_t where)
{