]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
feat(dracut-install): support ZSTD-compressed firmware with .zst suffix
authorнаб <nabijaczleweli@nabijaczleweli.xyz>
Tue, 26 Apr 2022 15:32:32 +0000 (17:32 +0200)
committerJóhann B. Guðmundsson <johannbg@gmail.com>
Thu, 9 Jun 2022 23:46:52 +0000 (23:46 +0000)
Coming in 5.19:
https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core.git/commit/?h=driver-core-next&id=23cfbc6ec44e5e80d5522976ff45ffcdcddfb230

src/install/dracut-install.c

index c8b25733d1e70b9964d2a43c9c788587451ac3b4..6025bd67ad1191a00b71a95aa09f544aabd46dff 100644 (file)
@@ -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) {