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@chromium.org>
Reviewed-on: https://review.coreboot.org/22196
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net>
Reviewed-by: Patrick Georgi <pgeorgi@google.com>
This commit is contained in:
Daisuke Nojiri 2017-10-26 17:40:41 -07:00 committed by Patrick Georgi
parent 8aba24d3e1
commit 0c2f0c1d31
1 changed files with 15 additions and 13 deletions

View File

@ -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",
*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 @@ 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;
}