summaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2021-03-15 18:00:16 +1300
committerSimon Glass <sjg@chromium.org>2021-03-27 13:59:37 +1300
commita202f17d7bc2a51af53352c6e21d6a70d167effe (patch)
treeb565dc3a89b4bb1c655cbf2ab5b5790fb1bf6933 /fs
parent0e2fee52d0fba6ceb455c7969eecb2cf73031267 (diff)
downloadu-boot-a202f17d7bc2a51af53352c6e21d6a70d167effe.tar.gz
u-boot-a202f17d7bc2a51af53352c6e21d6a70d167effe.tar.xz
u-boot-a202f17d7bc2a51af53352c6e21d6a70d167effe.zip
cbfs: Support reading compression information
CBFS now supports compressed filed. Add support for reading this information so that the correct decompression can be applied. The decompression itself is not implemented in CBFS. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/cbfs/cbfs.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/fs/cbfs/cbfs.c b/fs/cbfs/cbfs.c
index 9e534d15f2..443a148e3f 100644
--- a/fs/cbfs/cbfs.c
+++ b/fs/cbfs/cbfs.c
@@ -91,6 +91,7 @@ static int fill_node(struct cbfs_cachenode *node, void *start,
struct cbfs_fileheader *header)
{
uint name_len;
+ uint offset;
/* Check the header is large enough */
if (header->offset < sizeof(struct cbfs_fileheader))
@@ -104,6 +105,27 @@ static int fill_node(struct cbfs_cachenode *node, void *start,
node->name = start + sizeof(struct cbfs_fileheader);
node->name_length = name_len;
node->attr_offset = header->attributes_offset;
+ node->comp_algo = CBFS_COMPRESS_NONE;
+ node->decomp_size = 0;
+
+ for (offset = node->attr_offset; offset < header->offset;) {
+ const struct cbfs_file_attribute *attr;
+ uint tag, len;
+
+ attr = start + offset;
+ tag = be32_to_cpu(attr->tag);
+ len = be32_to_cpu(attr->len);
+ if (tag == CBFS_FILE_ATTR_TAG_COMPRESSION) {
+ struct cbfs_file_attr_compression *comp;
+
+ comp = start + offset;
+ node->comp_algo = be32_to_cpu(comp->compression);
+ node->decomp_size =
+ be32_to_cpu(comp->decompressed_size);
+ }
+
+ offset += len;
+ }
return 0;
}