[coreboot-gerrit] Patch set updated for coreboot: cbfstool: have decompress functions provide ouput data size

Aaron Durbin (adurbin@chromium.org) gerrit at coreboot.org
Sat Oct 24 22:19:41 CEST 2015


Aaron Durbin (adurbin at chromium.org) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/12173

-gerrit

commit 1733e675d6025994bf7e736d69e50809c9c6c253
Author: Aaron Durbin <adurbin at chromium.org>
Date:   Fri Oct 23 17:38:40 2015 -0500

    cbfstool: have decompress functions provide ouput data size
    
    Currently cbfs stage files that are compressed do not have
    the decompressed size readily available. Therefore there's
    no good way to know actual size of data after it is
    decompressed. Optionally return the decompressed data size
    if requested.
    
    Change-Id: If371753d28d0ff512118d8bc06fdd48f4a0aeae7
    Signed-off-by: Aaron Durbin <adurbin at chromium.org>
---
 util/cbfstool/cbfs_image.c |  2 +-
 util/cbfstool/common.h     |  6 ++++--
 util/cbfstool/compress.c   | 10 +++++++---
 util/cbfstool/lzma/lzma.c  |  6 +++++-
 4 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/util/cbfstool/cbfs_image.c b/util/cbfstool/cbfs_image.c
index bc5c5d7..bf01c96 100644
--- a/util/cbfstool/cbfs_image.c
+++ b/util/cbfstool/cbfs_image.c
@@ -692,7 +692,7 @@ int cbfs_export_entry(struct cbfs_image *image, const char *entry_name,
 	buffer.data = malloc(decompressed_size);
 	buffer.size = decompressed_size;
 	if (decompress(CBFS_SUBHEADER(entry), ntohl(entry->len),
-		buffer.data, buffer.size)) {
+		buffer.data, buffer.size, NULL)) {
 		ERROR("decompression failed for %s\n", entry_name);
 		return -1;
 	}
diff --git a/util/cbfstool/common.h b/util/cbfstool/common.h
index e889e52..4920d76 100644
--- a/util/cbfstool/common.h
+++ b/util/cbfstool/common.h
@@ -153,7 +153,8 @@ typedef int (*comp_func_ptr) (char *in, int in_len, char *out, int *out_len);
  * Returns 0 on error,
  *         != 0 otherwise, depending on the decompressing function.
  */
-typedef int (*decomp_func_ptr) (char *in, int in_len, char *out, int out_len);
+typedef int (*decomp_func_ptr) (char *in, int in_len, char *out, int out_len,
+				size_t *actual_size);
 
 enum comp_algo { CBFS_COMPRESS_NONE = 0, CBFS_COMPRESS_LZMA = 1 };
 
@@ -187,7 +188,8 @@ void print_supported_filetypes(void);
 
 /* lzma/lzma.c */
 int do_lzma_compress(char *in, int in_len, char *out, int *out_len);
-int do_lzma_uncompress(char *dst, int dst_len, char *src, int src_len);
+int do_lzma_uncompress(char *dst, int dst_len, char *src, int src_len,
+			size_t *actual_size);
 
 /* xdr.c */
 struct xdr {
diff --git a/util/cbfstool/compress.c b/util/cbfstool/compress.c
index 2bde7df..0313b96 100644
--- a/util/cbfstool/compress.c
+++ b/util/cbfstool/compress.c
@@ -31,9 +31,10 @@ static int lzma_compress(char *in, int in_len, char *out, int *out_len)
 	return do_lzma_compress(in, in_len, out, out_len);
 }
 
-static int lzma_decompress(char *in, int in_len, char *out, unused int out_len)
+static int lzma_decompress(char *in, int in_len, char *out, unused int out_len,
+				size_t *actual_size)
 {
-	return do_lzma_uncompress(out, out_len, in, in_len);
+	return do_lzma_uncompress(out, out_len, in, in_len, actual_size);
 }
 static int none_compress(char *in, int in_len, char *out, int *out_len)
 {
@@ -42,9 +43,12 @@ static int none_compress(char *in, int in_len, char *out, int *out_len)
 	return 0;
 }
 
-static int none_decompress(char *in, int in_len, char *out, unused int out_len)
+static int none_decompress(char *in, int in_len, char *out, unused int out_len,
+				size_t *actual_size)
 {
 	memcpy(out, in, in_len);
+	if (actual_size != NULL)
+		*actual_size = in_len;
 	return 0;
 }
 
diff --git a/util/cbfstool/lzma/lzma.c b/util/cbfstool/lzma/lzma.c
index 856932d..986ebfa 100644
--- a/util/cbfstool/lzma/lzma.c
+++ b/util/cbfstool/lzma/lzma.c
@@ -152,7 +152,8 @@ int do_lzma_compress(char *in, int in_len, char *out, int *out_len)
 	return 0;
 }
 
-int do_lzma_uncompress(char *dst, int dst_len, char *src, int src_len)
+int do_lzma_uncompress(char *dst, int dst_len, char *src, int src_len,
+			size_t *actual_size)
 {
 	if (src_len <= LZMA_PROPS_SIZE + 8) {
 		ERROR("LZMA: Input length is too small.\n");
@@ -184,5 +185,8 @@ int do_lzma_uncompress(char *dst, int dst_len, char *src, int src_len)
 		return -1;
 	}
 
+	if (actual_size != NULL)
+		*actual_size = destlen;
+
 	return 0;
 }



More information about the coreboot-gerrit mailing list