fix base-files-arch package
[openwrt.git] / openwrt / target / linux / linux-2.4 / patches / generic / 001-squashfs.patch
1 diff --new-file -ur linux-2.4.28/fs/Config.in linux-2.4.28-squashfs2.1-r2/fs/Config.in
2 --- linux-2.4.28/fs/Config.in 2004-11-17 11:54:21.000000000 +0000
3 +++ linux-2.4.28-squashfs2.1-r2/fs/Config.in 2004-12-02 02:14:05.000000000 +0000
4 @@ -51,6 +51,7 @@
5 int 'JFFS2 debugging verbosity (0 = quiet, 2 = noisy)' CONFIG_JFFS2_FS_DEBUG 0
6 fi
7 tristate 'Compressed ROM file system support' CONFIG_CRAMFS
8 +tristate 'Squashed file system support' CONFIG_SQUASHFS
9 bool 'Virtual memory file system support (former shm fs)' CONFIG_TMPFS
10 define_bool CONFIG_RAMFS y
11
12 diff --new-file -ur linux-2.4.28/fs/Makefile linux-2.4.28-squashfs2.1-r2/fs/Makefile
13 --- linux-2.4.28/fs/Makefile 2004-02-18 13:36:31.000000000 +0000
14 +++ linux-2.4.28-squashfs2.1-r2/fs/Makefile 2004-12-02 02:14:05.000000000 +0000
15 @@ -65,6 +65,7 @@
16 subdir-$(CONFIG_DEVPTS_FS) += devpts
17 subdir-$(CONFIG_SUN_OPENPROMFS) += openpromfs
18 subdir-$(CONFIG_BEFS_FS) += befs
19 +subdir-$(CONFIG_SQUASHFS) += squashfs
20 subdir-$(CONFIG_JFS_FS) += jfs
21 subdir-$(CONFIG_XFS_FS) += xfs
22
23 diff --new-file -ur linux-2.4.28/fs/squashfs/inode.c linux-2.4.28-squashfs2.1-r2/fs/squashfs/inode.c
24 --- linux-2.4.28/fs/squashfs/inode.c 1970-01-01 01:00:00.000000000 +0100
25 +++ linux-2.4.28-squashfs2.1-r2/fs/squashfs/inode.c 2004-12-15 10:13:06.000000000 +0000
26 @@ -0,0 +1,1677 @@
27 +/*
28 + * Squashfs - a compressed read only filesystem for Linux
29 + *
30 + * Copyright (c) 2002, 2003, 2004 Phillip Lougher <plougher@users.sourceforge.net>
31 + *
32 + * This program is free software; you can redistribute it and/or
33 + * modify it under the terms of the GNU General Public License
34 + * as published by the Free Software Foundation; either version 2,
35 + * or (at your option) any later version.
36 + *
37 + * This program is distributed in the hope that it will be useful,
38 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
39 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
40 + * GNU General Public License for more details.
41 + *
42 + * You should have received a copy of the GNU General Public License
43 + * along with this program; if not, write to the Free Software
44 + * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
45 + * Squashfs - a compressed read only filesystem for Linux
46 + *
47 + * inode.c
48 + */
49 +
50 +#define SQUASHFS_1_0_COMPATIBILITY
51 +
52 +#include <linux/types.h>
53 +#include <linux/squashfs_fs.h>
54 +#include <linux/module.h>
55 +#include <linux/errno.h>
56 +#include <linux/slab.h>
57 +#include <linux/fs.h>
58 +#include <linux/locks.h>
59 +#include <linux/init.h>
60 +#include <linux/dcache.h>
61 +#include <asm/uaccess.h>
62 +#include <linux/wait.h>
63 +#include <asm/semaphore.h>
64 +#include <linux/zlib.h>
65 +#include <linux/blkdev.h>
66 +#include <linux/vmalloc.h>
67 +
68 +#ifdef SQUASHFS_TRACE
69 +#define TRACE(s, args...) printk(KERN_NOTICE "SQUASHFS: "s, ## args)
70 +#else
71 +#define TRACE(s, args...) {}
72 +#endif
73 +
74 +#define ERROR(s, args...) printk(KERN_ERR "SQUASHFS error: "s, ## args)
75 +
76 +#define SERROR(s, args...) if(!silent) printk(KERN_ERR "SQUASHFS error: "s, ## args)
77 +#define WARNING(s, args...) printk(KERN_WARNING "SQUASHFS: "s, ## args)
78 +
79 +static struct super_block *squashfs_read_super(struct super_block *, void *, int);
80 +static void squashfs_put_super(struct super_block *);
81 +static int squashfs_statfs(struct super_block *, struct statfs *);
82 +static int squashfs_symlink_readpage(struct file *file, struct page *page);
83 +static int squashfs_readpage(struct file *file, struct page *page);
84 +static int squashfs_readpage4K(struct file *file, struct page *page);
85 +static int squashfs_readdir(struct file *, void *, filldir_t);
86 +static struct dentry *squashfs_lookup(struct inode *, struct dentry *);
87 +static unsigned int read_data(struct super_block *s, char *buffer,
88 + unsigned int index, unsigned int length, unsigned int *next_index);
89 +static int squashfs_get_cached_block(struct super_block *s, char *buffer,
90 + unsigned int block, unsigned int offset, int length,
91 + unsigned int *next_block, unsigned int *next_offset);
92 +static struct inode *squashfs_iget(struct super_block *s, squashfs_inode inode);
93 +static unsigned int read_blocklist(struct inode *inode, int index, int readahead_blks,
94 + char *block_list, unsigned short **block_p, unsigned int *bsize);
95 +static void squashfs_put_super(struct super_block *s);
96 +
97 +#ifdef SQUASHFS_1_0_COMPATIBILITY
98 +static int squashfs_readpage_lessthan4K(struct file *file, struct page *page);
99 +static struct inode *squashfs_iget_1(struct super_block *s, squashfs_inode inode);
100 +static unsigned int read_blocklist_1(struct inode *inode, int index, int readahead_blks,
101 + char *block_list, unsigned short **block_p, unsigned int *bsize);
102 +#endif
103 +
104 +DECLARE_MUTEX(read_data_mutex);
105 +
106 +static z_stream stream;
107 +
108 +static DECLARE_FSTYPE_DEV(squashfs_fs_type, "squashfs", squashfs_read_super);
109 +
110 +static unsigned char squashfs_filetype_table[] = {
111 + DT_UNKNOWN, DT_DIR, DT_REG, DT_LNK, DT_BLK, DT_CHR, DT_FIFO, DT_SOCK
112 +};
113 +
114 +static struct super_operations squashfs_ops = {
115 + statfs: squashfs_statfs,
116 + put_super: squashfs_put_super,
117 +};
118 +
119 +static struct address_space_operations squashfs_symlink_aops = {
120 + readpage: squashfs_symlink_readpage
121 +};
122 +
123 +static struct address_space_operations squashfs_aops = {
124 + readpage: squashfs_readpage
125 +};
126 +
127 +static struct address_space_operations squashfs_aops_4K = {
128 + readpage: squashfs_readpage4K
129 +};
130 +
131 +#ifdef SQUASHFS_1_0_COMPATIBILITY
132 +static struct address_space_operations squashfs_aops_lessthan4K = {
133 + readpage: squashfs_readpage_lessthan4K
134 +};
135 +#endif
136 +
137 +static struct file_operations squashfs_dir_ops = {
138 + read: generic_read_dir,
139 + readdir: squashfs_readdir
140 +};
141 +
142 +static struct inode_operations squashfs_dir_inode_ops = {
143 + lookup: squashfs_lookup
144 +};
145 +
146 +
147 +static struct buffer_head *get_block_length(struct super_block *s, int *cur_index, int *offset, int *c_byte)
148 +{
149 + squashfs_sb_info *msBlk = &s->u.squashfs_sb;
150 + unsigned short temp;
151 + struct buffer_head *bh;
152 +
153 + if(!(bh = sb_bread(s, *cur_index)))
154 + return NULL;
155 +
156 + if(msBlk->devblksize - *offset == 1) {
157 + if(msBlk->swap)
158 + ((unsigned char *) &temp)[1] = *((unsigned char *) (bh->b_data + *offset));
159 + else
160 + ((unsigned char *) &temp)[0] = *((unsigned char *) (bh->b_data + *offset));
161 + brelse(bh);
162 + if(!(bh = sb_bread(s, ++(*cur_index))))
163 + return NULL;
164 + if(msBlk->swap)
165 + ((unsigned char *) &temp)[0] = *((unsigned char *) bh->b_data);
166 + else
167 + ((unsigned char *) &temp)[1] = *((unsigned char *) bh->b_data);
168 + *c_byte = temp;
169 + *offset = 1;
170 + }
171 + else {
172 + if(msBlk->swap) {
173 + unsigned short temp;
174 + ((unsigned char *) &temp)[1] = *((unsigned char *) (bh->b_data + *offset));
175 + ((unsigned char *) &temp)[0] = *((unsigned char *) (bh->b_data + *offset + 1));
176 + *c_byte = temp;
177 + } else
178 + *c_byte = *((unsigned short *) (bh->b_data + *offset));
179 + *offset += 2;
180 + }
181 + if(SQUASHFS_CHECK_DATA(msBlk->sBlk.flags)) {
182 + if(*offset == msBlk->devblksize) {
183 + brelse(bh);
184 + if(!(bh = sb_bread(s, ++(*cur_index))))
185 + return NULL;
186 + offset = 0;
187 + }
188 + if(*((unsigned char *) (bh->b_data + *offset)) != SQUASHFS_MARKER_BYTE) {
189 + ERROR("Metadata block marker corrupt @ %x\n", *cur_index);
190 + brelse(bh);
191 + return NULL;
192 + }
193 + *offset ++;
194 + }
195 +
196 + return bh;
197 +}
198 +
199 +
200 +static unsigned int read_data(struct super_block *s, char *buffer,
201 + unsigned int index, unsigned int length, unsigned int *next_index)
202 +{
203 + squashfs_sb_info *msBlk = &s->u.squashfs_sb;
204 + struct buffer_head *bh[((SQUASHFS_FILE_MAX_SIZE - 1) >> msBlk->devblksize_log2) + 2];
205 + unsigned int offset = index & ((1 << msBlk->devblksize_log2) - 1);
206 + unsigned int cur_index = index >> msBlk->devblksize_log2;
207 + int bytes, avail_bytes, b = 0, k;
208 + char *c_buffer;
209 + unsigned int compressed;
210 + unsigned int c_byte = length;
211 +
212 + if(c_byte) {
213 + bytes = msBlk->devblksize - offset;
214 + compressed = SQUASHFS_COMPRESSED_BLOCK(c_byte);
215 + c_buffer = compressed ? msBlk->read_data : buffer;
216 + c_byte = SQUASHFS_COMPRESSED_SIZE_BLOCK(c_byte);
217 +
218 + TRACE("Block @ 0x%x, %scompressed size %d\n", index, compressed ? "" : "un", (unsigned int) c_byte);
219 +
220 + if(!(bh[0] = sb_getblk(s, cur_index)))
221 + goto block_release;
222 + for(b = 1; bytes < c_byte; b++) {
223 + if(!(bh[b] = sb_getblk(s, ++cur_index)))
224 + goto block_release;
225 + bytes += msBlk->devblksize;
226 + }
227 + ll_rw_block(READ, b, bh);
228 + } else {
229 + if(!(bh[0] = get_block_length(s, &cur_index, &offset, &c_byte)))
230 + goto read_failure;
231 +
232 + bytes = msBlk->devblksize - offset;
233 + compressed = SQUASHFS_COMPRESSED(c_byte);
234 + c_buffer = compressed ? msBlk->read_data : buffer;
235 + c_byte = SQUASHFS_COMPRESSED_SIZE(c_byte);
236 +
237 + TRACE("Block @ 0x%x, %scompressed size %d\n", index, compressed ? "" : "un", (unsigned int) c_byte);
238 +
239 + for(b = 1; bytes < c_byte; b++) {
240 + if(!(bh[b] = sb_getblk(s, ++cur_index)))
241 + goto block_release;
242 + bytes += msBlk->devblksize;
243 + }
244 + ll_rw_block(READ, b - 1, bh + 1);
245 + }
246 +
247 + if(compressed)
248 + down(&read_data_mutex);
249 +
250 + for(bytes = 0, k = 0; k < b; k++) {
251 + avail_bytes = (c_byte - bytes) > (msBlk->devblksize - offset) ? msBlk->devblksize - offset : c_byte - bytes;
252 + wait_on_buffer(bh[k]);
253 + memcpy(c_buffer + bytes, bh[k]->b_data + offset, avail_bytes);
254 + bytes += avail_bytes;
255 + offset = 0;
256 + brelse(bh[k]);
257 + }
258 +
259 + /*
260 + * uncompress block
261 + */
262 + if(compressed) {
263 + int zlib_err;
264 +
265 + stream.next_in = c_buffer;
266 + stream.avail_in = c_byte;
267 + stream.next_out = buffer;
268 + stream.avail_out = msBlk->read_size;
269 + if(((zlib_err = zlib_inflateInit(&stream)) != Z_OK) ||
270 + ((zlib_err = zlib_inflate(&stream, Z_FINISH)) != Z_STREAM_END) ||
271 + ((zlib_err = zlib_inflateEnd(&stream)) != Z_OK)) {
272 + ERROR("zlib_fs returned unexpected result 0x%x\n", zlib_err);
273 + bytes = 0;
274 + } else
275 + bytes = stream.total_out;
276 + up(&read_data_mutex);
277 + }
278 +
279 + if(next_index)
280 + *next_index = index + c_byte + (length ? 0 : (SQUASHFS_CHECK_DATA(msBlk->sBlk.flags) ? 3 : 2));
281 +
282 + return bytes;
283 +
284 +block_release:
285 + while(--b >= 0) brelse(bh[b]);
286 +
287 +read_failure:
288 + ERROR("sb_bread failed reading block 0x%x\n", cur_index);
289 + return 0;
290 +}
291 +static int squashfs_get_cached_block(struct super_block *s, char *buffer,
292 + unsigned int block, unsigned int offset, int length,
293 + unsigned int *next_block, unsigned int *next_offset)
294 +{
295 + squashfs_sb_info *msBlk = &s->u.squashfs_sb;
296 + int n, i, bytes, return_length = length;
297 + unsigned int next_index;
298 +
299 + TRACE("Entered squashfs_get_cached_block [%x:%x]\n", block, offset);
300 +
301 + for(;;) {
302 + for(i = 0; i < SQUASHFS_CACHED_BLKS; i++)
303 + if(msBlk->block_cache[i].block == block)
304 + break;
305 +
306 + down(&msBlk->block_cache_mutex);
307 + if(i == SQUASHFS_CACHED_BLKS) {
308 + /* read inode header block */
309 + for(i = msBlk->next_cache, n = SQUASHFS_CACHED_BLKS; n ; n --, i = (i + 1) % SQUASHFS_CACHED_BLKS)
310 + if(msBlk->block_cache[i].block != SQUASHFS_USED_BLK)
311 + break;
312 + if(n == 0) {
313 + up(&msBlk->block_cache_mutex);
314 + sleep_on(&msBlk->waitq);
315 + continue;
316 + }
317 + msBlk->next_cache = (i + 1) % SQUASHFS_CACHED_BLKS;
318 +
319 + if(msBlk->block_cache[i].block == SQUASHFS_INVALID_BLK) {
320 + if(!(msBlk->block_cache[i].data = (unsigned char *)
321 + kmalloc(SQUASHFS_METADATA_SIZE, GFP_KERNEL))) {
322 + ERROR("Failed to allocate cache block\n");
323 + up(&msBlk->block_cache_mutex);
324 + return 0;
325 + }
326 + }
327 +
328 + msBlk->block_cache[i].block = SQUASHFS_USED_BLK;
329 + up(&msBlk->block_cache_mutex);
330 + if(!(msBlk->block_cache[i].length = read_data(s, msBlk->block_cache[i].data, block, 0,
331 + &next_index))) {
332 + ERROR("Unable to read cache block [%x:%x]\n", block, offset);
333 + return 0;
334 + }
335 + down(&msBlk->block_cache_mutex);
336 + wake_up(&msBlk->waitq);
337 + msBlk->block_cache[i].block = block;
338 + msBlk->block_cache[i].next_index = next_index;
339 + TRACE("Read cache block [%x:%x]\n", block, offset);
340 + }
341 +
342 + if(msBlk->block_cache[i].block != block) {
343 + up(&msBlk->block_cache_mutex);
344 + continue;
345 + }
346 +
347 + if((bytes = msBlk->block_cache[i].length - offset) >= length) {
348 + if(buffer)
349 + memcpy(buffer, msBlk->block_cache[i].data + offset, length);
350 + if(msBlk->block_cache[i].length - offset == length) {
351 + *next_block = msBlk->block_cache[i].next_index;
352 + *next_offset = 0;
353 + } else {
354 + *next_block = block;
355 + *next_offset = offset + length;
356 + }
357 +
358 + up(&msBlk->block_cache_mutex);
359 + return return_length;
360 + } else {
361 + if(buffer) {
362 + memcpy(buffer, msBlk->block_cache[i].data + offset, bytes);
363 + buffer += bytes;
364 + }
365 + block = msBlk->block_cache[i].next_index;
366 + up(&msBlk->block_cache_mutex);
367 + length -= bytes;
368 + offset = 0;
369 + }
370 + }
371 +}
372 +
373 +
374 +static int get_fragment_location(struct super_block *s, unsigned int fragment, unsigned int *fragment_start_block, unsigned int *fragment_size)
375 +{
376 + squashfs_sb_info *msBlk = &s->u.squashfs_sb;
377 + unsigned int start_block = msBlk->fragment_index[SQUASHFS_FRAGMENT_INDEX(fragment)];
378 + int offset = SQUASHFS_FRAGMENT_INDEX_OFFSET(fragment);
379 + squashfs_fragment_entry fragment_entry;
380 +
381 + if(msBlk->swap) {
382 + squashfs_fragment_entry sfragment_entry;
383 +
384 + if(!squashfs_get_cached_block(s, (char *) &sfragment_entry, start_block, offset,
385 + sizeof(sfragment_entry), &start_block, &offset))
386 + return 0;
387 + SQUASHFS_SWAP_FRAGMENT_ENTRY(&fragment_entry, &sfragment_entry);
388 + } else
389 + if(!squashfs_get_cached_block(s, (char *) &fragment_entry, start_block, offset,
390 + sizeof(fragment_entry), &start_block, &offset))
391 + return 0;
392 +
393 + *fragment_start_block = fragment_entry.start_block;
394 + *fragment_size = fragment_entry.size;
395 +
396 + return 1;
397 +}
398 +
399 +
400 +void release_cached_fragment(squashfs_sb_info *msBlk, struct squashfs_fragment_cache *fragment)
401 +{
402 + down(&msBlk->fragment_mutex);
403 + fragment->locked --;
404 + wake_up(&msBlk->fragment_wait_queue);
405 + up(&msBlk->fragment_mutex);
406 +}
407 +
408 +
409 +struct squashfs_fragment_cache *get_cached_fragment(struct super_block *s, unsigned int start_block, int length)
410 +{
411 + int i, n;
412 + squashfs_sb_info *msBlk = &s->u.squashfs_sb;
413 +
414 + for(;;) {
415 + down(&msBlk->fragment_mutex);
416 + for(i = 0; i < SQUASHFS_CACHED_FRAGMENTS && msBlk->fragment[i].block != start_block; i++);
417 + if(i == SQUASHFS_CACHED_FRAGMENTS) {
418 + for(i = msBlk->next_fragment, n = SQUASHFS_CACHED_FRAGMENTS;
419 + n && msBlk->fragment[i].locked; n--, i = (i + 1) % SQUASHFS_CACHED_FRAGMENTS);
420 +
421 + if(n == 0) {
422 + up(&msBlk->fragment_mutex);
423 + sleep_on(&msBlk->fragment_wait_queue);
424 + continue;
425 + }
426 + msBlk->next_fragment = (msBlk->next_fragment + 1) % SQUASHFS_CACHED_FRAGMENTS;
427 +
428 + if(msBlk->fragment[i].data == NULL)
429 + if(!(msBlk->fragment[i].data = (unsigned char *)
430 + kmalloc(SQUASHFS_FILE_MAX_SIZE, GFP_KERNEL))) {
431 + ERROR("Failed to allocate fragment cache block\n");
432 + up(&msBlk->fragment_mutex);
433 + return NULL;
434 + }
435 +
436 + msBlk->fragment[i].block = SQUASHFS_INVALID_BLK;
437 + msBlk->fragment[i].locked = 1;
438 + up(&msBlk->fragment_mutex);
439 + if(!(msBlk->fragment[i].length = read_data(s, msBlk->fragment[i].data, start_block, length,
440 + NULL))) {
441 + ERROR("Unable to read fragment cache block [%x]\n", start_block);
442 + msBlk->fragment[i].locked = 0;
443 + return NULL;
444 + }
445 + msBlk->fragment[i].block = start_block;
446 + TRACE("New fragment %d, start block %d, locked %d\n", i, msBlk->fragment[i].block, msBlk->fragment[i].locked);
447 + return &msBlk->fragment[i];
448 + }
449 +
450 + msBlk->fragment[i].locked ++;
451 + up(&msBlk->fragment_mutex);
452 +
453 + TRACE("Got fragment %d, start block %d, locked %d\n", i, msBlk->fragment[i].block, msBlk->fragment[i].locked);
454 + return &msBlk->fragment[i];
455 + }
456 +}
457 +
458 +
459 +#ifdef SQUASHFS_1_0_COMPATIBILITY
460 +static struct inode *squashfs_iget_1(struct super_block *s, squashfs_inode inode)
461 +{
462 + struct inode *i = new_inode(s);
463 + squashfs_sb_info *msBlk = &s->u.squashfs_sb;
464 + squashfs_super_block *sBlk = &msBlk->sBlk;
465 + unsigned int block = SQUASHFS_INODE_BLK(inode) + sBlk->inode_table_start;
466 + unsigned int offset = SQUASHFS_INODE_OFFSET(inode);
467 + unsigned int next_block, next_offset;
468 + squashfs_base_inode_header_1 inodeb;
469 +
470 + TRACE("Entered squashfs_iget_1\n");
471 +
472 + if(msBlk->swap) {
473 + squashfs_base_inode_header_1 sinodeb;
474 +
475 + if(!squashfs_get_cached_block(s, (char *) &sinodeb, block, offset,
476 + sizeof(sinodeb), &next_block, &next_offset))
477 + goto failed_read;
478 + SQUASHFS_SWAP_BASE_INODE_HEADER_1(&inodeb, &sinodeb, sizeof(sinodeb));
479 + } else
480 + if(!squashfs_get_cached_block(s, (char *) &inodeb, block, offset,
481 + sizeof(inodeb), &next_block, &next_offset))
482 + goto failed_read;
483 +
484 + i->i_nlink = 1;
485 +
486 + i->i_mtime = sBlk->mkfs_time;
487 + i->i_atime = sBlk->mkfs_time;
488 + i->i_ctime = sBlk->mkfs_time;
489 +
490 + if(inodeb.inode_type != SQUASHFS_IPC_TYPE)
491 + i->i_uid = msBlk->uid[((inodeb.inode_type - 1) / SQUASHFS_TYPES) * 16 + inodeb.uid];
492 + i->i_ino = SQUASHFS_MK_VFS_INODE(block - sBlk->inode_table_start, offset);
493 +
494 + i->i_mode = inodeb.mode;
495 +
496 + switch(inodeb.inode_type == SQUASHFS_IPC_TYPE ? SQUASHFS_IPC_TYPE : (inodeb.inode_type - 1) % SQUASHFS_TYPES + 1) {
497 + case SQUASHFS_FILE_TYPE: {
498 + squashfs_reg_inode_header_1 inodep;
499 +
500 + if(msBlk->swap) {
501 + squashfs_reg_inode_header_1 sinodep;
502 +
503 + if(!squashfs_get_cached_block(s, (char *) &sinodep, block, offset, sizeof(sinodep),
504 + &next_block, &next_offset))
505 + goto failed_read;
506 + SQUASHFS_SWAP_REG_INODE_HEADER_1(&inodep, &sinodep);
507 + } else
508 + if(!squashfs_get_cached_block(s, (char *) &inodep, block, offset, sizeof(inodep),
509 + &next_block, &next_offset))
510 + goto failed_read;
511 +
512 + i->i_size = inodep.file_size;
513 + i->i_fop = &generic_ro_fops;
514 + if(sBlk->block_size > 4096)
515 + i->i_data.a_ops = &squashfs_aops;
516 + else if(sBlk->block_size == 4096)
517 + i->i_data.a_ops = &squashfs_aops_4K;
518 + else
519 + i->i_data.a_ops = &squashfs_aops_lessthan4K;
520 + i->i_mode |= S_IFREG;
521 + i->i_mtime = inodep.mtime;
522 + i->i_atime = inodep.mtime;
523 + i->i_ctime = inodep.mtime;
524 + i->i_blocks = ((i->i_size - 1) >> 9) + 1;
525 + i->i_blksize = PAGE_CACHE_SIZE;
526 + i->u.squashfs_i.u.s1.fragment_start_block = SQUASHFS_INVALID_BLK;
527 + i->u.squashfs_i.u.s1.fragment_offset = 0;
528 + i->u.squashfs_i.start_block = inodep.start_block;
529 + i->u.squashfs_i.block_list_start = next_block;
530 + i->u.squashfs_i.offset = next_offset;
531 + TRACE("File inode %x:%x, start_block %x, block_list_start %x, offset %x\n",
532 + SQUASHFS_INODE_BLK(inode), offset, inodep.start_block, next_block, next_offset);
533 + break;
534 + }
535 + case SQUASHFS_DIR_TYPE: {
536 + squashfs_dir_inode_header_1 inodep;
537 +
538 + if(msBlk->swap) {
539 + squashfs_dir_inode_header_1 sinodep;
540 +
541 + if(!squashfs_get_cached_block(s, (char *) &sinodep, block, offset, sizeof(sinodep),
542 + &next_block, &next_offset))
543 + goto failed_read;
544 + SQUASHFS_SWAP_DIR_INODE_HEADER_1(&inodep, &sinodep);
545 + } else
546 + if(!squashfs_get_cached_block(s, (char *) &inodep, block, offset, sizeof(inodep),
547 + &next_block, &next_offset))
548 + goto failed_read;
549 +
550 + i->i_size = inodep.file_size;
551 + i->i_op = &squashfs_dir_inode_ops;
552 + i->i_fop = &squashfs_dir_ops;
553 + i->i_mode |= S_IFDIR;
554 + i->i_mtime = inodep.mtime;
555 + i->i_atime = inodep.mtime;
556 + i->i_ctime = inodep.mtime;
557 + i->u.squashfs_i.start_block = inodep.start_block;
558 + i->u.squashfs_i.offset = inodep.offset;
559 + i->u.squashfs_i.u.s2.directory_index_count = 0;
560 + TRACE("Directory inode %x:%x, start_block %x, offset %x\n", SQUASHFS_INODE_BLK(inode), offset,
561 + inodep.start_block, inodep.offset);
562 + break;
563 + }
564 + case SQUASHFS_SYMLINK_TYPE: {
565 + squashfs_symlink_inode_header_1 inodep;
566 +
567 + if(msBlk->swap) {
568 + squashfs_symlink_inode_header_1 sinodep;
569 +
570 + if(!squashfs_get_cached_block(s, (char *) &sinodep, block, offset, sizeof(sinodep),
571 + &next_block, &next_offset))
572 + goto failed_read;
573 + SQUASHFS_SWAP_SYMLINK_INODE_HEADER_1(&inodep, &sinodep);
574 + } else
575 + if(!squashfs_get_cached_block(s, (char *) &inodep, block, offset, sizeof(inodep),
576 + &next_block, &next_offset))
577 + goto failed_read;
578 +
579 + i->i_size = inodep.symlink_size;
580 + i->i_op = &page_symlink_inode_operations;
581 + i->i_data.a_ops = &squashfs_symlink_aops;
582 + i->i_mode |= S_IFLNK;
583 + i->u.squashfs_i.start_block = next_block;
584 + i->u.squashfs_i.offset = next_offset;
585 + TRACE("Symbolic link inode %x:%x, start_block %x, offset %x\n",
586 + SQUASHFS_INODE_BLK(inode), offset, next_block, next_offset);
587 + break;
588 + }
589 + case SQUASHFS_BLKDEV_TYPE:
590 + case SQUASHFS_CHRDEV_TYPE: {
591 + squashfs_dev_inode_header_1 inodep;
592 +
593 + if(msBlk->swap) {
594 + squashfs_dev_inode_header_1 sinodep;
595 +
596 + if(!squashfs_get_cached_block(s, (char *) &sinodep, block, offset, sizeof(sinodep),
597 + &next_block, &next_offset))
598 + goto failed_read;
599 + SQUASHFS_SWAP_DEV_INODE_HEADER_1(&inodep, &sinodep);
600 + } else
601 + if(!squashfs_get_cached_block(s, (char *) &inodep, block, offset, sizeof(inodep),
602 + &next_block, &next_offset))
603 + goto failed_read;
604 +
605 + i->i_size = 0;
606 + i->i_mode |= (inodeb.inode_type == SQUASHFS_CHRDEV_TYPE) ? S_IFCHR : S_IFBLK;
607 + init_special_inode(i, i->i_mode, inodep.rdev);
608 + TRACE("Device inode %x:%x, rdev %x\n", SQUASHFS_INODE_BLK(inode), offset, inodep.rdev);
609 + break;
610 + }
611 + case SQUASHFS_IPC_TYPE: {
612 + squashfs_ipc_inode_header_1 inodep;
613 +
614 + if(msBlk->swap) {
615 + squashfs_ipc_inode_header_1 sinodep;
616 +
617 + if(!squashfs_get_cached_block(s, (char *) &sinodep, block, offset, sizeof(sinodep),
618 + &next_block, &next_offset))
619 + goto failed_read;
620 + SQUASHFS_SWAP_IPC_INODE_HEADER_1(&inodep, &sinodep);
621 + } else
622 + if(!squashfs_get_cached_block(s, (char *) &inodep, block, offset, sizeof(inodep),
623 + &next_block, &next_offset))
624 + goto failed_read;
625 +
626 + i->i_size = 0;
627 + i->i_mode |= (inodep.type == SQUASHFS_FIFO_TYPE) ? S_IFIFO : S_IFSOCK;
628 + i->i_uid = msBlk->uid[inodep.offset * 16 + inodeb.uid];
629 + init_special_inode(i, i->i_mode, 0);
630 + break;
631 + }
632 + default:
633 + ERROR("Unknown inode type %d in squashfs_iget!\n", inodeb.inode_type);
634 + goto failed_read1;
635 + }
636 +
637 + if(inodeb.guid == 15)
638 + i->i_gid = i->i_uid;
639 + else
640 + i->i_gid = msBlk->guid[inodeb.guid];
641 +
642 + insert_inode_hash(i);
643 + return i;
644 +
645 +failed_read:
646 + ERROR("Unable to read inode [%x:%x]\n", block, offset);
647 +
648 +failed_read1:
649 + return NULL;
650 +}
651 +#endif
652 +
653 +
654 +static struct inode *squashfs_iget(struct super_block *s, squashfs_inode inode)
655 +{
656 + struct inode *i = new_inode(s);
657 + squashfs_sb_info *msBlk = &s->u.squashfs_sb;
658 + squashfs_super_block *sBlk = &msBlk->sBlk;
659 + unsigned int block = SQUASHFS_INODE_BLK(inode) + sBlk->inode_table_start;
660 + unsigned int offset = SQUASHFS_INODE_OFFSET(inode);
661 + unsigned int next_block, next_offset;
662 + squashfs_base_inode_header inodeb;
663 +
664 + TRACE("Entered squashfs_iget\n");
665 +
666 + if(msBlk->swap) {
667 + squashfs_base_inode_header sinodeb;
668 +
669 + if(!squashfs_get_cached_block(s, (char *) &sinodeb, block, offset,
670 + sizeof(sinodeb), &next_block, &next_offset))
671 + goto failed_read;
672 + SQUASHFS_SWAP_BASE_INODE_HEADER(&inodeb, &sinodeb, sizeof(sinodeb));
673 + } else
674 + if(!squashfs_get_cached_block(s, (char *) &inodeb, block, offset,
675 + sizeof(inodeb), &next_block, &next_offset))
676 + goto failed_read;
677 +
678 + i->i_nlink = 1;
679 +
680 + i->i_mtime = sBlk->mkfs_time;
681 + i->i_atime = sBlk->mkfs_time;
682 + i->i_ctime = sBlk->mkfs_time;
683 +
684 + i->i_uid = msBlk->uid[inodeb.uid];
685 + i->i_ino = SQUASHFS_MK_VFS_INODE(block - sBlk->inode_table_start, offset);
686 +
687 + i->i_mode = inodeb.mode;
688 +
689 + switch(inodeb.inode_type) {
690 + case SQUASHFS_FILE_TYPE: {
691 + squashfs_reg_inode_header inodep;
692 +
693 + if(msBlk->swap) {
694 + squashfs_reg_inode_header sinodep;
695 +
696 + if(!squashfs_get_cached_block(s, (char *) &sinodep, block, offset, sizeof(sinodep),
697 + &next_block, &next_offset))
698 + goto failed_read;
699 + SQUASHFS_SWAP_REG_INODE_HEADER(&inodep, &sinodep);
700 + } else
701 + if(!squashfs_get_cached_block(s, (char *) &inodep, block, offset, sizeof(inodep),
702 + &next_block, &next_offset))
703 + goto failed_read;
704 +
705 + i->u.squashfs_i.u.s1.fragment_start_block = SQUASHFS_INVALID_BLK;
706 + if(inodep.fragment != SQUASHFS_INVALID_BLK && !get_fragment_location(s, inodep.fragment,
707 + &i->u.squashfs_i.u.s1.fragment_start_block, &i->u.squashfs_i.u.s1.fragment_size))
708 + goto failed_read;
709 +
710 + i->u.squashfs_i.u.s1.fragment_offset = inodep.offset;
711 + i->i_size = inodep.file_size;
712 + i->i_fop = &generic_ro_fops;
713 + if(sBlk->block_size > 4096)
714 + i->i_data.a_ops = &squashfs_aops;
715 + else
716 + i->i_data.a_ops = &squashfs_aops_4K;
717 + i->i_mode |= S_IFREG;
718 + i->i_mtime = inodep.mtime;
719 + i->i_atime = inodep.mtime;
720 + i->i_ctime = inodep.mtime;
721 + i->i_blocks = ((i->i_size - 1) >> 9) + 1;
722 + i->i_blksize = PAGE_CACHE_SIZE;
723 + i->u.squashfs_i.start_block = inodep.start_block;
724 + i->u.squashfs_i.block_list_start = next_block;
725 + i->u.squashfs_i.offset = next_offset;
726 + TRACE("File inode %x:%x, start_block %x, block_list_start %x, offset %x fragment_index %x fragment_offset %x\n",
727 + SQUASHFS_INODE_BLK(inode), offset, inodep.start_block, next_block, next_offset, inodep.fragment, inodep.offset);
728 + break;
729 + }
730 + case SQUASHFS_DIR_TYPE: {
731 + squashfs_dir_inode_header inodep;
732 +
733 + if(msBlk->swap) {
734 + squashfs_dir_inode_header sinodep;
735 +
736 + if(!squashfs_get_cached_block(s, (char *) &sinodep, block, offset, sizeof(sinodep),
737 + &next_block, &next_offset))
738 + goto failed_read;
739 + SQUASHFS_SWAP_DIR_INODE_HEADER(&inodep, &sinodep);
740 + } else
741 + if(!squashfs_get_cached_block(s, (char *) &inodep, block, offset, sizeof(inodep),
742 + &next_block, &next_offset))
743 + goto failed_read;
744 +
745 + i->i_size = inodep.file_size;
746 + i->i_op = &squashfs_dir_inode_ops;
747 + i->i_fop = &squashfs_dir_ops;
748 + i->i_mode |= S_IFDIR;
749 + i->i_mtime = inodep.mtime;
750 + i->i_atime = inodep.mtime;
751 + i->i_ctime = inodep.mtime;
752 + i->u.squashfs_i.start_block = inodep.start_block;
753 + i->u.squashfs_i.offset = inodep.offset;
754 + i->u.squashfs_i.u.s2.directory_index_count = 0;
755 + TRACE("Directory inode %x:%x, start_block %x, offset %x\n", SQUASHFS_INODE_BLK(inode), offset,
756 + inodep.start_block, inodep.offset);
757 + break;
758 + }
759 + case SQUASHFS_LDIR_TYPE: {
760 + squashfs_ldir_inode_header inodep;
761 +
762 + if(msBlk->swap) {
763 + squashfs_ldir_inode_header sinodep;
764 +
765 + if(!squashfs_get_cached_block(s, (char *) &sinodep, block, offset, sizeof(sinodep),
766 + &next_block, &next_offset))
767 + goto failed_read;
768 + SQUASHFS_SWAP_LDIR_INODE_HEADER(&inodep, &sinodep);
769 + } else
770 + if(!squashfs_get_cached_block(s, (char *) &inodep, block, offset, sizeof(inodep),
771 + &next_block, &next_offset))
772 + goto failed_read;
773 +
774 + i->i_size = inodep.file_size;
775 + i->i_op = &squashfs_dir_inode_ops;
776 + i->i_fop = &squashfs_dir_ops;
777 + i->i_mode |= S_IFDIR;
778 + i->i_mtime = inodep.mtime;
779 + i->i_atime = inodep.mtime;
780 + i->i_ctime = inodep.mtime;
781 + i->u.squashfs_i.start_block = inodep.start_block;
782 + i->u.squashfs_i.offset = inodep.offset;
783 + i->u.squashfs_i.u.s2.directory_index_start = next_block;
784 + i->u.squashfs_i.u.s2.directory_index_offset = next_offset;
785 + i->u.squashfs_i.u.s2.directory_index_count = inodep.i_count;
786 + TRACE("Long directory inode %x:%x, start_block %x, offset %x\n", SQUASHFS_INODE_BLK(inode), offset,
787 + inodep.start_block, inodep.offset);
788 + break;
789 + }
790 + case SQUASHFS_SYMLINK_TYPE: {
791 + squashfs_symlink_inode_header inodep;
792 +
793 + if(msBlk->swap) {
794 + squashfs_symlink_inode_header sinodep;
795 +
796 + if(!squashfs_get_cached_block(s, (char *) &sinodep, block, offset, sizeof(sinodep),
797 + &next_block, &next_offset))
798 + goto failed_read;
799 + SQUASHFS_SWAP_SYMLINK_INODE_HEADER(&inodep, &sinodep);
800 + } else
801 + if(!squashfs_get_cached_block(s, (char *) &inodep, block, offset, sizeof(inodep),
802 + &next_block, &next_offset))
803 + goto failed_read;
804 +
805 + i->i_size = inodep.symlink_size;
806 + i->i_op = &page_symlink_inode_operations;
807 + i->i_data.a_ops = &squashfs_symlink_aops;
808 + i->i_mode |= S_IFLNK;
809 + i->u.squashfs_i.start_block = next_block;
810 + i->u.squashfs_i.offset = next_offset;
811 + TRACE("Symbolic link inode %x:%x, start_block %x, offset %x\n",
812 + SQUASHFS_INODE_BLK(inode), offset, next_block, next_offset);
813 + break;
814 + }
815 + case SQUASHFS_BLKDEV_TYPE:
816 + case SQUASHFS_CHRDEV_TYPE: {
817 + squashfs_dev_inode_header inodep;
818 +
819 + if(msBlk->swap) {
820 + squashfs_dev_inode_header sinodep;
821 +
822 + if(!squashfs_get_cached_block(s, (char *) &sinodep, block, offset, sizeof(sinodep),
823 + &next_block, &next_offset))
824 + goto failed_read;
825 + SQUASHFS_SWAP_DEV_INODE_HEADER(&inodep, &sinodep);
826 + } else
827 + if(!squashfs_get_cached_block(s, (char *) &inodep, block, offset, sizeof(inodep),
828 + &next_block, &next_offset))
829 + goto failed_read;
830 +
831 + i->i_size = 0;
832 + i->i_mode |= (inodeb.inode_type == SQUASHFS_CHRDEV_TYPE) ? S_IFCHR : S_IFBLK;
833 + init_special_inode(i, i->i_mode, inodep.rdev);
834 + TRACE("Device inode %x:%x, rdev %x\n", SQUASHFS_INODE_BLK(inode), offset, inodep.rdev);
835 + break;
836 + }
837 + case SQUASHFS_FIFO_TYPE:
838 + case SQUASHFS_SOCKET_TYPE: {
839 + i->i_size = 0;
840 + i->i_mode |= (inodeb.inode_type == SQUASHFS_FIFO_TYPE) ? S_IFIFO : S_IFSOCK;
841 + init_special_inode(i, i->i_mode, 0);
842 + break;
843 + }
844 + default:
845 + ERROR("Unknown inode type %d in squashfs_iget!\n", inodeb.inode_type);
846 + goto failed_read1;
847 + }
848 +
849 + if(inodeb.guid == SQUASHFS_GUIDS)
850 + i->i_gid = i->i_uid;
851 + else
852 + i->i_gid = msBlk->guid[inodeb.guid];
853 +
854 + insert_inode_hash(i);
855 + return i;
856 +
857 +failed_read:
858 + ERROR("Unable to read inode [%x:%x]\n", block, offset);
859 +
860 +failed_read1:
861 + return NULL;
862 +}
863 +
864 +
865 +static struct super_block *squashfs_read_super(struct super_block *s,
866 + void *data, int silent)
867 +{
868 + kdev_t dev = s->s_dev;
869 + squashfs_sb_info *msBlk = &s->u.squashfs_sb;
870 + squashfs_super_block *sBlk = &msBlk->sBlk;
871 + int i;
872 +
873 + TRACE("Entered squashfs_read_superblock\n");
874 +
875 + msBlk->devblksize = get_hardsect_size(dev);
876 + if(msBlk->devblksize < BLOCK_SIZE)
877 + msBlk->devblksize = BLOCK_SIZE;
878 + msBlk->devblksize_log2 = ffz(~msBlk->devblksize);
879 + set_blocksize(dev, msBlk->devblksize);
880 + s->s_blocksize = msBlk->devblksize;
881 + s->s_blocksize_bits = msBlk->devblksize_log2;
882 +
883 + init_MUTEX(&msBlk->read_page_mutex);
884 + init_MUTEX(&msBlk->block_cache_mutex);
885 + init_MUTEX(&msBlk->fragment_mutex);
886 +
887 + init_waitqueue_head(&msBlk->waitq);
888 + init_waitqueue_head(&msBlk->fragment_wait_queue);
889 +
890 + if(!read_data(s, (char *) sBlk, SQUASHFS_START, sizeof(squashfs_super_block) | SQUASHFS_COMPRESSED_BIT_BLOCK, NULL)) {
891 + SERROR("unable to read superblock\n");
892 + goto failed_mount;
893 + }
894 +
895 + /* Check it is a SQUASHFS superblock */
896 + msBlk->swap = 0;
897 + if((s->s_magic = sBlk->s_magic) != SQUASHFS_MAGIC) {
898 + if(sBlk->s_magic == SQUASHFS_MAGIC_SWAP) {
899 + squashfs_super_block sblk;
900 + WARNING("Mounting a different endian SQUASHFS filesystem on %s\n", bdevname(dev));
901 + SQUASHFS_SWAP_SUPER_BLOCK(&sblk, sBlk);
902 + memcpy(sBlk, &sblk, sizeof(squashfs_super_block));
903 + msBlk->swap = 1;
904 + } else {
905 + SERROR("Can't find a SQUASHFS superblock on %s\n", bdevname(dev));
906 + goto failed_mount;
907 + }
908 + }
909 +
910 + /* Check the MAJOR & MINOR versions */
911 +#ifdef SQUASHFS_1_0_COMPATIBILITY
912 + if((sBlk->s_major != 1) && (sBlk->s_major != 2 || sBlk->s_minor > SQUASHFS_MINOR)) {
913 + SERROR("Major/Minor mismatch, filesystem is (%d:%d), I support (1 : x) or (2 : <= %d)\n",
914 + sBlk->s_major, sBlk->s_minor, SQUASHFS_MINOR);
915 + goto failed_mount;
916 + }
917 + if(sBlk->s_major == 1)
918 + sBlk->block_size = sBlk->block_size_1;
919 +#else
920 + if(sBlk->s_major != SQUASHFS_MAJOR || sBlk->s_minor > SQUASHFS_MINOR) {
921 + SERROR("Major/Minor mismatch, filesystem is (%d:%d), I support (%d: <= %d)\n",
922 + sBlk->s_major, sBlk->s_minor, SQUASHFS_MAJOR, SQUASHFS_MINOR);
923 + goto failed_mount;
924 + }
925 +#endif
926 +
927 + TRACE("Found valid superblock on %s\n", bdevname(dev));
928 + TRACE("Inodes are %scompressed\n", SQUASHFS_UNCOMPRESSED_INODES(sBlk->flags) ? "un" : "");
929 + TRACE("Data is %scompressed\n", SQUASHFS_UNCOMPRESSED_DATA(sBlk->flags) ? "un" : "");
930 + TRACE("Check data is %s present in the filesystem\n", SQUASHFS_CHECK_DATA(sBlk->flags) ? "" : "not");
931 + TRACE("Filesystem size %d bytes\n", sBlk->bytes_used);
932 + TRACE("Block size %d\n", sBlk->block_size);
933 + TRACE("Number of inodes %d\n", sBlk->inodes);
934 + if(sBlk->s_major > 1)
935 + TRACE("Number of fragments %d\n", sBlk->fragments);
936 + TRACE("Number of uids %d\n", sBlk->no_uids);
937 + TRACE("Number of gids %d\n", sBlk->no_guids);
938 + TRACE("sBlk->inode_table_start %x\n", sBlk->inode_table_start);
939 + TRACE("sBlk->directory_table_start %x\n", sBlk->directory_table_start);
940 + if(sBlk->s_major > 1)
941 + TRACE("sBlk->fragment_table_start %x\n", sBlk->fragment_table_start);
942 + TRACE("sBlk->uid_start %x\n", sBlk->uid_start);
943 +
944 + s->s_flags |= MS_RDONLY;
945 + s->s_op = &squashfs_ops;
946 +
947 + /* Init inode_table block pointer array */
948 + if(!(msBlk->block_cache = (squashfs_cache *) kmalloc(sizeof(squashfs_cache) * SQUASHFS_CACHED_BLKS, GFP_KERNEL))) {
949 + ERROR("Failed to allocate block cache\n");
950 + goto failed_mount;
951 + }
952 +
953 + for(i = 0; i < SQUASHFS_CACHED_BLKS; i++)
954 + msBlk->block_cache[i].block = SQUASHFS_INVALID_BLK;
955 +
956 + msBlk->next_cache = 0;
957 +
958 + /* Allocate read_data block */
959 + msBlk->read_size = (sBlk->block_size < SQUASHFS_METADATA_SIZE) ? SQUASHFS_METADATA_SIZE : sBlk->block_size;
960 + if(!(msBlk->read_data = (char *) kmalloc(msBlk->read_size, GFP_KERNEL))) {
961 + ERROR("Failed to allocate read_data block\n");
962 + goto failed_mount1;
963 + }
964 +
965 + /* Allocate read_page block */
966 + if(sBlk->block_size > PAGE_CACHE_SIZE) {
967 + if(!(msBlk->read_page = (char *) kmalloc(sBlk->block_size, GFP_KERNEL))) {
968 + ERROR("Failed to allocate read_page block\n");
969 + goto failed_mount2;
970 + }
971 + } else
972 + msBlk->read_page = NULL;
973 +
974 + /* Allocate uid and gid tables */
975 + if(!(msBlk->uid = (squashfs_uid *) kmalloc((sBlk->no_uids +
976 + sBlk->no_guids) * sizeof(squashfs_uid), GFP_KERNEL))) {
977 + ERROR("Failed to allocate uid/gid table\n");
978 + goto failed_mount3;
979 + }
980 + msBlk->guid = msBlk->uid + sBlk->no_uids;
981 +
982 + if(msBlk->swap) {
983 + squashfs_uid suid[sBlk->no_uids + sBlk->no_guids];
984 +
985 + if(!read_data(s, (char *) &suid, sBlk->uid_start, ((sBlk->no_uids + sBlk->no_guids) *
986 + sizeof(squashfs_uid)) | SQUASHFS_COMPRESSED_BIT_BLOCK, NULL)) {
987 + SERROR("unable to read uid/gid table\n");
988 + goto failed_mount4;
989 + }
990 + SQUASHFS_SWAP_DATA(msBlk->uid, suid, (sBlk->no_uids + sBlk->no_guids), (sizeof(squashfs_uid) * 8));
991 + } else
992 + if(!read_data(s, (char *) msBlk->uid, sBlk->uid_start, ((sBlk->no_uids + sBlk->no_guids) *
993 + sizeof(squashfs_uid)) | SQUASHFS_COMPRESSED_BIT_BLOCK, NULL)) {
994 + SERROR("unable to read uid/gid table\n");
995 + goto failed_mount4;
996 + }
997 +
998 +
999 +#ifdef SQUASHFS_1_0_COMPATIBILITY
1000 + if(sBlk->s_major == 1) {
1001 + msBlk->iget = squashfs_iget_1;
1002 + msBlk->read_blocklist = read_blocklist_1;
1003 + msBlk->fragment = NULL;
1004 + msBlk->fragment_index = NULL;
1005 + goto allocate_root;
1006 + }
1007 +#endif
1008 + msBlk->iget = squashfs_iget;
1009 + msBlk->read_blocklist = read_blocklist;
1010 +
1011 + if(!(msBlk->fragment = (struct squashfs_fragment_cache *) kmalloc(sizeof(struct squashfs_fragment_cache) * SQUASHFS_CACHED_FRAGMENTS, GFP_KERNEL))) {
1012 + ERROR("Failed to allocate fragment block cache\n");
1013 + goto failed_mount4;
1014 + }
1015 +
1016 + for(i = 0; i < SQUASHFS_CACHED_FRAGMENTS; i++) {
1017 + msBlk->fragment[i].locked = 0;
1018 + msBlk->fragment[i].block = SQUASHFS_INVALID_BLK;
1019 + msBlk->fragment[i].data = NULL;
1020 + }
1021 +
1022 + msBlk->next_fragment = 0;
1023 +
1024 + /* Allocate fragment index table */
1025 + if(!(msBlk->fragment_index = (squashfs_fragment_index *) kmalloc(SQUASHFS_FRAGMENT_INDEX_BYTES(sBlk->fragments), GFP_KERNEL))) {
1026 + ERROR("Failed to allocate uid/gid table\n");
1027 + goto failed_mount5;
1028 + }
1029 +
1030 + if(SQUASHFS_FRAGMENT_INDEX_BYTES(sBlk->fragments) &&
1031 + !read_data(s, (char *) msBlk->fragment_index, sBlk->fragment_table_start,
1032 + SQUASHFS_FRAGMENT_INDEX_BYTES(sBlk->fragments) | SQUASHFS_COMPRESSED_BIT_BLOCK, NULL)) {
1033 + SERROR("unable to read fragment index table\n");
1034 + goto failed_mount6;
1035 + }
1036 +
1037 + if(msBlk->swap) {
1038 + int i;
1039 + squashfs_fragment_index fragment;
1040 +
1041 + for(i = 0; i < SQUASHFS_FRAGMENT_INDEXES(sBlk->fragments); i++) {
1042 + SQUASHFS_SWAP_FRAGMENT_INDEXES((&fragment), &msBlk->fragment_index[i], 1);
1043 + msBlk->fragment_index[i] = fragment;
1044 + }
1045 + }
1046 +
1047 +#ifdef SQUASHFS_1_0_COMPATIBILITY
1048 +allocate_root:
1049 +#endif
1050 + if(!(s->s_root = d_alloc_root((msBlk->iget)(s, sBlk->root_inode)))) {
1051 + ERROR("Root inode create failed\n");
1052 + goto failed_mount5;
1053 + }
1054 +
1055 + TRACE("Leaving squashfs_read_super\n");
1056 + return s;
1057 +
1058 +failed_mount6:
1059 + kfree(msBlk->fragment_index);
1060 +failed_mount5:
1061 + kfree(msBlk->fragment);
1062 +failed_mount4:
1063 + kfree(msBlk->uid);
1064 +failed_mount3:
1065 + kfree(msBlk->read_page);
1066 +failed_mount2:
1067 + kfree(msBlk->read_data);
1068 +failed_mount1:
1069 + kfree(msBlk->block_cache);
1070 +failed_mount:
1071 + return NULL;
1072 +}
1073 +
1074 +
1075 +static int squashfs_statfs(struct super_block *s, struct statfs *buf)
1076 +{
1077 + squashfs_super_block *sBlk = &s->u.squashfs_sb.sBlk;
1078 +
1079 + TRACE("Entered squashfs_statfs\n");
1080 + buf->f_type = SQUASHFS_MAGIC;
1081 + buf->f_bsize = sBlk->block_size;
1082 + buf->f_blocks = ((sBlk->bytes_used - 1) >> sBlk->block_log) + 1;
1083 + buf->f_bfree = buf->f_bavail = 0;
1084 + buf->f_files = sBlk->inodes;
1085 + buf->f_ffree = 0;
1086 + buf->f_namelen = SQUASHFS_NAME_LEN;
1087 + return 0;
1088 +}
1089 +
1090 +
1091 +static int squashfs_symlink_readpage(struct file *file, struct page *page)
1092 +{
1093 + struct inode *inode = page->mapping->host;
1094 + int index = page->index << PAGE_CACHE_SHIFT, length, bytes;
1095 + unsigned int block = inode->u.squashfs_i.start_block;
1096 + int offset = inode->u.squashfs_i.offset;
1097 + void *pageaddr = kmap(page);
1098 +
1099 + TRACE("Entered squashfs_symlink_readpage, page index %x, start block %x, offset %x\n",
1100 + (unsigned int) page->index, inode->u.squashfs_i.start_block, inode->u.squashfs_i.offset);
1101 +
1102 + for(length = 0; length < index; length += bytes) {
1103 + if(!(bytes = squashfs_get_cached_block(inode->i_sb, NULL, block, offset,
1104 + PAGE_CACHE_SIZE, &block, &offset))) {
1105 + ERROR("Unable to read symbolic link [%x:%x]\n", block, offset);
1106 + goto skip_read;
1107 + }
1108 + }
1109 +
1110 + if(length != index) {
1111 + ERROR("(squashfs_symlink_readpage) length != index\n");
1112 + bytes = 0;
1113 + goto skip_read;
1114 + }
1115 +
1116 + bytes = (inode->i_size - length) > PAGE_CACHE_SIZE ? PAGE_CACHE_SIZE : inode->i_size - length;
1117 + if(!(bytes = squashfs_get_cached_block(inode->i_sb, pageaddr, block, offset, bytes, &block, &offset)))
1118 + ERROR("Unable to read symbolic link [%x:%x]\n", block, offset);
1119 +
1120 +skip_read:
1121 + memset(pageaddr + bytes, 0, PAGE_CACHE_SIZE - bytes);
1122 + kunmap(page);
1123 + flush_dcache_page(page);
1124 + SetPageUptodate(page);
1125 + UnlockPage(page);
1126 +
1127 + return 0;
1128 +}
1129 +
1130 +
1131 +#define SIZE 256
1132 +
1133 +#ifdef SQUASHFS_1_0_COMPATIBILITY
1134 +static unsigned int read_blocklist_1(struct inode *inode, int index, int readahead_blks,
1135 + char *block_list, unsigned short **block_p, unsigned int *bsize)
1136 +{
1137 + squashfs_sb_info *msBlk = &inode->i_sb->u.squashfs_sb;
1138 + unsigned short *block_listp;
1139 + int i = 0;
1140 + int block_ptr = inode->u.squashfs_i.block_list_start;
1141 + int offset = inode->u.squashfs_i.offset;
1142 + unsigned int block = inode->u.squashfs_i.start_block;
1143 +
1144 + for(;;) {
1145 + int blocks = (index + readahead_blks - i);
1146 + if(blocks > (SIZE >> 1)) {
1147 + if((index - i) <= (SIZE >> 1))
1148 + blocks = index - i;
1149 + else
1150 + blocks = SIZE >> 1;
1151 + }
1152 +
1153 + if(msBlk->swap) {
1154 + unsigned char sblock_list[SIZE];
1155 + if(!squashfs_get_cached_block(inode->i_sb, (char *) sblock_list, block_ptr, offset, blocks << 1, &block_ptr, &offset)) {
1156 + ERROR("Unable to read block list [%d:%x]\n", block_ptr, offset);
1157 + return 0;
1158 + }
1159 + SQUASHFS_SWAP_SHORTS(((unsigned short *)block_list), ((unsigned short *)sblock_list), blocks);
1160 + } else
1161 + if(!squashfs_get_cached_block(inode->i_sb, (char *) block_list, block_ptr, offset, blocks << 1, &block_ptr, &offset)) {
1162 + ERROR("Unable to read block list [%d:%x]\n", block_ptr, offset);
1163 + return 0;
1164 + }
1165 + for(block_listp = (unsigned short *) block_list; i < index && blocks; i ++, block_listp ++, blocks --)
1166 + block += SQUASHFS_COMPRESSED_SIZE(*block_listp);
1167 + if(blocks >= readahead_blks)
1168 + break;
1169 + }
1170 +
1171 + if(bsize)
1172 + *bsize = SQUASHFS_COMPRESSED_SIZE(*block_listp) | (!SQUASHFS_COMPRESSED(*block_listp) ? SQUASHFS_COMPRESSED_BIT_BLOCK : 0);
1173 + else
1174 + *block_p = block_listp;
1175 + return block;
1176 +}
1177 +#endif
1178 +
1179 +
1180 +
1181 +static unsigned int read_blocklist(struct inode *inode, int index, int readahead_blks,
1182 + char *block_list, unsigned short **block_p, unsigned int *bsize)
1183 +{
1184 + squashfs_sb_info *msBlk = &inode->i_sb->u.squashfs_sb;
1185 + unsigned int *block_listp;
1186 + int i = 0;
1187 + int block_ptr = inode->u.squashfs_i.block_list_start;
1188 + int offset = inode->u.squashfs_i.offset;
1189 + unsigned int block = inode->u.squashfs_i.start_block;
1190 +
1191 + for(;;) {
1192 + int blocks = (index + readahead_blks - i);
1193 + if(blocks > (SIZE >> 2)) {
1194 + if((index - i) <= (SIZE >> 2))
1195 + blocks = index - i;
1196 + else
1197 + blocks = SIZE >> 2;
1198 + }
1199 +
1200 + if(msBlk->swap) {
1201 + unsigned char sblock_list[SIZE];
1202 + if(!squashfs_get_cached_block(inode->i_sb, (char *) sblock_list, block_ptr, offset, blocks << 2, &block_ptr, &offset)) {
1203 + ERROR("Unable to read block list [%d:%x]\n", block_ptr, offset);
1204 + return 0;
1205 + }
1206 + SQUASHFS_SWAP_INTS(((unsigned int *)block_list), ((unsigned int *)sblock_list), blocks);
1207 + } else
1208 + if(!squashfs_get_cached_block(inode->i_sb, (char *) block_list, block_ptr, offset, blocks << 2, &block_ptr, &offset)) {
1209 + ERROR("Unable to read block list [%d:%x]\n", block_ptr, offset);
1210 + return 0;
1211 + }
1212 + for(block_listp = (unsigned int *) block_list; i < index && blocks; i ++, block_listp ++, blocks --)
1213 + block += SQUASHFS_COMPRESSED_SIZE_BLOCK(*block_listp);
1214 + if(blocks >= readahead_blks)
1215 + break;
1216 + }
1217 +
1218 + *bsize = *block_listp;
1219 + return block;
1220 +}
1221 +
1222 +
1223 +static int squashfs_readpage(struct file *file, struct page *page)
1224 +{
1225 + struct inode *inode = page->mapping->host;
1226 + squashfs_sb_info *msBlk = &inode->i_sb->u.squashfs_sb;
1227 + squashfs_super_block *sBlk = &msBlk->sBlk;
1228 + unsigned char block_list[SIZE];
1229 + unsigned int bsize, block, i = 0, bytes = 0, byte_offset = 0;
1230 + int index = page->index >> (sBlk->block_log - PAGE_CACHE_SHIFT);
1231 + void *pageaddr = kmap(page);
1232 + struct squashfs_fragment_cache *fragment = NULL;
1233 + char *data_ptr = msBlk->read_page;
1234 +
1235 + int mask = (1 << (sBlk->block_log - PAGE_CACHE_SHIFT)) - 1;
1236 + int start_index = page->index & ~mask;
1237 + int end_index = start_index | mask;
1238 +
1239 + TRACE("Entered squashfs_readpage, page index %x, start block %x\n", (unsigned int) page->index,
1240 + inode->u.squashfs_i.start_block);
1241 +
1242 + if(page->index >= ((inode->i_size + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT)) {
1243 + goto skip_read;
1244 + }
1245 +
1246 + if(inode->u.squashfs_i.u.s1.fragment_start_block == SQUASHFS_INVALID_BLK || index < (inode->i_size >> sBlk->block_log)) {
1247 + if((block = (msBlk->read_blocklist)(inode, index, 1, block_list, NULL, &bsize)) == 0)
1248 + goto skip_read;
1249 +
1250 + down(&msBlk->read_page_mutex);
1251 + if(!(bytes = read_data(inode->i_sb, msBlk->read_page, block, bsize, NULL))) {
1252 + ERROR("Unable to read page, block %x, size %x\n", block, bsize);
1253 + up(&msBlk->read_page_mutex);
1254 + goto skip_read;
1255 + }
1256 + } else {
1257 + if((fragment = get_cached_fragment(inode->i_sb, inode->u.squashfs_i.u.s1.fragment_start_block, inode->u.squashfs_i.u.s1.fragment_size)) == NULL) {
1258 + ERROR("Unable to read page, block %x, size %x\n", inode->u.squashfs_i.u.s1.fragment_start_block, (int) inode->u.squashfs_i.u.s1.fragment_size);
1259 + goto skip_read;
1260 + }
1261 + bytes = inode->u.squashfs_i.u.s1.fragment_offset + (inode->i_size & (sBlk->block_size - 1));
1262 + byte_offset = inode->u.squashfs_i.u.s1.fragment_offset;
1263 + data_ptr = fragment->data;
1264 + }
1265 +
1266 + for(i = start_index; i <= end_index && byte_offset < bytes; i++, byte_offset += PAGE_CACHE_SIZE) {
1267 + struct page *push_page;
1268 + int available_bytes = (bytes - byte_offset) > PAGE_CACHE_SIZE ? PAGE_CACHE_SIZE : bytes - byte_offset;
1269 +
1270 + TRACE("bytes %d, i %d, byte_offset %d, available_bytes %d\n", bytes, i, byte_offset, available_bytes);
1271 +
1272 + if(i == page->index) {
1273 + memcpy(pageaddr, data_ptr + byte_offset, available_bytes);
1274 + memset(pageaddr + available_bytes, 0, PAGE_CACHE_SIZE - available_bytes);
1275 + kunmap(page);
1276 + flush_dcache_page(page);
1277 + SetPageUptodate(page);
1278 + UnlockPage(page);
1279 + } else if((push_page = grab_cache_page_nowait(page->mapping, i))) {
1280 + void *pageaddr = kmap(push_page);
1281 + memcpy(pageaddr, data_ptr + byte_offset, available_bytes);
1282 + memset(pageaddr + available_bytes, 0, PAGE_CACHE_SIZE - available_bytes);
1283 + kunmap(push_page);
1284 + flush_dcache_page(push_page);
1285 + SetPageUptodate(push_page);
1286 + UnlockPage(push_page);
1287 + page_cache_release(push_page);
1288 + }
1289 + }
1290 +
1291 + if(inode->u.squashfs_i.u.s1.fragment_start_block == SQUASHFS_INVALID_BLK || index < (inode->i_size >> sBlk->block_log))
1292 + up(&msBlk->read_page_mutex);
1293 + else
1294 + release_cached_fragment(msBlk, fragment);
1295 +
1296 + return 0;
1297 +
1298 +skip_read:
1299 + memset(pageaddr + bytes, 0, PAGE_CACHE_SIZE - bytes);
1300 + kunmap(page);
1301 + flush_dcache_page(page);
1302 + SetPageUptodate(page);
1303 + UnlockPage(page);
1304 +
1305 + return 0;
1306 +}
1307 +
1308 +
1309 +static int squashfs_readpage4K(struct file *file, struct page *page)
1310 +{
1311 + struct inode *inode = page->mapping->host;
1312 + squashfs_sb_info *msBlk = &inode->i_sb->u.squashfs_sb;
1313 + squashfs_super_block *sBlk = &msBlk->sBlk;
1314 + unsigned char block_list[SIZE];
1315 + unsigned int bsize, block, bytes = 0;
1316 + void *pageaddr = kmap(page);
1317 +
1318 + TRACE("Entered squashfs_readpage4K, page index %x, start block %x\n", (unsigned int) page->index,
1319 + inode->u.squashfs_i.start_block);
1320 +
1321 + if(page->index >= ((inode->i_size + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT)) {
1322 + goto skip_read;
1323 + }
1324 +
1325 + if(inode->u.squashfs_i.u.s1.fragment_start_block == SQUASHFS_INVALID_BLK || page->index < (inode->i_size >> sBlk->block_log)) {
1326 + block = (msBlk->read_blocklist)(inode, page->index, 1, block_list, NULL, &bsize);
1327 +
1328 + if(!(bytes = read_data(inode->i_sb, pageaddr, block, bsize, NULL)))
1329 + ERROR("Unable to read page, block %x, size %x\n", block, bsize);
1330 + } else {
1331 + struct squashfs_fragment_cache *fragment;
1332 +
1333 + if((fragment = get_cached_fragment(inode->i_sb, inode->u.squashfs_i.u.s1.fragment_start_block, inode->u.squashfs_i.u.s1.fragment_size)) == NULL)
1334 + ERROR("Unable to read page, block %x, size %x\n", inode->u.squashfs_i.u.s1.fragment_start_block, (int) inode->u.squashfs_i.u.s1.fragment_size);
1335 + else {
1336 + bytes = inode->i_size & (sBlk->block_size - 1);
1337 + memcpy(pageaddr, fragment->data + inode->u.squashfs_i.u.s1.fragment_offset, bytes);
1338 + release_cached_fragment(msBlk, fragment);
1339 + }
1340 + }
1341 +
1342 +skip_read:
1343 + memset(pageaddr + bytes, 0, PAGE_CACHE_SIZE - bytes);
1344 + kunmap(page);
1345 + flush_dcache_page(page);
1346 + SetPageUptodate(page);
1347 + UnlockPage(page);
1348 +
1349 + return 0;
1350 +}
1351 +
1352 +
1353 +#ifdef SQUASHFS_1_0_COMPATIBILITY
1354 +static int squashfs_readpage_lessthan4K(struct file *file, struct page *page)
1355 +{
1356 + struct inode *inode = page->mapping->host;
1357 + squashfs_sb_info *msBlk = &inode->i_sb->u.squashfs_sb;
1358 + squashfs_super_block *sBlk = &msBlk->sBlk;
1359 + unsigned char block_list[SIZE];
1360 + unsigned short *block_listp, block, bytes = 0;
1361 + int index = page->index << (PAGE_CACHE_SHIFT - sBlk->block_log);
1362 + int file_blocks = ((inode->i_size - 1) >> sBlk->block_log) + 1;
1363 + int readahead_blks = 1 << (PAGE_CACHE_SHIFT - sBlk->block_log);
1364 + void *pageaddr = kmap(page);
1365 +
1366 + int i_end = index + (1 << (PAGE_CACHE_SHIFT - sBlk->block_log));
1367 + int byte;
1368 +
1369 + TRACE("Entered squashfs_readpage_lessthan4K, page index %x, start block %x\n", (unsigned int) page->index,
1370 + inode->u.squashfs_i.start_block);
1371 +
1372 + block = read_blocklist_1(inode, index, readahead_blks, block_list, &block_listp, NULL);
1373 +
1374 + if(i_end > file_blocks)
1375 + i_end = file_blocks;
1376 +
1377 + while(index < i_end) {
1378 + int c_byte = !SQUASHFS_COMPRESSED(*block_listp) ? SQUASHFS_COMPRESSED_SIZE(*block_listp) | SQUASHFS_COMPRESSED_BIT_BLOCK : *block_listp;
1379 + if(!(byte = read_data(inode->i_sb, pageaddr, block, c_byte, NULL))) {
1380 + ERROR("Unable to read page, block %x, size %x\n", block, *block_listp);
1381 + goto skip_read;
1382 + }
1383 + block += SQUASHFS_COMPRESSED_SIZE(*block_listp);
1384 + pageaddr += byte;
1385 + bytes += byte;
1386 + index ++;
1387 + block_listp ++;
1388 + }
1389 +
1390 +skip_read:
1391 + memset(pageaddr, 0, PAGE_CACHE_SIZE - bytes);
1392 + kunmap(page);
1393 + flush_dcache_page(page);
1394 + SetPageUptodate(page);
1395 + UnlockPage(page);
1396 +
1397 + return 0;
1398 +}
1399 +#endif
1400 +
1401 +
1402 +static int get_dir_index_using_offset(struct super_block *s, unsigned int *next_block,
1403 + unsigned int *next_offset, unsigned int index_start, unsigned int index_offset,
1404 + int i_count, long long f_pos)
1405 +{
1406 + squashfs_sb_info *msBlk = &s->u.squashfs_sb;
1407 + squashfs_super_block *sBlk = &msBlk->sBlk;
1408 + int i, length = 0;
1409 + squashfs_dir_index index;
1410 +
1411 + TRACE("Entered get_dir_index_using_offset, i_count %d, f_pos %d\n", i_count, (unsigned int) f_pos);
1412 +
1413 + if(f_pos == 0)
1414 + return 0;
1415 +
1416 + for(i = 0; i < i_count; i++) {
1417 + if(msBlk->swap) {
1418 + squashfs_dir_index sindex;
1419 + squashfs_get_cached_block(s, (char *) &sindex, index_start, index_offset,
1420 + sizeof(sindex), &index_start, &index_offset);
1421 + SQUASHFS_SWAP_DIR_INDEX(&index, &sindex);
1422 + } else
1423 + squashfs_get_cached_block(s, (char *) &index, index_start, index_offset,
1424 + sizeof(index), &index_start, &index_offset);
1425 +
1426 + if(index.index > f_pos)
1427 + break;
1428 +
1429 + squashfs_get_cached_block(s, NULL, index_start, index_offset,
1430 + index.size + 1, &index_start, &index_offset);
1431 +
1432 + length = index.index;
1433 + *next_block = index.start_block + sBlk->directory_table_start;
1434 + }
1435 +
1436 + *next_offset = (length + *next_offset) % SQUASHFS_METADATA_SIZE;
1437 + return length;
1438 +}
1439 +
1440 +
1441 +static int get_dir_index_using_name(struct super_block *s, unsigned int *next_block,
1442 + unsigned int *next_offset, unsigned int index_start, unsigned int index_offset,
1443 + int i_count, const char *name, int size)
1444 +{
1445 + squashfs_sb_info *msBlk = &s->u.squashfs_sb;
1446 + squashfs_super_block *sBlk = &msBlk->sBlk;
1447 + int i, length = 0;
1448 + char buffer[sizeof(squashfs_dir_index) + SQUASHFS_NAME_LEN + 1];
1449 + squashfs_dir_index *index = (squashfs_dir_index *) buffer;
1450 + char str[SQUASHFS_NAME_LEN + 1];
1451 +
1452 + TRACE("Entered get_dir_index_using_name, i_count %d\n", i_count);
1453 +
1454 + strncpy(str, name, size);
1455 + str[size] = '\0';
1456 +
1457 + for(i = 0; i < i_count; i++) {
1458 + if(msBlk->swap) {
1459 + squashfs_dir_index sindex;
1460 + squashfs_get_cached_block(s, (char *) &sindex, index_start, index_offset,
1461 + sizeof(sindex), &index_start, &index_offset);
1462 + SQUASHFS_SWAP_DIR_INDEX(index, &sindex);
1463 + } else
1464 + squashfs_get_cached_block(s, (char *) index, index_start, index_offset,
1465 + sizeof(squashfs_dir_index), &index_start, &index_offset);
1466 +
1467 + squashfs_get_cached_block(s, index->name, index_start, index_offset,
1468 + index->size + 1, &index_start, &index_offset);
1469 +
1470 + index->name[index->size + 1] = '\0';
1471 +
1472 + if(strcmp(index->name, str) > 0)
1473 + break;
1474 +
1475 + length = index->index;
1476 + *next_block = index->start_block + sBlk->directory_table_start;
1477 + }
1478 +
1479 + *next_offset = (length + *next_offset) % SQUASHFS_METADATA_SIZE;
1480 + return length;
1481 +}
1482 +
1483 +
1484 +static int squashfs_readdir(struct file *file, void *dirent, filldir_t filldir)
1485 +{
1486 + struct inode *i = file->f_dentry->d_inode;
1487 + squashfs_sb_info *msBlk = &i->i_sb->u.squashfs_sb;
1488 + squashfs_super_block *sBlk = &msBlk->sBlk;
1489 + int next_block = i->u.squashfs_i.start_block + sBlk->directory_table_start, next_offset =
1490 + i->u.squashfs_i.offset, length = 0, dirs_read = 0, dir_count;
1491 + squashfs_dir_header dirh;
1492 + char buffer[sizeof(squashfs_dir_entry) + SQUASHFS_NAME_LEN + 1];
1493 + squashfs_dir_entry *dire = (squashfs_dir_entry *) buffer;
1494 +
1495 + TRACE("Entered squashfs_readdir [%x:%x]\n", next_block, next_offset);
1496 +
1497 + length = get_dir_index_using_offset(i->i_sb, &next_block, &next_offset, i->u.squashfs_i.u.s2.directory_index_start,
1498 + i->u.squashfs_i.u.s2.directory_index_offset, i->u.squashfs_i.u.s2.directory_index_count, file->f_pos);
1499 +
1500 + while(length < i->i_size) {
1501 + /* read directory header */
1502 + if(msBlk->swap) {
1503 + squashfs_dir_header sdirh;
1504 + if(!squashfs_get_cached_block(i->i_sb, (char *) &sdirh, next_block,
1505 + next_offset, sizeof(sdirh), &next_block, &next_offset))
1506 + goto failed_read;
1507 + length += sizeof(sdirh);
1508 + SQUASHFS_SWAP_DIR_HEADER(&dirh, &sdirh);
1509 + } else {
1510 + if(!squashfs_get_cached_block(i->i_sb, (char *) &dirh, next_block,
1511 + next_offset, sizeof(dirh), &next_block, &next_offset))
1512 + goto failed_read;
1513 + length += sizeof(dirh);
1514 + }
1515 +
1516 + dir_count = dirh.count + 1;
1517 + while(dir_count--) {
1518 + if(msBlk->swap) {
1519 + squashfs_dir_entry sdire;
1520 + if(!squashfs_get_cached_block(i->i_sb, (char *) &sdire, next_block,
1521 + next_offset, sizeof(sdire), &next_block, &next_offset))
1522 + goto failed_read;
1523 + length += sizeof(sdire);
1524 + SQUASHFS_SWAP_DIR_ENTRY(dire, &sdire);
1525 + } else {
1526 + if(!squashfs_get_cached_block(i->i_sb, (char *) dire, next_block,
1527 + next_offset, sizeof(*dire), &next_block, &next_offset))
1528 + goto failed_read;
1529 + length += sizeof(*dire);
1530 + }
1531 +
1532 + if(!squashfs_get_cached_block(i->i_sb, dire->name, next_block,
1533 + next_offset, dire->size + 1, &next_block, &next_offset))
1534 + goto failed_read;
1535 + length += dire->size + 1;
1536 +
1537 + if(file->f_pos >= length)
1538 + continue;
1539 +
1540 + dire->name[dire->size + 1] = '\0';
1541 +
1542 + TRACE("Calling filldir(%x, %s, %d, %d, %x:%x, %d)\n", (unsigned int) dirent,
1543 + dire->name, dire->size + 1, (int) file->f_pos,
1544 + dirh.start_block, dire->offset, squashfs_filetype_table[dire->type]);
1545 +
1546 + if(filldir(dirent, dire->name, dire->size + 1, file->f_pos, SQUASHFS_MK_VFS_INODE(dirh.start_block,
1547 + dire->offset), squashfs_filetype_table[dire->type]) < 0) {
1548 + TRACE("Filldir returned less than 0\n");
1549 + return dirs_read;
1550 + }
1551 +
1552 + file->f_pos = length;
1553 + dirs_read ++;
1554 + }
1555 + }
1556 +
1557 + return dirs_read;
1558 +
1559 +failed_read:
1560 + ERROR("Unable to read directory block [%x:%x]\n", next_block, next_offset);
1561 + return 0;
1562 +}
1563 +
1564 +
1565 +static struct dentry *squashfs_lookup(struct inode *i, struct dentry *dentry)
1566 +{
1567 + const char *name =dentry->d_name.name;
1568 + int len = dentry->d_name.len;
1569 + struct inode *inode = NULL;
1570 + squashfs_sb_info *msBlk = &i->i_sb->u.squashfs_sb;
1571 + squashfs_super_block *sBlk = &msBlk->sBlk;
1572 + int next_block = i->u.squashfs_i.start_block + sBlk->directory_table_start, next_offset =
1573 + i->u.squashfs_i.offset, length = 0, dir_count;
1574 + squashfs_dir_header dirh;
1575 + char buffer[sizeof(squashfs_dir_entry) + SQUASHFS_NAME_LEN];
1576 + squashfs_dir_entry *dire = (squashfs_dir_entry *) buffer;
1577 + int squashfs_2_1 = sBlk->s_major == 2 && sBlk->s_minor == 1;
1578 +
1579 + TRACE("Entered squashfs_lookup [%x:%x]\n", next_block, next_offset);
1580 +
1581 + length = get_dir_index_using_name(i->i_sb, &next_block, &next_offset, i->u.squashfs_i.u.s2.directory_index_start,
1582 + i->u.squashfs_i.u.s2.directory_index_offset, i->u.squashfs_i.u.s2.directory_index_count, name, len);
1583 +
1584 + while(length < i->i_size) {
1585 + /* read directory header */
1586 + if(msBlk->swap) {
1587 + squashfs_dir_header sdirh;
1588 + if(!squashfs_get_cached_block(i->i_sb, (char *) &sdirh, next_block, next_offset,
1589 + sizeof(sdirh), &next_block, &next_offset))
1590 + goto failed_read;
1591 + length += sizeof(sdirh);
1592 + SQUASHFS_SWAP_DIR_HEADER(&dirh, &sdirh);
1593 + } else {
1594 + if(!squashfs_get_cached_block(i->i_sb, (char *) &dirh, next_block, next_offset,
1595 + sizeof(dirh), &next_block, &next_offset))
1596 + goto failed_read;
1597 + length += sizeof(dirh);
1598 + }
1599 +
1600 + dir_count = dirh.count + 1;
1601 + while(dir_count--) {
1602 + if(msBlk->swap) {
1603 + squashfs_dir_entry sdire;
1604 + if(!squashfs_get_cached_block(i->i_sb, (char *) &sdire,
1605 + next_block,next_offset, sizeof(sdire), &next_block, &next_offset))
1606 + goto failed_read;
1607 + length += sizeof(sdire);
1608 + SQUASHFS_SWAP_DIR_ENTRY(dire, &sdire);
1609 + } else {
1610 + if(!squashfs_get_cached_block(i->i_sb, (char *) dire,
1611 + next_block,next_offset, sizeof(*dire), &next_block, &next_offset))
1612 + goto failed_read;
1613 + length += sizeof(*dire);
1614 + }
1615 +
1616 + if(!squashfs_get_cached_block(i->i_sb, dire->name,
1617 + next_block, next_offset, dire->size + 1, &next_block, &next_offset))
1618 + goto failed_read;
1619 + length += dire->size + 1;
1620 +
1621 + if(squashfs_2_1 && name[0] < dire->name[0])
1622 + goto exit_loop;
1623 +
1624 + if((len == dire->size + 1) && !strncmp(name, dire->name, len)) {
1625 + squashfs_inode ino = SQUASHFS_MKINODE(dirh.start_block, dire->offset);
1626 +
1627 + TRACE("calling squashfs_iget for directory entry %s, inode %x:%x\n",
1628 + name, dirh.start_block, dire->offset);
1629 +
1630 + inode = (msBlk->iget)(i->i_sb, ino);
1631 +
1632 + goto exit_loop;
1633 + }
1634 + }
1635 + }
1636 +
1637 +exit_loop:
1638 + d_add(dentry, inode);
1639 + return ERR_PTR(0);
1640 +
1641 +failed_read:
1642 + ERROR("Unable to read directory block [%x:%x]\n", next_block, next_offset);
1643 + goto exit_loop;
1644 +}
1645 +
1646 +
1647 +static void squashfs_put_super(struct super_block *s)
1648 +{
1649 + int i;
1650 +
1651 + squashfs_sb_info *sbi = (squashfs_sb_info *) &s->u.squashfs_sb;
1652 + if(sbi->block_cache) {
1653 + for(i = 0; i < SQUASHFS_CACHED_BLKS; i++)
1654 + if(sbi->block_cache[i].block != SQUASHFS_INVALID_BLK)
1655 + kfree(sbi->block_cache[i].data);
1656 + kfree(sbi->block_cache);
1657 + }
1658 + if(sbi->read_data) kfree(sbi->read_data);
1659 + if(sbi->read_page) kfree(sbi->read_page);
1660 + if(sbi->uid) kfree(sbi->uid);
1661 + if(sbi->fragment) {
1662 + for(i = 0; i < SQUASHFS_CACHED_FRAGMENTS; i++)
1663 + if(sbi->fragment[i].data != NULL)
1664 + kfree(sbi->fragment[i].data);
1665 + kfree(sbi->fragment);
1666 + }
1667 + if(sbi->fragment_index) kfree(sbi->fragment_index);
1668 + sbi->block_cache = NULL;
1669 + sbi->uid = NULL;
1670 + sbi->read_data = NULL;
1671 + sbi->read_page = NULL;
1672 + sbi->fragment = NULL;
1673 + sbi->fragment_index = NULL;
1674 +}
1675 +
1676 +
1677 +static int __init init_squashfs_fs(void)
1678 +{
1679 +
1680 + printk(KERN_INFO "Squashfs 2.1-r2 (released 2004/12/15) (C) 2002-2004 Phillip Lougher\n");
1681 +
1682 + if(!(stream.workspace = (char *) vmalloc(zlib_inflate_workspacesize()))) {
1683 + ERROR("Failed to allocate zlib workspace\n");
1684 + return -ENOMEM;
1685 + }
1686 + return register_filesystem(&squashfs_fs_type);
1687 +}
1688 +
1689 +
1690 +static void __exit exit_squashfs_fs(void)
1691 +{
1692 + vfree(stream.workspace);
1693 + unregister_filesystem(&squashfs_fs_type);
1694 +}
1695 +
1696 +
1697 +EXPORT_NO_SYMBOLS;
1698 +
1699 +module_init(init_squashfs_fs);
1700 +module_exit(exit_squashfs_fs);
1701 +MODULE_DESCRIPTION("squashfs, a compressed read-only filesystem");
1702 +MODULE_AUTHOR("Phillip Lougher <plougher@users.sourceforge.net>");
1703 +MODULE_LICENSE("GPL");
1704 diff --new-file -ur linux-2.4.28/fs/squashfs/Makefile linux-2.4.28-squashfs2.1-r2/fs/squashfs/Makefile
1705 --- linux-2.4.28/fs/squashfs/Makefile 1970-01-01 01:00:00.000000000 +0100
1706 +++ linux-2.4.28-squashfs2.1-r2/fs/squashfs/Makefile 2004-12-02 02:14:05.000000000 +0000
1707 @@ -0,0 +1,11 @@
1708 +#
1709 +# Makefile for the linux squashfs routines.
1710 +#
1711 +
1712 +O_TARGET := squashfs.o
1713 +
1714 +obj-y := inode.o
1715 +
1716 +obj-m := $(O_TARGET)
1717 +
1718 +include $(TOPDIR)/Rules.make
1719 diff --new-file -ur linux-2.4.28/include/linux/fs.h linux-2.4.28-squashfs2.1-r2/include/linux/fs.h
1720 --- linux-2.4.28/include/linux/fs.h 2004-11-17 11:54:22.000000000 +0000
1721 +++ linux-2.4.28-squashfs2.1-r2/include/linux/fs.h 2004-12-02 02:14:05.000000000 +0000
1722 @@ -324,6 +324,7 @@
1723 #include <linux/usbdev_fs_i.h>
1724 #include <linux/jffs2_fs_i.h>
1725 #include <linux/cramfs_fs_sb.h>
1726 +#include <linux/squashfs_fs_i.h>
1727
1728 /*
1729 * Attribute flags. These should be or-ed together to figure out what
1730 @@ -519,6 +520,7 @@
1731 struct socket socket_i;
1732 struct usbdev_inode_info usbdev_i;
1733 struct jffs2_inode_info jffs2_i;
1734 + struct squashfs_inode_info squashfs_i;
1735 void *generic_ip;
1736 } u;
1737 };
1738 @@ -733,6 +735,7 @@
1739 #include <linux/usbdev_fs_sb.h>
1740 #include <linux/cramfs_fs_sb.h>
1741 #include <linux/jffs2_fs_sb.h>
1742 +#include <linux/squashfs_fs_sb.h>
1743
1744 extern struct list_head super_blocks;
1745 extern spinlock_t sb_lock;
1746 @@ -792,6 +795,7 @@
1747 struct usbdev_sb_info usbdevfs_sb;
1748 struct jffs2_sb_info jffs2_sb;
1749 struct cramfs_sb_info cramfs_sb;
1750 + struct squashfs_sb_info squashfs_sb;
1751 void *generic_sbp;
1752 } u;
1753 /*
1754 diff --new-file -ur linux-2.4.28/include/linux/squashfs_fs.h linux-2.4.28-squashfs2.1-r2/include/linux/squashfs_fs.h
1755 --- linux-2.4.28/include/linux/squashfs_fs.h 1970-01-01 01:00:00.000000000 +0100
1756 +++ linux-2.4.28-squashfs2.1-r2/include/linux/squashfs_fs.h 2004-12-02 02:52:36.000000000 +0000
1757 @@ -0,0 +1,512 @@
1758 +#ifndef SQUASHFS_FS
1759 +#define SQUASHFS_FS
1760 +/*
1761 + * Squashfs
1762 + *
1763 + * Copyright (c) 2002, 2003, 2004 Phillip Lougher <plougher@users.sourceforge.net>
1764 + *
1765 + * This program is free software; you can redistribute it and/or
1766 + * modify it under the terms of the GNU General Public License
1767 + * as published by the Free Software Foundation; either version 2,
1768 + * or (at your option) any later version.
1769 + *
1770 + * This program is distributed in the hope that it will be useful,
1771 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1772 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1773 + * GNU General Public License for more details.
1774 + *
1775 + * You should have received a copy of the GNU General Public License
1776 + * along with this program; if not, write to the Free Software
1777 + * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1778 + *
1779 + * squashfs_fs.h
1780 + */
1781 +
1782 +#define SQUASHFS_MAJOR 2
1783 +#define SQUASHFS_MINOR 1
1784 +#define SQUASHFS_MAGIC 0x73717368
1785 +#define SQUASHFS_MAGIC_SWAP 0x68737173
1786 +#define SQUASHFS_START 0
1787 +
1788 +/* size of metadata (inode and directory) blocks */
1789 +#define SQUASHFS_METADATA_SIZE 8192
1790 +#define SQUASHFS_METADATA_LOG 13
1791 +
1792 +/* default size of data blocks */
1793 +#define SQUASHFS_FILE_SIZE 65536
1794 +#define SQUASHFS_FILE_LOG 16
1795 +
1796 +#define SQUASHFS_FILE_MAX_SIZE 65536
1797 +
1798 +/* Max number of uids and gids */
1799 +#define SQUASHFS_UIDS 256
1800 +#define SQUASHFS_GUIDS 255
1801 +
1802 +/* Max length of filename (not 255) */
1803 +#define SQUASHFS_NAME_LEN 256
1804 +
1805 +#define SQUASHFS_INVALID ((long long) 0xffffffffffff)
1806 +#define SQUASHFS_INVALID_BLK ((long long) 0xffffffff)
1807 +#define SQUASHFS_USED_BLK ((long long) 0xfffffffe)
1808 +
1809 +/* Filesystem flags */
1810 +#define SQUASHFS_NOI 0
1811 +#define SQUASHFS_NOD 1
1812 +#define SQUASHFS_CHECK 2
1813 +#define SQUASHFS_NOF 3
1814 +#define SQUASHFS_NO_FRAG 4
1815 +#define SQUASHFS_ALWAYS_FRAG 5
1816 +#define SQUASHFS_DUPLICATE 6
1817 +#define SQUASHFS_BIT(flag, bit) ((flag >> bit) & 1)
1818 +#define SQUASHFS_UNCOMPRESSED_INODES(flags) SQUASHFS_BIT(flags, SQUASHFS_NOI)
1819 +#define SQUASHFS_UNCOMPRESSED_DATA(flags) SQUASHFS_BIT(flags, SQUASHFS_NOD)
1820 +#define SQUASHFS_UNCOMPRESSED_FRAGMENTS(flags) SQUASHFS_BIT(flags, SQUASHFS_NOF)
1821 +#define SQUASHFS_NO_FRAGMENTS(flags) SQUASHFS_BIT(flags, SQUASHFS_NO_FRAG)
1822 +#define SQUASHFS_ALWAYS_FRAGMENTS(flags) SQUASHFS_BIT(flags, SQUASHFS_ALWAYS_FRAG)
1823 +#define SQUASHFS_DUPLICATES(flags) SQUASHFS_BIT(flags, SQUASHFS_DUPLICATE)
1824 +#define SQUASHFS_CHECK_DATA(flags) SQUASHFS_BIT(flags, SQUASHFS_CHECK)
1825 +#define SQUASHFS_MKFLAGS(noi, nod, check_data, nof, no_frag, always_frag, duplicate_checking) (noi | (nod << 1) | (check_data << 2) | (nof << 3) | (no_frag << 4) | (always_frag << 5) | (duplicate_checking << 6))
1826 +
1827 +/* Max number of types and file types */
1828 +#define SQUASHFS_DIR_TYPE 1
1829 +#define SQUASHFS_FILE_TYPE 2
1830 +#define SQUASHFS_SYMLINK_TYPE 3
1831 +#define SQUASHFS_BLKDEV_TYPE 4
1832 +#define SQUASHFS_CHRDEV_TYPE 5
1833 +#define SQUASHFS_FIFO_TYPE 6
1834 +#define SQUASHFS_SOCKET_TYPE 7
1835 +#define SQUASHFS_LDIR_TYPE 8
1836 +
1837 +/* 1.0 filesystem type definitions */
1838 +#define SQUASHFS_TYPES 5
1839 +#define SQUASHFS_IPC_TYPE 0
1840 +
1841 +/* Flag whether block is compressed or uncompressed, bit is set if block is uncompressed */
1842 +#define SQUASHFS_COMPRESSED_BIT (1 << 15)
1843 +#define SQUASHFS_COMPRESSED_SIZE(B) (((B) & ~SQUASHFS_COMPRESSED_BIT) ? \
1844 + (B) & ~SQUASHFS_COMPRESSED_BIT : SQUASHFS_COMPRESSED_BIT)
1845 +
1846 +#define SQUASHFS_COMPRESSED(B) (!((B) & SQUASHFS_COMPRESSED_BIT))
1847 +
1848 +#define SQUASHFS_COMPRESSED_BIT_BLOCK (1 << 24)
1849 +#define SQUASHFS_COMPRESSED_SIZE_BLOCK(B) (((B) & ~SQUASHFS_COMPRESSED_BIT_BLOCK) ? \
1850 + (B) & ~SQUASHFS_COMPRESSED_BIT_BLOCK : SQUASHFS_COMPRESSED_BIT_BLOCK)
1851 +
1852 +#define SQUASHFS_COMPRESSED_BLOCK(B) (!((B) & SQUASHFS_COMPRESSED_BIT_BLOCK))
1853 +
1854 +/*
1855 + * Inode number ops. Inodes consist of a compressed block number, and an uncompressed
1856 + * offset within that block
1857 + */
1858 +#define SQUASHFS_INODE_BLK(a) ((unsigned int) ((a) >> 16))
1859 +#define SQUASHFS_INODE_OFFSET(a) ((unsigned int) ((a) & 0xffff))
1860 +#define SQUASHFS_MKINODE(A, B) ((squashfs_inode)(((squashfs_inode) (A) << 16)\
1861 + + (B)))
1862 +
1863 +/* Compute 32 bit VFS inode number from squashfs inode number */
1864 +#define SQUASHFS_MK_VFS_INODE(a, b) ((unsigned int) (((a) << 8) + ((b) >> 2) + 1))
1865 +
1866 +/* Translate between VFS mode and squashfs mode */
1867 +#define SQUASHFS_MODE(a) ((a) & 0xfff)
1868 +
1869 +/* fragment and fragment table defines */
1870 +typedef unsigned int squashfs_fragment_index;
1871 +#define SQUASHFS_FRAGMENT_BYTES(A) (A * sizeof(squashfs_fragment_entry))
1872 +#define SQUASHFS_FRAGMENT_INDEX(A) (SQUASHFS_FRAGMENT_BYTES(A) / SQUASHFS_METADATA_SIZE)
1873 +#define SQUASHFS_FRAGMENT_INDEX_OFFSET(A) (SQUASHFS_FRAGMENT_BYTES(A) % SQUASHFS_METADATA_SIZE)
1874 +#define SQUASHFS_FRAGMENT_INDEXES(A) ((SQUASHFS_FRAGMENT_BYTES(A) + SQUASHFS_METADATA_SIZE - 1) / SQUASHFS_METADATA_SIZE)
1875 +#define SQUASHFS_FRAGMENT_INDEX_BYTES(A) (SQUASHFS_FRAGMENT_INDEXES(A) * sizeof(squashfs_fragment_index))
1876 +#define SQUASHFS_CACHED_FRAGMENTS 3
1877 +
1878 +/* cached data constants for filesystem */
1879 +#define SQUASHFS_CACHED_BLKS 8
1880 +
1881 +#define SQUASHFS_MAX_FILE_SIZE_LOG 32
1882 +#define SQUASHFS_MAX_FILE_SIZE ((long long) 1 << (SQUASHFS_MAX_FILE_SIZE_LOG - 1))
1883 +
1884 +#define SQUASHFS_MARKER_BYTE 0xff
1885 +
1886 +
1887 +/*
1888 + * definitions for structures on disk
1889 + */
1890 +
1891 +typedef unsigned int squashfs_block;
1892 +typedef long long squashfs_inode;
1893 +
1894 +typedef unsigned int squashfs_uid;
1895 +
1896 +typedef struct squashfs_super_block {
1897 + unsigned int s_magic;
1898 + unsigned int inodes;
1899 + unsigned int bytes_used;
1900 + unsigned int uid_start;
1901 + unsigned int guid_start;
1902 + unsigned int inode_table_start;
1903 + unsigned int directory_table_start;
1904 + unsigned int s_major:16;
1905 + unsigned int s_minor:16;
1906 + unsigned int block_size_1:16;
1907 + unsigned int block_log:16;
1908 + unsigned int flags:8;
1909 + unsigned int no_uids:8;
1910 + unsigned int no_guids:8;
1911 + unsigned int mkfs_time /* time of filesystem creation */;
1912 + squashfs_inode root_inode;
1913 + unsigned int block_size;
1914 + unsigned int fragments;
1915 + unsigned int fragment_table_start;
1916 +} __attribute__ ((packed)) squashfs_super_block;
1917 +
1918 +typedef struct {
1919 + unsigned int index:27;
1920 + unsigned int start_block:29;
1921 + unsigned char size;
1922 + unsigned char name[0];
1923 +} __attribute__ ((packed)) squashfs_dir_index;
1924 +
1925 +typedef struct {
1926 + unsigned int inode_type:4;
1927 + unsigned int mode:12; /* protection */
1928 + unsigned int uid:8; /* index into uid table */
1929 + unsigned int guid:8; /* index into guid table */
1930 +} __attribute__ ((packed)) squashfs_base_inode_header;
1931 +
1932 +typedef squashfs_base_inode_header squashfs_ipc_inode_header;
1933 +
1934 +typedef struct {
1935 + unsigned int inode_type:4;
1936 + unsigned int mode:12; /* protection */
1937 + unsigned int uid:8; /* index into uid table */
1938 + unsigned int guid:8; /* index into guid table */
1939 + unsigned short rdev;
1940 +} __attribute__ ((packed)) squashfs_dev_inode_header;
1941 +
1942 +typedef struct {
1943 + unsigned int inode_type:4;
1944 + unsigned int mode:12; /* protection */
1945 + unsigned int uid:8; /* index into uid table */
1946 + unsigned int guid:8; /* index into guid table */
1947 + unsigned short symlink_size;
1948 + char symlink[0];
1949 +} __attribute__ ((packed)) squashfs_symlink_inode_header;
1950 +
1951 +typedef struct {
1952 + unsigned int inode_type:4;
1953 + unsigned int mode:12; /* protection */
1954 + unsigned int uid:8; /* index into uid table */
1955 + unsigned int guid:8; /* index into guid table */
1956 + unsigned int mtime;
1957 + squashfs_block start_block;
1958 + unsigned int fragment;
1959 + unsigned int offset;
1960 + unsigned int file_size:SQUASHFS_MAX_FILE_SIZE_LOG;
1961 + unsigned short block_list[0];
1962 +} __attribute__ ((packed)) squashfs_reg_inode_header;
1963 +
1964 +typedef struct {
1965 + unsigned int inode_type:4;
1966 + unsigned int mode:12; /* protection */
1967 + unsigned int uid:8; /* index into uid table */
1968 + unsigned int guid:8; /* index into guid table */
1969 + unsigned int file_size:19;
1970 + unsigned int offset:13;
1971 + unsigned int mtime;
1972 + unsigned int start_block:24;
1973 +} __attribute__ ((packed)) squashfs_dir_inode_header;
1974 +
1975 +typedef struct {
1976 + unsigned int inode_type:4;
1977 + unsigned int mode:12; /* protection */
1978 + unsigned int uid:8; /* index into uid table */
1979 + unsigned int guid:8; /* index into guid table */
1980 + unsigned int file_size:27;
1981 + unsigned int offset:13;
1982 + unsigned int mtime;
1983 + unsigned int start_block:24;
1984 + unsigned int i_count:16;
1985 + squashfs_dir_index index[0];
1986 +} __attribute__ ((packed)) squashfs_ldir_inode_header;
1987 +
1988 +typedef union {
1989 + squashfs_base_inode_header base;
1990 + squashfs_dev_inode_header dev;
1991 + squashfs_symlink_inode_header symlink;
1992 + squashfs_reg_inode_header reg;
1993 + squashfs_dir_inode_header dir;
1994 + squashfs_ldir_inode_header ldir;
1995 + squashfs_ipc_inode_header ipc;
1996 +} squashfs_inode_header;
1997 +
1998 +typedef struct {
1999 + unsigned int offset:13;
2000 + unsigned int type:3;
2001 + unsigned int size:8;
2002 + char name[0];
2003 +} __attribute__ ((packed)) squashfs_dir_entry;
2004 +
2005 +typedef struct {
2006 + unsigned int count:8;
2007 + unsigned int start_block:24;
2008 +} __attribute__ ((packed)) squashfs_dir_header;
2009 +
2010 +typedef struct {
2011 + unsigned int start_block;
2012 + unsigned int size;
2013 +} __attribute__ ((packed)) squashfs_fragment_entry;
2014 +
2015 +extern int squashfs_uncompress_block(void *d, int dstlen, void *s, int srclen);
2016 +extern int squashfs_uncompress_init(void);
2017 +extern int squashfs_uncompress_exit(void);
2018 +
2019 +/*
2020 + * macros to convert each packed bitfield structure from little endian to big
2021 + * endian and vice versa. These are needed when creating or using a filesystem on a
2022 + * machine with different byte ordering to the target architecture.
2023 + *
2024 + */
2025 +
2026 +#define SQUASHFS_SWAP_SUPER_BLOCK(s, d) {\
2027 + SQUASHFS_MEMSET(s, d, sizeof(squashfs_super_block));\
2028 + SQUASHFS_SWAP((s)->s_magic, d, 0, 32);\
2029 + SQUASHFS_SWAP((s)->inodes, d, 32, 32);\
2030 + SQUASHFS_SWAP((s)->bytes_used, d, 64, 32);\
2031 + SQUASHFS_SWAP((s)->uid_start, d, 96, 32);\
2032 + SQUASHFS_SWAP((s)->guid_start, d, 128, 32);\
2033 + SQUASHFS_SWAP((s)->inode_table_start, d, 160, 32);\
2034 + SQUASHFS_SWAP((s)->directory_table_start, d, 192, 32);\
2035 + SQUASHFS_SWAP((s)->s_major, d, 224, 16);\
2036 + SQUASHFS_SWAP((s)->s_minor, d, 240, 16);\
2037 + SQUASHFS_SWAP((s)->block_size_1, d, 256, 16);\
2038 + SQUASHFS_SWAP((s)->block_log, d, 272, 16);\
2039 + SQUASHFS_SWAP((s)->flags, d, 288, 8);\
2040 + SQUASHFS_SWAP((s)->no_uids, d, 296, 8);\
2041 + SQUASHFS_SWAP((s)->no_guids, d, 304, 8);\
2042 + SQUASHFS_SWAP((s)->mkfs_time, d, 312, 32);\
2043 + SQUASHFS_SWAP((s)->root_inode, d, 344, 64);\
2044 + SQUASHFS_SWAP((s)->block_size, d, 408, 32);\
2045 + SQUASHFS_SWAP((s)->fragments, d, 440, 32);\
2046 + SQUASHFS_SWAP((s)->fragment_table_start, d, 472, 32);\
2047 +}
2048 +
2049 +#define SQUASHFS_SWAP_BASE_INODE_HEADER(s, d, n) {\
2050 + SQUASHFS_MEMSET(s, d, n);\
2051 + SQUASHFS_SWAP((s)->inode_type, d, 0, 4);\
2052 + SQUASHFS_SWAP((s)->mode, d, 4, 12);\
2053 + SQUASHFS_SWAP((s)->uid, d, 16, 8);\
2054 + SQUASHFS_SWAP((s)->guid, d, 24, 8);\
2055 +}
2056 +
2057 +#define SQUASHFS_SWAP_IPC_INODE_HEADER(s, d) SQUASHFS_SWAP_BASE_INODE_HEADER(s, d, sizeof(squashfs_ipc_inode_header))
2058 +
2059 +#define SQUASHFS_SWAP_DEV_INODE_HEADER(s, d) {\
2060 + SQUASHFS_SWAP_BASE_INODE_HEADER(s, d, sizeof(squashfs_dev_inode_header));\
2061 + SQUASHFS_SWAP((s)->rdev, d, 32, 16);\
2062 +}
2063 +
2064 +#define SQUASHFS_SWAP_SYMLINK_INODE_HEADER(s, d) {\
2065 + SQUASHFS_SWAP_BASE_INODE_HEADER(s, d, sizeof(squashfs_symlink_inode_header));\
2066 + SQUASHFS_SWAP((s)->symlink_size, d, 32, 16);\
2067 +}
2068 +
2069 +#define SQUASHFS_SWAP_REG_INODE_HEADER(s, d) {\
2070 + SQUASHFS_SWAP_BASE_INODE_HEADER(s, d, sizeof(squashfs_reg_inode_header));\
2071 + SQUASHFS_SWAP((s)->mtime, d, 32, 32);\
2072 + SQUASHFS_SWAP((s)->start_block, d, 64, 32);\
2073 + SQUASHFS_SWAP((s)->fragment, d, 96, 32);\
2074 + SQUASHFS_SWAP((s)->offset, d, 128, 32);\
2075 + SQUASHFS_SWAP((s)->file_size, d, 160, SQUASHFS_MAX_FILE_SIZE_LOG);\
2076 +}
2077 +
2078 +#define SQUASHFS_SWAP_DIR_INODE_HEADER(s, d) {\
2079 + SQUASHFS_SWAP_BASE_INODE_HEADER(s, d, sizeof(squashfs_dir_inode_header));\
2080 + SQUASHFS_SWAP((s)->file_size, d, 32, 19);\
2081 + SQUASHFS_SWAP((s)->offset, d, 51, 13);\
2082 + SQUASHFS_SWAP((s)->mtime, d, 64, 32);\
2083 + SQUASHFS_SWAP((s)->start_block, d, 96, 24);\
2084 +}
2085 +
2086 +#define SQUASHFS_SWAP_LDIR_INODE_HEADER(s, d) {\
2087 + SQUASHFS_SWAP_BASE_INODE_HEADER(s, d, sizeof(squashfs_ldir_inode_header));\
2088 + SQUASHFS_SWAP((s)->file_size, d, 32, 27);\
2089 + SQUASHFS_SWAP((s)->offset, d, 59, 13);\
2090 + SQUASHFS_SWAP((s)->mtime, d, 72, 32);\
2091 + SQUASHFS_SWAP((s)->start_block, d, 104, 24);\
2092 + SQUASHFS_SWAP((s)->i_count, d, 128, 16);\
2093 +}
2094 +
2095 +#define SQUASHFS_SWAP_DIR_INDEX(s, d) {\
2096 + SQUASHFS_MEMSET(s, d, sizeof(squashfs_dir_index));\
2097 + SQUASHFS_SWAP((s)->index, d, 0, 27);\
2098 + SQUASHFS_SWAP((s)->start_block, d, 27, 29);\
2099 + SQUASHFS_SWAP((s)->size, d, 56, 8);\
2100 +}
2101 +
2102 +#define SQUASHFS_SWAP_DIR_HEADER(s, d) {\
2103 + SQUASHFS_MEMSET(s, d, sizeof(squashfs_dir_header));\
2104 + SQUASHFS_SWAP((s)->count, d, 0, 8);\
2105 + SQUASHFS_SWAP((s)->start_block, d, 8, 24);\
2106 +}
2107 +
2108 +#define SQUASHFS_SWAP_DIR_ENTRY(s, d) {\
2109 + SQUASHFS_MEMSET(s, d, sizeof(squashfs_dir_entry));\
2110 + SQUASHFS_SWAP((s)->offset, d, 0, 13);\
2111 + SQUASHFS_SWAP((s)->type, d, 13, 3);\
2112 + SQUASHFS_SWAP((s)->size, d, 16, 8);\
2113 +}
2114 +
2115 +#define SQUASHFS_SWAP_FRAGMENT_ENTRY(s, d) {\
2116 + SQUASHFS_MEMSET(s, d, sizeof(squashfs_fragment_entry));\
2117 + SQUASHFS_SWAP((s)->start_block, d, 0, 32);\
2118 + SQUASHFS_SWAP((s)->size, d, 32, 32);\
2119 +}
2120 +
2121 +#define SQUASHFS_SWAP_SHORTS(s, d, n) {\
2122 + int entry;\
2123 + int bit_position;\
2124 + SQUASHFS_MEMSET(s, d, n * 2);\
2125 + for(entry = 0, bit_position = 0; entry < n; entry++, bit_position += 16)\
2126 + SQUASHFS_SWAP(s[entry], d, bit_position, 16);\
2127 +}
2128 +
2129 +#define SQUASHFS_SWAP_INTS(s, d, n) {\
2130 + int entry;\
2131 + int bit_position;\
2132 + SQUASHFS_MEMSET(s, d, n * 4);\
2133 + for(entry = 0, bit_position = 0; entry < n; entry++, bit_position += 32)\
2134 + SQUASHFS_SWAP(s[entry], d, bit_position, 32);\
2135 +}
2136 +
2137 +#define SQUASHFS_SWAP_DATA(s, d, n, bits) {\
2138 + int entry;\
2139 + int bit_position;\
2140 + SQUASHFS_MEMSET(s, d, n * bits / 8);\
2141 + for(entry = 0, bit_position = 0; entry < n; entry++, bit_position += bits)\
2142 + SQUASHFS_SWAP(s[entry], d, bit_position, bits);\
2143 +}
2144 +
2145 +#define SQUASHFS_SWAP_FRAGMENT_INDEXES(s, d, n) SQUASHFS_SWAP_INTS(s, d, n)
2146 +
2147 +#ifdef SQUASHFS_1_0_COMPATIBILITY
2148 +typedef struct {
2149 + unsigned int inode_type:4;
2150 + unsigned int mode:12; /* protection */
2151 + unsigned int uid:4; /* index into uid table */
2152 + unsigned int guid:4; /* index into guid table */
2153 +} __attribute__ ((packed)) squashfs_base_inode_header_1;
2154 +
2155 +typedef struct {
2156 + unsigned int inode_type:4;
2157 + unsigned int mode:12; /* protection */
2158 + unsigned int uid:4; /* index into uid table */
2159 + unsigned int guid:4; /* index into guid table */
2160 + unsigned int type:4;
2161 + unsigned int offset:4;
2162 +} __attribute__ ((packed)) squashfs_ipc_inode_header_1;
2163 +
2164 +typedef struct {
2165 + unsigned int inode_type:4;
2166 + unsigned int mode:12; /* protection */
2167 + unsigned int uid:4; /* index into uid table */
2168 + unsigned int guid:4; /* index into guid table */
2169 + unsigned short rdev;
2170 +} __attribute__ ((packed)) squashfs_dev_inode_header_1;
2171 +
2172 +typedef struct {
2173 + unsigned int inode_type:4;
2174 + unsigned int mode:12; /* protection */
2175 + unsigned int uid:4; /* index into uid table */
2176 + unsigned int guid:4; /* index into guid table */
2177 + unsigned short symlink_size;
2178 + char symlink[0];
2179 +} __attribute__ ((packed)) squashfs_symlink_inode_header_1;
2180 +
2181 +typedef struct {
2182 + unsigned int inode_type:4;
2183 + unsigned int mode:12; /* protection */
2184 + unsigned int uid:4; /* index into uid table */
2185 + unsigned int guid:4; /* index into guid table */
2186 + unsigned int mtime;
2187 + squashfs_block start_block;
2188 + unsigned int file_size:SQUASHFS_MAX_FILE_SIZE_LOG;
2189 + unsigned short block_list[0];
2190 +} __attribute__ ((packed)) squashfs_reg_inode_header_1;
2191 +
2192 +typedef struct {
2193 + unsigned int inode_type:4;
2194 + unsigned int mode:12; /* protection */
2195 + unsigned int uid:4; /* index into uid table */
2196 + unsigned int guid:4; /* index into guid table */
2197 + unsigned int file_size:19;
2198 + unsigned int offset:13;
2199 + unsigned int mtime;
2200 + unsigned int start_block:24;
2201 +} __attribute__ ((packed)) squashfs_dir_inode_header_1;
2202 +
2203 +#define SQUASHFS_SWAP_BASE_INODE_HEADER_1(s, d, n) {\
2204 + SQUASHFS_MEMSET(s, d, n);\
2205 + SQUASHFS_SWAP((s)->inode_type, d, 0, 4);\
2206 + SQUASHFS_SWAP((s)->mode, d, 4, 12);\
2207 + SQUASHFS_SWAP((s)->uid, d, 16, 4);\
2208 + SQUASHFS_SWAP((s)->guid, d, 20, 4);\
2209 +}
2210 +
2211 +#define SQUASHFS_SWAP_IPC_INODE_HEADER_1(s, d) {\
2212 + SQUASHFS_SWAP_BASE_INODE_HEADER_1(s, d, sizeof(squashfs_ipc_inode_header_1));\
2213 + SQUASHFS_SWAP((s)->type, d, 24, 4);\
2214 + SQUASHFS_SWAP((s)->offset, d, 28, 4);\
2215 +}
2216 +
2217 +#define SQUASHFS_SWAP_DEV_INODE_HEADER_1(s, d) {\
2218 + SQUASHFS_SWAP_BASE_INODE_HEADER_1(s, d, sizeof(squashfs_dev_inode_header_1));\
2219 + SQUASHFS_SWAP((s)->rdev, d, 24, 16);\
2220 +}
2221 +
2222 +#define SQUASHFS_SWAP_SYMLINK_INODE_HEADER_1(s, d) {\
2223 + SQUASHFS_SWAP_BASE_INODE_HEADER(s, d, sizeof(squashfs_symlink_inode_header_1));\
2224 + SQUASHFS_SWAP((s)->symlink_size, d, 24, 16);\
2225 +}
2226 +
2227 +#define SQUASHFS_SWAP_REG_INODE_HEADER_1(s, d) {\
2228 + SQUASHFS_SWAP_BASE_INODE_HEADER(s, d, sizeof(squashfs_reg_inode_header_1));\
2229 + SQUASHFS_SWAP((s)->mtime, d, 24, 32);\
2230 + SQUASHFS_SWAP((s)->start_block, d, 56, 32);\
2231 + SQUASHFS_SWAP((s)->file_size, d, 88, SQUASHFS_MAX_FILE_SIZE_LOG);\
2232 +}
2233 +
2234 +#define SQUASHFS_SWAP_DIR_INODE_HEADER_1(s, d) {\
2235 + SQUASHFS_SWAP_BASE_INODE_HEADER(s, d, sizeof(squashfs_dir_inode_header_1));\
2236 + SQUASHFS_SWAP((s)->file_size, d, 24, 19);\
2237 + SQUASHFS_SWAP((s)->offset, d, 43, 13);\
2238 + SQUASHFS_SWAP((s)->mtime, d, 56, 32);\
2239 + SQUASHFS_SWAP((s)->start_block, d, 88, 24);\
2240 +}
2241 +#endif
2242 +
2243 +#ifdef __KERNEL__
2244 +/*
2245 + * macros used to swap each structure entry, taking into account
2246 + * bitfields and different bitfield placing conventions on differing architectures
2247 + */
2248 +#include <asm/byteorder.h>
2249 +#ifdef __BIG_ENDIAN
2250 + /* convert from little endian to big endian */
2251 +#define SQUASHFS_SWAP(value, p, pos, tbits) _SQUASHFS_SWAP(value, p, pos, tbits, b_pos)
2252 +#else
2253 + /* convert from big endian to little endian */
2254 +#define SQUASHFS_SWAP(value, p, pos, tbits) _SQUASHFS_SWAP(value, p, pos, tbits, 64 - tbits - b_pos)
2255 +#endif
2256 +
2257 +#define _SQUASHFS_SWAP(value, p, pos, tbits, SHIFT) {\
2258 + int bits;\
2259 + int b_pos = pos % 8;\
2260 + unsigned long long val = 0;\
2261 + unsigned char *s = (unsigned char *)p + (pos / 8);\
2262 + unsigned char *d = ((unsigned char *) &val) + 7;\
2263 + for(bits = 0; bits < (tbits + b_pos); bits += 8) \
2264 + *d-- = *s++;\
2265 + value = (val >> (SHIFT))/* & ((1 << tbits) - 1)*/;\
2266 +}
2267 +#define SQUASHFS_MEMSET(s, d, n) memset(s, 0, n);
2268 +#endif
2269 +#endif
2270 diff --new-file -ur linux-2.4.28/include/linux/squashfs_fs_i.h linux-2.4.28-squashfs2.1-r2/include/linux/squashfs_fs_i.h
2271 --- linux-2.4.28/include/linux/squashfs_fs_i.h 1970-01-01 01:00:00.000000000 +0100
2272 +++ linux-2.4.28-squashfs2.1-r2/include/linux/squashfs_fs_i.h 2004-12-15 10:13:06.000000000 +0000
2273 @@ -0,0 +1,42 @@
2274 +#ifndef SQUASHFS_FS_I
2275 +#define SQUASHFS_FS_I
2276 +/*
2277 + * Squashfs
2278 + *
2279 + * Copyright (c) 2002, 2003, 2004 Phillip Lougher <plougher@users.sourceforge.net>
2280 + *
2281 + * This program is free software; you can redistribute it and/or
2282 + * modify it under the terms of the GNU General Public License
2283 + * as published by the Free Software Foundation; either version 2,
2284 + * or (at your option) any later version.
2285 + *
2286 + * This program is distributed in the hope that it will be useful,
2287 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
2288 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2289 + * GNU General Public License for more details.
2290 + *
2291 + * You should have received a copy of the GNU General Public License
2292 + * along with this program; if not, write to the Free Software
2293 + * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
2294 + *
2295 + * squashfs_fs_i.h
2296 + */
2297 +
2298 +typedef struct squashfs_inode_info {
2299 + unsigned int start_block;
2300 + unsigned int block_list_start;
2301 + unsigned int offset;
2302 + union {
2303 + struct {
2304 + unsigned int fragment_start_block;
2305 + unsigned int fragment_size;
2306 + unsigned int fragment_offset;
2307 + } s1;
2308 + struct {
2309 + unsigned int directory_index_start;
2310 + unsigned int directory_index_offset;
2311 + unsigned int directory_index_count;
2312 + } s2;
2313 + } u;
2314 + } squashfs_inode_info;
2315 +#endif
2316 diff --new-file -ur linux-2.4.28/include/linux/squashfs_fs_sb.h linux-2.4.28-squashfs2.1-r2/include/linux/squashfs_fs_sb.h
2317 --- linux-2.4.28/include/linux/squashfs_fs_sb.h 1970-01-01 01:00:00.000000000 +0100
2318 +++ linux-2.4.28-squashfs2.1-r2/include/linux/squashfs_fs_sb.h 2004-12-02 02:52:36.000000000 +0000
2319 @@ -0,0 +1,65 @@
2320 +#ifndef SQUASHFS_FS_SB
2321 +#define SQUASHFS_FS_SB
2322 +/*
2323 + * Squashfs
2324 + *
2325 + * Copyright (c) 2002, 2003, 2004 Phillip Lougher <plougher@users.sourceforge.net>
2326 + *
2327 + * This program is free software; you can redistribute it and/or
2328 + * modify it under the terms of the GNU General Public License
2329 + * as published by the Free Software Foundation; either version 2,
2330 + * or (at your option) any later version.
2331 + *
2332 + * This program is distributed in the hope that it will be useful,
2333 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
2334 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2335 + * GNU General Public License for more details.
2336 + *
2337 + * You should have received a copy of the GNU General Public License
2338 + * along with this program; if not, write to the Free Software
2339 + * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
2340 + *
2341 + * squashfs_fs_sb.h
2342 + */
2343 +
2344 +#include <linux/squashfs_fs.h>
2345 +
2346 +typedef struct {
2347 + unsigned int block;
2348 + int length;
2349 + unsigned int next_index;
2350 + char *data;
2351 + } squashfs_cache;
2352 +
2353 +struct squashfs_fragment_cache {
2354 + unsigned int block;
2355 + int length;
2356 + unsigned int locked;
2357 + char *data;
2358 + };
2359 +
2360 +typedef struct squashfs_sb_info {
2361 + squashfs_super_block sBlk;
2362 + int devblksize;
2363 + int devblksize_log2;
2364 + int swap;
2365 + squashfs_cache *block_cache;
2366 + struct squashfs_fragment_cache *fragment;
2367 + int next_cache;
2368 + int next_fragment;
2369 + squashfs_uid *uid;
2370 + squashfs_uid *guid;
2371 + squashfs_fragment_index *fragment_index;
2372 + unsigned int read_size;
2373 + char *read_data;
2374 + char *read_page;
2375 + struct semaphore read_page_mutex;
2376 + struct semaphore block_cache_mutex;
2377 + struct semaphore fragment_mutex;
2378 + wait_queue_head_t waitq;
2379 + wait_queue_head_t fragment_wait_queue;
2380 + struct inode *(*iget)(struct super_block *s, squashfs_inode inode);
2381 + unsigned int (*read_blocklist)(struct inode *inode, int index, int readahead_blks,
2382 + char *block_list, unsigned short **block_p, unsigned int *bsize);
2383 + } squashfs_sb_info;
2384 +#endif
2385 diff --new-file -ur linux-2.4.28/init/do_mounts.c linux-2.4.28-squashfs2.1-r2/init/do_mounts.c
2386 --- linux-2.4.28/init/do_mounts.c 2003-11-28 18:26:21.000000000 +0000
2387 +++ linux-2.4.28-squashfs2.1-r2/init/do_mounts.c 2004-12-02 02:14:06.000000000 +0000
2388 @@ -15,6 +15,7 @@
2389 #include <linux/minix_fs.h>
2390 #include <linux/ext2_fs.h>
2391 #include <linux/romfs_fs.h>
2392 +#include <linux/squashfs_fs.h>
2393 #include <linux/cramfs_fs.h>
2394
2395 #define BUILD_CRAMDISK
2396 @@ -476,6 +477,7 @@
2397 * minix
2398 * ext2
2399 * romfs
2400 + * squashfs
2401 * cramfs
2402 * gzip
2403 */
2404 @@ -486,6 +488,7 @@
2405 struct minix_super_block *minixsb;
2406 struct ext2_super_block *ext2sb;
2407 struct romfs_super_block *romfsb;
2408 + struct squashfs_super_block *squashfsb;
2409 struct cramfs_super *cramfsb;
2410 int nblocks = -1;
2411 unsigned char *buf;
2412 @@ -497,6 +500,7 @@
2413 minixsb = (struct minix_super_block *) buf;
2414 ext2sb = (struct ext2_super_block *) buf;
2415 romfsb = (struct romfs_super_block *) buf;
2416 + squashfsb = (struct squashfs_super_block *) buf;
2417 cramfsb = (struct cramfs_super *) buf;
2418 memset(buf, 0xe5, size);
2419
2420 @@ -535,6 +539,15 @@
2421 goto done;
2422 }
2423
2424 + /* squashfs is at block zero too */
2425 + if (squashfsb->s_magic == SQUASHFS_MAGIC) {
2426 + printk(KERN_NOTICE
2427 + "RAMDISK: squashfs filesystem found at block %d\n",
2428 + start_block);
2429 + nblocks = (squashfsb->bytes_used+BLOCK_SIZE-1)>>BLOCK_SIZE_BITS;
2430 + goto done;
2431 + }
2432 +
2433 /*
2434 * Read block 1 to test for minix and ext2 superblock
2435 */
2436 diff --new-file -ur linux-2.4.28/lib/Config.in linux-2.4.28-squashfs2.1-r2/lib/Config.in
2437 --- linux-2.4.28/lib/Config.in 2003-11-28 18:26:21.000000000 +0000
2438 +++ linux-2.4.28-squashfs2.1-r2/lib/Config.in 2004-12-02 02:14:06.000000000 +0000
2439 @@ -10,6 +10,7 @@
2440 # Do we need the compression support?
2441 #
2442 if [ "$CONFIG_CRAMFS" = "y" -o \
2443 + "$CONFIG_SQUASHFS" = "y" -o \
2444 "$CONFIG_PPP_DEFLATE" = "y" -o \
2445 "$CONFIG_CRYPTO_DEFLATE" = "y" -o \
2446 "$CONFIG_JFFS2_FS" = "y" -o \
2447 @@ -17,6 +18,7 @@
2448 define_tristate CONFIG_ZLIB_INFLATE y
2449 else
2450 if [ "$CONFIG_CRAMFS" = "m" -o \
2451 + "$CONFIG_SQUASHFS" = "m" -o \
2452 "$CONFIG_PPP_DEFLATE" = "m" -o \
2453 "$CONFIG_CRYPTO_DEFLATE" = "m" -o \
2454 "$CONFIG_JFFS2_FS" = "m" -o \
This page took 0.142105 seconds and 5 git commands to generate.