The kexec decompression routines support detecting zlib or lzma compressed images. Lets add the ability to automatically decompress zstd ones as well. The zstd attempt is made after gzip because its fairly inexpensive relative lzma and gzip at this point remains a popular option. Signed-off-by: Jeremy Linton <jeremy.linton@xxxxxxx> --- kexec/kexec-pe-zboot.c | 3 ++- kexec/kexec.c | 10 +++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/kexec/kexec-pe-zboot.c b/kexec/kexec-pe-zboot.c index 3abd17d..0a82097 100644 --- a/kexec/kexec-pe-zboot.c +++ b/kexec/kexec-pe-zboot.c @@ -59,8 +59,9 @@ int pez_prepare(const char *crude_buf, off_t buf_sz, int *kernel_fd, * algorithms than are supported here, error out if we detect that. */ if (memcmp(&z->compress_type, "gzip", 4) && + memcmp(&z->compress_type, "zstd", 4) && memcmp(&z->compress_type, "lzma", 4)) { - dbgprintf("%s: kexec can only decompress gziped and lzma images.\n", __func__); + dbgprintf("%s: kexec can only decompress gziped, lzma and zstd images\n", __func__); return -1; } diff --git a/kexec/kexec.c b/kexec/kexec.c index 4f51987..70097ae 100644 --- a/kexec/kexec.c +++ b/kexec/kexec.c @@ -55,6 +55,7 @@ #include "kexec-sha256.h" #include "kexec-zlib.h" #include "kexec-lzma.h" +#include "kexec-zstd.h" #include <arch/options.h> #define KEXEC_LOADED_PATH "/sys/kernel/kexec_loaded" @@ -639,9 +640,12 @@ char *slurp_decompress_file(const char *filename, off_t *r_size) kernel_buf = zlib_decompress_file(filename, r_size); if (!kernel_buf) { - kernel_buf = lzma_decompress_file(filename, r_size); - if (!kernel_buf) - return slurp_file(filename, r_size); + kernel_buf = zstd_decompress_file(filename, r_size); + if (!kernel_buf) { + kernel_buf = lzma_decompress_file(filename, r_size); + if (!kernel_buf) + return slurp_file(filename, r_size); + } } return kernel_buf; } -- 2.47.0