From: Pingfan Liu <kernelfans@gmail.com>
To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org
Cc: Pingfan Liu <kernelfans@gmail.com>,
Ard Biesheuvel <ardb@kernel.org>,
kexec@lists.infradead.org
Subject: [PATCH 2/6] lib/decompress: Introduce decompress_method_by_name()
Date: Mon, 6 Mar 2023 11:03:01 +0800 [thread overview]
Message-ID: <20230306030305.15595-3-kernelfans@gmail.com> (raw)
In-Reply-To: <20230306030305.15595-1-kernelfans@gmail.com>
The zboot image packs the compressed file in the data section. Instead
of starting with the zip file header. It records the compressing method
name 'gzip','lzma' etc in the zboot image header.
Hence it is easier to decide the decompressing method by the name than
by the magic number.
Signed-off-by: Pingfan Liu <kernelfans@gmail.com>
Cc: Ard Biesheuvel <ardb@kernel.org>
Cc: kexec@lists.infradead.org
To: linux-kernel@vger.kernel.org
---
include/linux/decompress/generic.h | 2 ++
lib/decompress.c | 14 +++++++++++++-
2 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/include/linux/decompress/generic.h b/include/linux/decompress/generic.h
index 207d80138db5..077f15ce77b9 100644
--- a/include/linux/decompress/generic.h
+++ b/include/linux/decompress/generic.h
@@ -37,4 +37,6 @@ typedef int (*decompress_fn) (unsigned char *inbuf, long len,
decompress_fn decompress_method(const unsigned char *inbuf, long len,
const char **name);
+decompress_fn decompress_method_by_name(const unsigned char *name);
+
#endif
diff --git a/lib/decompress.c b/lib/decompress.c
index ab3fc90ffc64..8dd6f87e885f 100644
--- a/lib/decompress.c
+++ b/lib/decompress.c
@@ -2,7 +2,7 @@
/*
* decompress.c
*
- * Detect the decompression method based on magic number
+ * Detect the decompression method based on magic number or name
*/
#include <linux/decompress/generic.h>
@@ -82,3 +82,15 @@ decompress_fn __init decompress_method(const unsigned char *inbuf, long len,
*name = cf->name;
return cf->decompressor;
}
+
+decompress_fn __init decompress_method_by_name(const unsigned char *name)
+{
+ const struct compress_format *cf;
+
+ for (cf = compressed_formats; cf->name; cf++) {
+ if (!strcmp(name, cf->name))
+ break;
+
+ }
+ return cf->decompressor;
+}
--
2.31.1
next prev parent reply other threads:[~2023-03-06 3:03 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-06 3:02 [PATCH 0/6] arm64: make kexec_file able to load zboot image Pingfan Liu
2023-03-06 3:03 ` Pingfan Liu [this message]
2023-03-06 3:03 ` [PATCH 4/6] lib/decompress: Keep decompress routines based on selection Pingfan Liu
2023-03-06 3:03 ` [PATCH 6/6] init/Kconfig: Select decompressing method if compressing kernel Pingfan Liu
2023-03-06 8:08 ` [PATCH 0/6] arm64: make kexec_file able to load zboot image Ard Biesheuvel
2023-03-07 8:08 ` Pingfan Liu
2023-03-10 4:17 ` Pingfan Liu
2023-03-22 3:44 ` Dave Young
2023-03-23 3:40 ` Pingfan Liu
2023-03-10 8:57 ` Naresh Kamboju
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=20230306030305.15595-3-kernelfans@gmail.com \
--to=kernelfans@gmail.com \
--cc=ardb@kernel.org \
--cc=kexec@lists.infradead.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome