diff options
Diffstat (limited to 'fs/squashfs/zlib_wrapper.c')
-rw-r--r-- | fs/squashfs/zlib_wrapper.c | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/fs/squashfs/zlib_wrapper.c b/fs/squashfs/zlib_wrapper.c index bb049027d15c..8727caba6882 100644 --- a/fs/squashfs/zlib_wrapper.c +++ b/fs/squashfs/zlib_wrapper.c | |||
@@ -32,6 +32,7 @@ | |||
32 | #include "squashfs_fs_sb.h" | 32 | #include "squashfs_fs_sb.h" |
33 | #include "squashfs.h" | 33 | #include "squashfs.h" |
34 | #include "decompressor.h" | 34 | #include "decompressor.h" |
35 | #include "page_actor.h" | ||
35 | 36 | ||
36 | static void *zlib_init(struct squashfs_sb_info *dummy, void *buff) | 37 | static void *zlib_init(struct squashfs_sb_info *dummy, void *buff) |
37 | { | 38 | { |
@@ -62,14 +63,14 @@ static void zlib_free(void *strm) | |||
62 | 63 | ||
63 | 64 | ||
64 | static int zlib_uncompress(struct squashfs_sb_info *msblk, void *strm, | 65 | static int zlib_uncompress(struct squashfs_sb_info *msblk, void *strm, |
65 | void **buffer, struct buffer_head **bh, int b, int offset, int length, | 66 | struct buffer_head **bh, int b, int offset, int length, |
66 | int srclength, int pages) | 67 | struct squashfs_page_actor *output) |
67 | { | 68 | { |
68 | int zlib_err, zlib_init = 0; | 69 | int zlib_err, zlib_init = 0, k = 0; |
69 | int k = 0, page = 0; | ||
70 | z_stream *stream = strm; | 70 | z_stream *stream = strm; |
71 | 71 | ||
72 | stream->avail_out = 0; | 72 | stream->avail_out = PAGE_CACHE_SIZE; |
73 | stream->next_out = squashfs_first_page(output); | ||
73 | stream->avail_in = 0; | 74 | stream->avail_in = 0; |
74 | 75 | ||
75 | do { | 76 | do { |
@@ -81,15 +82,18 @@ static int zlib_uncompress(struct squashfs_sb_info *msblk, void *strm, | |||
81 | offset = 0; | 82 | offset = 0; |
82 | } | 83 | } |
83 | 84 | ||
84 | if (stream->avail_out == 0 && page < pages) { | 85 | if (stream->avail_out == 0) { |
85 | stream->next_out = buffer[page++]; | 86 | stream->next_out = squashfs_next_page(output); |
86 | stream->avail_out = PAGE_CACHE_SIZE; | 87 | if (stream->next_out != NULL) |
88 | stream->avail_out = PAGE_CACHE_SIZE; | ||
87 | } | 89 | } |
88 | 90 | ||
89 | if (!zlib_init) { | 91 | if (!zlib_init) { |
90 | zlib_err = zlib_inflateInit(stream); | 92 | zlib_err = zlib_inflateInit(stream); |
91 | if (zlib_err != Z_OK) | 93 | if (zlib_err != Z_OK) { |
94 | squashfs_finish_page(output); | ||
92 | goto out; | 95 | goto out; |
96 | } | ||
93 | zlib_init = 1; | 97 | zlib_init = 1; |
94 | } | 98 | } |
95 | 99 | ||
@@ -99,6 +103,8 @@ static int zlib_uncompress(struct squashfs_sb_info *msblk, void *strm, | |||
99 | put_bh(bh[k++]); | 103 | put_bh(bh[k++]); |
100 | } while (zlib_err == Z_OK); | 104 | } while (zlib_err == Z_OK); |
101 | 105 | ||
106 | squashfs_finish_page(output); | ||
107 | |||
102 | if (zlib_err != Z_STREAM_END) | 108 | if (zlib_err != Z_STREAM_END) |
103 | goto out; | 109 | goto out; |
104 | 110 | ||