[arch-projects] [mkinitcpio] [PATCH] lsinitcpio: Add zstd decompression support

Jelle van der Waa jelle at vdwaa.nl
Tue Apr 30 13:19:35 UTC 2019


Add detection support for zstd compressed initramfs, the magic number of
zstd is defined as 0xFD2FB528.

https://github.com/facebook/zstd/blob/dev/doc/zstd_compression_format.md

Signed-off-by: Jelle van der Waa <jelle at vdwaa.nl>
---
 lsinitcpio | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/lsinitcpio b/lsinitcpio
index bcb4a19..d44a714 100755
--- a/lsinitcpio
+++ b/lsinitcpio
@@ -131,6 +131,12 @@ detect_filetype() {
         return
     fi
 
+    read -rd '' bytes < <(hexdump -n 4 -e '"%x"' "$1")
+    if [[ $bytes = 'fd2fb528' ]]; then
+        echo 'zstd'
+        return
+    fi
+
     # still nothing? hrmm, maybe the user goofed and it's a kernel
     if kver "$1" >/dev/null; then
         die '%s is a kernel image, not an initramfs image!' "$1"
-- 
2.21.0


More information about the arch-projects mailing list