From: Joao Marcos Costa <joaomarcos.costa@bootlin.com>
To: u-boot@lists.denx.de
Subject: [PATCH v3 4/5] fs/squashfs: add support for zlib decompression
Date: Tue, 21 Jul 2020 11:22:58 +0200 [thread overview]
Message-ID: <20200721092259.26916-5-joaomarcos.costa@bootlin.com> (raw)
In-Reply-To: <20200721092259.26916-1-joaomarcos.costa@bootlin.com>
Add call to zlib's 'uncompress' function. Add function to display the
right error message depending on the decompression's return value.
Signed-off-by: Joao Marcos Costa <joaomarcos.costa@bootlin.com>
---
Changes in v3:
- No changes since v2.
Changes in v2:
- No changes since v1.
fs/squashfs/sqfs_decompressor.c | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/fs/squashfs/sqfs_decompressor.c b/fs/squashfs/sqfs_decompressor.c
index a899a5704b..a8c37f73b7 100644
--- a/fs/squashfs/sqfs_decompressor.c
+++ b/fs/squashfs/sqfs_decompressor.c
@@ -9,17 +9,41 @@
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
+#include <u-boot/zlib.h>
#include "sqfs_decompressor.h"
#include "sqfs_filesystem.h"
#include "sqfs_utils.h"
+static void zlib_decompression_status(int ret)
+{
+ switch (ret) {
+ case Z_BUF_ERROR:
+ printf("Error: 'dest' buffer is not large enough.\n");
+ break;
+ case Z_DATA_ERROR:
+ printf("Error: corrupted compressed data.\n");
+ break;
+ case Z_MEM_ERROR:
+ printf("Error: insufficient memory.\n");
+ break;
+ }
+}
+
int sqfs_decompress(u16 comp_type, void *dest, unsigned long *dest_len,
void *source, u32 lenp)
{
int ret = 0;
switch (comp_type) {
+ case SQFS_COMP_ZLIB:
+ ret = uncompress(dest, dest_len, source, lenp);
+ if (ret) {
+ zlib_decompression_status(ret);
+ return -EINVAL;
+ }
+
+ break;
default:
printf("Error: unknown compression type.\n");
return -EINVAL;
--
2.17.1
next prev parent reply other threads:[~2020-07-21 9:22 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-21 9:22 [PATCH v3 0/5] Add support for the SquashFS filesystem Joao Marcos Costa
2020-07-21 9:22 ` [PATCH v3 1/5] fs/squashfs: new filesystem Joao Marcos Costa
2020-07-21 9:22 ` [PATCH v3 2/5] fs/squashfs: add filesystem commands Joao Marcos Costa
2020-07-21 9:22 ` [PATCH v3 3/5] include/u-boot, lib/zlib: add sources for zlib decompression Joao Marcos Costa
2020-07-29 15:27 ` Tom Rini
2020-07-29 16:00 ` Joao Marcos Costa
2020-07-29 16:54 ` Tom Rini
2020-07-30 12:10 ` Joao Marcos Costa
2020-07-30 12:17 ` Tom Rini
2020-07-30 13:27 ` Joao Marcos Costa
2020-07-21 9:22 ` Joao Marcos Costa [this message]
2020-07-21 9:22 ` [PATCH v3 5/5] fs/fs.c: add symbolic link case to fs_ls_generic() Joao Marcos Costa
2020-07-29 12:54 ` [PATCH v3 0/5] Add support for the SquashFS filesystem Joao Marcos Costa
2020-07-29 15:21 ` Tom Rini
2020-07-29 16:02 ` Joao Marcos Costa
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200721092259.26916-5-joaomarcos.costa@bootlin.com \
--to=joaomarcos.costa@bootlin.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.