summaryrefslogtreecommitdiff
path: root/util/cbfstool
diff options
context:
space:
mode:
authorPatrick Georgi <patrick@georgi-clan.de>2015-08-26 12:23:26 +0200
committerPatrick Georgi <pgeorgi@google.com>2015-09-01 14:51:41 +0000
commita71c83fa5c3904b562bad939a3103387cd561c80 (patch)
treec6eb5814dad6d0cd4d271c57e932d10ca6741f1f /util/cbfstool
parentc82725c5b912a695b4582b34253029552932de69 (diff)
cbfstool: factor out parsing compression file attributes
cbfstool extract also needs it. Change-Id: I8302bb18c5f797eb0a43ec4e4269790f3d49a896 Signed-off-by: Patrick Georgi <patrick@georgi-clan.de> Reviewed-on: http://review.coreboot.org/11361 Tested-by: build bot (Jenkins) Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Diffstat (limited to 'util/cbfstool')
-rw-r--r--util/cbfstool/cbfs_image.c33
1 files changed, 22 insertions, 11 deletions
diff --git a/util/cbfstool/cbfs_image.c b/util/cbfstool/cbfs_image.c
index 5e914a409a..619bf0bd5b 100644
--- a/util/cbfstool/cbfs_image.c
+++ b/util/cbfstool/cbfs_image.c
@@ -178,6 +178,26 @@ static void cbfs_decode_payload_segment(struct cbfs_payload_segment *output,
assert(seg.size == 0);
}
+static int cbfs_file_get_compression_info(struct cbfs_file *entry,
+ uint32_t *decompressed_size)
+{
+ unsigned int compression = CBFS_COMPRESS_NONE;
+ *decompressed_size = ntohl(entry->len);
+ for (struct cbfs_file_attribute *attr = cbfs_file_first_attr(entry);
+ attr != NULL;
+ attr = cbfs_file_next_attr(entry, attr)) {
+ if (ntohl(attr->tag) == CBFS_FILE_ATTR_TAG_COMPRESSION) {
+ struct cbfs_file_attr_compression *ac =
+ (struct cbfs_file_attr_compression *)attr;
+ compression = ntohl(ac->compression);
+ if (decompressed_size)
+ *decompressed_size =
+ ntohl(ac->decompressed_size);
+ }
+ }
+ return compression;
+}
+
void cbfs_get_header(struct cbfs_header *header, void *src)
{
struct buffer outheader;
@@ -777,18 +797,9 @@ int cbfs_print_entry_info(struct cbfs_image *image, struct cbfs_file *entry,
if (!fp)
fp = stdout;
- unsigned int compression = CBFS_COMPRESS_NONE;
unsigned int decompressed_size = 0;
- for (struct cbfs_file_attribute *attr = cbfs_file_first_attr(entry);
- attr != NULL;
- attr = cbfs_file_next_attr(entry, attr)) {
- if (ntohl(attr->tag) == CBFS_FILE_ATTR_TAG_COMPRESSION) {
- struct cbfs_file_attr_compression *ac =
- (struct cbfs_file_attr_compression *)attr;
- compression = ntohl(ac->compression);
- decompressed_size = ntohl(ac->decompressed_size);
- }
- }
+ unsigned int compression = cbfs_file_get_compression_info(entry,
+ &decompressed_size);
if (compression == CBFS_COMPRESS_NONE) {
fprintf(fp, "%-30s 0x%-8x %-12s %d\n",