From 0c2f0c1d31ff9646713718a6cc69ed03c3b81410 Mon Sep 17 00:00:00 2001 From: Daisuke Nojiri Date: Thu, 26 Oct 2017 17:40:41 -0700 Subject: 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 Reviewed-on: https://review.coreboot.org/22196 Tested-by: build bot (Jenkins) Reviewed-by: Paul Menzel Reviewed-by: Patrick Georgi --- util/cbfstool/cbfs_image.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/util/cbfstool/cbfs_image.c b/util/cbfstool/cbfs_image.c index 780ab6db84..306fc291bd 100644 --- a/util/cbfstool/cbfs_image.c +++ b/util/cbfstool/cbfs_image.c @@ -1460,24 +1460,26 @@ int cbfs_print_entry_info(struct cbfs_image *image, struct cbfs_file *entry, 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", + 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)); - } else { - fprintf(fp, "%-30s 0x%-8x %-12s %d (%d after %s decompression)\n", + ntohl(entry->len), + 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), - decompressed_size, - lookup_name_by_type(types_cbfs_compression, - compression, "(unknown)") + 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 @@ int cbfs_print_directory(struct cbfs_image *image) { 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; } -- cgit v1.2.3