diff options
author | Yinghai Lu <yinghai@kernel.org> | 2014-08-08 17:23:14 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-08-08 18:57:26 -0400 |
commit | d97b07c54f34e88352ebe676beb798c8f59ac588 (patch) | |
tree | 3b864aca26ab13d9fdcdca3d1bdabc69830cea01 | |
parent | 38747439914c468ecba70b492b54dc4ef0b50453 (diff) |
initramfs: support initramfs that is bigger than 2GiB
Now with 64bit bzImage and kexec tools, we support ramdisk that size is
bigger than 2g, as we could put it above 4G.
Found compressed initramfs image could not be decompressed properly. It
turns out that image length is int during decompress detection, and it
will become < 0 when length is more than 2G. Furthermore, during
decompressing len as int is used for inbuf count, that has problem too.
Change len to long, that should be ok as on 32 bit platform long is
32bits.
Tested with following compressed initramfs image as root with kexec.
gzip, bzip2, xz, lzma, lzop, lz4.
run time for populate_rootfs():
size name Nehalem-EX Westmere-EX Ivybridge-EX
9034400256 root_img : 26s 24s 30s
3561095057 root_img.lz4 : 28s 27s 27s
3459554629 root_img.lzo : 29s 29s 28s
3219399480 root_img.gz : 64s 62s 49s
2251594592 root_img.xz : 262s 260s 183s
2226366598 root_img.lzma: 386s 376s 277s
2901482513 root_img.bz2 : 635s 599s
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Rashika Kheria <rashika.kheria@gmail.com>
Cc: Josh Triplett <josh@joshtriplett.org>
Cc: Kyungsik Lee <kyungsik.lee@lge.com>
Cc: P J P <ppandit@redhat.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>
Cc: "Daniel M. Weeks" <dan@danweeks.net>
Cc: Alexandre Courbot <acourbot@nvidia.com>
Cc: Jan Beulich <JBeulich@suse.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | crypto/zlib.c | 8 | ||||
-rw-r--r-- | fs/isofs/compress.c | 4 | ||||
-rw-r--r-- | fs/jffs2/compr_zlib.c | 7 | ||||
-rw-r--r-- | include/linux/decompress/bunzip2.h | 8 | ||||
-rw-r--r-- | include/linux/decompress/generic.h | 10 | ||||
-rw-r--r-- | include/linux/decompress/inflate.h | 8 | ||||
-rw-r--r-- | include/linux/decompress/unlz4.h | 8 | ||||
-rw-r--r-- | include/linux/decompress/unlzma.h | 8 | ||||
-rw-r--r-- | include/linux/decompress/unlzo.h | 8 | ||||
-rw-r--r-- | include/linux/decompress/unxz.h | 8 | ||||
-rw-r--r-- | include/linux/zlib.h | 4 | ||||
-rw-r--r-- | init/do_mounts_rd.c | 10 | ||||
-rw-r--r-- | init/initramfs.c | 22 | ||||
-rw-r--r-- | lib/decompress.c | 2 | ||||
-rw-r--r-- | lib/decompress_bunzip2.c | 26 | ||||
-rw-r--r-- | lib/decompress_inflate.c | 12 | ||||
-rw-r--r-- | lib/decompress_unlz4.c | 18 | ||||
-rw-r--r-- | lib/decompress_unlzma.c | 28 | ||||
-rw-r--r-- | lib/decompress_unlzo.c | 12 | ||||
-rw-r--r-- | lib/decompress_unxz.c | 10 |
20 files changed, 111 insertions, 110 deletions
diff --git a/crypto/zlib.c b/crypto/zlib.c index 06b62e5cdcc7..c9ee681d57fd 100644 --- a/crypto/zlib.c +++ b/crypto/zlib.c | |||
@@ -168,7 +168,7 @@ static int zlib_compress_update(struct crypto_pcomp *tfm, | |||
168 | } | 168 | } |
169 | 169 | ||
170 | ret = req->avail_out - stream->avail_out; | 170 | ret = req->avail_out - stream->avail_out; |
171 | pr_debug("avail_in %u, avail_out %u (consumed %u, produced %u)\n", | 171 | pr_debug("avail_in %lu, avail_out %lu (consumed %lu, produced %u)\n", |
172 | stream->avail_in, stream->avail_out, | 172 | stream->avail_in, stream->avail_out, |
173 | req->avail_in - stream->avail_in, ret); | 173 | req->avail_in - stream->avail_in, ret); |
174 | req->next_in = stream->next_in; | 174 | req->next_in = stream->next_in; |
@@ -198,7 +198,7 @@ static int zlib_compress_final(struct crypto_pcomp *tfm, | |||
198 | } | 198 | } |
199 | 199 | ||
200 | ret = req->avail_out - stream->avail_out; | 200 | ret = req->avail_out - stream->avail_out; |
201 | pr_debug("avail_in %u, avail_out %u (consumed %u, produced %u)\n", | 201 | pr_debug("avail_in %lu, avail_out %lu (consumed %lu, produced %u)\n", |
202 | stream->avail_in, stream->avail_out, | 202 | stream->avail_in, stream->avail_out, |
203 | req->avail_in - stream->avail_in, ret); | 203 | req->avail_in - stream->avail_in, ret); |
204 | req->next_in = stream->next_in; | 204 | req->next_in = stream->next_in; |
@@ -283,7 +283,7 @@ static int zlib_decompress_update(struct crypto_pcomp *tfm, | |||
283 | } | 283 | } |
284 | 284 | ||
285 | ret = req->avail_out - stream->avail_out; | 285 | ret = req->avail_out - stream->avail_out; |
286 | pr_debug("avail_in %u, avail_out %u (consumed %u, produced %u)\n", | 286 | pr_debug("avail_in %lu, avail_out %lu (consumed %lu, produced %u)\n", |
287 | stream->avail_in, stream->avail_out, | 287 | stream->avail_in, stream->avail_out, |
288 | req->avail_in - stream->avail_in, ret); | 288 | req->avail_in - stream->avail_in, ret); |
289 | req->next_in = stream->next_in; | 289 | req->next_in = stream->next_in; |
@@ -331,7 +331,7 @@ static int zlib_decompress_final(struct crypto_pcomp *tfm, | |||
331 | } | 331 | } |
332 | 332 | ||
333 | ret = req->avail_out - stream->avail_out; | 333 | ret = req->avail_out - stream->avail_out; |
334 | pr_debug("avail_in %u, avail_out %u (consumed %u, produced %u)\n", | 334 | pr_debug("avail_in %lu, avail_out %lu (consumed %lu, produced %u)\n", |
335 | stream->avail_in, stream->avail_out, | 335 | stream->avail_in, stream->avail_out, |
336 | req->avail_in - stream->avail_in, ret); | 336 | req->avail_in - stream->avail_in, ret); |
337 | req->next_in = stream->next_in; | 337 | req->next_in = stream->next_in; |
diff --git a/fs/isofs/compress.c b/fs/isofs/compress.c index 592e5115a561..f311bf084015 100644 --- a/fs/isofs/compress.c +++ b/fs/isofs/compress.c | |||
@@ -158,8 +158,8 @@ static loff_t zisofs_uncompress_block(struct inode *inode, loff_t block_start, | |||
158 | "zisofs: zisofs_inflate returned" | 158 | "zisofs: zisofs_inflate returned" |
159 | " %d, inode = %lu," | 159 | " %d, inode = %lu," |
160 | " page idx = %d, bh idx = %d," | 160 | " page idx = %d, bh idx = %d," |
161 | " avail_in = %d," | 161 | " avail_in = %ld," |
162 | " avail_out = %d\n", | 162 | " avail_out = %ld\n", |
163 | zerr, inode->i_ino, curpage, | 163 | zerr, inode->i_ino, curpage, |
164 | curbh, stream.avail_in, | 164 | curbh, stream.avail_in, |
165 | stream.avail_out); | 165 | stream.avail_out); |
diff --git a/fs/jffs2/compr_zlib.c b/fs/jffs2/compr_zlib.c index 0b9a1e44e833..5698dae5d92d 100644 --- a/fs/jffs2/compr_zlib.c +++ b/fs/jffs2/compr_zlib.c | |||
@@ -94,11 +94,12 @@ static int jffs2_zlib_compress(unsigned char *data_in, | |||
94 | 94 | ||
95 | while (def_strm.total_out < *dstlen - STREAM_END_SPACE && def_strm.total_in < *sourcelen) { | 95 | while (def_strm.total_out < *dstlen - STREAM_END_SPACE && def_strm.total_in < *sourcelen) { |
96 | def_strm.avail_out = *dstlen - (def_strm.total_out + STREAM_END_SPACE); | 96 | def_strm.avail_out = *dstlen - (def_strm.total_out + STREAM_END_SPACE); |
97 | def_strm.avail_in = min((unsigned)(*sourcelen-def_strm.total_in), def_strm.avail_out); | 97 | def_strm.avail_in = min_t(unsigned long, |
98 | jffs2_dbg(1, "calling deflate with avail_in %d, avail_out %d\n", | 98 | (*sourcelen-def_strm.total_in), def_strm.avail_out); |
99 | jffs2_dbg(1, "calling deflate with avail_in %ld, avail_out %ld\n", | ||
99 | def_strm.avail_in, def_strm.avail_out); | 100 | def_strm.avail_in, def_strm.avail_out); |
100 | ret = zlib_deflate(&def_strm, Z_PARTIAL_FLUSH); | 101 | ret = zlib_deflate(&def_strm, Z_PARTIAL_FLUSH); |
101 | jffs2_dbg(1, "deflate returned with avail_in %d, avail_out %d, total_in %ld, total_out %ld\n", | 102 | jffs2_dbg(1, "deflate returned with avail_in %ld, avail_out %ld, total_in %ld, total_out %ld\n", |
102 | def_strm.avail_in, def_strm.avail_out, | 103 | def_strm.avail_in, def_strm.avail_out, |
103 | def_strm.total_in, def_strm.total_out); | 104 | def_strm.total_in, def_strm.total_out); |
104 | if (ret != Z_OK) { | 105 | if (ret != Z_OK) { |
diff --git a/include/linux/decompress/bunzip2.h b/include/linux/decompress/bunzip2.h index 115272137a9c..4d683df898e6 100644 --- a/include/linux/decompress/bunzip2.h +++ b/include/linux/decompress/bunzip2.h | |||
@@ -1,10 +1,10 @@ | |||
1 | #ifndef DECOMPRESS_BUNZIP2_H | 1 | #ifndef DECOMPRESS_BUNZIP2_H |
2 | #define DECOMPRESS_BUNZIP2_H | 2 | #define DECOMPRESS_BUNZIP2_H |
3 | 3 | ||
4 | int bunzip2(unsigned char *inbuf, int len, | 4 | int bunzip2(unsigned char *inbuf, long len, |
5 | int(*fill)(void*, unsigned int), | 5 | long (*fill)(void*, unsigned long), |
6 | int(*flush)(void*, unsigned int), | 6 | long (*flush)(void*, unsigned long), |
7 | unsigned char *output, | 7 | unsigned char *output, |
8 | int *pos, | 8 | long *pos, |
9 | void(*error)(char *x)); | 9 | void(*error)(char *x)); |
10 | #endif | 10 | #endif |
diff --git a/include/linux/decompress/generic.h b/include/linux/decompress/generic.h index 0c7111a55a1a..1fcfd64b5076 100644 --- a/include/linux/decompress/generic.h +++ b/include/linux/decompress/generic.h | |||
@@ -1,11 +1,11 @@ | |||
1 | #ifndef DECOMPRESS_GENERIC_H | 1 | #ifndef DECOMPRESS_GENERIC_H |
2 | #define DECOMPRESS_GENERIC_H | 2 | #define DECOMPRESS_GENERIC_H |
3 | 3 | ||
4 | typedef int (*decompress_fn) (unsigned char *inbuf, int len, | 4 | typedef int (*decompress_fn) (unsigned char *inbuf, long len, |
5 | int(*fill)(void*, unsigned int), | 5 | long (*fill)(void*, unsigned long), |
6 | int(*flush)(void*, unsigned int), | 6 | long (*flush)(void*, unsigned long), |
7 | unsigned char *outbuf, | 7 | unsigned char *outbuf, |
8 | int *posp, | 8 | long *posp, |
9 | void(*error)(char *x)); | 9 | void(*error)(char *x)); |
10 | 10 | ||
11 | /* inbuf - input buffer | 11 | /* inbuf - input buffer |
@@ -33,7 +33,7 @@ typedef int (*decompress_fn) (unsigned char *inbuf, int len, | |||
33 | 33 | ||
34 | 34 | ||
35 | /* Utility routine to detect the decompression method */ | 35 | /* Utility routine to detect the decompression method */ |
36 | decompress_fn decompress_method(const unsigned char *inbuf, int len, | 36 | decompress_fn decompress_method(const unsigned char *inbuf, long len, |
37 | const char **name); | 37 | const char **name); |
38 | 38 | ||
39 | #endif | 39 | #endif |
diff --git a/include/linux/decompress/inflate.h b/include/linux/decompress/inflate.h index 1d0aedef9822..e4f411fdbd24 100644 --- a/include/linux/decompress/inflate.h +++ b/include/linux/decompress/inflate.h | |||
@@ -1,10 +1,10 @@ | |||
1 | #ifndef LINUX_DECOMPRESS_INFLATE_H | 1 | #ifndef LINUX_DECOMPRESS_INFLATE_H |
2 | #define LINUX_DECOMPRESS_INFLATE_H | 2 | #define LINUX_DECOMPRESS_INFLATE_H |
3 | 3 | ||
4 | int gunzip(unsigned char *inbuf, int len, | 4 | int gunzip(unsigned char *inbuf, long len, |
5 | int(*fill)(void*, unsigned int), | 5 | long (*fill)(void*, unsigned long), |
6 | int(*flush)(void*, unsigned int), | 6 | long (*flush)(void*, unsigned long), |
7 | unsigned char *output, | 7 | unsigned char *output, |
8 | int *pos, | 8 | long *pos, |
9 | void(*error_fn)(char *x)); | 9 | void(*error_fn)(char *x)); |
10 | #endif | 10 | #endif |
diff --git a/include/linux/decompress/unlz4.h b/include/linux/decompress/unlz4.h index d5b68bf3ec92..3273c2f36496 100644 --- a/include/linux/decompress/unlz4.h +++ b/include/linux/decompress/unlz4.h | |||
@@ -1,10 +1,10 @@ | |||
1 | #ifndef DECOMPRESS_UNLZ4_H | 1 | #ifndef DECOMPRESS_UNLZ4_H |
2 | #define DECOMPRESS_UNLZ4_H | 2 | #define DECOMPRESS_UNLZ4_H |
3 | 3 | ||
4 | int unlz4(unsigned char *inbuf, int len, | 4 | int unlz4(unsigned char *inbuf, long len, |
5 | int(*fill)(void*, unsigned int), | 5 | long (*fill)(void*, unsigned long), |
6 | int(*flush)(void*, unsigned int), | 6 | long (*flush)(void*, unsigned long), |
7 | unsigned char *output, | 7 | unsigned char *output, |
8 | int *pos, | 8 | long *pos, |
9 | void(*error)(char *x)); | 9 | void(*error)(char *x)); |
10 | #endif | 10 | #endif |
diff --git a/include/linux/decompress/unlzma.h b/include/linux/decompress/unlzma.h index 7796538f1bf4..8a891a193840 100644 --- a/include/linux/decompress/unlzma.h +++ b/include/linux/decompress/unlzma.h | |||
@@ -1,11 +1,11 @@ | |||
1 | #ifndef DECOMPRESS_UNLZMA_H | 1 | #ifndef DECOMPRESS_UNLZMA_H |
2 | #define DECOMPRESS_UNLZMA_H | 2 | #define DECOMPRESS_UNLZMA_H |
3 | 3 | ||
4 | int unlzma(unsigned char *, int, | 4 | int unlzma(unsigned char *, long, |
5 | int(*fill)(void*, unsigned int), | 5 | long (*fill)(void*, unsigned long), |
6 | int(*flush)(void*, unsigned int), | 6 | long (*flush)(void*, unsigned long), |
7 | unsigned char *output, | 7 | unsigned char *output, |
8 | int *posp, | 8 | long *posp, |
9 | void(*error)(char *x) | 9 | void(*error)(char *x) |
10 | ); | 10 | ); |
11 | 11 | ||
diff --git a/include/linux/decompress/unlzo.h b/include/linux/decompress/unlzo.h index 987229752519..af18f95d6570 100644 --- a/include/linux/decompress/unlzo.h +++ b/include/linux/decompress/unlzo.h | |||
@@ -1,10 +1,10 @@ | |||
1 | #ifndef DECOMPRESS_UNLZO_H | 1 | #ifndef DECOMPRESS_UNLZO_H |
2 | #define DECOMPRESS_UNLZO_H | 2 | #define DECOMPRESS_UNLZO_H |
3 | 3 | ||
4 | int unlzo(unsigned char *inbuf, int len, | 4 | int unlzo(unsigned char *inbuf, long len, |
5 | int(*fill)(void*, unsigned int), | 5 | long (*fill)(void*, unsigned long), |
6 | int(*flush)(void*, unsigned int), | 6 | long (*flush)(void*, unsigned long), |
7 | unsigned char *output, | 7 | unsigned char *output, |
8 | int *pos, | 8 | long *pos, |
9 | void(*error)(char *x)); | 9 | void(*error)(char *x)); |
10 | #endif | 10 | #endif |
diff --git a/include/linux/decompress/unxz.h b/include/linux/decompress/unxz.h index 41728fc6c8a1..f764e2a7201e 100644 --- a/include/linux/decompress/unxz.h +++ b/include/linux/decompress/unxz.h | |||
@@ -10,10 +10,10 @@ | |||
10 | #ifndef DECOMPRESS_UNXZ_H | 10 | #ifndef DECOMPRESS_UNXZ_H |
11 | #define DECOMPRESS_UNXZ_H | 11 | #define DECOMPRESS_UNXZ_H |
12 | 12 | ||
13 | int unxz(unsigned char *in, int in_size, | 13 | int unxz(unsigned char *in, long in_size, |
14 | int (*fill)(void *dest, unsigned int size), | 14 | long (*fill)(void *dest, unsigned long size), |
15 | int (*flush)(void *src, unsigned int size), | 15 | long (*flush)(void *src, unsigned long size), |
16 | unsigned char *out, int *in_used, | 16 | unsigned char *out, long *in_used, |
17 | void (*error)(char *x)); | 17 | void (*error)(char *x)); |
18 | 18 | ||
19 | #endif | 19 | #endif |
diff --git a/include/linux/zlib.h b/include/linux/zlib.h index 197abb2a54c5..92dbbd3f6c75 100644 --- a/include/linux/zlib.h +++ b/include/linux/zlib.h | |||
@@ -83,11 +83,11 @@ struct internal_state; | |||
83 | 83 | ||
84 | typedef struct z_stream_s { | 84 | typedef struct z_stream_s { |
85 | const Byte *next_in; /* next input byte */ | 85 | const Byte *next_in; /* next input byte */ |
86 | uInt avail_in; /* number of bytes available at next_in */ | 86 | uLong avail_in; /* number of bytes available at next_in */ |
87 | uLong total_in; /* total nb of input bytes read so far */ | 87 | uLong total_in; /* total nb of input bytes read so far */ |
88 | 88 | ||
89 | Byte *next_out; /* next output byte should be put there */ | 89 | Byte *next_out; /* next output byte should be put there */ |
90 | uInt avail_out; /* remaining free space at next_out */ | 90 | uLong avail_out; /* remaining free space at next_out */ |
91 | uLong total_out; /* total nb of bytes output so far */ | 91 | uLong total_out; /* total nb of bytes output so far */ |
92 | 92 | ||
93 | char *msg; /* last error message, NULL if no error */ | 93 | char *msg; /* last error message, NULL if no error */ |
diff --git a/init/do_mounts_rd.c b/init/do_mounts_rd.c index a8227022e3a0..e5d059e8aa11 100644 --- a/init/do_mounts_rd.c +++ b/init/do_mounts_rd.c | |||
@@ -311,9 +311,9 @@ static int exit_code; | |||
311 | static int decompress_error; | 311 | static int decompress_error; |
312 | static int crd_infd, crd_outfd; | 312 | static int crd_infd, crd_outfd; |
313 | 313 | ||
314 | static int __init compr_fill(void *buf, unsigned int len) | 314 | static long __init compr_fill(void *buf, unsigned long len) |
315 | { | 315 | { |
316 | int r = sys_read(crd_infd, buf, len); | 316 | long r = sys_read(crd_infd, buf, len); |
317 | if (r < 0) | 317 | if (r < 0) |
318 | printk(KERN_ERR "RAMDISK: error while reading compressed data"); | 318 | printk(KERN_ERR "RAMDISK: error while reading compressed data"); |
319 | else if (r == 0) | 319 | else if (r == 0) |
@@ -321,13 +321,13 @@ static int __init compr_fill(void *buf, unsigned int len) | |||
321 | return r; | 321 | return r; |
322 | } | 322 | } |
323 | 323 | ||
324 | static int __init compr_flush(void *window, unsigned int outcnt) | 324 | static long __init compr_flush(void *window, unsigned long outcnt) |
325 | { | 325 | { |
326 | int written = sys_write(crd_outfd, window, outcnt); | 326 | long written = sys_write(crd_outfd, window, outcnt); |
327 | if (written != outcnt) { | 327 | if (written != outcnt) { |
328 | if (decompress_error == 0) | 328 | if (decompress_error == 0) |
329 | printk(KERN_ERR | 329 | printk(KERN_ERR |
330 | "RAMDISK: incomplete write (%d != %d)\n", | 330 | "RAMDISK: incomplete write (%ld != %ld)\n", |
331 | written, outcnt); | 331 | written, outcnt); |
332 | decompress_error = 1; | 332 | decompress_error = 1; |
333 | return -1; | 333 | return -1; |
diff --git a/init/initramfs.c b/init/initramfs.c index 4f276b6a167b..a7566031242e 100644 --- a/init/initramfs.c +++ b/init/initramfs.c | |||
@@ -197,7 +197,7 @@ static __initdata enum state { | |||
197 | } state, next_state; | 197 | } state, next_state; |
198 | 198 | ||
199 | static __initdata char *victim; | 199 | static __initdata char *victim; |
200 | static __initdata unsigned count; | 200 | static unsigned long count __initdata; |
201 | static __initdata loff_t this_header, next_header; | 201 | static __initdata loff_t this_header, next_header; |
202 | 202 | ||
203 | static inline void __init eat(unsigned n) | 203 | static inline void __init eat(unsigned n) |
@@ -209,7 +209,7 @@ static inline void __init eat(unsigned n) | |||
209 | 209 | ||
210 | static __initdata char *vcollected; | 210 | static __initdata char *vcollected; |
211 | static __initdata char *collected; | 211 | static __initdata char *collected; |
212 | static __initdata int remains; | 212 | static long remains __initdata; |
213 | static __initdata char *collect; | 213 | static __initdata char *collect; |
214 | 214 | ||
215 | static void __init read_into(char *buf, unsigned size, enum state next) | 215 | static void __init read_into(char *buf, unsigned size, enum state next) |
@@ -236,7 +236,7 @@ static int __init do_start(void) | |||
236 | 236 | ||
237 | static int __init do_collect(void) | 237 | static int __init do_collect(void) |
238 | { | 238 | { |
239 | unsigned n = remains; | 239 | unsigned long n = remains; |
240 | if (count < n) | 240 | if (count < n) |
241 | n = count; | 241 | n = count; |
242 | memcpy(collect, victim, n); | 242 | memcpy(collect, victim, n); |
@@ -407,7 +407,7 @@ static __initdata int (*actions[])(void) = { | |||
407 | [Reset] = do_reset, | 407 | [Reset] = do_reset, |
408 | }; | 408 | }; |
409 | 409 | ||
410 | static int __init write_buffer(char *buf, unsigned len) | 410 | static long __init write_buffer(char *buf, unsigned long len) |
411 | { | 411 | { |
412 | count = len; | 412 | count = len; |
413 | victim = buf; | 413 | victim = buf; |
@@ -417,11 +417,11 @@ static int __init write_buffer(char *buf, unsigned len) | |||
417 | return len - count; | 417 | return len - count; |
418 | } | 418 | } |
419 | 419 | ||
420 | static int __init flush_buffer(void *bufv, unsigned len) | 420 | static long __init flush_buffer(void *bufv, unsigned long len) |
421 | { | 421 | { |
422 | char *buf = (char *) bufv; | 422 | char *buf = (char *) bufv; |
423 | int written; | 423 | long written; |
424 | int origLen = len; | 424 | long origLen = len; |
425 | if (message) | 425 | if (message) |
426 | return -1; | 426 | return -1; |
427 | while ((written = write_buffer(buf, len)) < len && !message) { | 427 | while ((written = write_buffer(buf, len)) < len && !message) { |
@@ -440,13 +440,13 @@ static int __init flush_buffer(void *bufv, unsigned len) | |||
440 | return origLen; | 440 | return origLen; |
441 | } | 441 | } |
442 | 442 | ||
443 | static unsigned my_inptr; /* index of next byte to be processed in inbuf */ | 443 | static unsigned long my_inptr; /* index of next byte to be processed in inbuf */ |
444 | 444 | ||
445 | #include <linux/decompress/generic.h> | 445 | #include <linux/decompress/generic.h> |
446 | 446 | ||
447 | static char * __init unpack_to_rootfs(char *buf, unsigned len) | 447 | static char * __init unpack_to_rootfs(char *buf, unsigned long len) |
448 | { | 448 | { |
449 | int written, res; | 449 | long written; |
450 | decompress_fn decompress; | 450 | decompress_fn decompress; |
451 | const char *compress_name; | 451 | const char *compress_name; |
452 | static __initdata char msg_buf[64]; | 452 | static __initdata char msg_buf[64]; |
@@ -480,7 +480,7 @@ static char * __init unpack_to_rootfs(char *buf, unsigned len) | |||
480 | decompress = decompress_method(buf, len, &compress_name); | 480 | decompress = decompress_method(buf, len, &compress_name); |
481 | pr_debug("Detected %s compressed data\n", compress_name); | 481 | pr_debug("Detected %s compressed data\n", compress_name); |
482 | if (decompress) { | 482 | if (decompress) { |
483 | res = decompress(buf, len, NULL, flush_buffer, NULL, | 483 | int res = decompress(buf, len, NULL, flush_buffer, NULL, |
484 | &my_inptr, error); | 484 | &my_inptr, error); |
485 | if (res) | 485 | if (res) |
486 | error("decompressor failed"); | 486 | error("decompressor failed"); |
diff --git a/lib/decompress.c b/lib/decompress.c index 86069d74c062..37f3c786348f 100644 --- a/lib/decompress.c +++ b/lib/decompress.c | |||
@@ -54,7 +54,7 @@ static const struct compress_format compressed_formats[] __initconst = { | |||
54 | { {0, 0}, NULL, NULL } | 54 | { {0, 0}, NULL, NULL } |
55 | }; | 55 | }; |
56 | 56 | ||
57 | decompress_fn __init decompress_method(const unsigned char *inbuf, int len, | 57 | decompress_fn __init decompress_method(const unsigned char *inbuf, long len, |
58 | const char **name) | 58 | const char **name) |
59 | { | 59 | { |
60 | const struct compress_format *cf; | 60 | const struct compress_format *cf; |
diff --git a/lib/decompress_bunzip2.c b/lib/decompress_bunzip2.c index 31c5f7675fbf..8290e0bef7ea 100644 --- a/lib/decompress_bunzip2.c +++ b/lib/decompress_bunzip2.c | |||
@@ -92,8 +92,8 @@ struct bunzip_data { | |||
92 | /* State for interrupting output loop */ | 92 | /* State for interrupting output loop */ |
93 | int writeCopies, writePos, writeRunCountdown, writeCount, writeCurrent; | 93 | int writeCopies, writePos, writeRunCountdown, writeCount, writeCurrent; |
94 | /* I/O tracking data (file handles, buffers, positions, etc.) */ | 94 | /* I/O tracking data (file handles, buffers, positions, etc.) */ |
95 | int (*fill)(void*, unsigned int); | 95 | long (*fill)(void*, unsigned long); |
96 | int inbufCount, inbufPos /*, outbufPos*/; | 96 | long inbufCount, inbufPos /*, outbufPos*/; |
97 | unsigned char *inbuf /*,*outbuf*/; | 97 | unsigned char *inbuf /*,*outbuf*/; |
98 | unsigned int inbufBitCount, inbufBits; | 98 | unsigned int inbufBitCount, inbufBits; |
99 | /* The CRC values stored in the block header and calculated from the | 99 | /* The CRC values stored in the block header and calculated from the |
@@ -617,7 +617,7 @@ decode_next_byte: | |||
617 | goto decode_next_byte; | 617 | goto decode_next_byte; |
618 | } | 618 | } |
619 | 619 | ||
620 | static int INIT nofill(void *buf, unsigned int len) | 620 | static long INIT nofill(void *buf, unsigned long len) |
621 | { | 621 | { |
622 | return -1; | 622 | return -1; |
623 | } | 623 | } |
@@ -625,8 +625,8 @@ static int INIT nofill(void *buf, unsigned int len) | |||
625 | /* Allocate the structure, read file header. If in_fd ==-1, inbuf must contain | 625 | /* Allocate the structure, read file header. If in_fd ==-1, inbuf must contain |
626 | a complete bunzip file (len bytes long). If in_fd!=-1, inbuf and len are | 626 | a complete bunzip file (len bytes long). If in_fd!=-1, inbuf and len are |
627 | ignored, and data is read from file handle into temporary buffer. */ | 627 | ignored, and data is read from file handle into temporary buffer. */ |
628 | static int INIT start_bunzip(struct bunzip_data **bdp, void *inbuf, int len, | 628 | static int INIT start_bunzip(struct bunzip_data **bdp, void *inbuf, long len, |
629 | int (*fill)(void*, unsigned int)) | 629 | long (*fill)(void*, unsigned long)) |
630 | { | 630 | { |
631 | struct bunzip_data *bd; | 631 | struct bunzip_data *bd; |
632 | unsigned int i, j, c; | 632 | unsigned int i, j, c; |
@@ -675,11 +675,11 @@ static int INIT start_bunzip(struct bunzip_data **bdp, void *inbuf, int len, | |||
675 | 675 | ||
676 | /* Example usage: decompress src_fd to dst_fd. (Stops at end of bzip2 data, | 676 | /* Example usage: decompress src_fd to dst_fd. (Stops at end of bzip2 data, |
677 | not end of file.) */ | 677 | not end of file.) */ |
678 | STATIC int INIT bunzip2(unsigned char *buf, int len, | 678 | STATIC int INIT bunzip2(unsigned char *buf, long len, |
679 | int(*fill)(void*, unsigned int), | 679 | long (*fill)(void*, unsigned long), |
680 | int(*flush)(void*, unsigned int), | 680 | long (*flush)(void*, unsigned long), |
681 | unsigned char *outbuf, | 681 | unsigned char *outbuf, |
682 | int *pos, | 682 | long *pos, |
683 | void(*error)(char *x)) | 683 | void(*error)(char *x)) |
684 | { | 684 | { |
685 | struct bunzip_data *bd; | 685 | struct bunzip_data *bd; |
@@ -743,11 +743,11 @@ exit_0: | |||
743 | } | 743 | } |
744 | 744 | ||
745 | #ifdef PREBOOT | 745 | #ifdef PREBOOT |
746 | STATIC int INIT decompress(unsigned char *buf, int len, | 746 | STATIC int INIT decompress(unsigned char *buf, long len, |
747 | int(*fill)(void*, unsigned int), | 747 | long (*fill)(void*, unsigned long), |
748 | int(*flush)(void*, unsigned int), | 748 | long (*flush)(void*, unsigned long), |
749 | unsigned char *outbuf, | 749 | unsigned char *outbuf, |
750 | int *pos, | 750 | long *pos, |
751 | void(*error)(char *x)) | 751 | void(*error)(char *x)) |
752 | { | 752 | { |
753 | return bunzip2(buf, len - 4, fill, flush, outbuf, pos, error); | 753 | return bunzip2(buf, len - 4, fill, flush, outbuf, pos, error); |
diff --git a/lib/decompress_inflate.c b/lib/decompress_inflate.c index 0edfd742a154..d4c7891635ec 100644 --- a/lib/decompress_inflate.c +++ b/lib/decompress_inflate.c | |||
@@ -27,17 +27,17 @@ | |||
27 | 27 | ||
28 | #define GZIP_IOBUF_SIZE (16*1024) | 28 | #define GZIP_IOBUF_SIZE (16*1024) |
29 | 29 | ||
30 | static int INIT nofill(void *buffer, unsigned int len) | 30 | static long INIT nofill(void *buffer, unsigned long len) |
31 | { | 31 | { |
32 | return -1; | 32 | return -1; |
33 | } | 33 | } |
34 | 34 | ||
35 | /* Included from initramfs et al code */ | 35 | /* Included from initramfs et al code */ |
36 | STATIC int INIT gunzip(unsigned char *buf, int len, | 36 | STATIC int INIT gunzip(unsigned char *buf, long len, |
37 | int(*fill)(void*, unsigned int), | 37 | long (*fill)(void*, unsigned long), |
38 | int(*flush)(void*, unsigned int), | 38 | long (*flush)(void*, unsigned long), |
39 | unsigned char *out_buf, | 39 | unsigned char *out_buf, |
40 | int *pos, | 40 | long *pos, |
41 | void(*error)(char *x)) { | 41 | void(*error)(char *x)) { |
42 | u8 *zbuf; | 42 | u8 *zbuf; |
43 | struct z_stream_s *strm; | 43 | struct z_stream_s *strm; |
@@ -142,7 +142,7 @@ STATIC int INIT gunzip(unsigned char *buf, int len, | |||
142 | 142 | ||
143 | /* Write any data generated */ | 143 | /* Write any data generated */ |
144 | if (flush && strm->next_out > out_buf) { | 144 | if (flush && strm->next_out > out_buf) { |
145 | int l = strm->next_out - out_buf; | 145 | long l = strm->next_out - out_buf; |
146 | if (l != flush(out_buf, l)) { | 146 | if (l != flush(out_buf, l)) { |
147 | rc = -1; | 147 | rc = -1; |
148 | error("write error"); | 148 | error("write error"); |
diff --git a/lib/decompress_unlz4.c b/lib/decompress_unlz4.c index 3ad7f3954dfd..40f66ebe57b7 100644 --- a/lib/decompress_unlz4.c +++ b/lib/decompress_unlz4.c | |||
@@ -31,10 +31,10 @@ | |||
31 | #define LZ4_DEFAULT_UNCOMPRESSED_CHUNK_SIZE (8 << 20) | 31 | #define LZ4_DEFAULT_UNCOMPRESSED_CHUNK_SIZE (8 << 20) |
32 | #define ARCHIVE_MAGICNUMBER 0x184C2102 | 32 | #define ARCHIVE_MAGICNUMBER 0x184C2102 |
33 | 33 | ||
34 | STATIC inline int INIT unlz4(u8 *input, int in_len, | 34 | STATIC inline int INIT unlz4(u8 *input, long in_len, |
35 | int (*fill) (void *, unsigned int), | 35 | long (*fill)(void *, unsigned long), |
36 | int (*flush) (void *, unsigned int), | 36 | long (*flush)(void *, unsigned long), |
37 | u8 *output, int *posp, | 37 | u8 *output, long *posp, |
38 | void (*error) (char *x)) | 38 | void (*error) (char *x)) |
39 | { | 39 | { |
40 | int ret = -1; | 40 | int ret = -1; |
@@ -43,7 +43,7 @@ STATIC inline int INIT unlz4(u8 *input, int in_len, | |||
43 | u8 *inp; | 43 | u8 *inp; |
44 | u8 *inp_start; | 44 | u8 *inp_start; |
45 | u8 *outp; | 45 | u8 *outp; |
46 | int size = in_len; | 46 | long size = in_len; |
47 | #ifdef PREBOOT | 47 | #ifdef PREBOOT |
48 | size_t out_len = get_unaligned_le32(input + in_len); | 48 | size_t out_len = get_unaligned_le32(input + in_len); |
49 | #endif | 49 | #endif |
@@ -196,11 +196,11 @@ exit_0: | |||
196 | } | 196 | } |
197 | 197 | ||
198 | #ifdef PREBOOT | 198 | #ifdef PREBOOT |
199 | STATIC int INIT decompress(unsigned char *buf, int in_len, | 199 | STATIC int INIT decompress(unsigned char *buf, long in_len, |
200 | int(*fill)(void*, unsigned int), | 200 | long (*fill)(void*, unsigned long), |
201 | int(*flush)(void*, unsigned int), | 201 | long (*flush)(void*, unsigned long), |
202 | unsigned char *output, | 202 | unsigned char *output, |
203 | int *posp, | 203 | long *posp, |
204 | void(*error)(char *x) | 204 | void(*error)(char *x) |
205 | ) | 205 | ) |
206 | { | 206 | { |
diff --git a/lib/decompress_unlzma.c b/lib/decompress_unlzma.c index 32adb73a9038..0be83af62b88 100644 --- a/lib/decompress_unlzma.c +++ b/lib/decompress_unlzma.c | |||
@@ -65,11 +65,11 @@ static long long INIT read_int(unsigned char *ptr, int size) | |||
65 | #define LZMA_IOBUF_SIZE 0x10000 | 65 | #define LZMA_IOBUF_SIZE 0x10000 |
66 | 66 | ||
67 | struct rc { | 67 | struct rc { |
68 | int (*fill)(void*, unsigned int); | 68 | long (*fill)(void*, unsigned long); |
69 | uint8_t *ptr; | 69 | uint8_t *ptr; |
70 | uint8_t *buffer; | 70 | uint8_t *buffer; |
71 | uint8_t *buffer_end; | 71 | uint8_t *buffer_end; |
72 | int buffer_size; | 72 | long buffer_size; |
73 | uint32_t code; | 73 | uint32_t code; |
74 | uint32_t range; | 74 | uint32_t range; |
75 | uint32_t bound; | 75 | uint32_t bound; |
@@ -82,7 +82,7 @@ struct rc { | |||
82 | #define RC_MODEL_TOTAL_BITS 11 | 82 | #define RC_MODEL_TOTAL_BITS 11 |
83 | 83 | ||
84 | 84 | ||
85 | static int INIT nofill(void *buffer, unsigned int len) | 85 | static long INIT nofill(void *buffer, unsigned long len) |
86 | { | 86 | { |
87 | return -1; | 87 | return -1; |
88 | } | 88 | } |
@@ -99,8 +99,8 @@ static void INIT rc_read(struct rc *rc) | |||
99 | 99 | ||
100 | /* Called once */ | 100 | /* Called once */ |
101 | static inline void INIT rc_init(struct rc *rc, | 101 | static inline void INIT rc_init(struct rc *rc, |
102 | int (*fill)(void*, unsigned int), | 102 | long (*fill)(void*, unsigned long), |
103 | char *buffer, int buffer_size) | 103 | char *buffer, long buffer_size) |
104 | { | 104 | { |
105 | if (fill) | 105 | if (fill) |
106 | rc->fill = fill; | 106 | rc->fill = fill; |
@@ -280,7 +280,7 @@ struct writer { | |||
280 | size_t buffer_pos; | 280 | size_t buffer_pos; |
281 | int bufsize; | 281 | int bufsize; |
282 | size_t global_pos; | 282 | size_t global_pos; |
283 | int(*flush)(void*, unsigned int); | 283 | long (*flush)(void*, unsigned long); |
284 | struct lzma_header *header; | 284 | struct lzma_header *header; |
285 | }; | 285 | }; |
286 | 286 | ||
@@ -534,11 +534,11 @@ static inline int INIT process_bit1(struct writer *wr, struct rc *rc, | |||
534 | 534 | ||
535 | 535 | ||
536 | 536 | ||
537 | STATIC inline int INIT unlzma(unsigned char *buf, int in_len, | 537 | STATIC inline int INIT unlzma(unsigned char *buf, long in_len, |
538 | int(*fill)(void*, unsigned int), | 538 | long (*fill)(void*, unsigned long), |
539 | int(*flush)(void*, unsigned int), | 539 | long (*flush)(void*, unsigned long), |
540 | unsigned char *output, | 540 | unsigned char *output, |
541 | int *posp, | 541 | long *posp, |
542 | void(*error)(char *x) | 542 | void(*error)(char *x) |
543 | ) | 543 | ) |
544 | { | 544 | { |
@@ -667,11 +667,11 @@ exit_0: | |||
667 | } | 667 | } |
668 | 668 | ||
669 | #ifdef PREBOOT | 669 | #ifdef PREBOOT |
670 | STATIC int INIT decompress(unsigned char *buf, int in_len, | 670 | STATIC int INIT decompress(unsigned char *buf, long in_len, |
671 | int(*fill)(void*, unsigned int), | 671 | long (*fill)(void*, unsigned long), |
672 | int(*flush)(void*, unsigned int), | 672 | long (*flush)(void*, unsigned long), |
673 | unsigned char *output, | 673 | unsigned char *output, |
674 | int *posp, | 674 | long *posp, |
675 | void(*error)(char *x) | 675 | void(*error)(char *x) |
676 | ) | 676 | ) |
677 | { | 677 | { |
diff --git a/lib/decompress_unlzo.c b/lib/decompress_unlzo.c index 960183d4258f..b94a31bdd87d 100644 --- a/lib/decompress_unlzo.c +++ b/lib/decompress_unlzo.c | |||
@@ -51,7 +51,7 @@ static const unsigned char lzop_magic[] = { | |||
51 | #define HEADER_SIZE_MIN (9 + 7 + 4 + 8 + 1 + 4) | 51 | #define HEADER_SIZE_MIN (9 + 7 + 4 + 8 + 1 + 4) |
52 | #define HEADER_SIZE_MAX (9 + 7 + 1 + 8 + 8 + 4 + 1 + 255 + 4) | 52 | #define HEADER_SIZE_MAX (9 + 7 + 1 + 8 + 8 + 4 + 1 + 255 + 4) |
53 | 53 | ||
54 | STATIC inline int INIT parse_header(u8 *input, int *skip, int in_len) | 54 | STATIC inline long INIT parse_header(u8 *input, long *skip, long in_len) |
55 | { | 55 | { |
56 | int l; | 56 | int l; |
57 | u8 *parse = input; | 57 | u8 *parse = input; |
@@ -108,14 +108,14 @@ STATIC inline int INIT parse_header(u8 *input, int *skip, int in_len) | |||
108 | return 1; | 108 | return 1; |
109 | } | 109 | } |
110 | 110 | ||
111 | STATIC inline int INIT unlzo(u8 *input, int in_len, | 111 | STATIC int INIT unlzo(u8 *input, long in_len, |
112 | int (*fill) (void *, unsigned int), | 112 | long (*fill)(void *, unsigned long), |
113 | int (*flush) (void *, unsigned int), | 113 | long (*flush)(void *, unsigned long), |
114 | u8 *output, int *posp, | 114 | u8 *output, long *posp, |
115 | void (*error) (char *x)) | 115 | void (*error) (char *x)) |
116 | { | 116 | { |
117 | u8 r = 0; | 117 | u8 r = 0; |
118 | int skip = 0; | 118 | long skip = 0; |
119 | u32 src_len, dst_len; | 119 | u32 src_len, dst_len; |
120 | size_t tmp; | 120 | size_t tmp; |
121 | u8 *in_buf, *in_buf_save, *out_buf; | 121 | u8 *in_buf, *in_buf_save, *out_buf; |
diff --git a/lib/decompress_unxz.c b/lib/decompress_unxz.c index 9f34eb56854d..b07a78340e9d 100644 --- a/lib/decompress_unxz.c +++ b/lib/decompress_unxz.c | |||
@@ -248,10 +248,10 @@ void *memmove(void *dest, const void *src, size_t size) | |||
248 | * both input and output buffers are available as a single chunk, i.e. when | 248 | * both input and output buffers are available as a single chunk, i.e. when |
249 | * fill() and flush() won't be used. | 249 | * fill() and flush() won't be used. |
250 | */ | 250 | */ |
251 | STATIC int INIT unxz(unsigned char *in, int in_size, | 251 | STATIC int INIT unxz(unsigned char *in, long in_size, |
252 | int (*fill)(void *dest, unsigned int size), | 252 | long (*fill)(void *dest, unsigned long size), |
253 | int (*flush)(void *src, unsigned int size), | 253 | long (*flush)(void *src, unsigned long size), |
254 | unsigned char *out, int *in_used, | 254 | unsigned char *out, long *in_used, |
255 | void (*error)(char *x)) | 255 | void (*error)(char *x)) |
256 | { | 256 | { |
257 | struct xz_buf b; | 257 | struct xz_buf b; |
@@ -329,7 +329,7 @@ STATIC int INIT unxz(unsigned char *in, int in_size, | |||
329 | * returned by xz_dec_run(), but probably | 329 | * returned by xz_dec_run(), but probably |
330 | * it's not too bad. | 330 | * it's not too bad. |
331 | */ | 331 | */ |
332 | if (flush(b.out, b.out_pos) != (int)b.out_pos) | 332 | if (flush(b.out, b.out_pos) != (long)b.out_pos) |
333 | ret = XZ_BUF_ERROR; | 333 | ret = XZ_BUF_ERROR; |
334 | 334 | ||
335 | b.out_pos = 0; | 335 | b.out_pos = 0; |