diff options
author | Yunhong Jiang <yunhong.jiang@intel.com> | 2015-08-04 12:17:53 -0700 |
---|---|---|
committer | Yunhong Jiang <yunhong.jiang@intel.com> | 2015-08-04 15:44:42 -0700 |
commit | 9ca8dbcc65cfc63d6f5ef3312a33184e1d726e00 (patch) | |
tree | 1c9cafbcd35f783a87880a10f85d1a060db1a563 /kernel/lib/decompress.c | |
parent | 98260f3884f4a202f9ca5eabed40b1354c489b29 (diff) |
Add the rt linux 4.1.3-rt3 as base
Import the rt linux 4.1.3-rt3 as OPNFV kvm base.
It's from git://git.kernel.org/pub/scm/linux/kernel/git/rt/linux-rt-devel.git linux-4.1.y-rt and
the base is:
commit 0917f823c59692d751951bf5ea699a2d1e2f26a2
Author: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Date: Sat Jul 25 12:13:34 2015 +0200
Prepare v4.1.3-rt3
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
We lose all the git history this way and it's not good. We
should apply another opnfv project repo in future.
Change-Id: I87543d81c9df70d99c5001fbdf646b202c19f423
Signed-off-by: Yunhong Jiang <yunhong.jiang@intel.com>
Diffstat (limited to 'kernel/lib/decompress.c')
-rw-r--r-- | kernel/lib/decompress.c | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/kernel/lib/decompress.c b/kernel/lib/decompress.c new file mode 100644 index 000000000..528ff932d --- /dev/null +++ b/kernel/lib/decompress.c @@ -0,0 +1,75 @@ +/* + * decompress.c + * + * Detect the decompression method based on magic number + */ + +#include <linux/decompress/generic.h> + +#include <linux/decompress/bunzip2.h> +#include <linux/decompress/unlzma.h> +#include <linux/decompress/unxz.h> +#include <linux/decompress/inflate.h> +#include <linux/decompress/unlzo.h> +#include <linux/decompress/unlz4.h> + +#include <linux/types.h> +#include <linux/string.h> +#include <linux/init.h> +#include <linux/printk.h> + +#ifndef CONFIG_DECOMPRESS_GZIP +# define gunzip NULL +#endif +#ifndef CONFIG_DECOMPRESS_BZIP2 +# define bunzip2 NULL +#endif +#ifndef CONFIG_DECOMPRESS_LZMA +# define unlzma NULL +#endif +#ifndef CONFIG_DECOMPRESS_XZ +# define unxz NULL +#endif +#ifndef CONFIG_DECOMPRESS_LZO +# define unlzo NULL +#endif +#ifndef CONFIG_DECOMPRESS_LZ4 +# define unlz4 NULL +#endif + +struct compress_format { + unsigned char magic[2]; + const char *name; + decompress_fn decompressor; +}; + +static const struct compress_format compressed_formats[] __initconst = { + { {0x1f, 0x8b}, "gzip", gunzip }, + { {0x1f, 0x9e}, "gzip", gunzip }, + { {0x42, 0x5a}, "bzip2", bunzip2 }, + { {0x5d, 0x00}, "lzma", unlzma }, + { {0xfd, 0x37}, "xz", unxz }, + { {0x89, 0x4c}, "lzo", unlzo }, + { {0x02, 0x21}, "lz4", unlz4 }, + { {0, 0}, NULL, NULL } +}; + +decompress_fn __init decompress_method(const unsigned char *inbuf, long len, + const char **name) +{ + const struct compress_format *cf; + + if (len < 2) + return NULL; /* Need at least this much... */ + + pr_debug("Compressed data magic: %#.2x %#.2x\n", inbuf[0], inbuf[1]); + + for (cf = compressed_formats; cf->name; cf++) { + if (!memcmp(inbuf, cf->magic, 2)) + break; + + } + if (name) + *name = cf->name; + return cf->decompressor; +} |