From: Mikhail Novosyolov Date: Tue, 4 May 2021 09:28:46 +0000 (+0300) Subject: feat: support ZSTD-compressed kernel modules X-Git-Tag: 054~35 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ce9af251af5fca08ea206ef980005853a4dac36e;p=thirdparty%2Fdracut.git feat: support ZSTD-compressed kernel modules Modern Linux kernels support zstd-compressed modules, which was added by commit 73f3d1b48f50 ("lib: Add zstd modules"). Commit c3d7ef377eb ("kbuild: add support for zstd compressed modules") added support of compressing modules with zstd to kernel Makefiles. libkmod >= 28 built with libzstd is also required. --- diff --git a/dracut-init.sh b/dracut-init.sh index 93ea84044..b6e3714a8 100644 --- a/dracut-init.sh +++ b/dracut-init.sh @@ -625,6 +625,7 @@ get_decompress_cmd() { *.gz) echo 'gzip -f -d' ;; *.bz2) echo 'bzip2 -d' ;; *.xz) echo 'xz -f -d' ;; + *.zst) echo 'zstd -f -d ' ;; esac } diff --git a/dracut.sh b/dracut.sh index 580b08266..a7d66edb9 100755 --- a/dracut.sh +++ b/dracut.sh @@ -1271,6 +1271,7 @@ if [[ $no_kernel != yes ]] && [[ -d $srcmods ]]; then case "$_mod" in *.ko.gz) kcompress=gzip ;; *.ko.xz) kcompress=xz ;; + *.ko.zst) kcompress=zstd ;; esac if [[ $kcompress ]]; then if ! command -v "$kcompress" &> /dev/null; then diff --git a/install/dracut-install.c b/install/dracut-install.c index 495ed2f1d..b4eec363a 100644 --- a/install/dracut-install.c +++ b/install/dracut-install.c @@ -1937,6 +1937,10 @@ static int install_modules(int argc, char **argv) int len = strlen(modname); modname[len - 6] = 0; } + if (endswith(modname, ".ko.zst")) { + int len = strlen(modname); + modname[len - 7] = 0; + } r = kmod_module_new_from_lookup(ctx, modname, &modlist); if (r < 0) { if (!arg_optional) {