Index: ecos/packages/fs/jffs2/current/cdl/jffs2.cdl =================================================================== RCS file: /cvs/ecos/ecos/packages/fs/jffs2/current/cdl/jffs2.cdl,v retrieving revision 1.8 diff -w -u -r1.8 jffs2.cdl --- ecos/packages/fs/jffs2/current/cdl/jffs2.cdl 15 Jul 2003 20:45:32 -0000 1.8 +++ ecos/packages/fs/jffs2/current/cdl/jffs2.cdl 6 Aug 2003 06:12:41 -0000 @@ -58,7 +58,7 @@ requires CYGPKG_IO_FILEIO requires CYGPKG_IO_FLASH - requires CYGPKG_COMPRESS_ZLIB + requires CYGINT_ISO_MALLOC requires CYGPKG_ISOINFRA @@ -115,6 +115,19 @@ This option specifies the set of tests for the JFFS2 FS package." } + # Compression support + # + # + cdl_option CYGPKG_FS_JFFS2_COMPRESS { + display "JFFS2 compress support" + flavor bool + requires CYGPKG_COMPRESS_ZLIB + default_value 1 + description "JFFS2 has the ability to compress images. This saves flash, but +requires a fair bit of extra RAM(~100k?). +" + + } } # End of jffs2.cdl Index: ecos/packages/fs/jffs2/current/include/linux/jffs2.h =================================================================== RCS file: /cvs/ecos/ecos/packages/fs/jffs2/current/include/linux/jffs2.h,v retrieving revision 1.2 diff -w -u -r1.2 jffs2.h --- ecos/packages/fs/jffs2/current/include/linux/jffs2.h 15 Jul 2003 20:45:32 -0000 1.2 +++ ecos/packages/fs/jffs2/current/include/linux/jffs2.h 6 Aug 2003 06:12:41 -0000 @@ -36,6 +36,10 @@ /* How small can we sensibly write nodes? */ #define JFFS2_MIN_DATA_LEN 128 + + + + #define JFFS2_COMPR_NONE 0x00 #define JFFS2_COMPR_ZERO 0x01 #define JFFS2_COMPR_RTIME 0x02 @@ -43,6 +47,7 @@ #define JFFS2_COMPR_COPY 0x04 #define JFFS2_COMPR_DYNRUBIN 0x05 #define JFFS2_COMPR_ZLIB 0x06 + /* Compatibility flags. */ #define JFFS2_COMPAT_MASK 0xc000 /* What do to if an unknown nodetype is found */ #define JFFS2_NODE_ACCURATE 0x2000 Index: ecos/packages/fs/jffs2/current/src/compr.c =================================================================== RCS file: /cvs/ecos/ecos/packages/fs/jffs2/current/src/compr.c,v retrieving revision 1.3 diff -w -u -r1.3 compr.c --- ecos/packages/fs/jffs2/current/src/compr.c 5 Feb 2003 00:00:40 -0000 1.3 +++ ecos/packages/fs/jffs2/current/src/compr.c 6 Aug 2003 06:12:41 -0000 @@ -28,6 +28,8 @@ #include +#ifdef CYGPKG_FS_JFFS2_COMPRESS + int jffs2_zlib_compress(unsigned char *data_in, unsigned char *cpage_out, uint32_t *sourcelen, uint32_t *dstlen); void jffs2_zlib_decompress(unsigned char *data_in, unsigned char *cpage_out, uint32_t srclen, uint32_t destlen); int jffs2_rtime_compress(unsigned char *data_in, unsigned char *cpage_out, uint32_t *sourcelen, uint32_t *dstlen); @@ -38,6 +40,8 @@ void jffs2_dynrubin_decompress(unsigned char *data_in, unsigned char *cpage_out, uint32_t srclen, uint32_t destlen); + + /* jffs2_compress: * @data: Pointer to uncompressed data * @cdata: Pointer to buffer for compressed data @@ -136,3 +140,5 @@ } return 0; } + +#endif Index: ecos/packages/fs/jffs2/current/src/compr_rtime.c =================================================================== RCS file: /cvs/ecos/ecos/packages/fs/jffs2/current/src/compr_rtime.c,v retrieving revision 1.4 diff -w -u -r1.4 compr_rtime.c --- ecos/packages/fs/jffs2/current/src/compr_rtime.c 15 Jul 2003 20:45:32 -0000 1.4 +++ ecos/packages/fs/jffs2/current/src/compr_rtime.c 6 Aug 2003 06:12:41 -0000 @@ -26,6 +26,7 @@ #include #include + /* _compress returns the compressed size, -1 if bigger */ int jffs2_rtime_compress(unsigned char *data_in, unsigned char *cpage_out, uint32_t *sourcelen, uint32_t *dstlen) @@ -100,5 +101,4 @@ } } } - Index: ecos/packages/fs/jffs2/current/src/compr_rubin.c =================================================================== RCS file: /cvs/ecos/ecos/packages/fs/jffs2/current/src/compr_rubin.c,v retrieving revision 1.3 diff -w -u -r1.3 compr_rubin.c --- ecos/packages/fs/jffs2/current/src/compr_rubin.c 5 Feb 2003 00:00:40 -0000 1.3 +++ ecos/packages/fs/jffs2/current/src/compr_rubin.c 6 Aug 2003 06:12:41 -0000 @@ -17,8 +17,6 @@ #include "compr_rubin.h" #include "histo_mips.h" - - static void init_rubin(struct rubin_state *rs, int div, int *bits) { int c; Index: ecos/packages/fs/jffs2/current/src/erase.c =================================================================== RCS file: /cvs/ecos/ecos/packages/fs/jffs2/current/src/erase.c,v retrieving revision 1.4 diff -w -u -r1.4 erase.c --- ecos/packages/fs/jffs2/current/src/erase.c 15 Jul 2003 20:45:32 -0000 1.4 +++ ecos/packages/fs/jffs2/current/src/erase.c 6 Aug 2003 06:12:47 -0000 @@ -363,11 +363,12 @@ jeb->dirty_size = 0; jeb->wasted_size = 0; } else { - struct jffs2_unknown_node marker = { - .magic = cpu_to_je16(JFFS2_MAGIC_BITMASK), - .nodetype = cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER), - .totlen = cpu_to_je32(c->cleanmarker_size) - }; + + struct jffs2_unknown_node marker; + memset(&marker, 0, sizeof(marker)); + marker.magic = cpu_to_je16(JFFS2_MAGIC_BITMASK); + marker.nodetype = cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER); + marker.totlen = cpu_to_je32(c->cleanmarker_size); marker.hdr_crc = cpu_to_je32(crc32(0, &marker, je32_to_cpu(marker.totlen) - 4)); Index: ecos/packages/fs/jffs2/current/src/gc.c =================================================================== RCS file: /cvs/ecos/ecos/packages/fs/jffs2/current/src/gc.c,v retrieving revision 1.4 diff -w -u -r1.4 gc.c --- ecos/packages/fs/jffs2/current/src/gc.c 15 Jul 2003 20:45:32 -0000 1.4 +++ ecos/packages/fs/jffs2/current/src/gc.c 6 Aug 2003 06:12:47 -0000 @@ -1085,9 +1085,11 @@ writebuf = pg_ptr + (offset & (PAGE_CACHE_SIZE -1)); +#ifdef CYGPKG_FS_JFFS2_COMPRESS if (comprbuf) { comprtype = jffs2_compress(writebuf, comprbuf, &datalen, &cdatalen); } +#endif if (comprtype) { writebuf = comprbuf; } else { Index: ecos/packages/fs/jffs2/current/src/read.c =================================================================== RCS file: /cvs/ecos/ecos/packages/fs/jffs2/current/src/read.c,v retrieving revision 1.4 diff -w -u -r1.4 read.c --- ecos/packages/fs/jffs2/current/src/read.c 15 Jul 2003 20:45:32 -0000 1.4 +++ ecos/packages/fs/jffs2/current/src/read.c 6 Aug 2003 06:12:47 -0000 @@ -84,7 +84,8 @@ */ if (ri->compr == JFFS2_COMPR_NONE && len == je32_to_cpu(ri->dsize)) { readbuf = buf; - } else { + } + else { readbuf = kmalloc(je32_to_cpu(ri->csize), GFP_KERNEL); if (!readbuf) { ret = -ENOMEM; @@ -92,6 +93,7 @@ } } if (ri->compr != JFFS2_COMPR_NONE) { +#ifdef CYGPKG_FS_JFFS2_COMPRESS if (len < je32_to_cpu(ri->dsize)) { decomprbuf = kmalloc(je32_to_cpu(ri->dsize), GFP_KERNEL); if (!decomprbuf) { @@ -101,10 +103,15 @@ } else { decomprbuf = buf; } +#else + ret = -EINVAL; + goto out_readbuf; +#endif } else { decomprbuf = readbuf; } + D2(printk(KERN_DEBUG "Read %d bytes to %p\n", je32_to_cpu(ri->csize), readbuf)); ret = jffs2_flash_read(c, (ref_offset(fd->raw)) + sizeof(*ri), @@ -123,6 +130,8 @@ goto out_decomprbuf; } D2(printk(KERN_DEBUG "Data CRC matches calculated CRC %08x\n", crc)); + +#ifdef CYGPKG_FS_JFFS2_COMPRESS if (ri->compr != JFFS2_COMPR_NONE) { D2(printk(KERN_DEBUG "Decompress %d bytes from %p to %d bytes at %p\n", je32_to_cpu(ri->csize), readbuf, je32_to_cpu(ri->dsize), decomprbuf)); @@ -132,7 +141,7 @@ goto out_decomprbuf; } } - +#endif if (len < je32_to_cpu(ri->dsize)) { memcpy(buf, decomprbuf+ofs, len); } Index: ecos/packages/fs/jffs2/current/src/write.c =================================================================== RCS file: /cvs/ecos/ecos/packages/fs/jffs2/current/src/write.c,v retrieving revision 1.3 diff -w -u -r1.3 write.c --- ecos/packages/fs/jffs2/current/src/write.c 5 Feb 2003 00:00:40 -0000 1.3 +++ ecos/packages/fs/jffs2/current/src/write.c 6 Aug 2003 06:12:47 -0000 @@ -300,6 +300,7 @@ datalen = writelen; cdatalen = min_t(uint32_t, alloclen - sizeof(*ri), writelen); +#ifdef CYGPKG_FS_JFFS2_COMPRESS comprbuf = kmalloc(cdatalen, GFP_KERNEL); if (comprbuf) { comprtype = jffs2_compress(buf, comprbuf, &datalen, &cdatalen); @@ -308,9 +309,12 @@ /* Either compression failed, or the allocation of comprbuf failed */ if (comprbuf) kfree(comprbuf); +#endif comprbuf = buf; datalen = cdatalen; +#ifdef CYGPKG_FS_JFFS2_COMPRESS } +#endif /* Now comprbuf points to the data to be written, be it compressed or not. comprtype holds the compression type, and comprtype == JFFS2_COMPR_NONE means that the comprbuf doesn't need to be kfree()d.