diff options
Diffstat (limited to 'fs/squashfs/block.c')
-rw-r--r-- | fs/squashfs/block.c | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/fs/squashfs/block.c b/fs/squashfs/block.c index c837dfc2b3c6..2a7960310349 100644 --- a/fs/squashfs/block.c +++ b/fs/squashfs/block.c | |||
@@ -80,7 +80,7 @@ static struct buffer_head *get_block_length(struct super_block *sb, | |||
80 | * generated a larger block - this does occasionally happen with zlib). | 80 | * generated a larger block - this does occasionally happen with zlib). |
81 | */ | 81 | */ |
82 | int squashfs_read_data(struct super_block *sb, void **buffer, u64 index, | 82 | int squashfs_read_data(struct super_block *sb, void **buffer, u64 index, |
83 | int length, u64 *next_index, int srclength) | 83 | int length, u64 *next_index, int srclength, int pages) |
84 | { | 84 | { |
85 | struct squashfs_sb_info *msblk = sb->s_fs_info; | 85 | struct squashfs_sb_info *msblk = sb->s_fs_info; |
86 | struct buffer_head **bh; | 86 | struct buffer_head **bh; |
@@ -184,7 +184,7 @@ int squashfs_read_data(struct super_block *sb, void **buffer, u64 index, | |||
184 | offset = 0; | 184 | offset = 0; |
185 | } | 185 | } |
186 | 186 | ||
187 | if (msblk->stream.avail_out == 0) { | 187 | if (msblk->stream.avail_out == 0 && page < pages) { |
188 | msblk->stream.next_out = buffer[page++]; | 188 | msblk->stream.next_out = buffer[page++]; |
189 | msblk->stream.avail_out = PAGE_CACHE_SIZE; | 189 | msblk->stream.avail_out = PAGE_CACHE_SIZE; |
190 | } | 190 | } |
@@ -201,25 +201,20 @@ int squashfs_read_data(struct super_block *sb, void **buffer, u64 index, | |||
201 | zlib_init = 1; | 201 | zlib_init = 1; |
202 | } | 202 | } |
203 | 203 | ||
204 | zlib_err = zlib_inflate(&msblk->stream, Z_NO_FLUSH); | 204 | zlib_err = zlib_inflate(&msblk->stream, Z_SYNC_FLUSH); |
205 | 205 | ||
206 | if (msblk->stream.avail_in == 0 && k < b) | 206 | if (msblk->stream.avail_in == 0 && k < b) |
207 | put_bh(bh[k++]); | 207 | put_bh(bh[k++]); |
208 | } while (zlib_err == Z_OK); | 208 | } while (zlib_err == Z_OK); |
209 | 209 | ||
210 | if (zlib_err != Z_STREAM_END) { | 210 | if (zlib_err != Z_STREAM_END) { |
211 | ERROR("zlib_inflate returned unexpected result" | 211 | ERROR("zlib_inflate error, data probably corrupt\n"); |
212 | " 0x%x, srclength %d, avail_in %d," | ||
213 | " avail_out %d\n", zlib_err, srclength, | ||
214 | msblk->stream.avail_in, | ||
215 | msblk->stream.avail_out); | ||
216 | goto release_mutex; | 212 | goto release_mutex; |
217 | } | 213 | } |
218 | 214 | ||
219 | zlib_err = zlib_inflateEnd(&msblk->stream); | 215 | zlib_err = zlib_inflateEnd(&msblk->stream); |
220 | if (zlib_err != Z_OK) { | 216 | if (zlib_err != Z_OK) { |
221 | ERROR("zlib_inflateEnd returned unexpected result 0x%x," | 217 | ERROR("zlib_inflate error, data probably corrupt\n"); |
222 | " srclength %d\n", zlib_err, srclength); | ||
223 | goto release_mutex; | 218 | goto release_mutex; |
224 | } | 219 | } |
225 | length = msblk->stream.total_out; | 220 | length = msblk->stream.total_out; |
@@ -268,7 +263,8 @@ block_release: | |||
268 | put_bh(bh[k]); | 263 | put_bh(bh[k]); |
269 | 264 | ||
270 | read_failure: | 265 | read_failure: |
271 | ERROR("sb_bread failed reading block 0x%llx\n", cur_index); | 266 | ERROR("squashfs_read_data failed to read block 0x%llx\n", |
267 | (unsigned long long) index); | ||
272 | kfree(bh); | 268 | kfree(bh); |
273 | return -EIO; | 269 | return -EIO; |
274 | } | 270 | } |