decompress = decompress_method(buf, len, &compress_name); 这个函数根据压缩文件(ramdisk.img)的头两个字节(0x1f,0x8b)
在内核文件lib/decompress.c中有- 34 static const struct compress_format {
- 35 unsigned char magic[2];
- 36 const char *name;
- 37 decompress_fn decompressor;
- 38 } compressed_formats[] = {
- 39 { {037, 0213}, "gzip", gunzip }, //转为16进制0x1f 0x8b
- 40 { {037, 0236}, "gzip", gunzip },
- 41 { {0x42, 0x5a}, "bzip2", bunzip2 },
- 42 { {0x5d, 0x00}, "lzma", unlzma },
- 43 { {0xfd, 0x37}, "xz", unxz },
- 44 { {0x89, 0x4c}, "lzo", unlzo },
- 45 { {0, 0}, NULL, NULL }
- 46 };
复制代码 所以解压调用的是内核的lib/decompress_inflate.c中的gunzip这个函数 |