3 # Patch managed by http://www.mn-logistik.de/unsupported/pxa250/patcher
6 --- linux-2.4.20/Makefile~120-openwrt 2005-01-07 02:52:47.163951000 -0500
7 +++ linux-2.4.20/Makefile 2005-01-07 02:54:46.351831784 -0500
9 FINDHPATH = $(HPATH)/asm $(HPATH)/linux $(HPATH)/scsi $(HPATH)/net $(HPATH)/math-emu
12 -HOSTCFLAGS = -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer
13 +HOSTCFLAGS = -Wall -Wstrict-prototypes -Os -fomit-frame-pointer
19 CPPFLAGS := -D__KERNEL__ -I$(HPATH)
21 -CFLAGS := $(CPPFLAGS) -Wall -Wstrict-prototypes -Wno-trigraphs -O2 \
22 +CFLAGS := $(CPPFLAGS) -Wall -Wstrict-prototypes -Wno-trigraphs -Os \
23 -fno-strict-aliasing -fno-common
25 # Turn on -pg to instrument the kernel with calls to mcount().
26 --- linux-2.4.20/arch/mips/brcm-boards/bcm947xx/setup.c~120-openwrt 2005-01-07 02:52:47.170950000 -0500
27 +++ linux-2.4.20/arch/mips/brcm-boards/bcm947xx/setup.c 2005-01-07 02:54:46.351831784 -0500
29 #include <linux/ext2_fs.h>
30 #include <linux/romfs_fs.h>
31 #include <linux/cramfs_fs.h>
32 +#include <linux/squashfs_fs.h>
37 #ifdef CONFIG_MTD_PARTITIONS
39 static struct mtd_partition bcm947xx_parts[] = {
40 - { name: "pmon", offset: 0, size: 0, /*mask_flags: MTD_WRITEABLE,*/ },
41 + { name: "pmon", offset: 0, size: 0, mask_flags: MTD_WRITEABLE, },
42 { name: "linux", offset: 0, size: 0, },
43 { name: "rootfs", offset: 0, size: 0, /*mask_flags: MTD_WRITEABLE,*/ },
44 { name: "nvram", offset: 0, size: 0, },
45 + { name: "OpenWrt", offset: 0, size: 0, },
49 -struct mtd_partition * __init
50 -init_mtd_partitions(struct mtd_info *mtd, size_t size)
53 +find_root(struct mtd_info *mtd, size_t size, struct mtd_partition *part)
55 - struct minix_super_block *minixsb;
56 - struct ext2_super_block *ext2sb;
57 - struct romfs_super_block *romfsb;
58 struct cramfs_super *cramfsb;
59 + struct squashfs_super_block *squashfsb;
60 struct trx_header *trx;
62 unsigned char buf[512];
66 - minixsb = (struct minix_super_block *) buf;
67 - ext2sb = (struct ext2_super_block *) buf;
68 - romfsb = (struct romfs_super_block *) buf;
69 cramfsb = (struct cramfs_super *) buf;
70 + squashfsb = (struct squashfs_super_block *) buf;
71 trx = (struct trx_header *) buf;
73 - /* Look at every 64 KB boundary */
74 - for (off = 0; off < size; off += (64 * 1024)) {
78 + for (off = 0; off < size; off += mtd->erasesize) {
79 memset(buf, 0xe5, sizeof(buf));
82 - * Read block 0 to test for romfs and cramfs superblock
83 + * Read block 0 to test for cramfs superblock
85 if (MTD_READ(mtd, off, sizeof(buf), &len, buf) ||
87 @@ -207,75 +209,105 @@
89 /* Try looking at TRX header for rootfs offset */
90 if (le32_to_cpu(trx->magic) == TRX_MAGIC) {
91 - bcm947xx_parts[1].offset = off;
92 if (le32_to_cpu(trx->offsets[1]) > off)
93 off = le32_to_cpu(trx->offsets[1]);
97 - /* romfs is at block zero too */
98 - if (romfsb->word0 == ROMSB_WORD0 &&
99 - romfsb->word1 == ROMSB_WORD1) {
101 - "%s: romfs filesystem found at block %d\n",
102 - mtd->name, off / BLOCK_SIZE);
107 + /* need to find cramfs */
108 if (cramfsb->magic == CRAMFS_MAGIC) {
110 "%s: cramfs filesystem found at block %d\n",
111 mtd->name, off / BLOCK_SIZE);
116 - * Read block 1 to test for minix and ext2 superblock
118 - if (MTD_READ(mtd, off + BLOCK_SIZE, sizeof(buf), &len, buf) ||
119 - len != sizeof(buf))
123 - if (minixsb->s_magic == MINIX_SUPER_MAGIC ||
124 - minixsb->s_magic == MINIX_SUPER_MAGIC2) {
126 - "%s: Minix filesystem found at block %d\n",
127 - mtd->name, off / BLOCK_SIZE);
128 + part->size = cramfsb->size;
133 - if (ext2sb->s_magic == cpu_to_le16(EXT2_SUPER_MAGIC)) {
135 + if (squashfsb->s_magic == SQUASHFS_MAGIC) {
137 - "%s: ext2 filesystem found at block %d\n",
138 + "%s: squashfs filesystem found at block %d\n",
139 mtd->name, off / BLOCK_SIZE);
140 + part->size = squashfsb->bytes_used+2048;
147 - "%s: Couldn't find valid ROM disk image\n",
148 + "%s: Couldn't find valid cramfs image\n",
153 + part->offset = off;
158 +struct mtd_partition * __init
159 +init_mtd_partitions(struct mtd_info *mtd, size_t size)
162 + bcm947xx_parts[0].offset=0;
163 + bcm947xx_parts[0].size=256*1024;
166 /* Find and size nvram */
167 bcm947xx_parts[3].offset = size - ROUNDUP(NVRAM_SPACE, mtd->erasesize);
168 bcm947xx_parts[3].size = size - bcm947xx_parts[3].offset;
170 /* Find and size rootfs */
172 - bcm947xx_parts[2].offset = off;
173 - bcm947xx_parts[2].size = bcm947xx_parts[3].offset - bcm947xx_parts[2].offset;
175 + //if (off < size) {
176 + // bcm947xx_parts[2].offset = off;
177 + // bcm947xx_parts[2].size = bcm947xx_parts[3].offset - bcm947xx_parts[2].offset;
180 + /* Find and size rootfs */
181 + find_root(mtd,size,&bcm947xx_parts[2]);
185 /* Size linux (kernel and rootfs) */
186 + bcm947xx_parts[1].offset = bcm947xx_parts[0].size;
187 bcm947xx_parts[1].size = bcm947xx_parts[3].offset - bcm947xx_parts[1].offset;
191 + /* calculate leftover flash, and assign it to the jffs partition */
195 + // get the offset to the end of the root_fs
196 + spot=bcm947xx_parts[2].offset+bcm947xx_parts[2].size;
197 + // round it up to an erase size boundary
198 + spot+=mtd->erasesize-1;
199 + // mask the number to the boundary
200 + mask=mtd->erasesize;
202 + mask=mask^0xffffffff;
204 + // length = flashsize - start position - nvram size
206 + len=len-bcm947xx_parts[3].size;
209 + bcm947xx_parts[4].offset = spot;
210 + bcm947xx_parts[4].size = len;
216 bcm947xx_parts[0].size = bcm947xx_parts[1].offset - bcm947xx_parts[0].offset;
219 + //for(x=0; x<5; x++) {
220 + // printk(KERN_NOTICE
221 + // "Partition %d mask_flags %08x\n",
222 + // x,bcm947xx_parts[x].mask_flags);
226 return bcm947xx_parts;
229 --- linux-2.4.20/drivers/mtd/maps/bcm947xx-flash.c~120-openwrt 2005-01-07 02:52:47.190946000 -0500
230 +++ linux-2.4.20/drivers/mtd/maps/bcm947xx-flash.c 2005-01-07 02:54:46.352831632 -0500
233 void bcm947xx_map_copy_from(struct map_info *map, void *to, unsigned long from, ssize_t len)
235 + //memcpy_fromio(to, map->map_priv_1 + from, len);
237 memcpy_fromio(to, map->map_priv_1 + from, len);
240 + u16 *dest = (u16 *) to;
241 + u16 *src = (u16 *) (map->map_priv_1 + from);
243 + for (i = 0; i < (len / 2); i++) {
248 + *((u8 *)dest+len-1) = src[i] & 0xff;
252 void bcm947xx_map_write8(struct map_info *map, __u8 d, unsigned long adr)
253 --- linux-2.4.20/drivers/net/Makefile~120-openwrt 2005-01-07 02:52:47.191946000 -0500
254 +++ linux-2.4.20/drivers/net/Makefile 2005-01-07 02:54:46.352831632 -0500
256 list-multi := rcpci.o
257 rcpci-objs := rcpci45.o rclanmtl.o
263 ifeq ($(CONFIG_HW_QOS),y)
264 --- linux-2.4.20/fs/Config.in~120-openwrt 2002-11-28 18:53:15.000000000 -0500
265 +++ linux-2.4.20/fs/Config.in 2005-01-07 02:54:46.352831632 -0500
267 int 'JFFS2 debugging verbosity (0 = quiet, 2 = noisy)' CONFIG_JFFS2_FS_DEBUG 0
269 tristate 'Compressed ROM file system support' CONFIG_CRAMFS
270 +tristate 'Squashed file system support' CONFIG_SQUASHFS
271 bool 'Virtual memory file system support (former shm fs)' CONFIG_TMPFS
272 define_bool CONFIG_RAMFS y
274 --- linux-2.4.20/fs/Makefile~120-openwrt 2002-11-28 18:53:15.000000000 -0500
275 +++ linux-2.4.20/fs/Makefile 2005-01-07 02:54:46.353831480 -0500
277 subdir-$(CONFIG_SUN_OPENPROMFS) += openpromfs
278 subdir-$(CONFIG_BEFS_FS) += befs
279 subdir-$(CONFIG_JFS_FS) += jfs
280 +subdir-$(CONFIG_SQUASHFS) += squashfs
283 obj-$(CONFIG_BINFMT_AOUT) += binfmt_aout.o
284 --- /dev/null 2004-04-06 13:56:48.000000000 -0400
285 +++ linux-2.4.20/fs/squashfs/Makefile 2005-01-07 02:54:46.353831480 -0500
288 +# Makefile for the linux squashfs routines.
291 +O_TARGET := squashfs.o
295 +obj-m := $(O_TARGET)
297 +include $(TOPDIR)/Rules.make
298 --- /dev/null 2004-04-06 13:56:48.000000000 -0400
299 +++ linux-2.4.20/fs/squashfs/inode.c 2005-01-07 02:54:46.355831176 -0500
302 + * Squashfs - a compressed read only filesystem for Linux
304 + * Copyright (c) 2002, 2003, 2004 Phillip Lougher <plougher@users.sourceforge.net>
306 + * This program is free software; you can redistribute it and/or
307 + * modify it under the terms of the GNU General Public License
308 + * as published by the Free Software Foundation; either version 2,
309 + * or (at your option) any later version.
311 + * This program is distributed in the hope that it will be useful,
312 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
313 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
314 + * GNU General Public License for more details.
316 + * You should have received a copy of the GNU General Public License
317 + * along with this program; if not, write to the Free Software
318 + * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
319 + * Squashfs - a compressed read only filesystem for Linux
324 +#define SQUASHFS_1_0_COMPATIBILITY
326 +#include <linux/types.h>
327 +#include <linux/squashfs_fs.h>
328 +#include <linux/module.h>
329 +#include <linux/errno.h>
330 +#include <linux/slab.h>
331 +#include <linux/fs.h>
332 +#include <linux/locks.h>
333 +#include <linux/init.h>
334 +#include <linux/dcache.h>
335 +#include <asm/uaccess.h>
336 +#include <linux/wait.h>
337 +#include <asm/semaphore.h>
338 +#include <linux/zlib.h>
339 +#include <linux/blkdev.h>
340 +#include <linux/vmalloc.h>
342 +#ifdef SQUASHFS_TRACE
343 +#define TRACE(s, args...) printk(KERN_NOTICE "SQUASHFS: "s, ## args)
345 +#define TRACE(s, args...) {}
348 +#define ERROR(s, args...) printk(KERN_ERR "SQUASHFS error: "s, ## args)
350 +#define SERROR(s, args...) if(!silent) printk(KERN_ERR "SQUASHFS error: "s, ## args)
351 +#define WARNING(s, args...) printk(KERN_WARNING "SQUASHFS: "s, ## args)
353 +static struct super_block *squashfs_read_super(struct super_block *, void *, int);
354 +static void squashfs_put_super(struct super_block *);
355 +static int squashfs_statfs(struct super_block *, struct statfs *);
356 +static int squashfs_symlink_readpage(struct file *file, struct page *page);
357 +static int squashfs_readpage(struct file *file, struct page *page);
358 +static int squashfs_readpage4K(struct file *file, struct page *page);
359 +static int squashfs_readdir(struct file *, void *, filldir_t);
360 +static struct dentry *squashfs_lookup(struct inode *, struct dentry *);
361 +static unsigned int read_data(struct super_block *s, char *buffer,
362 + unsigned int index, unsigned int length, int, unsigned int *next_index);
363 +static int squashfs_get_cached_block(struct super_block *s, char *buffer,
364 + unsigned int block, unsigned int offset, int length,
365 + unsigned int *next_block, unsigned int *next_offset);
366 +static struct inode *squashfs_iget(struct super_block *s, squashfs_inode inode);
367 +static unsigned int read_blocklist(struct inode *inode, int index, int readahead_blks,
368 + char *block_list, char **block_p, unsigned int *bsize);
369 +static void squashfs_put_super(struct super_block *s);
371 +#ifdef SQUASHFS_1_0_COMPATIBILITY
372 +static int squashfs_readpage_lessthan4K(struct file *file, struct page *page);
373 +static struct inode *squashfs_iget_1(struct super_block *s, squashfs_inode inode);
374 +static unsigned int read_blocklist_1(struct inode *inode, int index, int readahead_blks,
375 + char *block_list, char **block_p, unsigned int *bsize);
378 +DECLARE_MUTEX(read_data_mutex);
380 +static z_stream stream;
382 +static DECLARE_FSTYPE_DEV(squashfs_fs_type, "squashfs", squashfs_read_super);
384 +static unsigned char squashfs_filetype_table[] = {
385 + DT_UNKNOWN, DT_DIR, DT_REG, DT_LNK, DT_BLK, DT_CHR, DT_FIFO, DT_SOCK
388 +static struct super_operations squashfs_ops = {
389 + statfs: squashfs_statfs,
390 + put_super: squashfs_put_super,
393 +static struct address_space_operations squashfs_symlink_aops = {
394 + readpage: squashfs_symlink_readpage
397 +static struct address_space_operations squashfs_aops = {
398 + readpage: squashfs_readpage
401 +static struct address_space_operations squashfs_aops_4K = {
402 + readpage: squashfs_readpage4K
405 +#ifdef SQUASHFS_1_0_COMPATIBILITY
406 +static struct address_space_operations squashfs_aops_lessthan4K = {
407 + readpage: squashfs_readpage_lessthan4K
411 +static struct file_operations squashfs_dir_ops = {
412 + read: generic_read_dir,
413 + readdir: squashfs_readdir
416 +static struct inode_operations squashfs_dir_inode_ops = {
417 + lookup: squashfs_lookup
421 +static unsigned int read_data(struct super_block *s, char *buffer,
422 + unsigned int index, unsigned int length, int datablock, unsigned int *next_index)
424 + squashfs_sb_info *msBlk = &s->u.squashfs_sb;
425 + struct buffer_head *bh[((SQUASHFS_FILE_MAX_SIZE - 1) >> msBlk->devblksize_log2) + 2];
426 + unsigned int offset = index & ((1 << msBlk->devblksize_log2) - 1);
427 + unsigned int cur_index = index >> msBlk->devblksize_log2;
428 + int bytes, avail_bytes, b, k;
430 + unsigned int compressed;
431 + unsigned int c_byte = length;
434 + bytes = msBlk->devblksize - offset;
436 + c_buffer = (compressed = SQUASHFS_COMPRESSED_BLOCK(c_byte)) ? msBlk->read_data : buffer;
437 + c_byte = SQUASHFS_COMPRESSED_SIZE_BLOCK(c_byte);
439 + c_buffer = (compressed = SQUASHFS_COMPRESSED(c_byte)) ? msBlk->read_data : buffer;
440 + c_byte = SQUASHFS_COMPRESSED_SIZE(c_byte);
443 + TRACE("Block @ 0x%x, %scompressed size %d\n", index, compressed ? "" : "un", (unsigned int) c_byte);
445 + if(!(bh[0] = sb_getblk(s, cur_index)))
446 + goto block_release;
447 + for(b = 1; bytes < c_byte; b++) {
448 + if(!(bh[b] = sb_getblk(s, ++cur_index)))
449 + goto block_release;
450 + bytes += msBlk->devblksize;
452 + ll_rw_block(READ, b, bh);
454 + unsigned short temp;
455 + if(!(bh[0] = sb_bread(s, cur_index)))
458 + if(msBlk->devblksize - offset == 1) {
460 + ((unsigned char *) &temp)[1] = *((unsigned char *) (bh[0]->b_data + offset));
462 + ((unsigned char *) &temp)[0] = *((unsigned char *) (bh[0]->b_data + offset));
464 + if(!(bh[0] = sb_bread(s, ++cur_index)))
467 + ((unsigned char *) &temp)[0] = *((unsigned char *) bh[0]->b_data);
469 + ((unsigned char *) &temp)[1] = *((unsigned char *) bh[0]->b_data);
475 + unsigned short temp;
476 + ((unsigned char *) &temp)[1] = *((unsigned char *) (bh[0]->b_data + offset));
477 + ((unsigned char *) &temp)[0] = *((unsigned char *) (bh[0]->b_data + offset + 1));
480 + c_byte = *((unsigned short *) (bh[0]->b_data + offset));
483 + if(SQUASHFS_CHECK_DATA(msBlk->sBlk.flags)) {
484 + if(offset == msBlk->devblksize) {
486 + if(!(bh[0] = sb_bread(s, ++cur_index)))
490 + if(*((unsigned char *) (bh[0]->b_data + offset)) != SQUASHFS_MARKER_BYTE) {
491 + ERROR("Metadata block marker corrupt @ %x\n", index);
498 + bytes = msBlk->devblksize - offset;
500 + c_buffer = (compressed = SQUASHFS_COMPRESSED_BLOCK(c_byte)) ? msBlk->read_data : buffer;
501 + c_byte = SQUASHFS_COMPRESSED_SIZE_BLOCK(c_byte);
503 + c_buffer = (compressed = SQUASHFS_COMPRESSED(c_byte)) ? msBlk->read_data : buffer;
504 + c_byte = SQUASHFS_COMPRESSED_SIZE(c_byte);
507 + TRACE("Block @ 0x%x, %scompressed size %d\n", index, compressed ? "" : "un", (unsigned int) c_byte);
509 + for(b = 1; bytes < c_byte; b++) {
510 + if(!(bh[b] = sb_getblk(s, ++cur_index)))
511 + goto block_release;
512 + bytes += msBlk->devblksize;
514 + ll_rw_block(READ, b - 1, bh + 1);
518 + down(&read_data_mutex);
520 + for(bytes = 0, k = 0; k < b; k++) {
521 + avail_bytes = (c_byte - bytes) > (msBlk->devblksize - offset) ? msBlk->devblksize - offset : c_byte - bytes;
522 + wait_on_buffer(bh[k]);
523 + memcpy(c_buffer + bytes, bh[k]->b_data + offset, avail_bytes);
524 + bytes += avail_bytes;
535 + stream.next_in = c_buffer;
536 + stream.avail_in = c_byte;
537 + stream.next_out = buffer;
538 + stream.avail_out = msBlk->read_size;
539 + if(((zlib_err = zlib_inflateInit(&stream)) != Z_OK) ||
540 + ((zlib_err = zlib_inflate(&stream, Z_FINISH)) != Z_STREAM_END) ||
541 + ((zlib_err = zlib_inflateEnd(&stream)) != Z_OK)) {
542 + ERROR("zlib_fs returned unexpected result 0x%x\n", zlib_err);
545 + bytes = stream.total_out;
546 + up(&read_data_mutex);
550 + *next_index = index + c_byte + (length ? 0 : (SQUASHFS_CHECK_DATA(msBlk->sBlk.flags) ? 3 : 2));
555 + while(--b >= 0) brelse(bh[b]);
558 + ERROR("sb_bread failed reading block 0x%x\n", cur_index);
563 +static int squashfs_get_cached_block(struct super_block *s, char *buffer,
564 + unsigned int block, unsigned int offset, int length,
565 + unsigned int *next_block, unsigned int *next_offset)
567 + squashfs_sb_info *msBlk = &s->u.squashfs_sb;
568 + int n, i, bytes, return_length = length;
569 + unsigned int next_index;
571 + TRACE("Entered squashfs_get_cached_block [%x:%x]\n", block, offset);
574 + for(i = 0; i < SQUASHFS_CACHED_BLKS; i++)
575 + if(msBlk->block_cache[i].block == block)
578 + down(&msBlk->block_cache_mutex);
579 + if(i == SQUASHFS_CACHED_BLKS) {
580 + /* read inode header block */
581 + for(i = msBlk->next_cache, n = SQUASHFS_CACHED_BLKS; n ; n --, i = (i + 1) % SQUASHFS_CACHED_BLKS)
582 + if(msBlk->block_cache[i].block != SQUASHFS_USED_BLK)
585 + up(&msBlk->block_cache_mutex);
586 + sleep_on(&msBlk->waitq);
589 + msBlk->next_cache = (i + 1) % SQUASHFS_CACHED_BLKS;
591 + if(msBlk->block_cache[i].block == SQUASHFS_INVALID_BLK) {
592 + if(!(msBlk->block_cache[i].data = (unsigned char *)
593 + kmalloc(SQUASHFS_METADATA_SIZE, GFP_KERNEL))) {
594 + ERROR("Failed to allocate cache block\n");
595 + up(&msBlk->block_cache_mutex);
600 + msBlk->block_cache[i].block = SQUASHFS_USED_BLK;
601 + up(&msBlk->block_cache_mutex);
602 + if(!(msBlk->block_cache[i].length = read_data(s, msBlk->block_cache[i].data, block, 0, 0,
604 + ERROR("Unable to read cache block [%x:%x]\n", block, offset);
607 + down(&msBlk->block_cache_mutex);
608 + wake_up(&msBlk->waitq);
609 + msBlk->block_cache[i].block = block;
610 + msBlk->block_cache[i].next_index = next_index;
611 + TRACE("Read cache block [%x:%x]\n", block, offset);
614 + if(msBlk->block_cache[i].block != block) {
615 + up(&msBlk->block_cache_mutex);
619 + if((bytes = msBlk->block_cache[i].length - offset) >= length) {
621 + memcpy(buffer, msBlk->block_cache[i].data + offset, length);
622 + if(msBlk->block_cache[i].length - offset == length) {
623 + *next_block = msBlk->block_cache[i].next_index;
626 + *next_block = block;
627 + *next_offset = offset + length;
630 + up(&msBlk->block_cache_mutex);
631 + return return_length;
634 + memcpy(buffer, msBlk->block_cache[i].data + offset, bytes);
637 + block = msBlk->block_cache[i].next_index;
638 + up(&msBlk->block_cache_mutex);
646 +static int get_fragment_location(struct super_block *s, unsigned int fragment, unsigned int *fragment_start_block, unsigned int *fragment_size)
648 + squashfs_sb_info *msBlk = &s->u.squashfs_sb;
649 + unsigned int start_block = msBlk->fragment_index[SQUASHFS_FRAGMENT_INDEX(fragment)];
650 + int offset = SQUASHFS_FRAGMENT_INDEX_OFFSET(fragment);
651 + squashfs_fragment_entry fragment_entry;
654 + squashfs_fragment_entry sfragment_entry;
656 + if(!squashfs_get_cached_block(s, (char *) &sfragment_entry, start_block, offset,
657 + sizeof(sfragment_entry), &start_block, &offset))
659 + SQUASHFS_SWAP_FRAGMENT_ENTRY(&fragment_entry, &sfragment_entry);
661 + if(!squashfs_get_cached_block(s, (char *) &fragment_entry, start_block, offset,
662 + sizeof(fragment_entry), &start_block, &offset))
665 + *fragment_start_block = fragment_entry.start_block;
666 + *fragment_size = fragment_entry.size;
672 +void release_cached_fragment(squashfs_sb_info *msBlk, struct squashfs_fragment_cache *fragment)
674 + down(&msBlk->fragment_mutex);
675 + fragment->locked --;
676 + wake_up(&msBlk->fragment_wait_queue);
677 + up(&msBlk->fragment_mutex);
681 +struct squashfs_fragment_cache *get_cached_fragment(struct super_block *s, unsigned int start_block, int length)
684 + squashfs_sb_info *msBlk = &s->u.squashfs_sb;
687 + down(&msBlk->fragment_mutex);
688 + for(i = 0; i < SQUASHFS_CACHED_FRAGMENTS && msBlk->fragment[i].block != start_block; i++);
689 + if(i == SQUASHFS_CACHED_FRAGMENTS) {
690 + for(i = msBlk->next_fragment, n = SQUASHFS_CACHED_FRAGMENTS;
691 + n && msBlk->fragment[i].locked; n--, i = (i + 1) % SQUASHFS_CACHED_FRAGMENTS);
694 + up(&msBlk->fragment_mutex);
695 + sleep_on(&msBlk->fragment_wait_queue);
698 + msBlk->next_fragment = (msBlk->next_fragment + 1) % SQUASHFS_CACHED_FRAGMENTS;
700 + if(msBlk->fragment[i].data == NULL)
701 + if(!(msBlk->fragment[i].data = (unsigned char *)
702 + kmalloc(SQUASHFS_FILE_MAX_SIZE, GFP_KERNEL))) {
703 + ERROR("Failed to allocate fragment cache block\n");
704 + up(&msBlk->fragment_mutex);
708 + msBlk->fragment[i].block = SQUASHFS_INVALID_BLK;
709 + msBlk->fragment[i].locked = 1;
710 + up(&msBlk->fragment_mutex);
711 + if(!(msBlk->fragment[i].length = read_data(s, msBlk->fragment[i].data, start_block, length,
713 + ERROR("Unable to read fragment cache block [%x]\n", start_block);
714 + msBlk->fragment[i].locked = 0;
717 + msBlk->fragment[i].block = start_block;
718 + TRACE("New fragment %d, start block %d, locked %d\n", i, msBlk->fragment[i].block, msBlk->fragment[i].locked);
719 + return &msBlk->fragment[i];
722 + msBlk->fragment[i].locked ++;
723 + up(&msBlk->fragment_mutex);
725 + TRACE("Got fragment %d, start block %d, locked %d\n", i, msBlk->fragment[i].block, msBlk->fragment[i].locked);
726 + return &msBlk->fragment[i];
731 +#ifdef SQUASHFS_1_0_COMPATIBILITY
732 +static struct inode *squashfs_iget_1(struct super_block *s, squashfs_inode inode)
734 + struct inode *i = new_inode(s);
735 + squashfs_sb_info *msBlk = &s->u.squashfs_sb;
736 + squashfs_super_block *sBlk = &msBlk->sBlk;
737 + unsigned int block = SQUASHFS_INODE_BLK(inode) + sBlk->inode_table_start;
738 + unsigned int offset = SQUASHFS_INODE_OFFSET(inode);
739 + unsigned int next_block, next_offset;
740 + squashfs_base_inode_header_1 inodeb;
742 + TRACE("Entered squashfs_iget_1\n");
745 + squashfs_base_inode_header_1 sinodeb;
747 + if(!squashfs_get_cached_block(s, (char *) &sinodeb, block, offset,
748 + sizeof(sinodeb), &next_block, &next_offset))
750 + SQUASHFS_SWAP_BASE_INODE_HEADER_1(&inodeb, &sinodeb, sizeof(sinodeb));
752 + if(!squashfs_get_cached_block(s, (char *) &inodeb, block, offset,
753 + sizeof(inodeb), &next_block, &next_offset))
758 + i->i_mtime = sBlk->mkfs_time;
759 + i->i_atime = sBlk->mkfs_time;
760 + i->i_ctime = sBlk->mkfs_time;
762 + if(inodeb.inode_type != SQUASHFS_IPC_TYPE)
763 + i->i_uid = msBlk->uid[((inodeb.inode_type - 1) / SQUASHFS_TYPES) * 16 + inodeb.uid];
764 + i->i_ino = SQUASHFS_MK_VFS_INODE(block - sBlk->inode_table_start, offset);
766 + i->i_mode = inodeb.mode;
768 + switch(inodeb.inode_type == SQUASHFS_IPC_TYPE ? SQUASHFS_IPC_TYPE : (inodeb.inode_type - 1) % SQUASHFS_TYPES + 1) {
769 + case SQUASHFS_FILE_TYPE: {
770 + squashfs_reg_inode_header_1 inodep;
773 + squashfs_reg_inode_header_1 sinodep;
775 + if(!squashfs_get_cached_block(s, (char *) &sinodep, block, offset, sizeof(sinodep),
776 + &next_block, &next_offset))
778 + SQUASHFS_SWAP_REG_INODE_HEADER_1(&inodep, &sinodep);
780 + if(!squashfs_get_cached_block(s, (char *) &inodep, block, offset, sizeof(inodep),
781 + &next_block, &next_offset))
784 + i->i_size = inodep.file_size;
785 + i->i_fop = &generic_ro_fops;
786 + if(sBlk->block_size > 4096)
787 + i->i_data.a_ops = &squashfs_aops;
788 + else if(sBlk->block_size == 4096)
789 + i->i_data.a_ops = &squashfs_aops_4K;
791 + i->i_data.a_ops = &squashfs_aops_lessthan4K;
792 + i->i_mode |= S_IFREG;
793 + i->i_mtime = inodep.mtime;
794 + i->i_atime = inodep.mtime;
795 + i->i_ctime = inodep.mtime;
796 + i->i_blocks = ((i->i_size - 1) >> 9) + 1;
797 + i->i_blksize = PAGE_CACHE_SIZE;
798 + i->u.squashfs_i.fragment_start_block = SQUASHFS_INVALID_BLK;
799 + i->u.squashfs_i.fragment_offset = 0;
800 + i->u.squashfs_i.start_block = inodep.start_block;
801 + i->u.squashfs_i.block_list_start = next_block;
802 + i->u.squashfs_i.offset = next_offset;
803 + TRACE("File inode %x:%x, start_block %x, block_list_start %x, offset %x\n",
804 + SQUASHFS_INODE_BLK(inode), offset, inodep.start_block, next_block, next_offset);
807 + case SQUASHFS_DIR_TYPE: {
808 + squashfs_dir_inode_header_1 inodep;
811 + squashfs_dir_inode_header_1 sinodep;
813 + if(!squashfs_get_cached_block(s, (char *) &sinodep, block, offset, sizeof(sinodep),
814 + &next_block, &next_offset))
816 + SQUASHFS_SWAP_DIR_INODE_HEADER_1(&inodep, &sinodep);
818 + if(!squashfs_get_cached_block(s, (char *) &inodep, block, offset, sizeof(inodep),
819 + &next_block, &next_offset))
822 + i->i_size = inodep.file_size;
823 + i->i_op = &squashfs_dir_inode_ops;
824 + i->i_fop = &squashfs_dir_ops;
825 + i->i_mode |= S_IFDIR;
826 + i->i_mtime = inodep.mtime;
827 + i->i_atime = inodep.mtime;
828 + i->i_ctime = inodep.mtime;
829 + i->u.squashfs_i.start_block = inodep.start_block;
830 + i->u.squashfs_i.offset = inodep.offset;
831 + TRACE("Directory inode %x:%x, start_block %x, offset %x\n", SQUASHFS_INODE_BLK(inode), offset,
832 + inodep.start_block, inodep.offset);
835 + case SQUASHFS_SYMLINK_TYPE: {
836 + squashfs_symlink_inode_header_1 inodep;
839 + squashfs_symlink_inode_header_1 sinodep;
841 + if(!squashfs_get_cached_block(s, (char *) &sinodep, block, offset, sizeof(sinodep),
842 + &next_block, &next_offset))
844 + SQUASHFS_SWAP_SYMLINK_INODE_HEADER_1(&inodep, &sinodep);
846 + if(!squashfs_get_cached_block(s, (char *) &inodep, block, offset, sizeof(inodep),
847 + &next_block, &next_offset))
850 + i->i_size = inodep.symlink_size;
851 + i->i_op = &page_symlink_inode_operations;
852 + i->i_data.a_ops = &squashfs_symlink_aops;
853 + i->i_mode |= S_IFLNK;
854 + i->u.squashfs_i.start_block = next_block;
855 + i->u.squashfs_i.offset = next_offset;
856 + TRACE("Symbolic link inode %x:%x, start_block %x, offset %x\n",
857 + SQUASHFS_INODE_BLK(inode), offset, next_block, next_offset);
860 + case SQUASHFS_BLKDEV_TYPE:
861 + case SQUASHFS_CHRDEV_TYPE: {
862 + squashfs_dev_inode_header_1 inodep;
865 + squashfs_dev_inode_header_1 sinodep;
867 + if(!squashfs_get_cached_block(s, (char *) &sinodep, block, offset, sizeof(sinodep),
868 + &next_block, &next_offset))
870 + SQUASHFS_SWAP_DEV_INODE_HEADER_1(&inodep, &sinodep);
872 + if(!squashfs_get_cached_block(s, (char *) &inodep, block, offset, sizeof(inodep),
873 + &next_block, &next_offset))
877 + i->i_mode |= (inodeb.inode_type == SQUASHFS_CHRDEV_TYPE) ? S_IFCHR : S_IFBLK;
878 + init_special_inode(i, i->i_mode, inodep.rdev);
879 + TRACE("Device inode %x:%x, rdev %x\n", SQUASHFS_INODE_BLK(inode), offset, inodep.rdev);
882 + case SQUASHFS_IPC_TYPE: {
883 + squashfs_ipc_inode_header_1 inodep;
886 + squashfs_ipc_inode_header_1 sinodep;
888 + if(!squashfs_get_cached_block(s, (char *) &sinodep, block, offset, sizeof(sinodep),
889 + &next_block, &next_offset))
891 + SQUASHFS_SWAP_IPC_INODE_HEADER_1(&inodep, &sinodep);
893 + if(!squashfs_get_cached_block(s, (char *) &inodep, block, offset, sizeof(inodep),
894 + &next_block, &next_offset))
898 + i->i_mode |= (inodep.type == SQUASHFS_FIFO_TYPE) ? S_IFIFO : S_IFSOCK;
899 + i->i_uid = msBlk->uid[inodep.offset * 16 + inodeb.uid];
900 + init_special_inode(i, i->i_mode, 0);
904 + ERROR("Unknown inode type %d in squashfs_iget!\n", inodeb.inode_type);
908 + if(inodeb.guid == SQUASHFS_GUIDS)
909 + i->i_gid = i->i_uid;
911 + i->i_gid = msBlk->guid[inodeb.guid];
916 + ERROR("Unable to read inode [%x:%x]\n", block, offset);
924 +static struct inode *squashfs_iget(struct super_block *s, squashfs_inode inode)
926 + struct inode *i = new_inode(s);
927 + squashfs_sb_info *msBlk = &s->u.squashfs_sb;
928 + squashfs_super_block *sBlk = &msBlk->sBlk;
929 + unsigned int block = SQUASHFS_INODE_BLK(inode) + sBlk->inode_table_start;
930 + unsigned int offset = SQUASHFS_INODE_OFFSET(inode);
931 + unsigned int next_block, next_offset;
932 + squashfs_base_inode_header inodeb;
934 + TRACE("Entered squashfs_iget\n");
937 + squashfs_base_inode_header sinodeb;
939 + if(!squashfs_get_cached_block(s, (char *) &sinodeb, block, offset,
940 + sizeof(sinodeb), &next_block, &next_offset))
942 + SQUASHFS_SWAP_BASE_INODE_HEADER(&inodeb, &sinodeb, sizeof(sinodeb));
944 + if(!squashfs_get_cached_block(s, (char *) &inodeb, block, offset,
945 + sizeof(inodeb), &next_block, &next_offset))
950 + i->i_mtime = sBlk->mkfs_time;
951 + i->i_atime = sBlk->mkfs_time;
952 + i->i_ctime = sBlk->mkfs_time;
954 + if(inodeb.inode_type != SQUASHFS_IPC_TYPE)
955 + i->i_uid = msBlk->uid[((inodeb.inode_type - 1) / SQUASHFS_TYPES) * 16 + inodeb.uid];
956 + i->i_ino = SQUASHFS_MK_VFS_INODE(block - sBlk->inode_table_start, offset);
958 + i->i_mode = inodeb.mode;
960 + switch(inodeb.inode_type) {
961 + case SQUASHFS_FILE_TYPE: {
962 + squashfs_reg_inode_header inodep;
965 + squashfs_reg_inode_header sinodep;
967 + if(!squashfs_get_cached_block(s, (char *) &sinodep, block, offset, sizeof(sinodep),
968 + &next_block, &next_offset))
970 + SQUASHFS_SWAP_REG_INODE_HEADER(&inodep, &sinodep);
972 + if(!squashfs_get_cached_block(s, (char *) &inodep, block, offset, sizeof(inodep),
973 + &next_block, &next_offset))
976 + i->u.squashfs_i.fragment_start_block = SQUASHFS_INVALID_BLK;
977 + if(inodep.fragment != SQUASHFS_INVALID_BLK && !get_fragment_location(s, inodep.fragment,
978 + &i->u.squashfs_i.fragment_start_block, &i->u.squashfs_i.fragment_size))
981 + i->u.squashfs_i.fragment_offset = inodep.offset;
982 + i->i_size = inodep.file_size;
983 + i->i_fop = &generic_ro_fops;
984 + if(sBlk->block_size > 4096)
985 + i->i_data.a_ops = &squashfs_aops;
987 + i->i_data.a_ops = &squashfs_aops_4K;
988 + i->i_mode |= S_IFREG;
989 + i->i_mtime = inodep.mtime;
990 + i->i_atime = inodep.mtime;
991 + i->i_ctime = inodep.mtime;
992 + i->i_blocks = ((i->i_size - 1) >> 9) + 1;
993 + i->i_blksize = PAGE_CACHE_SIZE;
994 + i->u.squashfs_i.start_block = inodep.start_block;
995 + i->u.squashfs_i.block_list_start = next_block;
996 + i->u.squashfs_i.offset = next_offset;
997 + TRACE("File inode %x:%x, start_block %x, block_list_start %x, offset %x fragment_index %x fragment_offset %x\n",
998 + SQUASHFS_INODE_BLK(inode), offset, inodep.start_block, next_block, next_offset, inodep.fragment, inodep.offset);
1001 + case SQUASHFS_DIR_TYPE: {
1002 + squashfs_dir_inode_header inodep;
1005 + squashfs_dir_inode_header sinodep;
1007 + if(!squashfs_get_cached_block(s, (char *) &sinodep, block, offset, sizeof(sinodep),
1008 + &next_block, &next_offset))
1010 + SQUASHFS_SWAP_DIR_INODE_HEADER(&inodep, &sinodep);
1012 + if(!squashfs_get_cached_block(s, (char *) &inodep, block, offset, sizeof(inodep),
1013 + &next_block, &next_offset))
1016 + i->i_size = inodep.file_size;
1017 + i->i_op = &squashfs_dir_inode_ops;
1018 + i->i_fop = &squashfs_dir_ops;
1019 + i->i_mode |= S_IFDIR;
1020 + i->i_mtime = inodep.mtime;
1021 + i->i_atime = inodep.mtime;
1022 + i->i_ctime = inodep.mtime;
1023 + i->u.squashfs_i.start_block = inodep.start_block;
1024 + i->u.squashfs_i.offset = inodep.offset;
1025 + TRACE("Directory inode %x:%x, start_block %x, offset %x\n", SQUASHFS_INODE_BLK(inode), offset,
1026 + inodep.start_block, inodep.offset);
1029 + case SQUASHFS_SYMLINK_TYPE: {
1030 + squashfs_symlink_inode_header inodep;
1033 + squashfs_symlink_inode_header sinodep;
1035 + if(!squashfs_get_cached_block(s, (char *) &sinodep, block, offset, sizeof(sinodep),
1036 + &next_block, &next_offset))
1038 + SQUASHFS_SWAP_SYMLINK_INODE_HEADER(&inodep, &sinodep);
1040 + if(!squashfs_get_cached_block(s, (char *) &inodep, block, offset, sizeof(inodep),
1041 + &next_block, &next_offset))
1044 + i->i_size = inodep.symlink_size;
1045 + i->i_op = &page_symlink_inode_operations;
1046 + i->i_data.a_ops = &squashfs_symlink_aops;
1047 + i->i_mode |= S_IFLNK;
1048 + i->u.squashfs_i.start_block = next_block;
1049 + i->u.squashfs_i.offset = next_offset;
1050 + TRACE("Symbolic link inode %x:%x, start_block %x, offset %x\n",
1051 + SQUASHFS_INODE_BLK(inode), offset, next_block, next_offset);
1054 + case SQUASHFS_BLKDEV_TYPE:
1055 + case SQUASHFS_CHRDEV_TYPE: {
1056 + squashfs_dev_inode_header inodep;
1059 + squashfs_dev_inode_header sinodep;
1061 + if(!squashfs_get_cached_block(s, (char *) &sinodep, block, offset, sizeof(sinodep),
1062 + &next_block, &next_offset))
1064 + SQUASHFS_SWAP_DEV_INODE_HEADER(&inodep, &sinodep);
1066 + if(!squashfs_get_cached_block(s, (char *) &inodep, block, offset, sizeof(inodep),
1067 + &next_block, &next_offset))
1071 + i->i_mode |= (inodeb.inode_type == SQUASHFS_CHRDEV_TYPE) ? S_IFCHR : S_IFBLK;
1072 + init_special_inode(i, i->i_mode, inodep.rdev);
1073 + TRACE("Device inode %x:%x, rdev %x\n", SQUASHFS_INODE_BLK(inode), offset, inodep.rdev);
1076 + case SQUASHFS_FIFO_TYPE:
1077 + case SQUASHFS_SOCKET_TYPE: {
1079 + i->i_mode |= (inodeb.inode_type == SQUASHFS_FIFO_TYPE) ? S_IFIFO : S_IFSOCK;
1080 + init_special_inode(i, i->i_mode, 0);
1084 + ERROR("Unknown inode type %d in squashfs_iget!\n", inodeb.inode_type);
1085 + goto failed_read1;
1088 + if(inodeb.guid == SQUASHFS_GUIDS)
1089 + i->i_gid = i->i_uid;
1091 + i->i_gid = msBlk->guid[inodeb.guid];
1096 + ERROR("Unable to read inode [%x:%x]\n", block, offset);
1103 +static struct super_block *squashfs_read_super(struct super_block *s,
1104 + void *data, int silent)
1106 + kdev_t dev = s->s_dev;
1107 + squashfs_sb_info *msBlk = &s->u.squashfs_sb;
1108 + squashfs_super_block *sBlk = &msBlk->sBlk;
1111 + TRACE("Entered squashfs_read_superblock\n");
1113 + msBlk->devblksize = get_hardsect_size(dev);
1114 + if(msBlk->devblksize < BLOCK_SIZE)
1115 + msBlk->devblksize = BLOCK_SIZE;
1116 + msBlk->devblksize_log2 = ffz(~msBlk->devblksize);
1117 + set_blocksize(dev, msBlk->devblksize);
1118 + s->s_blocksize = msBlk->devblksize;
1119 + s->s_blocksize_bits = msBlk->devblksize_log2;
1121 + init_MUTEX(&msBlk->read_page_mutex);
1122 + init_MUTEX(&msBlk->block_cache_mutex);
1123 + init_MUTEX(&msBlk->fragment_mutex);
1125 + init_waitqueue_head(&msBlk->waitq);
1126 + init_waitqueue_head(&msBlk->fragment_wait_queue);
1128 + if(!read_data(s, (char *) sBlk, SQUASHFS_START, sizeof(squashfs_super_block) | SQUASHFS_COMPRESSED_BIT, 0, NULL)) {
1129 + SERROR("unable to read superblock\n");
1130 + goto failed_mount;
1133 + /* Check it is a SQUASHFS superblock */
1135 + if((s->s_magic = sBlk->s_magic) != SQUASHFS_MAGIC) {
1136 + if(sBlk->s_magic == SQUASHFS_MAGIC_SWAP) {
1137 + squashfs_super_block sblk;
1138 + WARNING("Mounting a different endian SQUASHFS filesystem on %s\n", bdevname(dev));
1139 + SQUASHFS_SWAP_SUPER_BLOCK(&sblk, sBlk);
1140 + memcpy(sBlk, &sblk, sizeof(squashfs_super_block));
1143 + SERROR("Can't find a SQUASHFS superblock on %s\n", bdevname(dev));
1144 + goto failed_mount;
1148 + /* Check the MAJOR & MINOR versions */
1149 +#ifdef SQUASHFS_1_0_COMPATIBILITY
1150 + if((sBlk->s_major != 1) && (sBlk->s_major != 2 || sBlk->s_minor > SQUASHFS_MINOR)) {
1151 + SERROR("Major/Minor mismatch, filesystem is (%d:%d), I support (1 : x) or (2 : <= %d)\n",
1152 + sBlk->s_major, sBlk->s_minor, SQUASHFS_MINOR);
1153 + goto failed_mount;
1155 + if(sBlk->s_major == 1)
1156 + sBlk->block_size = sBlk->block_size_1;
1158 + if(sBlk->s_major != SQUASHFS_MAJOR || sBlk->s_minor > SQUASHFS_MINOR) {
1159 + SERROR("Major/Minor mismatch, filesystem is (%d:%d), I support (%d: <= %d)\n",
1160 + sBlk->s_major, sBlk->s_minor, SQUASHFS_MAJOR, SQUASHFS_MINOR);
1161 + goto failed_mount;
1165 + TRACE("Found valid superblock on %s\n", bdevname(dev));
1166 + TRACE("Inodes are %scompressed\n", SQUASHFS_UNCOMPRESSED_INODES(sBlk->flags) ? "un" : "");
1167 + TRACE("Data is %scompressed\n", SQUASHFS_UNCOMPRESSED_DATA(sBlk->flags) ? "un" : "");
1168 + TRACE("Check data is %s present in the filesystem\n", SQUASHFS_CHECK_DATA(sBlk->flags) ? "" : "not");
1169 + TRACE("Filesystem size %d bytes\n", sBlk->bytes_used);
1170 + TRACE("Block size %d\n", sBlk->block_size);
1171 + TRACE("Number of inodes %d\n", sBlk->inodes);
1172 + if(sBlk->s_major > 1)
1173 + TRACE("Number of fragments %d\n", sBlk->fragments);
1174 + TRACE("Number of uids %d\n", sBlk->no_uids);
1175 + TRACE("Number of gids %d\n", sBlk->no_guids);
1176 + TRACE("sBlk->inode_table_start %x\n", sBlk->inode_table_start);
1177 + TRACE("sBlk->directory_table_start %x\n", sBlk->directory_table_start);
1178 + if(sBlk->s_major > 1)
1179 + TRACE("sBlk->fragment_table_start %x\n", sBlk->fragment_table_start);
1180 + TRACE("sBlk->uid_start %x\n", sBlk->uid_start);
1182 + s->s_flags |= MS_RDONLY;
1183 + s->s_op = &squashfs_ops;
1185 + /* Init inode_table block pointer array */
1186 + if(!(msBlk->block_cache = (squashfs_cache *) kmalloc(sizeof(squashfs_cache) * SQUASHFS_CACHED_BLKS, GFP_KERNEL))) {
1187 + ERROR("Failed to allocate block cache\n");
1188 + goto failed_mount;
1191 + for(i = 0; i < SQUASHFS_CACHED_BLKS; i++)
1192 + msBlk->block_cache[i].block = SQUASHFS_INVALID_BLK;
1194 + msBlk->next_cache = 0;
1196 + /* Allocate read_data block */
1197 + msBlk->read_size = (sBlk->block_size < SQUASHFS_METADATA_SIZE) ? SQUASHFS_METADATA_SIZE : sBlk->block_size;
1198 + if(!(msBlk->read_data = (char *) kmalloc(msBlk->read_size, GFP_KERNEL))) {
1199 + ERROR("Failed to allocate read_data block\n");
1200 + goto failed_mount1;
1203 + /* Allocate read_page block */
1204 + if(sBlk->block_size > PAGE_CACHE_SIZE &&
1205 + !(msBlk->read_page = (char *) kmalloc(sBlk->block_size, GFP_KERNEL))) {
1206 + ERROR("Failed to allocate read_page block\n");
1207 + goto failed_mount2;
1210 + /* Allocate uid and gid tables */
1211 + if(!(msBlk->uid = (squashfs_uid *) kmalloc((sBlk->no_uids +
1212 + sBlk->no_guids) * sizeof(squashfs_uid), GFP_KERNEL))) {
1213 + ERROR("Failed to allocate uid/gid table\n");
1214 + goto failed_mount3;
1216 + msBlk->guid = msBlk->uid + sBlk->no_uids;
1219 + squashfs_uid suid[sBlk->no_uids + sBlk->no_guids];
1221 + if(!read_data(s, (char *) &suid, sBlk->uid_start, ((sBlk->no_uids + sBlk->no_guids) *
1222 + sizeof(squashfs_uid)) | SQUASHFS_COMPRESSED_BIT, 0, NULL)) {
1223 + SERROR("unable to read uid/gid table\n");
1224 + goto failed_mount4;
1226 + SQUASHFS_SWAP_DATA(msBlk->uid, suid, (sBlk->no_uids + sBlk->no_guids), (sizeof(squashfs_uid) * 8));
1228 + if(!read_data(s, (char *) msBlk->uid, sBlk->uid_start, ((sBlk->no_uids + sBlk->no_guids) *
1229 + sizeof(squashfs_uid)) | SQUASHFS_COMPRESSED_BIT, 0, NULL)) {
1230 + SERROR("unable to read uid/gid table\n");
1231 + goto failed_mount4;
1235 +#ifdef SQUASHFS_1_0_COMPATIBILITY
1236 + if(sBlk->s_major == 1) {
1237 + msBlk->iget = squashfs_iget_1;
1238 + msBlk->read_blocklist = read_blocklist_1;
1239 + msBlk->fragment = (struct squashfs_fragment_cache *) msBlk->fragment_index = NULL;
1240 + goto allocate_root;
1243 + msBlk->iget = squashfs_iget;
1244 + msBlk->read_blocklist = read_blocklist;
1246 + if(!(msBlk->fragment = (struct squashfs_fragment_cache *) kmalloc(sizeof(struct squashfs_fragment_cache) * SQUASHFS_CACHED_FRAGMENTS, GFP_KERNEL))) {
1247 + ERROR("Failed to allocate fragment block cache\n");
1248 + goto failed_mount4;
1251 + for(i = 0; i < SQUASHFS_CACHED_FRAGMENTS; i++) {
1252 + msBlk->fragment[i].locked = 0;
1253 + msBlk->fragment[i].block = SQUASHFS_INVALID_BLK;
1254 + msBlk->fragment[i].data = NULL;
1257 + msBlk->next_fragment = 0;
1259 + /* Allocate fragment index table */
1260 + if(!(msBlk->fragment_index = (squashfs_fragment_index *) kmalloc(SQUASHFS_FRAGMENT_INDEX_BYTES(sBlk->fragments), GFP_KERNEL))) {
1261 + ERROR("Failed to allocate uid/gid table\n");
1262 + goto failed_mount5;
1265 + if(SQUASHFS_FRAGMENT_INDEX_BYTES(sBlk->fragments) &&
1266 + !read_data(s, (char *) msBlk->fragment_index, sBlk->fragment_table_start,
1267 + SQUASHFS_FRAGMENT_INDEX_BYTES(sBlk->fragments) | SQUASHFS_COMPRESSED_BIT, 0, NULL)) {
1268 + SERROR("unable to read fragment index table\n");
1269 + goto failed_mount6;
1274 + squashfs_fragment_index fragment;
1276 + for(i = 0; i < SQUASHFS_FRAGMENT_INDEXES(sBlk->fragments); i++) {
1277 + SQUASHFS_SWAP_FRAGMENT_INDEXES((&fragment), &msBlk->fragment_index[i], 1);
1278 + msBlk->fragment_index[i] = fragment;
1282 +#ifdef SQUASHFS_1_0_COMPATIBILITY
1285 + if(!(s->s_root = d_alloc_root((msBlk->iget)(s, sBlk->root_inode)))) {
1286 + ERROR("Root inode create failed\n");
1287 + goto failed_mount5;
1290 + TRACE("Leaving squashfs_read_super\n");
1294 + kfree(msBlk->fragment_index);
1296 + kfree(msBlk->fragment);
1298 + kfree(msBlk->uid);
1300 + kfree(msBlk->read_page);
1302 + kfree(msBlk->read_data);
1304 + kfree(msBlk->block_cache);
1310 +static int squashfs_statfs(struct super_block *s, struct statfs *buf)
1312 + squashfs_super_block *sBlk = &s->u.squashfs_sb.sBlk;
1314 + TRACE("Entered squashfs_statfs\n");
1315 + buf->f_type = SQUASHFS_MAGIC;
1316 + buf->f_bsize = sBlk->block_size;
1317 + buf->f_blocks = ((sBlk->bytes_used - 1) >> sBlk->block_log) + 1;
1318 + buf->f_bfree = buf->f_bavail = 0;
1319 + buf->f_files = sBlk->inodes;
1321 + buf->f_namelen = SQUASHFS_NAME_LEN;
1326 +static int squashfs_symlink_readpage(struct file *file, struct page *page)
1328 + struct inode *inode = page->mapping->host;
1329 + int index = page->index << PAGE_CACHE_SHIFT, length, bytes;
1330 + int block = inode->u.squashfs_i.start_block;
1331 + int offset = inode->u.squashfs_i.offset;
1332 + void *pageaddr = kmap(page);
1334 + TRACE("Entered squashfs_symlink_readpage, page index %x, start block %x, offset %x\n",
1335 + (unsigned int) page->index, inode->u.squashfs_i.start_block, inode->u.squashfs_i.offset);
1337 + for(length = 0; length < index; length += bytes) {
1338 + if(!(bytes = squashfs_get_cached_block(inode->i_sb, NULL, block, offset,
1339 + PAGE_CACHE_SIZE, &block, &offset))) {
1340 + ERROR("Unable to read symbolic link [%x:%x]\n", block, offset);
1345 + if(length != index) {
1346 + ERROR("(squashfs_symlink_readpage) length != index\n");
1351 + bytes = (inode->i_size - length) > PAGE_CACHE_SIZE ? PAGE_CACHE_SIZE : inode->i_size - length;
1352 + if(!(bytes = squashfs_get_cached_block(inode->i_sb, pageaddr, block, offset, bytes, &block, &offset)))
1353 + ERROR("Unable to read symbolic link [%x:%x]\n", block, offset);
1356 + memset(pageaddr + bytes, 0, PAGE_CACHE_SIZE - bytes);
1358 + flush_dcache_page(page);
1359 + SetPageUptodate(page);
1368 +#ifdef SQUASHFS_1_0_COMPATIBILITY
1369 +static unsigned int read_blocklist_1(struct inode *inode, int index, int readahead_blks,
1370 + char *block_list, char **block_p, unsigned int *bsize)
1372 + squashfs_sb_info *msBlk = &inode->i_sb->u.squashfs_sb;
1373 + unsigned short *block_listp;
1375 + int block_ptr = inode->u.squashfs_i.block_list_start;
1376 + int offset = inode->u.squashfs_i.offset;
1377 + int block = inode->u.squashfs_i.start_block;
1380 + int blocks = (index + readahead_blks - i);
1381 + if(blocks > (SIZE >> 1)) {
1382 + if((index - i) <= (SIZE >> 1))
1383 + blocks = index - i;
1385 + blocks = SIZE >> 1;
1389 + unsigned char sblock_list[SIZE];
1390 + if(!squashfs_get_cached_block(inode->i_sb, (char *) sblock_list, block_ptr, offset, blocks << 1, &block_ptr, &offset)) {
1391 + ERROR("Unable to read block list [%d:%x]\n", block_ptr, offset);
1394 + SQUASHFS_SWAP_SHORTS(((unsigned short *)block_list), ((unsigned short *)sblock_list), blocks);
1396 + if(!squashfs_get_cached_block(inode->i_sb, (char *) block_list, block_ptr, offset, blocks << 1, &block_ptr, &offset)) {
1397 + ERROR("Unable to read block list [%d:%x]\n", block_ptr, offset);
1400 + for(block_listp = (unsigned short *) block_list; i < index && blocks; i ++, block_listp ++, blocks --)
1401 + block += SQUASHFS_COMPRESSED_SIZE(*block_listp);
1402 + if(blocks >= readahead_blks)
1407 + *bsize = SQUASHFS_COMPRESSED_SIZE(*block_listp) | (!SQUASHFS_COMPRESSED(*block_listp) ? SQUASHFS_COMPRESSED_BIT_BLOCK : 0);
1409 + (unsigned short *) *block_p = block_listp;
1416 +static unsigned int read_blocklist(struct inode *inode, int index, int readahead_blks,
1417 + char *block_list, char **block_p, unsigned int *bsize)
1419 + squashfs_sb_info *msBlk = &inode->i_sb->u.squashfs_sb;
1420 + unsigned int *block_listp;
1422 + int block_ptr = inode->u.squashfs_i.block_list_start;
1423 + int offset = inode->u.squashfs_i.offset;
1424 + int block = inode->u.squashfs_i.start_block;
1427 + int blocks = (index + readahead_blks - i);
1428 + if(blocks > (SIZE >> 2)) {
1429 + if((index - i) <= (SIZE >> 2))
1430 + blocks = index - i;
1432 + blocks = SIZE >> 2;
1436 + unsigned char sblock_list[SIZE];
1437 + if(!squashfs_get_cached_block(inode->i_sb, (char *) sblock_list, block_ptr, offset, blocks << 2, &block_ptr, &offset)) {
1438 + ERROR("Unable to read block list [%d:%x]\n", block_ptr, offset);
1441 + SQUASHFS_SWAP_INTS(((unsigned int *)block_list), ((unsigned int *)sblock_list), blocks);
1443 + if(!squashfs_get_cached_block(inode->i_sb, (char *) block_list, block_ptr, offset, blocks << 2, &block_ptr, &offset)) {
1444 + ERROR("Unable to read block list [%d:%x]\n", block_ptr, offset);
1447 + for(block_listp = (unsigned int *) block_list; i < index && blocks; i ++, block_listp ++, blocks --)
1448 + block += SQUASHFS_COMPRESSED_SIZE_BLOCK(*block_listp);
1449 + if(blocks >= readahead_blks)
1453 + *bsize = *block_listp;
1458 +static int squashfs_readpage(struct file *file, struct page *page)
1460 + struct inode *inode = page->mapping->host;
1461 + squashfs_sb_info *msBlk = &inode->i_sb->u.squashfs_sb;
1462 + squashfs_super_block *sBlk = &msBlk->sBlk;
1463 + unsigned char block_list[SIZE];
1464 + unsigned int bsize, block, i = 0, bytes = 0, byte_offset = 0;
1465 + int index = page->index >> (sBlk->block_log - PAGE_CACHE_SHIFT);
1466 + void *pageaddr = kmap(page);
1467 + struct squashfs_fragment_cache *fragment;
1468 + char *data_ptr = msBlk->read_page;
1470 + int mask = (1 << (sBlk->block_log - PAGE_CACHE_SHIFT)) - 1;
1471 + int start_index = page->index & ~mask;
1472 + int end_index = start_index | mask;
1474 + TRACE("Entered squashfs_readpage, page index %x, start block %x\n", (unsigned int) page->index,
1475 + inode->u.squashfs_i.start_block);
1477 + if(inode->u.squashfs_i.fragment_start_block == SQUASHFS_INVALID_BLK || index < (inode->i_size >> sBlk->block_log)) {
1478 + if((block = (msBlk->read_blocklist)(inode, index, 1, block_list, NULL, &bsize)) == 0)
1481 + down(&msBlk->read_page_mutex);
1482 + if(!(bytes = read_data(inode->i_sb, msBlk->read_page, block, bsize, 1, NULL))) {
1483 + ERROR("Unable to read page, block %x, size %x\n", block, bsize);
1484 + up(&msBlk->read_page_mutex);
1488 + if((fragment = get_cached_fragment(inode->i_sb, inode->u.squashfs_i.fragment_start_block, inode->u.squashfs_i.fragment_size)) == NULL) {
1489 + ERROR("Unable to read page, block %x, size %x\n", inode->u.squashfs_i.fragment_start_block, (int) inode->u.squashfs_i.fragment_size);
1492 + bytes = inode->u.squashfs_i.fragment_offset + (inode->i_size & (sBlk->block_size - 1));
1493 + byte_offset = inode->u.squashfs_i.fragment_offset;
1494 + data_ptr = fragment->data;
1497 + for(i = start_index; i <= end_index && byte_offset < bytes; i++, byte_offset += PAGE_CACHE_SIZE) {
1498 + struct page *push_page;
1499 + int available_bytes = (bytes - byte_offset) > PAGE_CACHE_SIZE ? PAGE_CACHE_SIZE : bytes - byte_offset;
1501 + TRACE("bytes %d, i %d, byte_offset %d, available_bytes %d\n", bytes, i, byte_offset, available_bytes);
1503 + if(i == page->index) {
1504 + memcpy(pageaddr, data_ptr + byte_offset, available_bytes);
1505 + memset(pageaddr + available_bytes, 0, PAGE_CACHE_SIZE - available_bytes);
1507 + flush_dcache_page(page);
1508 + SetPageUptodate(page);
1510 + } else if((push_page = grab_cache_page_nowait(page->mapping, i))) {
1511 + void *pageaddr = kmap(push_page);
1512 + memcpy(pageaddr, data_ptr + byte_offset, available_bytes);
1513 + memset(pageaddr + available_bytes, 0, PAGE_CACHE_SIZE - available_bytes);
1514 + kunmap(push_page);
1515 + flush_dcache_page(push_page);
1516 + SetPageUptodate(push_page);
1517 + UnlockPage(push_page);
1518 + page_cache_release(push_page);
1522 + if(inode->u.squashfs_i.fragment_start_block == SQUASHFS_INVALID_BLK || index < (inode->i_size >> sBlk->block_log))
1523 + up(&msBlk->read_page_mutex);
1525 + release_cached_fragment(msBlk, fragment);
1530 + memset(pageaddr + bytes, 0, PAGE_CACHE_SIZE - bytes);
1532 + flush_dcache_page(page);
1533 + SetPageUptodate(page);
1540 +static int squashfs_readpage4K(struct file *file, struct page *page)
1542 + struct inode *inode = page->mapping->host;
1543 + squashfs_sb_info *msBlk = &inode->i_sb->u.squashfs_sb;
1544 + squashfs_super_block *sBlk = &msBlk->sBlk;
1545 + unsigned char block_list[SIZE];
1546 + unsigned int bsize, block, bytes = 0;
1547 + void *pageaddr = kmap(page);
1549 + TRACE("Entered squashfs_readpage4K, page index %x, start block %x\n", (unsigned int) page->index,
1550 + inode->u.squashfs_i.start_block);
1552 + if(page->index < (inode->i_size >> sBlk->block_log)) {
1553 + block = (msBlk->read_blocklist)(inode, page->index, 1, block_list, NULL, &bsize);
1555 + if(!(bytes = read_data(inode->i_sb, pageaddr, block, bsize, 1, NULL)))
1556 + ERROR("Unable to read page, block %x, size %x\n", block, bsize);
1558 + struct squashfs_fragment_cache *fragment;
1560 + if((fragment = get_cached_fragment(inode->i_sb, inode->u.squashfs_i.fragment_start_block, inode->u.squashfs_i.fragment_size)) == NULL)
1561 + ERROR("Unable to read page, block %x, size %x\n", inode->u.squashfs_i.fragment_start_block, (int) inode->u.squashfs_i.fragment_size);
1563 + bytes = inode->i_size & (sBlk->block_size - 1);
1564 + memcpy(pageaddr, fragment->data + inode->u.squashfs_i.fragment_offset, bytes);
1565 + release_cached_fragment(msBlk, fragment);
1569 + memset(pageaddr + bytes, 0, PAGE_CACHE_SIZE - bytes);
1571 + flush_dcache_page(page);
1572 + SetPageUptodate(page);
1579 +#ifdef SQUASHFS_1_0_COMPATIBILITY
1580 +static int squashfs_readpage_lessthan4K(struct file *file, struct page *page)
1582 + struct inode *inode = page->mapping->host;
1583 + squashfs_sb_info *msBlk = &inode->i_sb->u.squashfs_sb;
1584 + squashfs_super_block *sBlk = &msBlk->sBlk;
1585 + unsigned char block_list[SIZE];
1586 + unsigned short *block_listp, block, bytes = 0;
1587 + int index = page->index << (PAGE_CACHE_SHIFT - sBlk->block_log);
1588 + int file_blocks = ((inode->i_size - 1) >> sBlk->block_log) + 1;
1589 + int readahead_blks = 1 << (PAGE_CACHE_SHIFT - sBlk->block_log);
1590 + void *pageaddr = kmap(page);
1592 + int i_end = index + (1 << (PAGE_CACHE_SHIFT - sBlk->block_log));
1595 + TRACE("Entered squashfs_readpage_lessthan4K, page index %x, start block %x\n", (unsigned int) page->index,
1596 + inode->u.squashfs_i.start_block);
1598 + block = read_blocklist_1(inode, index, readahead_blks, block_list, (char **) &block_listp, NULL);
1600 + if(i_end > file_blocks)
1601 + i_end = file_blocks;
1603 + while(index < i_end) {
1604 + if(!(byte = read_data(inode->i_sb, pageaddr, block, *block_listp, 0, NULL))) {
1605 + ERROR("Unable to read page, block %x, size %x\n", block, *block_listp);
1608 + block += SQUASHFS_COMPRESSED_SIZE(*block_listp);
1616 + memset(pageaddr, 0, PAGE_CACHE_SIZE - bytes);
1618 + flush_dcache_page(page);
1619 + SetPageUptodate(page);
1627 +static int squashfs_readdir(struct file *file, void *dirent, filldir_t filldir)
1629 + struct inode *i = file->f_dentry->d_inode;
1630 + squashfs_sb_info *msBlk = &i->i_sb->u.squashfs_sb;
1631 + squashfs_super_block *sBlk = &msBlk->sBlk;
1632 + int next_block = i->u.squashfs_i.start_block + sBlk->directory_table_start, next_offset =
1633 + i->u.squashfs_i.offset, length = 0, dirs_read = 0, dir_count;
1634 + squashfs_dir_header dirh;
1635 + char buffer[sizeof(squashfs_dir_entry) + SQUASHFS_NAME_LEN + 1];
1636 + squashfs_dir_entry *dire = (squashfs_dir_entry *) buffer;
1638 + TRACE("Entered squashfs_readdir [%x:%x]\n", next_block, next_offset);
1640 + while(length < i->i_size) {
1641 + /* read directory header */
1643 + squashfs_dir_header sdirh;
1644 + if(!squashfs_get_cached_block(i->i_sb, (char *) &sdirh, next_block,
1645 + next_offset, sizeof(sdirh), &next_block, &next_offset))
1647 + length += sizeof(sdirh);
1648 + SQUASHFS_SWAP_DIR_HEADER(&dirh, &sdirh);
1650 + if(!squashfs_get_cached_block(i->i_sb, (char *) &dirh, next_block,
1651 + next_offset, sizeof(dirh), &next_block, &next_offset))
1653 + length += sizeof(dirh);
1656 + dir_count = dirh.count + 1;
1657 + while(dir_count--) {
1659 + squashfs_dir_entry sdire;
1660 + if(!squashfs_get_cached_block(i->i_sb, (char *) &sdire, next_block,
1661 + next_offset, sizeof(sdire), &next_block, &next_offset))
1663 + length += sizeof(sdire);
1664 + SQUASHFS_SWAP_DIR_ENTRY(dire, &sdire);
1666 + if(!squashfs_get_cached_block(i->i_sb, (char *) dire, next_block,
1667 + next_offset, sizeof(*dire), &next_block, &next_offset))
1669 + length += sizeof(*dire);
1672 + if(!squashfs_get_cached_block(i->i_sb, dire->name, next_block,
1673 + next_offset, dire->size + 1, &next_block, &next_offset))
1675 + length += dire->size + 1;
1677 + if(file->f_pos >= length)
1680 + dire->name[dire->size + 1] = '\0';
1682 + TRACE("Calling filldir(%x, %s, %d, %d, %x:%x, %d)\n", (unsigned int) dirent,
1683 + dire->name, dire->size + 1, (int) file->f_pos,
1684 + dirh.start_block, dire->offset, squashfs_filetype_table[dire->type]);
1686 + if(filldir(dirent, dire->name, dire->size + 1, file->f_pos, SQUASHFS_MK_VFS_INODE(dirh.start_block,
1687 + dire->offset), squashfs_filetype_table[dire->type]) < 0) {
1688 + TRACE("Filldir returned less than 0\n");
1692 + file->f_pos = length;
1700 + ERROR("Unable to read directory block [%x:%x]\n", next_block, next_offset);
1705 +static struct dentry *squashfs_lookup(struct inode *i, struct dentry *dentry)
1707 + const char *name =dentry->d_name.name;
1708 + int len = dentry->d_name.len;
1709 + struct inode *inode = NULL;
1710 + squashfs_sb_info *msBlk = &i->i_sb->u.squashfs_sb;
1711 + squashfs_super_block *sBlk = &msBlk->sBlk;
1712 + int next_block = i->u.squashfs_i.start_block + sBlk->directory_table_start, next_offset =
1713 + i->u.squashfs_i.offset, length = 0, dir_count;
1714 + squashfs_dir_header dirh;
1715 + char buffer[sizeof(squashfs_dir_entry) + SQUASHFS_NAME_LEN];
1716 + squashfs_dir_entry *dire = (squashfs_dir_entry *) buffer;
1718 + TRACE("Entered squashfs_lookup [%x:%x]\n", next_block, next_offset);
1720 + while(length < i->i_size) {
1721 + /* read directory header */
1723 + squashfs_dir_header sdirh;
1724 + if(!squashfs_get_cached_block(i->i_sb, (char *) &sdirh, next_block, next_offset,
1725 + sizeof(sdirh), &next_block, &next_offset))
1727 + length += sizeof(sdirh);
1728 + SQUASHFS_SWAP_DIR_HEADER(&dirh, &sdirh);
1730 + if(!squashfs_get_cached_block(i->i_sb, (char *) &dirh, next_block, next_offset,
1731 + sizeof(dirh), &next_block, &next_offset))
1733 + length += sizeof(dirh);
1736 + dir_count = dirh.count + 1;
1737 + while(dir_count--) {
1739 + squashfs_dir_entry sdire;
1740 + if(!squashfs_get_cached_block(i->i_sb, (char *) &sdire,
1741 + next_block,next_offset, sizeof(sdire), &next_block, &next_offset))
1743 + length += sizeof(sdire);
1744 + SQUASHFS_SWAP_DIR_ENTRY(dire, &sdire);
1746 + if(!squashfs_get_cached_block(i->i_sb, (char *) dire,
1747 + next_block,next_offset, sizeof(*dire), &next_block, &next_offset))
1749 + length += sizeof(*dire);
1752 + if(!squashfs_get_cached_block(i->i_sb, dire->name,
1753 + next_block, next_offset, dire->size + 1, &next_block, &next_offset))
1755 + length += dire->size + 1;
1757 + if((len == dire->size + 1) && !strncmp(name, dire->name, len)) {
1758 + squashfs_inode ino = SQUASHFS_MKINODE(dirh.start_block, dire->offset);
1760 + TRACE("calling squashfs_iget for directory entry %s, inode %x:%x\n",
1761 + name, dirh.start_block, dire->offset);
1763 + inode = (msBlk->iget)(i->i_sb, ino);
1771 + d_add(dentry, inode);
1772 + return ERR_PTR(0);
1775 + ERROR("Unable to read directory block [%x:%x]\n", next_block, next_offset);
1780 +static void squashfs_put_super(struct super_block *s)
1782 + if(s->u.squashfs_sb.block_cache) kfree(s->u.squashfs_sb.block_cache);
1783 + if(s->u.squashfs_sb.read_data) kfree(s->u.squashfs_sb.read_data);
1784 + if(s->u.squashfs_sb.read_page) kfree(s->u.squashfs_sb.read_page);
1785 + if(s->u.squashfs_sb.uid) kfree(s->u.squashfs_sb.uid);
1786 + s->u.squashfs_sb.block_cache = (void *) s->u.squashfs_sb.uid =
1787 + s->u.squashfs_sb.read_data = s->u.squashfs_sb.read_page = NULL;
1791 +static int __init init_squashfs_fs(void)
1794 + if(!(stream.workspace = (char *) vmalloc(zlib_inflate_workspacesize()))) {
1795 + ERROR("Failed to allocate zlib workspace\n");
1798 + return register_filesystem(&squashfs_fs_type);
1802 +static void __exit exit_squashfs_fs(void)
1804 + vfree(stream.workspace);
1805 + unregister_filesystem(&squashfs_fs_type);
1811 +module_init(init_squashfs_fs);
1812 +module_exit(exit_squashfs_fs);
1813 +MODULE_DESCRIPTION("squashfs, a compressed read-only filesystem");
1814 +MODULE_AUTHOR("Phillip Lougher <plougher@users.sourceforge.net>");
1815 +MODULE_LICENSE("GPL");
1816 --- linux-2.4.20/include/linux/fs.h~120-openwrt 2002-11-28 18:53:15.000000000 -0500
1817 +++ linux-2.4.20/include/linux/fs.h 2005-01-07 02:54:46.357830872 -0500
1819 #include <linux/usbdev_fs_i.h>
1820 #include <linux/jffs2_fs_i.h>
1821 #include <linux/cramfs_fs_sb.h>
1822 +#include <linux/squashfs_fs_i.h>
1825 * Attribute flags. These should be or-ed together to figure out what
1827 struct socket socket_i;
1828 struct usbdev_inode_info usbdev_i;
1829 struct jffs2_inode_info jffs2_i;
1830 + struct squashfs_inode_info squashfs_i;
1835 #include <linux/usbdev_fs_sb.h>
1836 #include <linux/cramfs_fs_sb.h>
1837 #include <linux/jffs2_fs_sb.h>
1838 +#include <linux/squashfs_fs_sb.h>
1840 extern struct list_head super_blocks;
1841 extern spinlock_t sb_lock;
1843 struct usbdev_sb_info usbdevfs_sb;
1844 struct jffs2_sb_info jffs2_sb;
1845 struct cramfs_sb_info cramfs_sb;
1846 + struct squashfs_sb_info squashfs_sb;
1850 --- /dev/null 2004-04-06 13:56:48.000000000 -0400
1851 +++ linux-2.4.20/include/linux/squashfs_fs.h 2005-01-07 02:54:46.357830872 -0500
1853 +#ifndef SQUASHFS_FS
1854 +#define SQUASHFS_FS
1858 + * Copyright (c) 2002, 2003, 2004 Phillip Lougher <plougher@users.sourceforge.net>
1860 + * This program is free software; you can redistribute it and/or
1861 + * modify it under the terms of the GNU General Public License
1862 + * as published by the Free Software Foundation; either version 2,
1863 + * or (at your option) any later version.
1865 + * This program is distributed in the hope that it will be useful,
1866 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1867 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1868 + * GNU General Public License for more details.
1870 + * You should have received a copy of the GNU General Public License
1871 + * along with this program; if not, write to the Free Software
1872 + * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1877 +#define SQUASHFS_MAJOR 2
1878 +#define SQUASHFS_MINOR 0
1879 +#define SQUASHFS_MAGIC 0x73717368
1880 +#define SQUASHFS_MAGIC_SWAP 0x68737173
1881 +#define SQUASHFS_START 0
1883 +/* size of metadata (inode and directory) blocks */
1884 +#define SQUASHFS_METADATA_SIZE 8192
1885 +#define SQUASHFS_METADATA_LOG 13
1887 +/* default size of data blocks */
1888 +#define SQUASHFS_FILE_SIZE 65536
1889 +#define SQUASHFS_FILE_LOG 16
1891 +#define SQUASHFS_FILE_MAX_SIZE 65536
1893 +/* Max number of uids and gids */
1894 +#define SQUASHFS_UIDS 256
1895 +#define SQUASHFS_GUIDS 255
1897 +/* Max length of filename (not 255) */
1898 +#define SQUASHFS_NAME_LEN 256
1900 +#define SQUASHFS_INVALID ((long long) 0xffffffffffff)
1901 +#define SQUASHFS_INVALID_BLK ((long long) 0xffffffff)
1902 +#define SQUASHFS_USED_BLK ((long long) 0xfffffffe)
1904 +/* Filesystem flags */
1905 +#define SQUASHFS_NOI 0
1906 +#define SQUASHFS_NOD 1
1907 +#define SQUASHFS_CHECK 2
1908 +#define SQUASHFS_NOF 3
1909 +#define SQUASHFS_NO_FRAG 4
1910 +#define SQUASHFS_ALWAYS_FRAG 5
1911 +#define SQUASHFS_DUPLICATE 6
1912 +#define SQUASHFS_BIT(flag, bit) ((flag >> bit) & 1)
1913 +#define SQUASHFS_UNCOMPRESSED_INODES(flags) SQUASHFS_BIT(flags, SQUASHFS_NOI)
1914 +#define SQUASHFS_UNCOMPRESSED_DATA(flags) SQUASHFS_BIT(flags, SQUASHFS_NOD)
1915 +#define SQUASHFS_UNCOMPRESSED_FRAGMENTS(flags) SQUASHFS_BIT(flags, SQUASHFS_NOF)
1916 +#define SQUASHFS_NO_FRAGMENTS(flags) SQUASHFS_BIT(flags, SQUASHFS_NO_FRAG)
1917 +#define SQUASHFS_ALWAYS_FRAGMENTS(flags) SQUASHFS_BIT(flags, SQUASHFS_ALWAYS_FRAG)
1918 +#define SQUASHFS_DUPLICATES(flags) SQUASHFS_BIT(flags, SQUASHFS_DUPLICATE)
1919 +#define SQUASHFS_CHECK_DATA(flags) SQUASHFS_BIT(flags, SQUASHFS_CHECK)
1920 +#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))
1922 +/* Max number of types and file types */
1923 +#define SQUASHFS_DIR_TYPE 1
1924 +#define SQUASHFS_FILE_TYPE 2
1925 +#define SQUASHFS_SYMLINK_TYPE 3
1926 +#define SQUASHFS_BLKDEV_TYPE 4
1927 +#define SQUASHFS_CHRDEV_TYPE 5
1928 +#define SQUASHFS_FIFO_TYPE 6
1929 +#define SQUASHFS_SOCKET_TYPE 7
1931 +/* 1.0 filesystem type definitions */
1932 +#define SQUASHFS_TYPES 5
1933 +#define SQUASHFS_IPC_TYPE 0
1935 +/* Flag whether block is compressed or uncompressed, bit is set if block is uncompressed */
1936 +#define SQUASHFS_COMPRESSED_BIT (1 << 15)
1937 +#define SQUASHFS_COMPRESSED_SIZE(B) (((B) & ~SQUASHFS_COMPRESSED_BIT) ? \
1938 + (B) & ~SQUASHFS_COMPRESSED_BIT : SQUASHFS_COMPRESSED_BIT)
1940 +#define SQUASHFS_COMPRESSED(B) (!((B) & SQUASHFS_COMPRESSED_BIT))
1942 +#define SQUASHFS_COMPRESSED_BIT_BLOCK (1 << 24)
1943 +#define SQUASHFS_COMPRESSED_SIZE_BLOCK(B) (((B) & ~SQUASHFS_COMPRESSED_BIT_BLOCK) ? \
1944 + (B) & ~SQUASHFS_COMPRESSED_BIT_BLOCK : SQUASHFS_COMPRESSED_BIT_BLOCK)
1946 +#define SQUASHFS_COMPRESSED_BLOCK(B) (!((B) & SQUASHFS_COMPRESSED_BIT_BLOCK))
1949 + * Inode number ops. Inodes consist of a compressed block number, and an uncompressed
1950 + * offset within that block
1952 +#define SQUASHFS_INODE_BLK(a) ((unsigned int) ((a) >> 16))
1953 +#define SQUASHFS_INODE_OFFSET(a) ((unsigned int) ((a) & 0xffff))
1954 +#define SQUASHFS_MKINODE(A, B) ((squashfs_inode)(((squashfs_inode) (A) << 16)\
1957 +/* Compute 32 bit VFS inode number from squashfs inode number */
1958 +#define SQUASHFS_MK_VFS_INODE(a, b) ((unsigned int) (((a) << 8) + ((b) >> 2) + 1))
1960 +/* Translate between VFS mode and squashfs mode */
1961 +#define SQUASHFS_MODE(a) ((a) & 0xfff)
1963 +/* fragment and fragment table defines */
1964 +typedef unsigned int squashfs_fragment_index;
1965 +#define SQUASHFS_FRAGMENT_BYTES(A) (A * sizeof(squashfs_fragment_entry))
1966 +#define SQUASHFS_FRAGMENT_INDEX(A) (SQUASHFS_FRAGMENT_BYTES(A) / SQUASHFS_METADATA_SIZE)
1967 +#define SQUASHFS_FRAGMENT_INDEX_OFFSET(A) (SQUASHFS_FRAGMENT_BYTES(A) % SQUASHFS_METADATA_SIZE)
1968 +#define SQUASHFS_FRAGMENT_INDEXES(A) ((SQUASHFS_FRAGMENT_BYTES(A) + SQUASHFS_METADATA_SIZE - 1) / SQUASHFS_METADATA_SIZE)
1969 +#define SQUASHFS_FRAGMENT_INDEX_BYTES(A) (SQUASHFS_FRAGMENT_INDEXES(A) * sizeof(squashfs_fragment_index))
1970 +#define SQUASHFS_CACHED_FRAGMENTS 3
1972 +/* cached data constants for filesystem */
1973 +#define SQUASHFS_CACHED_BLKS 8
1975 +#define SQUASHFS_MAX_FILE_SIZE_LOG 32
1976 +#define SQUASHFS_MAX_FILE_SIZE ((long long) 1 << (SQUASHFS_MAX_FILE_SIZE_LOG - 1))
1978 +#define SQUASHFS_MARKER_BYTE 0xff
1981 + * definitions for structures on disk
1984 +typedef unsigned int squashfs_block;
1985 +typedef long long squashfs_inode;
1987 +typedef unsigned int squashfs_uid;
1989 +typedef struct squashfs_super_block {
1990 + unsigned int s_magic;
1991 + unsigned int inodes;
1992 + unsigned int bytes_used;
1993 + unsigned int uid_start;
1994 + unsigned int guid_start;
1995 + unsigned int inode_table_start;
1996 + unsigned int directory_table_start;
1997 + unsigned int s_major:16;
1998 + unsigned int s_minor:16;
1999 + unsigned int block_size_1:16;
2000 + unsigned int block_log:16;
2001 + unsigned int flags:8;
2002 + unsigned int no_uids:8;
2003 + unsigned int no_guids:8;
2004 + time_t mkfs_time /* time of filesystem creation */;
2005 + squashfs_inode root_inode;
2006 + unsigned int block_size;
2007 + unsigned int fragments;
2008 + unsigned int fragment_table_start;
2009 +} __attribute__ ((packed)) squashfs_super_block;
2012 + unsigned int inode_type:4;
2013 + unsigned int mode:12; /* protection */
2014 + unsigned int uid:8; /* index into uid table */
2015 + unsigned int guid:8; /* index into guid table */
2016 +} __attribute__ ((packed)) squashfs_base_inode_header;
2018 +typedef squashfs_base_inode_header squashfs_ipc_inode_header;
2021 + unsigned int inode_type:4;
2022 + unsigned int mode:12; /* protection */
2023 + unsigned int uid:8; /* index into uid table */
2024 + unsigned int guid:8; /* index into guid table */
2025 + unsigned short rdev;
2026 +} __attribute__ ((packed)) squashfs_dev_inode_header;
2029 + unsigned int inode_type:4;
2030 + unsigned int mode:12; /* protection */
2031 + unsigned int uid:8; /* index into uid table */
2032 + unsigned int guid:8; /* index into guid table */
2033 + unsigned short symlink_size;
2035 +} __attribute__ ((packed)) squashfs_symlink_inode_header;
2038 + unsigned int inode_type:4;
2039 + unsigned int mode:12; /* protection */
2040 + unsigned int uid:8; /* index into uid table */
2041 + unsigned int guid:8; /* index into guid table */
2043 + squashfs_block start_block;
2044 + unsigned int fragment;
2045 + unsigned int offset;
2046 + unsigned int file_size:SQUASHFS_MAX_FILE_SIZE_LOG;
2047 + unsigned short block_list[0];
2048 +} __attribute__ ((packed)) squashfs_reg_inode_header;
2051 + unsigned int inode_type:4;
2052 + unsigned int mode:12; /* protection */
2053 + unsigned int uid:8; /* index into uid table */
2054 + unsigned int guid:8; /* index into guid table */
2055 + unsigned int file_size:19;
2056 + unsigned int offset:13;
2058 + unsigned int start_block:24;
2059 +} __attribute__ ((packed)) squashfs_dir_inode_header;
2062 + squashfs_base_inode_header base;
2063 + squashfs_dev_inode_header dev;
2064 + squashfs_symlink_inode_header symlink;
2065 + squashfs_reg_inode_header reg;
2066 + squashfs_dir_inode_header dir;
2067 + squashfs_ipc_inode_header ipc;
2068 +} squashfs_inode_header;
2071 + unsigned int offset:13;
2072 + unsigned int type:3;
2073 + unsigned int size:8;
2075 +} __attribute__ ((packed)) squashfs_dir_entry;
2078 + unsigned int count:8;
2079 + unsigned int start_block:24;
2080 +} __attribute__ ((packed)) squashfs_dir_header;
2084 + unsigned int start_block;
2085 + unsigned int size;
2086 +} __attribute__ ((packed)) squashfs_fragment_entry;
2088 +extern int squashfs_uncompress_block(void *d, int dstlen, void *s, int srclen);
2089 +extern int squashfs_uncompress_init(void);
2090 +extern int squashfs_uncompress_exit(void);
2093 + * macros to convert each packed bitfield structure from little endian to big
2094 + * endian and vice versa. These are needed when creating or using a filesystem on a
2095 + * machine with different byte ordering to the target architecture.
2099 +#define SQUASHFS_SWAP_SUPER_BLOCK(s, d) {\
2100 + SQUASHFS_MEMSET(s, d, sizeof(squashfs_super_block));\
2101 + SQUASHFS_SWAP((s)->s_magic, d, 0, 32);\
2102 + SQUASHFS_SWAP((s)->inodes, d, 32, 32);\
2103 + SQUASHFS_SWAP((s)->bytes_used, d, 64, 32);\
2104 + SQUASHFS_SWAP((s)->uid_start, d, 96, 32);\
2105 + SQUASHFS_SWAP((s)->guid_start, d, 128, 32);\
2106 + SQUASHFS_SWAP((s)->inode_table_start, d, 160, 32);\
2107 + SQUASHFS_SWAP((s)->directory_table_start, d, 192, 32);\
2108 + SQUASHFS_SWAP((s)->s_major, d, 224, 16);\
2109 + SQUASHFS_SWAP((s)->s_minor, d, 240, 16);\
2110 + SQUASHFS_SWAP((s)->block_size_1, d, 256, 16);\
2111 + SQUASHFS_SWAP((s)->block_log, d, 272, 16);\
2112 + SQUASHFS_SWAP((s)->flags, d, 288, 8);\
2113 + SQUASHFS_SWAP((s)->no_uids, d, 296, 8);\
2114 + SQUASHFS_SWAP((s)->no_guids, d, 304, 8);\
2115 + SQUASHFS_SWAP((s)->mkfs_time, d, 312, 32);\
2116 + SQUASHFS_SWAP((s)->root_inode, d, 344, 64);\
2117 + SQUASHFS_SWAP((s)->block_size, d, 408, 32);\
2118 + SQUASHFS_SWAP((s)->fragments, d, 440, 32);\
2119 + SQUASHFS_SWAP((s)->fragment_table_start, d, 472, 32);\
2122 +#define SQUASHFS_SWAP_BASE_INODE_HEADER(s, d, n) {\
2123 + SQUASHFS_MEMSET(s, d, n);\
2124 + SQUASHFS_SWAP((s)->inode_type, d, 0, 4);\
2125 + SQUASHFS_SWAP((s)->mode, d, 4, 12);\
2126 + SQUASHFS_SWAP((s)->uid, d, 16, 8);\
2127 + SQUASHFS_SWAP((s)->guid, d, 24, 8);\
2130 +#define SQUASHFS_SWAP_IPC_INODE_HEADER(s, d) SQUASHFS_SWAP_BASE_INODE_HEADER(s, d, sizeof(squashfs_ipc_inode_header))
2132 +#define SQUASHFS_SWAP_DEV_INODE_HEADER(s, d) {\
2133 + SQUASHFS_SWAP_BASE_INODE_HEADER(s, d, sizeof(squashfs_dev_inode_header));\
2134 + SQUASHFS_SWAP((s)->rdev, d, 32, 16);\
2137 +#define SQUASHFS_SWAP_SYMLINK_INODE_HEADER(s, d) {\
2138 + SQUASHFS_SWAP_BASE_INODE_HEADER(s, d, sizeof(squashfs_symlink_inode_header));\
2139 + SQUASHFS_SWAP((s)->symlink_size, d, 32, 16);\
2142 +#define SQUASHFS_SWAP_REG_INODE_HEADER(s, d) {\
2143 + SQUASHFS_SWAP_BASE_INODE_HEADER(s, d, sizeof(squashfs_reg_inode_header));\
2144 + SQUASHFS_SWAP((s)->mtime, d, 32, 32);\
2145 + SQUASHFS_SWAP((s)->start_block, d, 64, 32);\
2146 + SQUASHFS_SWAP((s)->fragment, d, 96, 32);\
2147 + SQUASHFS_SWAP((s)->offset, d, 128, 32);\
2148 + SQUASHFS_SWAP((s)->file_size, d, 160, SQUASHFS_MAX_FILE_SIZE_LOG);\
2151 +#define SQUASHFS_SWAP_DIR_INODE_HEADER(s, d) {\
2152 + SQUASHFS_SWAP_BASE_INODE_HEADER(s, d, sizeof(squashfs_dir_inode_header));\
2153 + SQUASHFS_SWAP((s)->file_size, d, 32, 19);\
2154 + SQUASHFS_SWAP((s)->offset, d, 51, 13);\
2155 + SQUASHFS_SWAP((s)->mtime, d, 64, 32);\
2156 + SQUASHFS_SWAP((s)->start_block, d, 96, 24);\
2159 +#define SQUASHFS_SWAP_DIR_HEADER(s, d) {\
2160 + SQUASHFS_MEMSET(s, d, sizeof(squashfs_dir_header));\
2161 + SQUASHFS_SWAP((s)->count, d, 0, 8);\
2162 + SQUASHFS_SWAP((s)->start_block, d, 8, 24);\
2165 +#define SQUASHFS_SWAP_DIR_ENTRY(s, d) {\
2166 + SQUASHFS_MEMSET(s, d, sizeof(squashfs_dir_entry));\
2167 + SQUASHFS_SWAP((s)->offset, d, 0, 13);\
2168 + SQUASHFS_SWAP((s)->type, d, 13, 3);\
2169 + SQUASHFS_SWAP((s)->size, d, 16, 8);\
2172 +#define SQUASHFS_SWAP_FRAGMENT_ENTRY(s, d) {\
2173 + SQUASHFS_MEMSET(s, d, sizeof(squashfs_fragment_entry));\
2174 + SQUASHFS_SWAP((s)->start_block, d, 0, 32);\
2175 + SQUASHFS_SWAP((s)->size, d, 32, 32);\
2178 +#define SQUASHFS_SWAP_SHORTS(s, d, n) {\
2180 + int bit_position;\
2181 + SQUASHFS_MEMSET(s, d, n * 2);\
2182 + for(entry = 0, bit_position = 0; entry < n; entry++, bit_position += 16)\
2183 + SQUASHFS_SWAP(s[entry], d, bit_position, 16);\
2186 +#define SQUASHFS_SWAP_INTS(s, d, n) {\
2188 + int bit_position;\
2189 + SQUASHFS_MEMSET(s, d, n * 4);\
2190 + for(entry = 0, bit_position = 0; entry < n; entry++, bit_position += 32)\
2191 + SQUASHFS_SWAP(s[entry], d, bit_position, 32);\
2194 +#define SQUASHFS_SWAP_DATA(s, d, n, bits) {\
2196 + int bit_position;\
2197 + SQUASHFS_MEMSET(s, d, n * bits / 8);\
2198 + for(entry = 0, bit_position = 0; entry < n; entry++, bit_position += bits)\
2199 + SQUASHFS_SWAP(s[entry], d, bit_position, bits);\
2202 +#define SQUASHFS_SWAP_FRAGMENT_INDEXES(s, d, n) SQUASHFS_SWAP_INTS(s, d, n)
2204 +#ifdef SQUASHFS_1_0_COMPATIBILITY
2206 + unsigned int inode_type:4;
2207 + unsigned int mode:12; /* protection */
2208 + unsigned int uid:4; /* index into uid table */
2209 + unsigned int guid:4; /* index into guid table */
2210 +} __attribute__ ((packed)) squashfs_base_inode_header_1;
2213 + unsigned int inode_type:4;
2214 + unsigned int mode:12; /* protection */
2215 + unsigned int uid:4; /* index into uid table */
2216 + unsigned int guid:4; /* index into guid table */
2217 + unsigned int type:4;
2218 + unsigned int offset:4;
2219 +} __attribute__ ((packed)) squashfs_ipc_inode_header_1;
2222 + unsigned int inode_type:4;
2223 + unsigned int mode:12; /* protection */
2224 + unsigned int uid:4; /* index into uid table */
2225 + unsigned int guid:4; /* index into guid table */
2226 + unsigned short rdev;
2227 +} __attribute__ ((packed)) squashfs_dev_inode_header_1;
2230 + unsigned int inode_type:4;
2231 + unsigned int mode:12; /* protection */
2232 + unsigned int uid:4; /* index into uid table */
2233 + unsigned int guid:4; /* index into guid table */
2234 + unsigned short symlink_size;
2236 +} __attribute__ ((packed)) squashfs_symlink_inode_header_1;
2239 + unsigned int inode_type:4;
2240 + unsigned int mode:12; /* protection */
2241 + unsigned int uid:4; /* index into uid table */
2242 + unsigned int guid:4; /* index into guid table */
2244 + squashfs_block start_block;
2245 + unsigned int file_size:SQUASHFS_MAX_FILE_SIZE_LOG;
2246 + unsigned short block_list[0];
2247 +} __attribute__ ((packed)) squashfs_reg_inode_header_1;
2250 + unsigned int inode_type:4;
2251 + unsigned int mode:12; /* protection */
2252 + unsigned int uid:4; /* index into uid table */
2253 + unsigned int guid:4; /* index into guid table */
2254 + unsigned int file_size:19;
2255 + unsigned int offset:13;
2257 + unsigned int start_block:24;
2258 +} __attribute__ ((packed)) squashfs_dir_inode_header_1;
2260 +#define SQUASHFS_SWAP_BASE_INODE_HEADER_1(s, d, n) {\
2261 + SQUASHFS_MEMSET(s, d, n);\
2262 + SQUASHFS_SWAP((s)->inode_type, d, 0, 4);\
2263 + SQUASHFS_SWAP((s)->mode, d, 4, 12);\
2264 + SQUASHFS_SWAP((s)->uid, d, 16, 4);\
2265 + SQUASHFS_SWAP((s)->guid, d, 20, 4);\
2268 +#define SQUASHFS_SWAP_IPC_INODE_HEADER_1(s, d) {\
2269 + SQUASHFS_SWAP_BASE_INODE_HEADER_1(s, d, sizeof(squashfs_ipc_inode_header_1));\
2270 + SQUASHFS_SWAP((s)->type, d, 24, 4);\
2271 + SQUASHFS_SWAP((s)->offset, d, 28, 4);\
2274 +#define SQUASHFS_SWAP_DEV_INODE_HEADER_1(s, d) {\
2275 + SQUASHFS_SWAP_BASE_INODE_HEADER_1(s, d, sizeof(squashfs_dev_inode_header_1));\
2276 + SQUASHFS_SWAP((s)->rdev, d, 24, 16);\
2279 +#define SQUASHFS_SWAP_SYMLINK_INODE_HEADER_1(s, d) {\
2280 + SQUASHFS_SWAP_BASE_INODE_HEADER(s, d, sizeof(squashfs_symlink_inode_header_1));\
2281 + SQUASHFS_SWAP((s)->symlink_size, d, 24, 16);\
2284 +#define SQUASHFS_SWAP_REG_INODE_HEADER_1(s, d) {\
2285 + SQUASHFS_SWAP_BASE_INODE_HEADER(s, d, sizeof(squashfs_reg_inode_header_1));\
2286 + SQUASHFS_SWAP((s)->mtime, d, 24, 32);\
2287 + SQUASHFS_SWAP((s)->start_block, d, 56, 32);\
2288 + SQUASHFS_SWAP((s)->file_size, d, 88, SQUASHFS_MAX_FILE_SIZE_LOG);\
2291 +#define SQUASHFS_SWAP_DIR_INODE_HEADER_1(s, d) {\
2292 + SQUASHFS_SWAP_BASE_INODE_HEADER(s, d, sizeof(squashfs_dir_inode_header_1));\
2293 + SQUASHFS_SWAP((s)->file_size, d, 24, 19);\
2294 + SQUASHFS_SWAP((s)->offset, d, 43, 13);\
2295 + SQUASHFS_SWAP((s)->mtime, d, 56, 32);\
2296 + SQUASHFS_SWAP((s)->start_block, d, 88, 24);\
2302 + * macros used to swap each structure entry, taking into account
2303 + * bitfields and different bitfield placing conventions on differing architectures
2305 +#include <asm/byteorder.h>
2306 +#ifdef __BIG_ENDIAN
2307 + /* convert from little endian to big endian */
2308 +#define SQUASHFS_SWAP(value, p, pos, tbits) _SQUASHFS_SWAP(value, p, pos, tbits, b_pos)
2310 + /* convert from big endian to little endian */
2311 +#define SQUASHFS_SWAP(value, p, pos, tbits) _SQUASHFS_SWAP(value, p, pos, tbits, 64 - tbits - b_pos)
2314 +#define _SQUASHFS_SWAP(value, p, pos, tbits, SHIFT) {\
2316 + int b_pos = pos % 8;\
2317 + unsigned long long val = 0;\
2318 + unsigned char *s = (unsigned char *)p + (pos / 8);\
2319 + unsigned char *d = ((unsigned char *) &val) + 7;\
2320 + for(bits = 0; bits < (tbits + b_pos); bits += 8) \
2322 + value = (val >> (SHIFT))/* & ((1 << tbits) - 1)*/;\
2324 +#define SQUASHFS_MEMSET(s, d, n) memset(s, 0, n);
2327 --- /dev/null 2004-04-06 13:56:48.000000000 -0400
2328 +++ linux-2.4.20/include/linux/squashfs_fs_i.h 2005-01-07 02:54:46.358830720 -0500
2330 +#ifndef SQUASHFS_FS_I
2331 +#define SQUASHFS_FS_I
2335 + * Copyright (c) 2002, 2003, 2004 Phillip Lougher <plougher@users.sourceforge.net>
2337 + * This program is free software; you can redistribute it and/or
2338 + * modify it under the terms of the GNU General Public License
2339 + * as published by the Free Software Foundation; either version 2,
2340 + * or (at your option) any later version.
2342 + * This program is distributed in the hope that it will be useful,
2343 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
2344 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2345 + * GNU General Public License for more details.
2347 + * You should have received a copy of the GNU General Public License
2348 + * along with this program; if not, write to the Free Software
2349 + * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
2354 +typedef struct squashfs_inode_info {
2355 + unsigned int start_block;
2356 + unsigned int block_list_start;
2357 + unsigned int offset;
2358 + unsigned int fragment_start_block;
2359 + unsigned int fragment_size;
2360 + unsigned int fragment_offset;
2361 + } squashfs_inode_info;
2363 --- /dev/null 2004-04-06 13:56:48.000000000 -0400
2364 +++ linux-2.4.20/include/linux/squashfs_fs_sb.h 2005-01-07 02:54:46.358830720 -0500
2366 +#ifndef SQUASHFS_FS_SB
2367 +#define SQUASHFS_FS_SB
2371 + * Copyright (c) 2002, 2003, 2004 Phillip Lougher <plougher@users.sourceforge.net>
2373 + * This program is free software; you can redistribute it and/or
2374 + * modify it under the terms of the GNU General Public License
2375 + * as published by the Free Software Foundation; either version 2,
2376 + * or (at your option) any later version.
2378 + * This program is distributed in the hope that it will be useful,
2379 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
2380 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2381 + * GNU General Public License for more details.
2383 + * You should have received a copy of the GNU General Public License
2384 + * along with this program; if not, write to the Free Software
2385 + * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
2387 + * squashfs_fs_sb.h
2390 +#include <linux/squashfs_fs.h>
2393 + unsigned int block;
2395 + unsigned int next_index;
2399 +struct squashfs_fragment_cache {
2400 + unsigned int block;
2402 + unsigned int locked;
2406 +typedef struct squashfs_sb_info {
2407 + squashfs_super_block sBlk;
2409 + int devblksize_log2;
2411 + squashfs_cache *block_cache;
2412 + struct squashfs_fragment_cache *fragment;
2414 + int next_fragment;
2415 + squashfs_uid *uid;
2416 + squashfs_uid *guid;
2417 + squashfs_fragment_index *fragment_index;
2418 + unsigned int read_size;
2421 + struct semaphore read_page_mutex;
2422 + struct semaphore block_cache_mutex;
2423 + struct semaphore fragment_mutex;
2424 + wait_queue_head_t waitq;
2425 + wait_queue_head_t fragment_wait_queue;
2426 + struct inode *(*iget)(struct super_block *s, squashfs_inode inode);
2427 + unsigned int (*read_blocklist)(struct inode *inode, int index, int readahead_blks,
2428 + char *block_list, char **block_p, unsigned int *bsize);
2429 + } squashfs_sb_info;
2431 --- linux-2.4.20/init/do_mounts.c~120-openwrt 2005-01-07 02:52:47.205944000 -0500
2432 +++ linux-2.4.20/init/do_mounts.c 2005-01-07 02:55:17.301126776 -0500
2434 #include <linux/minix_fs.h>
2435 #include <linux/ext2_fs.h>
2436 #include <linux/romfs_fs.h>
2437 +#include <linux/cramfs_fs.h>
2438 +#include <linux/squashfs_fs.h>
2440 #define BUILD_CRAMDISK
2449 identify_ramdisk_image(int fd, int start_block)
2451 struct ext2_super_block *ext2sb;
2452 struct romfs_super_block *romfsb;
2453 struct cramfs_super *cramfsb;
2454 + struct squashfs_super_block *squashfsb;
2459 ext2sb = (struct ext2_super_block *) buf;
2460 romfsb = (struct romfs_super_block *) buf;
2461 cramfsb = (struct cramfs_super *) buf;
2462 + squashfsb = (struct squashfs_super_block *) buf;
2463 memset(buf, 0xe5, size);
2466 @@ -535,6 +540,15 @@
2470 + /* squashfs is at block zero too */
2471 + if (squashfsb->s_magic == SQUASHFS_MAGIC) {
2472 + printk(KERN_NOTICE
2473 + "RAMDISK: squashfs filesystem found at block %d\n",
2475 + nblocks = (squashfsb->bytes_used+BLOCK_SIZE-1)>>BLOCK_SIZE_BITS;
2480 * Read block 1 to test for minix and ext2 superblock
2482 --- linux-2.4.20/kernel/ksyms.c~120-openwrt 2002-11-28 18:53:15.000000000 -0500
2483 +++ linux-2.4.20/kernel/ksyms.c 2005-01-07 02:54:46.362830112 -0500
2485 EXPORT_SYMBOL(simple_strtoull);
2486 EXPORT_SYMBOL(system_utsname); /* UTS data */
2487 EXPORT_SYMBOL(uts_sem); /* UTS semaphore */
2489 +//#ifndef __mips__ //bite me. -mbm.
2490 EXPORT_SYMBOL(sys_call_table);
2493 EXPORT_SYMBOL(machine_restart);
2494 EXPORT_SYMBOL(machine_halt);
2495 EXPORT_SYMBOL(machine_power_off);
2496 --- linux-2.4.20/lib/Config.in~120-openwrt 2002-11-28 18:53:15.000000000 -0500
2497 +++ linux-2.4.20/lib/Config.in 2005-01-07 02:54:46.363829960 -0500
2499 # Do we need the compression support?
2501 if [ "$CONFIG_CRAMFS" = "y" -o \
2502 + "$CONFIG_SQUASHFS" = "y" -o \
2503 "$CONFIG_PPP_DEFLATE" = "y" -o \
2504 "$CONFIG_JFFS2_FS" = "y" -o \
2505 "$CONFIG_ZISOFS_FS" = "y" ]; then
2506 define_tristate CONFIG_ZLIB_INFLATE y
2508 if [ "$CONFIG_CRAMFS" = "m" -o \
2509 + "$CONFIG_SQUASHFS" = "m" -o \
2510 "$CONFIG_PPP_DEFLATE" = "m" -o \
2511 "$CONFIG_JFFS2_FS" = "m" -o \
2512 "$CONFIG_ZISOFS_FS" = "m" ]; then