Anastasia Klimchuk has uploaded this change for review.
layout: Hoist prepare_layout_for_extraction into libflashrom API
Currently extract operation is not available via libflashrom API.
It consists of two calls: prepare_layout_for_extraction and read
operation. The latter is already a part of libflashrom API. So
prepare_layout_for_extraction is remaining piece to make extract
operation available in libflashrom.
TEST ME ON DEVICE
BUG=b:222384032
Change-Id: I3f5b4079528ddd4d1ca9acfa6d107e8c3d6814ff
Signed-off-by: Anastasia Klimchuk <aklm@chromium.org>
---
M cli_classic.c
M layout.c
M layout.h
M libflashrom.h
M libflashrom.map
5 files changed, 26 insertions(+), 20 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/55/62555/1
diff --git a/cli_classic.c b/cli_classic.c
index f044e87..573d28f 100644
--- a/cli_classic.c
+++ b/cli_classic.c
@@ -184,7 +184,7 @@
static int do_extract(struct flashctx *const flash)
{
const struct flashrom_layout *const layout = get_layout(flash);
- prepare_layout_for_extraction(layout);
+ flashrom_layout_prepare_for_extraction(layout);
return do_read(flash, NULL);
}
diff --git a/layout.c b/layout.c
index b4ccdaa..50a2900 100644
--- a/layout.c
+++ b/layout.c
@@ -299,24 +299,6 @@
return ret;
}
-void prepare_layout_for_extraction(const struct flashrom_layout *const layout)
-{
- struct romentry *entry = NULL;
- unsigned int i;
-
- while ((entry = mutable_layout_next(layout, entry))) {
- entry->included = true;
-
- if (!entry->file)
- entry->file = strdup(entry->name);
-
- for (i = 0; entry->file[i]; ++i) {
- if (isspace(entry->file[i]))
- entry->file[i] = '_';
- }
- }
-}
-
const struct romentry *layout_next_included_region(
const struct flashrom_layout *const l, const chipoff_t where)
{
@@ -455,6 +437,29 @@
}
/**
+ * @brief Fill in file name for each included region.
+ *
+ * @param layout The layout to prepare.
+ */
+void flashrom_layout_prepare_for_extraction(const struct flashrom_layout *const layout)
+{
+ struct romentry *entry = NULL;
+ unsigned int i;
+
+ while ((entry = mutable_layout_next(layout, entry))) {
+ entry->included = true;
+
+ if (!entry->file)
+ entry->file = strdup(entry->name);
+
+ for (i = 0; entry->file[i]; ++i) {
+ if (isspace(entry->file[i]))
+ entry->file[i] = '_';
+ }
+ }
+}
+
+/**
* @brief Free a layout.
*
* @param layout Layout to free.
diff --git a/layout.h b/layout.h
index ce8386a..6ab42d8 100644
--- a/layout.h
+++ b/layout.h
@@ -63,7 +63,6 @@
const struct romentry *layout_next_included(const struct flashrom_layout *, const struct romentry *);
const struct romentry *layout_next(const struct flashrom_layout *, const struct romentry *);
int included_regions_overlap(const struct flashrom_layout *);
-void prepare_layout_for_extraction(const struct flashrom_layout *const);
int layout_sanity_checks(const struct flashrom_flashctx *);
#endif /* !__LAYOUT_H__ */
diff --git a/libflashrom.h b/libflashrom.h
index 557978d..eaaa480 100644
--- a/libflashrom.h
+++ b/libflashrom.h
@@ -116,6 +116,7 @@
int flashrom_layout_include_region(struct flashrom_layout *, const char *name);
int flashrom_layout_get_region_range(struct flashrom_layout *, const char *name,
unsigned int *start, unsigned int *len);
+void flashrom_layout_prepare_for_extraction(const struct flashrom_layout *const);
void flashrom_layout_release(struct flashrom_layout *);
void flashrom_layout_set(struct flashrom_flashctx *, const struct flashrom_layout *);
diff --git a/libflashrom.map b/libflashrom.map
index 2249d35..fce24cc 100644
--- a/libflashrom.map
+++ b/libflashrom.map
@@ -16,6 +16,7 @@
flashrom_init;
flashrom_layout_get_region_range;
flashrom_layout_include_region;
+ flashrom_layout_prepare_for_extraction;
flashrom_layout_read_fmap_from_buffer;
flashrom_layout_read_fmap_from_rom;
flashrom_layout_read_from_ifd;
To view, visit change 62555. To unsubscribe, or for help writing mail filters, visit settings.