1 From fdf23ed283bc6ef5c25076ce2065f892120ff556 Mon Sep 17 00:00:00 2001
2 From: Phillip Lougher <phillip@lougher.demon.co.uk>
3 Date: Thu, 22 Oct 2009 04:57:38 +0100
4 Subject: [PATCH] Squashfs: Make unlzma available to non initramfs/initrd code
6 Add a config option DECOMPRESS_LZMA_NEEDED which allows subsystems to
7 specify they need the unlzma code. Normally decompress_unlzma.c is
8 compiled with __init and unlzma is not exported to modules.
10 Signed-off-by: Phillip Lougher <phillip@lougher.demon.co.uk>
12 fs/squashfs/Kconfig | 1 +
13 include/linux/decompress/bunzip2_mm.h | 12 ++++++++++++
14 include/linux/decompress/inflate_mm.h | 12 ++++++++++++
15 include/linux/decompress/mm.h | 3 ---
16 include/linux/decompress/unlzma_mm.h | 20 ++++++++++++++++++++
18 lib/decompress_bunzip2.c | 1 +
19 lib/decompress_inflate.c | 1 +
20 lib/decompress_unlzma.c | 5 ++++-
21 9 files changed, 54 insertions(+), 4 deletions(-)
22 create mode 100644 include/linux/decompress/bunzip2_mm.h
23 create mode 100644 include/linux/decompress/inflate_mm.h
24 create mode 100644 include/linux/decompress/unlzma_mm.h
26 --- a/fs/squashfs/Kconfig
27 +++ b/fs/squashfs/Kconfig
28 @@ -41,6 +41,7 @@ config SQUASHFS_LZMA
29 bool "Include support for LZMA compressed file systems"
31 select DECOMPRESS_LZMA
32 + select DECOMPRESS_LZMA_NEEDED
34 config SQUASHFS_EMBEDDED
37 +++ b/include/linux/decompress/bunzip2_mm.h
43 +/* Code active when included from pre-boot environment: */
46 +/* Compile for initramfs/initrd code only */
52 +++ b/include/linux/decompress/inflate_mm.h
58 +/* Code active when included from pre-boot environment: */
61 +/* Compile for initramfs/initrd code only */
66 --- a/include/linux/decompress/mm.h
67 +++ b/include/linux/decompress/mm.h
68 @@ -63,8 +63,6 @@ static void free(void *where)
70 #define set_error_fn(x)
76 /* Code active when compiled standalone for use when loading ramdisk: */
77 @@ -87,7 +85,6 @@ static void free(void *where)
78 static void(*error)(char *m);
79 #define set_error_fn(x) error = x;
84 #include <linux/init.h>
86 +++ b/include/linux/decompress/unlzma_mm.h
93 +/* Code active when included from pre-boot environment: */
96 +#elif defined(CONFIG_DECOMPRESS_LZMA_NEEDED)
98 +/* Make it available to non initramfs/initrd code */
100 +#include <linux/module.h>
103 +/* Compile for initramfs/initrd code only */
110 @@ -121,6 +121,9 @@ config DECOMPRESS_LZO
111 select LZO_DECOMPRESS
114 +config DECOMPRESS_LZMA_NEEDED
118 # Generic allocator support is selected if needed
120 --- a/lib/decompress_bunzip2.c
121 +++ b/lib/decompress_bunzip2.c
123 #include <linux/slab.h>
126 +#include <linux/decompress/bunzip2_mm.h>
127 #include <linux/decompress/mm.h>
130 --- a/lib/decompress_inflate.c
131 +++ b/lib/decompress_inflate.c
136 +#include <linux/decompress/inflate_mm.h>
137 #include <linux/decompress/mm.h>
139 #define GZIP_IOBUF_SIZE (16*1024)
140 --- a/lib/decompress_unlzma.c
141 +++ b/lib/decompress_unlzma.c
143 #include <linux/slab.h>
146 +#include <linux/decompress/unlzma_mm.h>
147 #include <linux/decompress/mm.h>
149 #define MIN(a, b) (((a) < (b)) ? (a) : (b))
150 @@ -531,7 +532,7 @@ static inline void INIT process_bit1(str
154 -STATIC inline int INIT unlzma(unsigned char *buf, int in_len,
155 +STATIC int INIT unlzma(unsigned char *buf, int in_len,
156 int(*fill)(void*, unsigned int),
157 int(*flush)(void*, unsigned int),
158 unsigned char *output,
159 @@ -664,4 +665,6 @@ STATIC int INIT decompress(unsigned char
161 return unlzma(buf, in_len - 4, fill, flush, output, posp, error_fn);
163 +#elif defined(CONFIG_DECOMPRESS_LZMA_NEEDED)
164 +EXPORT_SYMBOL(unlzma);