If /proc/config.gz
is unavailable, how do I know what decompression algorithms the running kernel is capable of using on a compressed cpio
initramfs
?
Is the gzip
algorithm always available, even when CONFIG_DECOMPRESS_GZIP
is not y
when building the kernel?
Best Answer
Compression algorithms are declared in
lib/decompress.c
. Gzip is defined inlib/decompress_inflate.c
and doesn't get any special status; it'll only be there ifCONFIG_DECOMPRESS_GZIP
isy
when the kernel is compiled.The list of available compression algorithms is the
compressed_formats
structure. Since it's defined asstatic
, it isn't available in other source files. The only function that uses it is thus thedecompress_method
function inlib/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.