How do I know what decompression algorithms are compiled-in into the linux kernel?
Compression algorithms are declared in lib/decompress.c
. Gzip is defined in lib/decompress_inflate.c
and doesn't get any special status; it'll only be there if CONFIG_DECOMPRESS_GZIP
is y
when the kernel is compiled.
The list of available compression algorithms is the compressed_formats
structure. Since it's defined as static
, it isn't available in other source files. The only function that uses it is thus the decompress_method
function in lib/decompress.c
itself. So the only way to get a kernel to use the table of supported algorithms is to attempt to decompress something that starts with the appropriate two-byte magic sequence, and see if that function returns the algorithm name.
You can tell which decompression functions are supported by searching the list of kernel symbols (/proc/kallsyms
). The functions aren't identified as such, so you'll need to bake in the list of symbol names.
</proc/kallsyms cut -d " " -f 3 |
grep -xF -e gunzip -e bzip2 -e unlzma -e unxz -e unlzo -e unlz4