From: наб Date: Tue, 26 Apr 2022 15:32:32 +0000 (+0200) Subject: feat(dracut-install): support ZSTD-compressed firmware with .zst suffix X-Git-Tag: 057~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9d8387ed803dfc3e8b97d2e415a15083774d7ac6;p=thirdparty%2Fdracut.git feat(dracut-install): support ZSTD-compressed firmware with .zst suffix Coming in 5.19: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core.git/commit/?h=driver-core-next&id=23cfbc6ec44e5e80d5522976ff45ffcdcddfb230 --- diff --git a/src/install/dracut-install.c b/src/install/dracut-install.c index c8b25733d..6025bd67a 100644 --- a/src/install/dracut-install.c +++ b/src/install/dracut-install.c @@ -1371,18 +1371,20 @@ static int install_all(int argc, char **argv) static int install_firmware_fullpath(const char *fwpath) { - const char *fw; - _cleanup_free_ char *fwpath_xz = NULL; - fw = fwpath; + const char *fw = fwpath; + _cleanup_free_ char *fwpath_compressed = NULL; struct stat sb; int ret; if (stat(fwpath, &sb) != 0) { - _asprintf(&fwpath_xz, "%s.xz", fwpath); - if (stat(fwpath_xz, &sb) != 0) { - log_debug("stat(%s) != 0", fwpath); - return 1; + _asprintf(&fwpath_compressed, "%s.zst", fwpath); + if (access(fwpath_compressed, F_OK) != 0) { + strcpy(fwpath_compressed + strlen(fwpath) + 1, "xz"); + if (access(fwpath_compressed, F_OK) != 0) { + log_debug("stat(%s) != 0", fwpath); + return 1; + } } - fw = fwpath_xz; + fw = fwpath_compressed; } ret = dracut_install(fw, fw, false, false, true); if (ret == 0) {