summaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorPatrick Georgi <patrick@georgi-clan.de>2015-08-26 12:13:03 +0200
committerPatrick Georgi <pgeorgi@google.com>2015-09-01 14:51:29 +0000
commitc82725c5b912a695b4582b34253029552932de69 (patch)
tree149217076e17f3a59194bfdc407c7c200afd4f9b /util
parent8984a637c121d06a408a5f2b3b9d5233a7aa0e6e (diff)
downloadcoreboot-c82725c5b912a695b4582b34253029552932de69.tar.gz
coreboot-c82725c5b912a695b4582b34253029552932de69.tar.bz2
coreboot-c82725c5b912a695b4582b34253029552932de69.zip
cbfstool: support compressed files in cbfstool print
Display compressed and decompressed sizes, as well as the compression algorithm used, when a compressed file is encountered. Change-Id: I13c2332702c4a5bec379e1ebda72753e06f8e135 Signed-off-by: Patrick Georgi <patrick@georgi-clan.de> Reviewed-on: http://review.coreboot.org/11359 Tested-by: build bot (Jenkins) Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Diffstat (limited to 'util')
-rw-r--r--util/cbfstool/cbfs_image.c35
1 files changed, 30 insertions, 5 deletions
diff --git a/util/cbfstool/cbfs_image.c b/util/cbfstool/cbfs_image.c
index d295058ea15d..5e914a409acb 100644
--- a/util/cbfstool/cbfs_image.c
+++ b/util/cbfstool/cbfs_image.c
@@ -777,11 +777,36 @@ int cbfs_print_entry_info(struct cbfs_image *image, struct cbfs_file *entry,
if (!fp)
fp = stdout;
- fprintf(fp, "%-30s 0x%-8x %-12s %d\n",
- *name ? name : "(empty)",
- cbfs_get_entry_addr(image, entry),
- get_cbfs_entry_type_name(ntohl(entry->type)),
- ntohl(entry->len));
+ 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);
+ }
+ }
+
+ if (compression == CBFS_COMPRESS_NONE) {
+ fprintf(fp, "%-30s 0x%-8x %-12s %d\n",
+ *name ? name : "(empty)",
+ cbfs_get_entry_addr(image, entry),
+ get_cbfs_entry_type_name(ntohl(entry->type)),
+ ntohl(entry->len));
+ } else {
+ fprintf(fp, "%-30s 0x%-8x %-12s %d (%d after %s decompression)\n",
+ *name ? name : "(empty)",
+ cbfs_get_entry_addr(image, entry),
+ get_cbfs_entry_type_name(ntohl(entry->type)),
+ ntohl(entry->len),
+ decompressed_size,
+ lookup_name_by_type(types_cbfs_compression,
+ compression, "(unknown)")
+ );
+ }
if (!verbose)
return 0;