[coreboot-gerrit] Change in coreboot[master]: cbfstool: Print compression algorithm

Daisuke Nojiri (Code Review) gerrit at coreboot.org
Fri Oct 27 02:44:12 CEST 2017


Daisuke Nojiri has uploaded this change for review. ( https://review.coreboot.org/22196


Change subject: cbfstool: Print compression algorithm
......................................................................

cbfstool: Print compression algorithm

This patch adds a column to the print command to show the compression
algorithm used for the file.

Name                           Offset     Type           Size   Comp
fallback/romstage              0x0        stage           56236 none
ecrw                           0xf2380    raw             62162 LZMA (131072 decompressed)

BUG=b:66956286
BRANCH=none
TEST=Run 'cbfstool image.bin print'

Change-Id: I4bbb60ab467adac4ae5486ddafec86ad9682a40e
Signed-off-by: Daisuke Nojiri <dnojiri at chromium.org>
---
M util/cbfstool/cbfs_image.c
1 file changed, 15 insertions(+), 13 deletions(-)



  git pull ssh://review.coreboot.org:29418/coreboot refs/changes/96/22196/1

diff --git a/util/cbfstool/cbfs_image.c b/util/cbfstool/cbfs_image.c
index 780ab6d..306fc29 100644
--- a/util/cbfstool/cbfs_image.c
+++ b/util/cbfstool/cbfs_image.c
@@ -1460,24 +1460,26 @@
 	unsigned int decompressed_size = 0;
 	unsigned int compression = cbfs_file_get_compression_info(entry,
 		&decompressed_size);
+	const char *compression_name = lookup_name_by_type(
+			types_cbfs_compression, compression, "????");
 
-	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",
+	if (compression == CBFS_COMPRESS_NONE)
+		fprintf(fp, "%-30s 0x%-8x %-12s %8d %-4s\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)")
+			compression_name
 			);
-	}
+	else
+		fprintf(fp, "%-30s 0x%-8x %-12s %8d %-4s (%d decompressed)\n",
+			*name ? name : "(empty)",
+			cbfs_get_entry_addr(image, entry),
+			get_cbfs_entry_type_name(ntohl(entry->type)),
+			ntohl(entry->len),
+			compression_name,
+			decompressed_size
+			);
 
 	struct cbfs_file_attr_hash *hash = NULL;
 	while ((hash = cbfs_file_get_next_hash(entry, hash)) != NULL) {
@@ -1579,7 +1581,7 @@
 {
 	if (cbfs_is_legacy_cbfs(image))
 		cbfs_print_header_info(image);
-	printf("%-30s %-10s %-12s Size\n", "Name", "Offset", "Type");
+	printf("%-30s %-10s %-12s   Size   Comp\n", "Name", "Offset", "Type");
 	cbfs_walk(image, cbfs_print_entry_info, NULL);
 	return 0;
 }

-- 
To view, visit https://review.coreboot.org/22196
To unsubscribe, visit https://review.coreboot.org/settings

Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I4bbb60ab467adac4ae5486ddafec86ad9682a40e
Gerrit-Change-Number: 22196
Gerrit-PatchSet: 1
Gerrit-Owner: Daisuke Nojiri <dnojiri at chromium.org>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.coreboot.org/pipermail/coreboot-gerrit/attachments/20171027/c9b3d2e1/attachment.html>


More information about the coreboot-gerrit mailing list