]>
Commit | Line | Data |
---|---|---|
68f47eb1 | 1 | Index: linux-2.6.21.1/fs/squashfs/inode.c |
2 | =================================================================== | |
3 | RCS file: linux-2.6.21.1/fs/squashfs/inode.c,v | |
4 | retrieving revision 1.1 | |
5 | retrieving revision 1.4 | |
6 | diff -u -p -r1.1 -r1.4 | |
7 | --- linux-2.6.21.1/fs/squashfs/inode.c 16 Jan 2007 03:30:24 -0000 1.1 | |
8 | +++ linux-2.6.21.1/fs/squashfs/inode.c 5 Mar 2007 12:01:30 -0000 1.4 | |
9 | @@ -33,6 +33,28 @@ | |
10 | #include <linux/smp_lock.h> | |
11 | ||
12 | #include "squashfs.h" | |
5c4263a1 | 13 | +#include <linux/sqlzma.h> |
68f47eb1 | 14 | +#include "sqmagic.h" |
15 | + | |
16 | +#undef KeepPreemptive | |
17 | +#if defined(CONFIG_PREEMPT) && !defined(UnsquashNoPreempt) | |
18 | +#define KeepPreemptive | |
19 | +#endif | |
20 | + | |
21 | +struct sqlzma { | |
22 | +#ifdef KeepPreemptive | |
23 | + struct mutex mtx; | |
24 | +#endif | |
25 | + unsigned char read_data[SQUASHFS_FILE_MAX_SIZE]; | |
26 | + struct sqlzma_un un; | |
27 | +}; | |
28 | +static DEFINE_PER_CPU(struct sqlzma *, sqlzma); | |
29 | + | |
30 | +#define dpri(fmt, args...) /* printk("%s:%d: " fmt, __func__, __LINE__, ##args) */ | |
31 | +#define dpri_un(un) dpri("un{%d, {%d %p}, {%d %p}, {%d %p}}\n", \ | |
32 | + (un)->un_lzma, (un)->un_a[0].sz, (un)->un_a[0].buf, \ | |
33 | + (un)->un_a[1].sz, (un)->un_a[1].buf, \ | |
34 | + (un)->un_a[2].sz, (un)->un_a[2].buf) | |
35 | ||
36 | static void vfs_read_inode(struct inode *i); | |
37 | static struct dentry *squashfs_get_parent(struct dentry *child); | |
38 | @@ -238,66 +260,74 @@ SQSH_EXTERN unsigned int squashfs_read_d | |
39 | } | |
40 | ||
41 | if (compressed) { | |
42 | - int zlib_err = 0; | |
43 | + int zlib_err = Z_STREAM_END; | |
44 | + int rest, start; | |
45 | + enum {Src, Dst}; | |
46 | + struct sized_buf sbuf[2]; | |
47 | + struct sqlzma *percpu; | |
48 | ||
49 | /* | |
50 | * uncompress block | |
51 | */ | |
52 | - | |
53 | - mutex_lock(&msblk->read_data_mutex); | |
54 | - | |
55 | - msblk->stream.next_out = buffer; | |
56 | - msblk->stream.avail_out = srclength; | |
57 | - | |
58 | - for (bytes = 0; k < b; k++) { | |
59 | - avail_bytes = (c_byte - bytes) > (msblk->devblksize - offset) ? | |
60 | - msblk->devblksize - offset : | |
61 | - c_byte - bytes; | |
62 | + for (k = 0; k < b; k++) { | |
63 | wait_on_buffer(bh[k]); | |
64 | if (!buffer_uptodate(bh[k])) | |
65 | - goto release_mutex; | |
66 | - | |
67 | - msblk->stream.next_in = bh[k]->b_data + offset; | |
68 | - msblk->stream.avail_in = avail_bytes; | |
69 | - | |
70 | - if (k == 0) { | |
71 | - zlib_err = zlib_inflateInit(&msblk->stream); | |
72 | - if (zlib_err != Z_OK) { | |
73 | - ERROR("zlib_inflateInit returned unexpected result 0x%x, srclength %d\n", | |
74 | - zlib_err, srclength); | |
75 | - goto release_mutex; | |
76 | - } | |
77 | - | |
78 | - if (avail_bytes == 0) { | |
79 | - offset = 0; | |
80 | - brelse(bh[k]); | |
81 | - continue; | |
82 | - } | |
83 | - } | |
84 | - | |
85 | - zlib_err = zlib_inflate(&msblk->stream, Z_NO_FLUSH); | |
86 | - if (zlib_err != Z_OK && zlib_err != Z_STREAM_END) { | |
87 | - ERROR("zlib_inflate returned unexpected result 0x%x, srclength %d, avail_in %d, avail_out %d\n", | |
88 | - zlib_err, srclength, msblk->stream.avail_in, msblk->stream.avail_out); | |
89 | - goto release_mutex; | |
90 | - } | |
91 | + goto block_release; | |
92 | + } | |
93 | ||
94 | - bytes += avail_bytes; | |
95 | + avail_bytes = 0; | |
96 | + for (k = 0; !avail_bytes && k < b; k++) { | |
97 | + avail_bytes = msblk->devblksize - offset; | |
98 | + if (c_byte < avail_bytes) | |
99 | + avail_bytes = c_byte; | |
100 | + if (avail_bytes) | |
101 | + break; | |
102 | offset = 0; | |
103 | brelse(bh[k]); | |
104 | } | |
105 | + bytes = 0; | |
106 | + if (!avail_bytes) | |
107 | + goto block_release; // nothing to be process | |
108 | ||
109 | - if (zlib_err != Z_STREAM_END) | |
110 | - goto release_mutex; | |
111 | - | |
112 | - zlib_err = zlib_inflateEnd(&msblk->stream); | |
113 | - if (zlib_err != Z_OK) { | |
114 | - ERROR("zlib_inflateEnd returned unexpected result 0x%x, srclength %d\n", | |
115 | - zlib_err, srclength); | |
116 | + start = k; | |
117 | + /* it disables preemption */ | |
118 | + percpu = get_cpu_var(sqlzma); | |
119 | +#ifdef KeepPreemptive | |
120 | + put_cpu_var(sqlzma); | |
121 | + mutex_lock(&percpu->mtx); | |
122 | +#endif | |
123 | + | |
124 | + for (; k < b; k++) { | |
125 | + memcpy(percpu->read_data + bytes, bh[k]->b_data + offset, | |
126 | + avail_bytes); | |
127 | + bytes += avail_bytes; | |
128 | + offset = 0; | |
129 | + brelse(bh[k]); | |
130 | + avail_bytes = msblk->devblksize - offset; | |
131 | + rest = c_byte - bytes; | |
132 | + if (rest < avail_bytes) | |
133 | + avail_bytes = rest; | |
134 | + } | |
135 | + | |
136 | + sbuf[Src].buf = percpu->read_data; | |
137 | + sbuf[Src].sz = bytes; | |
138 | + sbuf[Dst].buf = buffer; | |
139 | + sbuf[Dst].sz = srclength; | |
140 | + dpri_un(&percpu->un); | |
141 | + dpri("src %d %p, dst %d %p\n", sbuf[Src].sz, sbuf[Src].buf, | |
142 | + sbuf[Dst].sz, sbuf[Dst].buf); | |
143 | + zlib_err = sqlzma_un(&percpu->un, sbuf + Src, sbuf + Dst); | |
144 | + bytes = percpu->un.un_reslen; | |
145 | + | |
146 | +#ifdef KeepPreemptive | |
147 | + mutex_unlock(&percpu->mtx); | |
148 | +#else | |
149 | + put_cpu_var(sqlzma); | |
150 | +#endif | |
151 | + if (unlikely(zlib_err)) { | |
152 | + dpri("zlib_err %d\n", zlib_err); | |
153 | goto release_mutex; | |
154 | } | |
155 | - bytes = msblk->stream.total_out; | |
156 | - mutex_unlock(&msblk->read_data_mutex); | |
157 | } else { | |
158 | int i; | |
159 | ||
160 | @@ -325,7 +355,7 @@ SQSH_EXTERN unsigned int squashfs_read_d | |
161 | return bytes; | |
162 | ||
163 | release_mutex: | |
164 | - mutex_unlock(&msblk->read_data_mutex); | |
165 | + //mutex_unlock(&msblk->read_data_mutex); | |
166 | ||
167 | block_release: | |
168 | for (; k < b; k++) | |
169 | @@ -1106,29 +1136,28 @@ static int squashfs_fill_super(struct su | |
170 | { | |
171 | struct squashfs_sb_info *msblk; | |
172 | struct squashfs_super_block *sblk; | |
173 | - int i; | |
174 | + int i, err; | |
175 | char b[BDEVNAME_SIZE]; | |
176 | struct inode *root; | |
177 | + void *label; | |
178 | ||
179 | TRACE("Entered squashfs_read_superblock\n"); | |
180 | ||
181 | + err = -ENOMEM; | |
182 | if (!(s->s_fs_info = kmalloc(sizeof(struct squashfs_sb_info), | |
183 | GFP_KERNEL))) { | |
184 | ERROR("Failed to allocate superblock\n"); | |
185 | goto failure; | |
186 | } | |
187 | + label = &&out_fsinfo; | |
188 | memset(s->s_fs_info, 0, sizeof(struct squashfs_sb_info)); | |
189 | msblk = s->s_fs_info; | |
190 | - if (!(msblk->stream.workspace = vmalloc(zlib_inflate_workspacesize()))) { | |
191 | - ERROR("Failed to allocate zlib workspace\n"); | |
192 | - goto failure; | |
193 | - } | |
194 | sblk = &msblk->sblk; | |
195 | ||
196 | msblk->devblksize = sb_min_blocksize(s, BLOCK_SIZE); | |
197 | msblk->devblksize_log2 = ffz(~msblk->devblksize); | |
198 | ||
199 | - mutex_init(&msblk->read_data_mutex); | |
200 | + //mutex_init(&msblk->read_data_mutex); | |
201 | mutex_init(&msblk->read_page_mutex); | |
202 | mutex_init(&msblk->block_cache_mutex); | |
203 | mutex_init(&msblk->fragment_mutex); | |
204 | @@ -1137,45 +1166,60 @@ static int squashfs_fill_super(struct su | |
205 | init_waitqueue_head(&msblk->waitq); | |
206 | init_waitqueue_head(&msblk->fragment_wait_queue); | |
207 | ||
208 | + err = -EINVAL; | |
209 | sblk->bytes_used = sizeof(struct squashfs_super_block); | |
210 | if (!squashfs_read_data(s, (char *) sblk, SQUASHFS_START, | |
211 | sizeof(struct squashfs_super_block) | | |
212 | SQUASHFS_COMPRESSED_BIT_BLOCK, NULL, sizeof(struct squashfs_super_block))) { | |
213 | SERROR("unable to read superblock\n"); | |
214 | - goto failed_mount; | |
215 | + goto *label; | |
216 | } | |
217 | ||
218 | /* Check it is a SQUASHFS superblock */ | |
219 | + s->s_magic = sblk->s_magic; | |
220 | msblk->swap = 0; | |
221 | - if ((s->s_magic = sblk->s_magic) != SQUASHFS_MAGIC) { | |
222 | - if (sblk->s_magic == SQUASHFS_MAGIC_SWAP) { | |
223 | - struct squashfs_super_block ssblk; | |
224 | - | |
225 | - WARNING("Mounting a different endian SQUASHFS " | |
226 | - "filesystem on %s\n", bdevname(s->s_bdev, b)); | |
227 | - | |
228 | - SQUASHFS_SWAP_SUPER_BLOCK(&ssblk, sblk); | |
229 | - memcpy(sblk, &ssblk, sizeof(struct squashfs_super_block)); | |
230 | - msblk->swap = 1; | |
231 | - } else { | |
232 | - SERROR("Can't find a SQUASHFS superblock on %s\n", | |
233 | - bdevname(s->s_bdev, b)); | |
234 | - goto failed_mount; | |
235 | - } | |
236 | + dpri("magic 0x%x\n", sblk->s_magic); | |
237 | + switch (sblk->s_magic) { | |
238 | + struct squashfs_super_block ssblk; | |
239 | + | |
240 | + case SQUASHFS_MAGIC_SWAP: | |
241 | + /*FALLTHROUGH*/ | |
242 | + case SQUASHFS_MAGIC_LZMA_SWAP: | |
243 | + WARNING("Mounting a different endian SQUASHFS " | |
244 | + "filesystem on %s\n", bdevname(s->s_bdev, b)); | |
245 | + | |
246 | + SQUASHFS_SWAP_SUPER_BLOCK(&ssblk, sblk); | |
247 | + memcpy(sblk, &ssblk, sizeof(struct squashfs_super_block)); | |
248 | + msblk->swap = 1; | |
249 | + /*FALLTHROUGH*/ | |
250 | + case SQUASHFS_MAGIC: | |
251 | + case SQUASHFS_MAGIC_LZMA: | |
252 | + break; | |
253 | + default: | |
254 | + SERROR("Can't find a SQUASHFS superblock on %s\n", | |
255 | + bdevname(s->s_bdev, b)); | |
256 | + goto *label; | |
257 | + } | |
258 | + | |
259 | + { | |
260 | + struct sqlzma *p; | |
261 | + dpri("block_size %d\n", sblk->block_size); | |
262 | + BUG_ON(sblk->block_size > sizeof(p->read_data)); | |
263 | } | |
264 | ||
265 | /* Check the MAJOR & MINOR versions */ | |
266 | + err = -EINVAL; | |
267 | if(!supported_squashfs_filesystem(msblk, silent)) | |
268 | - goto failed_mount; | |
269 | + goto *label; | |
270 | ||
271 | /* Check the filesystem does not extend beyond the end of the | |
272 | block device */ | |
273 | if(sblk->bytes_used < 0 || sblk->bytes_used > i_size_read(s->s_bdev->bd_inode)) | |
274 | - goto failed_mount; | |
275 | + goto *label; | |
276 | ||
277 | /* Check the root inode for sanity */ | |
278 | if (SQUASHFS_INODE_OFFSET(sblk->root_inode) > SQUASHFS_METADATA_SIZE) | |
279 | - goto failed_mount; | |
280 | + goto *label; | |
281 | ||
282 | TRACE("Found valid superblock on %s\n", bdevname(s->s_bdev, b)); | |
283 | TRACE("Inodes are %scompressed\n", | |
284 | @@ -1205,11 +1249,13 @@ static int squashfs_fill_super(struct su | |
285 | s->s_op = &squashfs_super_ops; | |
286 | ||
287 | /* Init inode_table block pointer array */ | |
288 | + err = -ENOMEM; | |
289 | if (!(msblk->block_cache = kmalloc(sizeof(struct squashfs_cache) * | |
290 | SQUASHFS_CACHED_BLKS, GFP_KERNEL))) { | |
291 | ERROR("Failed to allocate block cache\n"); | |
292 | - goto failed_mount; | |
293 | + goto *label; | |
294 | } | |
295 | + label = &&out_block_cache; | |
296 | ||
297 | for (i = 0; i < SQUASHFS_CACHED_BLKS; i++) | |
298 | msblk->block_cache[i].block = SQUASHFS_INVALID_BLK; | |
299 | @@ -1219,17 +1265,21 @@ static int squashfs_fill_super(struct su | |
300 | /* Allocate read_page block */ | |
301 | if (!(msblk->read_page = kmalloc(sblk->block_size, GFP_KERNEL))) { | |
302 | ERROR("Failed to allocate read_page block\n"); | |
303 | - goto failed_mount; | |
304 | + goto *label; | |
305 | } | |
306 | + label = &&out_read_page; | |
307 | ||
308 | /* Allocate uid and gid tables */ | |
309 | if (!(msblk->uid = kmalloc((sblk->no_uids + sblk->no_guids) * | |
310 | sizeof(unsigned int), GFP_KERNEL))) { | |
311 | ERROR("Failed to allocate uid/gid table\n"); | |
312 | - goto failed_mount; | |
313 | + goto *label; | |
314 | } | |
315 | + label = &&out_uid; | |
316 | msblk->guid = msblk->uid + sblk->no_uids; | |
317 | ||
318 | + dpri("swap %d\n", msblk->swap); | |
319 | + err = -EINVAL; | |
320 | if (msblk->swap) { | |
321 | unsigned int suid[sblk->no_uids + sblk->no_guids]; | |
322 | ||
323 | @@ -1238,7 +1288,7 @@ static int squashfs_fill_super(struct su | |
324 | sizeof(unsigned int)) | | |
325 | SQUASHFS_COMPRESSED_BIT_BLOCK, NULL, (sblk->no_uids + sblk->no_guids) * sizeof(unsigned int))) { | |
326 | ERROR("unable to read uid/gid table\n"); | |
327 | - goto failed_mount; | |
328 | + goto *label; | |
329 | } | |
330 | ||
331 | SQUASHFS_SWAP_DATA(msblk->uid, suid, (sblk->no_uids + | |
332 | @@ -1249,18 +1299,20 @@ static int squashfs_fill_super(struct su | |
333 | sizeof(unsigned int)) | | |
334 | SQUASHFS_COMPRESSED_BIT_BLOCK, NULL, (sblk->no_uids + sblk->no_guids) * sizeof(unsigned int))) { | |
335 | ERROR("unable to read uid/gid table\n"); | |
336 | - goto failed_mount; | |
337 | + goto *label; | |
338 | } | |
339 | ||
340 | ||
341 | if (sblk->s_major == 1 && squashfs_1_0_supported(msblk)) | |
342 | goto allocate_root; | |
343 | ||
344 | + err = -ENOMEM; | |
345 | if (!(msblk->fragment = kmalloc(sizeof(struct squashfs_fragment_cache) * | |
346 | SQUASHFS_CACHED_FRAGMENTS, GFP_KERNEL))) { | |
347 | ERROR("Failed to allocate fragment block cache\n"); | |
348 | - goto failed_mount; | |
349 | + goto *label; | |
350 | } | |
351 | + label = &&out_fragment; | |
352 | ||
353 | for (i = 0; i < SQUASHFS_CACHED_FRAGMENTS; i++) { | |
354 | msblk->fragment[i].locked = 0; | |
355 | @@ -1272,7 +1324,7 @@ static int squashfs_fill_super(struct su | |
356 | ||
357 | /* Allocate and read fragment index table */ | |
358 | if (msblk->read_fragment_index_table(s) == 0) | |
359 | - goto failed_mount; | |
360 | + goto *label; | |
361 | ||
362 | if(sblk->s_major < 3 || sblk->lookup_table_start == SQUASHFS_INVALID_BLK) | |
363 | goto allocate_root; | |
364 | @@ -1285,9 +1337,12 @@ static int squashfs_fill_super(struct su | |
365 | s->s_export_op = &squashfs_export_ops; | |
366 | ||
367 | allocate_root: | |
368 | + dpri("alloate_root\n"); | |
369 | root = new_inode(s); | |
370 | - if ((msblk->read_inode)(root, sblk->root_inode) == 0) | |
371 | + if ((msblk->read_inode)(root, sblk->root_inode) == 0) { | |
372 | + iput(root); | |
373 | goto failed_mount; | |
374 | + } | |
375 | insert_inode_hash(root); | |
376 | ||
377 | if ((s->s_root = d_alloc_root(root)) == NULL) { | |
378 | @@ -1302,18 +1357,20 @@ allocate_root: | |
379 | failed_mount: | |
380 | kfree(msblk->inode_lookup_table); | |
381 | kfree(msblk->fragment_index); | |
382 | + kfree(msblk->fragment_index_2); | |
383 | + out_fragment: | |
384 | kfree(msblk->fragment); | |
385 | + out_uid: | |
386 | kfree(msblk->uid); | |
387 | + out_read_page: | |
388 | kfree(msblk->read_page); | |
389 | + out_block_cache: | |
390 | kfree(msblk->block_cache); | |
391 | - kfree(msblk->fragment_index_2); | |
392 | - vfree(msblk->stream.workspace); | |
393 | + out_fsinfo: | |
394 | kfree(s->s_fs_info); | |
395 | s->s_fs_info = NULL; | |
396 | - return -EINVAL; | |
397 | - | |
398 | -failure: | |
399 | - return -ENOMEM; | |
400 | + failure: | |
401 | + return err; | |
402 | } | |
403 | ||
404 | ||
405 | @@ -1324,7 +1381,7 @@ static int squashfs_statfs(struct dentry | |
406 | ||
407 | TRACE("Entered squashfs_statfs\n"); | |
408 | ||
409 | - buf->f_type = SQUASHFS_MAGIC; | |
410 | + buf->f_type = sblk->s_magic; | |
411 | buf->f_bsize = sblk->block_size; | |
412 | buf->f_blocks = ((sblk->bytes_used - 1) >> sblk->block_log) + 1; | |
413 | buf->f_bfree = buf->f_bavail = 0; | |
414 | @@ -2235,7 +2292,6 @@ static void squashfs_put_super(struct su | |
415 | kfree(sbi->fragment_index); | |
416 | kfree(sbi->fragment_index_2); | |
417 | kfree(sbi->meta_index); | |
418 | - vfree(sbi->stream.workspace); | |
419 | kfree(s->s_fs_info); | |
420 | s->s_fs_info = NULL; | |
421 | } | |
422 | @@ -2251,17 +2307,62 @@ static int squashfs_get_sb(struct file_s | |
423 | } | |
424 | ||
425 | ||
426 | +static void free_sqlzma(void) | |
427 | +{ | |
428 | + int cpu; | |
429 | + struct sqlzma *p; | |
430 | + | |
431 | + for_each_online_cpu(cpu) { | |
432 | + p = per_cpu(sqlzma, cpu); | |
433 | + if (p) { | |
434 | +#ifdef KeepPreemptive | |
435 | + mutex_destroy(&p->mtx); | |
436 | +#endif | |
437 | + sqlzma_fin(&p->un); | |
438 | + kfree(p); | |
439 | + } | |
440 | + } | |
441 | +} | |
442 | + | |
443 | static int __init init_squashfs_fs(void) | |
444 | { | |
445 | + struct sqlzma *p; | |
446 | + int cpu; | |
447 | int err = init_inodecache(); | |
448 | if (err) | |
449 | goto out; | |
450 | ||
451 | + for_each_online_cpu(cpu) { | |
452 | + dpri("%d: %p\n", cpu, per_cpu(sqlzma, cpu)); | |
453 | + err = -ENOMEM; | |
454 | + p = kmalloc(sizeof(struct sqlzma), GFP_KERNEL); | |
455 | + if (p) { | |
456 | +#ifdef KeepPreemptive | |
457 | + mutex_init(&p->mtx); | |
458 | +#endif | |
459 | + err = sqlzma_init(&p->un, 1, 0); | |
460 | + if (unlikely(err)) { | |
461 | + ERROR("Failed to intialize uncompress workspace\n"); | |
462 | + break; | |
463 | + } | |
464 | + per_cpu(sqlzma, cpu) = p; | |
465 | + err = 0; | |
466 | + } else | |
467 | + break; | |
468 | + } | |
469 | + if (unlikely(err)) { | |
470 | + free_sqlzma(); | |
471 | + goto out; | |
472 | + } | |
473 | + | |
474 | printk(KERN_INFO "squashfs: version 3.2-r2 (2007/01/15) " | |
475 | - "Phillip Lougher\n"); | |
476 | + "Phillip Lougher\n" | |
477 | + "squashfs: LZMA suppport for slax.org by jro\n"); | |
478 | ||
479 | - if ((err = register_filesystem(&squashfs_fs_type))) | |
480 | + if ((err = register_filesystem(&squashfs_fs_type))) { | |
481 | + free_sqlzma(); | |
482 | destroy_inodecache(); | |
483 | + } | |
484 | ||
485 | out: | |
486 | return err; | |
487 | @@ -2271,6 +2372,7 @@ out: | |
488 | static void __exit exit_squashfs_fs(void) | |
489 | { | |
490 | unregister_filesystem(&squashfs_fs_type); | |
491 | + free_sqlzma(); | |
492 | destroy_inodecache(); | |
493 | } | |
494 | ||
495 | @@ -2324,6 +2426,6 @@ static void destroy_inodecache(void) | |
496 | ||
497 | module_init(init_squashfs_fs); | |
498 | module_exit(exit_squashfs_fs); | |
499 | -MODULE_DESCRIPTION("squashfs 3.2-r2, a compressed read-only filesystem"); | |
500 | -MODULE_AUTHOR("Phillip Lougher <phillip@lougher.org.uk>"); | |
501 | +MODULE_DESCRIPTION("squashfs 3.2-r2, a compressed read-only filesystem, and LZMA suppport for slax.org"); | |
502 | +MODULE_AUTHOR("Phillip Lougher <phillip@lougher.org.uk>, and LZMA suppport for slax.org by jro"); | |
503 | MODULE_LICENSE("GPL"); | |
504 | Index: linux-2.6.21.1/include/linux/squashfs_fs_sb.h | |
505 | =================================================================== | |
506 | RCS file: linux-2.6.21.1/include/linux/squashfs_fs_sb.h,v | |
507 | retrieving revision 1.1 | |
508 | retrieving revision 1.2 | |
509 | diff -u -p -r1.1 -r1.2 | |
510 | --- linux-2.6.21.1/include/linux/squashfs_fs_sb.h 16 Jan 2007 03:30:24 -0000 1.1 | |
511 | +++ linux-2.6.21.1/include/linux/squashfs_fs_sb.h 16 Jan 2007 05:08:17 -0000 1.2 | |
512 | @@ -24,6 +24,7 @@ | |
513 | */ | |
514 | ||
515 | #include <linux/squashfs_fs.h> | |
5c4263a1 | 516 | +#include <linux/sqlzma.h> |
68f47eb1 | 517 | |
518 | struct squashfs_cache { | |
519 | long long block; | |
520 | @@ -54,7 +55,7 @@ struct squashfs_sb_info { | |
521 | long long *fragment_index; | |
522 | unsigned int *fragment_index_2; | |
523 | char *read_page; | |
524 | - struct mutex read_data_mutex; | |
525 | + //struct mutex read_data_mutex; | |
526 | struct mutex read_page_mutex; | |
527 | struct mutex block_cache_mutex; | |
528 | struct mutex fragment_mutex; | |
529 | @@ -62,7 +63,6 @@ struct squashfs_sb_info { | |
530 | wait_queue_head_t waitq; | |
531 | wait_queue_head_t fragment_wait_queue; | |
532 | struct meta_index *meta_index; | |
533 | - z_stream stream; | |
534 | long long *inode_lookup_table; | |
535 | int (*read_inode)(struct inode *i, squashfs_inode_t \ | |
536 | inode); | |
5c4263a1 JR |
537 | diff -NurpP --minimal linux-2.6.21.a/include/linux/sqlzma.h linux-2.6.21/include/linux/sqlzma.h |
538 | --- linux-2.6.21.a/include/linux/sqlzma.h 1970-01-01 01:00:00.000000000 +0100 | |
539 | +++ linux-2.6.21/include/linux/sqlzma.h 2007-01-07 16:12:48.000000000 +0100 | |
f58a9851 | 540 | @@ -0,0 +1,79 @@ |
541 | +/* | |
542 | + * Copyright (C) 2006 Junjiro Okajima | |
543 | + * Copyright (C) 2006 Tomas Matejicek, slax.org | |
544 | + * | |
545 | + * LICENSE follows the described one in lzma. | |
546 | + */ | |
547 | + | |
548 | +/* $Id$ */ | |
549 | + | |
550 | +#ifndef __sqlzma_h__ | |
551 | +#define __sqlzma_h__ | |
552 | + | |
553 | +#ifndef __KERNEL__ | |
554 | +#include <stdlib.h> | |
555 | +#include <string.h> | |
556 | +#include <zlib.h> | |
557 | +#ifdef _REENTRANT | |
558 | +#include <pthread.h> | |
559 | +#endif | |
560 | +#else | |
561 | +#include <linux/zlib.h> | |
562 | +#endif | |
563 | +#define _7ZIP_BYTE_DEFINED | |
564 | + | |
565 | +/* | |
566 | + * detect the compression method automatically by the first byte of compressed | |
567 | + * data. | |
568 | + * according to rfc1950, the first byte of zlib compression must be 0x?8. | |
569 | + */ | |
570 | +#define is_lzma(c) (c == 0x5d) | |
571 | + | |
572 | +/* ---------------------------------------------------------------------- */ | |
573 | + | |
574 | +#ifdef __cplusplus | |
575 | +extern "C" { | |
576 | +#endif | |
577 | + | |
578 | +#ifndef __KERNEL__ | |
579 | +/* for mksquashfs only */ | |
580 | +int sqlzma_cm(int lzma, z_stream *stream, Bytef *next_in, uInt avail_in, | |
581 | + Bytef *next_out, uInt avail_out); | |
582 | +#endif | |
583 | + | |
584 | +/* ---------------------------------------------------------------------- */ | |
585 | +/* | |
586 | + * Three patterns for sqlzma uncompression. very dirty code. | |
587 | + * - kernel space (squashfs kernel module) | |
588 | + * - user space with pthread (mksquashfs) | |
589 | + * - user space without pthread (unsquashfs) | |
590 | + */ | |
591 | + | |
592 | +struct sized_buf { | |
593 | + unsigned int sz; | |
594 | + unsigned char *buf; | |
595 | +}; | |
596 | + | |
597 | +enum {SQUN_PROB, SQUN_RESULT, SQUN_LAST}; | |
598 | +struct sqlzma_un { | |
599 | + int un_lzma; | |
600 | + struct sized_buf un_a[SQUN_LAST]; | |
601 | + unsigned char un_prob[31960]; /* unlzma 64KB */ | |
602 | + z_stream un_stream; | |
603 | +#define un_cmbuf un_stream.next_in | |
604 | +#define un_cmlen un_stream.avail_in | |
605 | +#define un_resbuf un_stream.next_out | |
606 | +#define un_resroom un_stream.avail_out | |
607 | +#define un_reslen un_stream.total_out | |
608 | +}; | |
609 | + | |
610 | +int sqlzma_init(struct sqlzma_un *un, int do_lzma, unsigned int res_sz); | |
611 | +int sqlzma_un(struct sqlzma_un *un, struct sized_buf *src, struct sized_buf *dst); | |
612 | +void sqlzma_fin(struct sqlzma_un *un); | |
613 | + | |
614 | +/* ---------------------------------------------------------------------- */ | |
615 | + | |
616 | +#ifdef __cplusplus | |
617 | +}; | |
618 | +#endif | |
619 | +#endif | |
620 | diff -NurpP --minimal linux-2.6.21.a/fs/squashfs/sqmagic.h linux-2.6.21/fs/squashfs/sqmagic.h | |
621 | --- linux-2.6.21.a/fs/squashfs/sqmagic.h 1970-01-01 01:00:00.000000000 +0100 | |
622 | +++ linux-2.6.21/fs/squashfs/sqmagic.h 2006-11-27 04:54:58.000000000 +0100 | |
623 | @@ -0,0 +1,17 @@ | |
624 | +/* | |
625 | + * Copyright (C) 2006 Junjiro Okajima | |
626 | + * Copyright (C) 2006 Tomas Matejicek, slax.org | |
627 | + * | |
628 | + * LICENSE must follow the one in squashfs. | |
629 | + */ | |
630 | + | |
631 | +/* $Id$ */ | |
632 | + | |
633 | +#ifndef __sqmagic_h__ | |
634 | +#define __sqmagic_h__ | |
635 | + | |
636 | +/* see SQUASHFS_MAGIC in squashfs_fs.h */ | |
637 | +#define SQUASHFS_MAGIC_LZMA 0x71736873 | |
638 | +#define SQUASHFS_MAGIC_LZMA_SWAP 0x73687371 | |
639 | + | |
640 | +#endif |