From: Marco Felsch <m.felsch@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 1/3] filetype: add zstd support
Date: Wed, 24 Jan 2024 14:47:36 +0100 [thread overview]
Message-ID: <20240124134738.133782-2-m.felsch@pengutronix.de> (raw)
In-Reply-To: <20240124134738.133782-1-m.felsch@pengutronix.de>
Add support to detect ZSTD compressed files.
Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
---
common/filetype.c | 4 ++++
include/filetype.h | 2 ++
2 files changed, 6 insertions(+)
diff --git a/common/filetype.c b/common/filetype.c
index 14948db4469f..7f1ce20d0094 100644
--- a/common/filetype.c
+++ b/common/filetype.c
@@ -17,6 +17,7 @@
#include <disks.h>
#include <image-sparse.h>
#include <elf.h>
+#include <linux/zstd.h>
#include <mach/imx/imx-header.h>
@@ -78,6 +79,7 @@ static const struct filetype_str filetype_str[] = {
[filetype_mxs_sd_image] = { "i.MX23/28 SD card image", "mxs-sd-image" },
[filetype_rockchip_rkns_image] = { "Rockchip boot image", "rk-image" },
[filetype_fip] = { "TF-A Firmware Image Package", "fip" },
+ [filetype_zstd_compressed] = { "ZSTD compressed", "zstd" },
};
const char *file_type_to_string(enum filetype f)
@@ -320,6 +322,8 @@ enum filetype file_detect_type(const void *_buf, size_t bufsize)
return filetype_rockchip_rkns_image;
if (le32_to_cpu(buf[0]) == le32_to_cpu(0xaa640001))
return filetype_fip;
+ if (le32_to_cpu(buf[0]) == le32_to_cpu(ZSTD_MAGICNUMBER))
+ return filetype_zstd_compressed;
if ((buf8[0] == 0x5a || buf8[0] == 0x69 || buf8[0] == 0x78 ||
buf8[0] == 0x8b || buf8[0] == 0x9c) &&
diff --git a/include/filetype.h b/include/filetype.h
index e5aa050ebc27..a1f98f2a983a 100644
--- a/include/filetype.h
+++ b/include/filetype.h
@@ -60,6 +60,7 @@ enum filetype {
filetype_fip,
filetype_qemu_fw_cfg,
filetype_nxp_fspi_image,
+ filetype_zstd_compressed,
filetype_max,
};
@@ -84,6 +85,7 @@ static inline bool file_is_compressed_file(enum filetype ft)
case filetype_gzip:
case filetype_bzip2:
case filetype_xz_compressed:
+ case filetype_zstd_compressed:
return true;
default:
return false;
--
2.39.2
next prev parent reply other threads:[~2024-01-24 13:49 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-24 13:47 [PATCH 0/3] Add bootm ZSTD support Marco Felsch
2024-01-24 13:47 ` Marco Felsch [this message]
2024-01-24 13:47 ` [PATCH 2/3] bootm: add support to boot ZSTD compressed images Marco Felsch
2024-01-24 13:47 ` [PATCH 3/3] uncompress: add detected file type debug print Marco Felsch
2024-01-24 13:56 ` Ahmad Fatoum
2024-01-24 13:58 ` Marco Felsch
2024-01-24 14:22 ` Marco Felsch
2024-01-25 7:38 ` [PATCH 0/3] Add bootm ZSTD support Sascha Hauer
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=20240124134738.133782-2-m.felsch@pengutronix.de \
--to=m.felsch@pengutronix.de \
--cc=barebox@lists.infradead.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