31 #include <linux/slab.h>
32 #include <linux/string.h>
44 static struct buffer_head *get_block_length(
struct super_block *
sb,
48 struct buffer_head *bh;
50 bh = sb_bread(sb, *cur_index);
55 *length = (
unsigned char) bh->b_data[*offset];
57 bh = sb_bread(sb, ++(*cur_index));
60 *length |= (
unsigned char) bh->b_data[0] << 8;
63 *length = (
unsigned char) bh->b_data[*offset] |
64 (
unsigned char) bh->b_data[*offset + 1] << 8;
69 bh = sb_bread(sb, ++(*cur_index));
90 int length,
u64 *next_index,
int srclength,
int pages)
93 struct buffer_head **bh;
98 bh = kcalloc(((srclength + msblk->
devblksize - 1)
111 *next_index = index +
length;
113 TRACE(
"Block @ 0x%llx, %scompressed size %d, src size %d\n",
114 index, compressed ?
"" :
"un", length, srclength);
116 if (length < 0 || length > srclength ||
120 for (b = 0; bytes <
length; b++, cur_index++) {
121 bh[
b] = sb_getblk(sb, cur_index);
134 bh[0] = get_block_length(sb, &cur_index, &offset, &length);
143 *next_index = index + length + 2;
145 TRACE(
"Block @ 0x%llx, %scompressed size %d\n", index,
146 compressed ?
"" :
"un", length);
148 if (length < 0 || length > srclength ||
152 for (; bytes <
length; b++) {
153 bh[
b] = sb_getblk(sb, ++cur_index);
162 length = squashfs_decompress(msblk, buffer, bh, b, offset,
163 length, srclength, pages);
170 int i,
in, pg_offset = 0;
172 for (i = 0; i <
b; i++) {
173 wait_on_buffer(bh[i]);
174 if (!buffer_uptodate(bh[i]))
178 for (bytes = length;
k <
b;
k++) {
189 bh[
k]->b_data + offset,
avail);
207 ERROR(
"squashfs_read_data failed to read block 0x%llx\n",
208 (
unsigned long long) index);