Squashfs-tools: add LZO support
Hi,
Thanks for the patches. Is there a way to increase the compression level? Right now my file system compressed with zlib is 176MB and with this patch using lzo it's 232MB. I've read that lzo's compression level can be increased to near zlib levels, but compression times suffer. Compression times don't matter to me, but increased decompression speed is intriguing.
Thanks again,
Kirk
Quoted 260 lines · Chan Jeong
From: Chan Jeong <[email protected]>
Subject: [Squashfs-devel] [PATCH 2/2] Squashfs-tools: add LZO support
To: [email protected]
Cc: "'Phillip Lougher'" <[email protected]>, "'Gunho Lee'" <[email protected]>, "'Tim Bird'" <[email protected]>, [email protected], "'Hyo Jun Im'" <[email protected]>
Date: Tuesday, May 18, 2010, 12:05 AM
This patch adds LZO compression and
decompression to Squashfs tools.The patch is against the latest cvs version and requires the LZO library
from http://www.oberhumer.com/opensource/lzo.Signed-off-by Chan Jeong <[email protected]>--- Makefile | 20 +++++++++++ compressor.c | 7 ++++ lzo_wrapper.c | 99 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ squashfs_fs.h | 1 4 files changed, 127 insertions(+)diff -uprN -x .cvs squashfs-tools.cvs.orig/Makefile squashfs-tools.cvs/Makefile
--- squashfs-tools.cvs.orig/Makefile2010-05-13 02:17:06.000000000 +0900 +++ squashfs-tools.cvs/Makefile 2010-05-18 11:36:58.000000000 +0900(quoted diff) +4
-0@@ -15,6 +15,18 @@ #LZMA_SUPPORT = 1 #LZMA_DIR = ../../../LZMA/lzma465 +# +# Building LZO support +# +# The LZO library (http://www.oberhumer.com/opensource/lzo/)is supported.
(quoted diff) +2
-0+# +# To build using the LZO library (2.0.3 used indevelopment, other versions may
+# work) - download, unpack, build and install it, uncomment and setLZO_DIRto
+# installed directory prefix, and uncomment theLZO_SUPPORTline below.(quoted diff) +12
-0+ +#LZO_SUPPORT = 1 +#LZO_DIR = /usr/local + #Compression default. COMP_DEFAULT = gzip@@ -47,6 +59,14 @@ UNSQUASHFS_OBJS += xz_wrapper.o LIBS += -llzma endif +ifdef LZO_SUPPORT +CFLAGS += -DLZO_SUPPORT +INCLUDEDIR += -I$(LZO_DIR)/include +MKSQUASHFS_OBJS += lzo_wrapper.o +UNSQUASHFS_OBJS += lzo_wrapper.o +LIBS += -L$(LZO_DIR)/lib -llzo2 +endif + .PHONY: all all: mksquashfs unsquashfsdiff -uprN -x .cvs
squashfs-tools.cvs.orig/compressor.csquashfs-tools.cvs/compressor.c
---squashfs-tools.cvs.orig/compressor.c2009-08-29 10:05:34.000000000 +0900 +++ squashfs-tools.cvs/compressor.c 2010-05-18 11:37:46.000000000 +0900(quoted diff) +1
-0@@ -29,6 +29,8 @@ extern int gzip_compress(void **, char * extern int gzip_uncompress(char *, char *, int, int, int *); extern int lzma_compress(void **, char *, char *, int, int, int *); extern int lzma_uncompress(char *, char *, int, int, int *); +extern int lzo_compress(void **, char *, char *, int, int,int *);
+extern intlzo_uncompress(char *, char *, int, int, int *);struct compressor compressor[] = {
{gzip_compress,gzip_uncompress,ZLIB_COMPRESSION, "gzip", 1 },(quoted diff) +5
-0@@ -37,6 +39,11 @@ struct compressor compressor[] = { #else { NULL, NULL, LZMA_COMPRESSION, "lzma", 0 }, #endif +#ifdef LZO_SUPPORT + { lzo_compress, lzo_uncompress, LZO_COMPRESSION, "lzo", 1 }, +#else + { NULL, NULL, LZO_COMPRESSION, "lzo", 0 }, +#endif{ NULL, NULL , 0, "unknown", 0}
};diff -uprN -x .cvs
squashfs-tools.cvs.orig/lzo_wrapper.csquashfs-tools.cvs/lzo_wrapper.c
---squashfs-tools.cvs.orig/lzo_wrapper.c1970-01-01 09:00:00.000000000 +0900 +++ squashfs-tools.cvs/lzo_wrapper.c 2010-05-18 11:59:30.000000000 +0900(quoted diff) +5
-0@@ -0,0 +1,99 @@ +/* + * Copyright (c) 2010 LG Electronics + * Chan Jeong <[email protected]> + * + * This program is free software; you can redistribute itand/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2,
+ * or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ *lzo_wrapper.c
+ */(quoted diff) +10
-0+ +#include <stdlib.h> +#include <string.h> + +#include <lzo/lzoconf.h> +#include <lzo/lzo1x.h> + +/* worst-case expansion calculation during compression, + see LZO FAQ for more information */ +#define LZO_OUTPUT_BUFFER_SIZE(size)(size + (size/16) + 64 + 3)
(quoted diff) +2
-0+ +int lzo_compress(void **strm, char *d, char *s, int size,int
block_size,
+ int *error)(quoted diff) +9
-0+{ + int res = 0; + lzo_bytep out; + lzo_uint outlen; + lzo_voidp wrkmem; + void **buffers = (void **)*strm; + + if(buffers == NULL) { + if((buffers = *strm=
calloc(2, sizeof(void *))) == NULL)
+
gotomalloc_failed;
+
+ /* work memory */
+if((buffers[0] = malloc(LZO1X_1_MEM_COMPRESS)) == NULL)
+
gotomalloc_failed;
+
+ /* temporal output
buffer */
+if((buffers[1] = malloc(LZO_OUTPUT_BUFFER_SIZE(block_size))) == NULL)+
gotomalloc_failed;
+ }
+
+ wrkmem = buffers[0];
+ out = buffers[1];
+ res =lzo1x_1_compress((lzo_bytep)s, size, out, &outlen, wrkmem);
+if(res != LZO_E_OK){
+ /*
+ * All
other errors return failure, with the compressor + *
specific error code in *error
+ */
+ *error = res;
+ return -1;
+ }
+
+ if(outlen >= size) {
+ /*
+ * Output
buffer overflow. Return out of buffer space + */
+ return 0;
+ }
+
+ /*
+ * Success, return the
compressed size.
+ */
+memcpy(d, out, outlen);
+ return outlen;(quoted diff) +5
-0+ +malloc_failed: + if(buffers) { + if(buffers[0]) { +
free(buffers[0]);
+ }
+ free(buffers);
+ }
+ return -1;(quoted diff) +4
-0+} + + +int lzo_uncompress(char *d, char *s, int size, int
block_size, int *error)
+{
+ int res;
+lzo_uintbytes =block_size;
+
+ res = lzo1x_decompress((lzo_bytep)s,
size, (lzo_bytep)d, &bytes, NULL);(quoted diff) +4
-0+ + *error = res; + return res == LZO_E_OK ? bytes : -1; +}diff -uprN -x .cvs
squashfs-tools.cvs.orig/squashfs_fs.hsquashfs-tools.cvs/squashfs_fs.h
---squashfs-tools.cvs.orig/squashfs_fs.h2010-05-13 04:28:38.000000000 +0900 +++ squashfs-tools.cvs/squashfs_fs.h 2010-05-18 11:43:22.000000000 +0900(quoted diff) +1
-0@@ -238,6 +238,7 @@ typedef long long squashfs_inode_t; #define ZLIB_COMPRESSION 1 #define LZMA_COMPRESSION 2 +#define LZO_COMPRESSION3
struct
squashfs_super_block{
unsigned int
s_magic;------------------------------------------------------------------------------
_______________________________________________
Squashfs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/squashfs-devel
Hi,
Yes, you can try lzo1x-999 compression just with 2-line change. The increased compression level, lzo1x-999, would be better than lzo1x-1 for slow I/O storage and higher CPU.
If you have any chance to share some test result like decompression time comparison, it would be nice.
Thanks,
Chan Jeong
lzo_wrapper.c renamed from lzo_wrapper.c.orig +2 -2
@@ -43,7 +43,7 @@ int lzo_compress(void **strm, char *d, c goto malloc_failed;/* work memory */ -if ((buffers[0 ] =malloc (LZO1X_1_MEM_COMPRESS )) ==NULL ) +if ((buffers[0 ] =malloc (LZO1X_999_MEM_COMPRESS )) ==NULL ) goto malloc_failed;/* temporal output buffer */
@@ -53,7 +53,7 @@ int lzo_compress(void **strm, char *d, c wrkmem = buffers[0 ]; out = buffers[1 ]; - res =lzo1x_1_compress ((lzo_bytep )s, size, out, &outlen, wrkmem); + res =lzo1x_999_compress ((lzo_bytep )s, size, out, &outlen, wrkmem);if (res !=LZO_E_OK ) {/* * All other errors return failure, with the compressor
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of kirk w
Sent: Saturday, May 22, 2010 12:54 PM
To: [email protected]; Chan Jeong
Cc: 'Phillip Lougher'; 'Gunho Lee'; 'Tim Bird'; [email protected]; 'Hyo Jun Im'
Subject: Re: [Squashfs-devel] [PATCH 2/2] Squashfs-tools: add LZO support
Hi,
Thanks for the patches. Is there a way to increase the compression level? Right now my file system compressed with zlib is 176MB and with this patch using lzo it's 232MB. I've read that lzo's compression level can be increased to near zlib levels, but compression times suffer. Compression times don't matter to me, but increased decompression speed is intriguing.
Thanks again,
Kirk
Quoted 4 lines · Chan Jeong
From: Chan Jeong <[email protected]>
Subject: [Squashfs-devel] [PATCH 2/2] Squashfs-tools: add LZO support
To: [email protected]
Cc: "'Phillip Lougher'" <phillip-cnXvMjJKhjYG2Il/[email protected]>, "'Gunho Lee'" <[email protected]>, "'Tim Bird'" <[email protected]>,
[email protected], "'Hyo Jun Im'" <[email protected]>
Quoted 249 lines
Date: Tuesday, May 18, 2010, 12:05 AM
This patch adds LZO compression and
decompression to Squashfs tools.The patch is against the latest cvs version and requires the LZO library
from http://www.oberhumer.com/opensource/lzo.Signed-off-by Chan Jeong <[email protected]>--- Makefile | 20 +++++++++++ compressor.c | 7 ++++ lzo_wrapper.c | 99 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ squashfs_fs.h | 1 4 files changed, 127 insertions(+)diff -uprN -x .cvs squashfs-tools.cvs.orig/Makefile squashfs-tools.cvs/Makefile
--- squashfs-tools.cvs.orig/Makefile2010-05-13 02:17:06.000000000 +0900 +++ squashfs-tools.cvs/Makefile 2010-05-18 11:36:58.000000000 +0900(quoted diff) +4
-0@@ -15,6 +15,18 @@ #LZMA_SUPPORT = 1 #LZMA_DIR = ../../../LZMA/lzma465 +# +# Building LZO support +# +# The LZO library (http://www.oberhumer.com/opensource/lzo/)is supported.
(quoted diff) +2
-0+# +# To build using the LZO library (2.0.3 used indevelopment, other versions may
+# work) - download, unpack, build and install it, uncomment and setLZO_DIRto
+# installed directory prefix, and uncomment theLZO_SUPPORTline below.(quoted diff) +12
-0+ +#LZO_SUPPORT = 1 +#LZO_DIR = /usr/local + #Compression default. COMP_DEFAULT = gzip@@ -47,6 +59,14 @@ UNSQUASHFS_OBJS += xz_wrapper.o LIBS += -llzma endif +ifdef LZO_SUPPORT +CFLAGS += -DLZO_SUPPORT +INCLUDEDIR += -I$(LZO_DIR)/include +MKSQUASHFS_OBJS += lzo_wrapper.o +UNSQUASHFS_OBJS += lzo_wrapper.o +LIBS += -L$(LZO_DIR)/lib -llzo2 +endif + .PHONY: all all: mksquashfs unsquashfsdiff -uprN -x .cvs
squashfs-tools.cvs.orig/compressor.csquashfs-tools.cvs/compressor.c
---squashfs-tools.cvs.orig/compressor.c2009-08-29 10:05:34.000000000 +0900 +++ squashfs-tools.cvs/compressor.c 2010-05-18 11:37:46.000000000 +0900(quoted diff) +1
-0@@ -29,6 +29,8 @@ extern int gzip_compress(void **, char * extern int gzip_uncompress(char *, char *, int, int, int *); extern int lzma_compress(void **, char *, char *, int, int, int *); extern int lzma_uncompress(char *, char *, int, int, int *); +extern int lzo_compress(void **, char *, char *, int, int,int *);
+extern intlzo_uncompress(char *, char *, int, int, int *);struct compressor compressor[] = {
{gzip_compress,gzip_uncompress,ZLIB_COMPRESSION, "gzip", 1 },(quoted diff) +5
-0@@ -37,6 +39,11 @@ struct compressor compressor[] = { #else { NULL, NULL, LZMA_COMPRESSION, "lzma", 0 }, #endif +#ifdef LZO_SUPPORT + { lzo_compress, lzo_uncompress, LZO_COMPRESSION, "lzo", 1 }, +#else + { NULL, NULL, LZO_COMPRESSION, "lzo", 0 }, +#endif{ NULL, NULL , 0, "unknown", 0}
};diff -uprN -x .cvs
squashfs-tools.cvs.orig/lzo_wrapper.csquashfs-tools.cvs/lzo_wrapper.c
---squashfs-tools.cvs.orig/lzo_wrapper.c1970-01-01 09:00:00.000000000 +0900 +++ squashfs-tools.cvs/lzo_wrapper.c 2010-05-18 11:59:30.000000000 +0900(quoted diff) +5
-0@@ -0,0 +1,99 @@ +/* + * Copyright (c) 2010 LG Electronics + * Chan Jeong <[email protected]> + * + * This program is free software; you can redistribute itand/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2,
+ * or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ *lzo_wrapper.c
+ */(quoted diff) +10
-0+ +#include <stdlib.h> +#include <string.h> + +#include <lzo/lzoconf.h> +#include <lzo/lzo1x.h> + +/* worst-case expansion calculation during compression, + see LZO FAQ for more information */ +#define LZO_OUTPUT_BUFFER_SIZE(size)(size + (size/16) + 64 + 3)
(quoted diff) +2
-0+ +int lzo_compress(void **strm, char *d, char *s, int size,int
block_size,
+ int *error)(quoted diff) +9
-0+{ + int res = 0; + lzo_bytep out; + lzo_uint outlen; + lzo_voidp wrkmem; + void **buffers = (void **)*strm; + + if(buffers == NULL) { + if((buffers = *strm=
calloc(2, sizeof(void *))) == NULL)
+
gotomalloc_failed;
+
+ /* work memory */
+if((buffers[0] = malloc(LZO1X_1_MEM_COMPRESS)) == NULL)
+
gotomalloc_failed;
+
+ /* temporal output
buffer */
+if((buffers[1] = malloc(LZO_OUTPUT_BUFFER_SIZE(block_size))) == NULL)+
gotomalloc_failed;
+ }
+
+ wrkmem = buffers[0];
+ out = buffers[1];
+ res =lzo1x_1_compress((lzo_bytep)s, size, out, &outlen, wrkmem);
+if(res != LZO_E_OK){
+ /*
+ * All
other errors return failure, with the compressor + *
specific error code in *error
+ */
+ *error = res;
+ return -1;
+ }
+
+ if(outlen >= size) {
+ /*
+ * Output
buffer overflow. Return out of buffer space + */
+ return 0;
+ }
+
+ /*
+ * Success, return the
compressed size.
+ */
+memcpy(d, out, outlen);
+ return outlen;(quoted diff) +5
-0+ +malloc_failed: + if(buffers) { + if(buffers[0]) { +
free(buffers[0]);
+ }
+ free(buffers);
+ }
+ return -1;(quoted diff) +4
-0+} + + +int lzo_uncompress(char *d, char *s, int size, int
block_size, int *error)
+{
+ int res;
+lzo_uintbytes =block_size;
+
+ res = lzo1x_decompress((lzo_bytep)s,
size, (lzo_bytep)d, &bytes, NULL);(quoted diff) +4
-0+ + *error = res; + return res == LZO_E_OK ? bytes : -1; +}diff -uprN -x .cvs
squashfs-tools.cvs.orig/squashfs_fs.hsquashfs-tools.cvs/squashfs_fs.h
---squashfs-tools.cvs.orig/squashfs_fs.h2010-05-13 04:28:38.000000000 +0900 +++ squashfs-tools.cvs/squashfs_fs.h 2010-05-18 11:43:22.000000000 +0900(quoted diff) +1
-0@@ -238,6 +238,7 @@ typedef long long squashfs_inode_t; #define ZLIB_COMPRESSION 1 #define LZMA_COMPRESSION 2 +#define LZO_COMPRESSION3
struct
squashfs_super_block{
unsigned int
s_magic;
Quoted 7 lines
------------------------------------------------------------------------------
_______________________________________________
Squashfs-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/squashfs-devel
--
To unsubscribe from this list: send the line "unsubscribe linux-embedded" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
------------------------------------------------------------------------------
Hi,
Here are some figures for Squashfs file read time. The lzo1x-999 would be better than lzo1x-1 in most cases and lzo1x-999 is also used for lzo-compressed kernel.
Uncompressed size: 9.86 MiB
on a X86 PC (2.4GHz)
gzip : 3.96 MiB 0.17s
lzo1x-1 : 5.25 MiB 0.10s
lzo1x-999 : 4.28 MiB 0.09s
on a MIPS board (403 MHz)
gzip : 3.96 MiB 1.01s
lzo1x-1 : 5.25 MiB 1.17s
lzo1x-999 : 4.28 MiB 1.05s
The Squashfs-gzip is better than Squashfs-lzo1x-999 on my mips board which has very poor NAND flash read performance.
Chan Jeong
-----Original Message-----
From: Chan Jeong [mailto:[email protected]]
Sent: Monday, May 24, 2010 11:06 AM
To: 'kirk w'; [email protected]
Cc: 'Phillip Lougher'; 'Gunho Lee'; 'Tim Bird'; [email protected]; 'Hyo Jun Im'
Subject: Re: [Squashfs-devel] [PATCH 2/2] Squashfs-tools: add LZO support
Hi,
Yes, you can try lzo1x-999 compression just with 2-line change. The increased compression level, lzo1x-999, would be better than lzo1x-1 for slow I/O storage and higher CPU.
If you have any chance to share some test result like decompression time comparison, it would be nice.
Thanks,
Chan Jeong
lzo_wrapper.c renamed from lzo_wrapper.c.orig +2 -2
@@ -43,7 +43,7 @@ int lzo_compress(void **strm, char *d, c goto malloc_failed;/* work memory */ -if ((buffers[0 ] =malloc (LZO1X_1_MEM_COMPRESS )) ==NULL ) +if ((buffers[0 ] =malloc (LZO1X_999_MEM_COMPRESS )) ==NULL ) goto malloc_failed;/* temporal output buffer */
@@ -53,7 +53,7 @@ int lzo_compress(void **strm, char *d, c wrkmem = buffers[0 ]; out = buffers[1 ]; - res =lzo1x_1_compress ((lzo_bytep )s, size, out, &outlen, wrkmem); + res =lzo1x_999_compress ((lzo_bytep )s, size, out, &outlen, wrkmem);if (res !=LZO_E_OK ) {/* * All other errors return failure, with the compressor
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of kirk w
Sent: Saturday, May 22, 2010 12:54 PM
To: [email protected]; Chan Jeong
Cc: 'Phillip Lougher'; 'Gunho Lee'; 'Tim Bird'; [email protected]; 'Hyo Jun Im'
Subject: Re: [Squashfs-devel] [PATCH 2/2] Squashfs-tools: add LZO support
Hi,
Thanks for the patches. Is there a way to increase the compression level? Right now my file system compressed with zlib is 176MB and with this patch using lzo it's 232MB. I've read that lzo's compression level can be increased to near zlib levels, but compression times suffer. Compression times don't matter to me, but increased decompression speed is intriguing.
Thanks again,
Kirk
Quoted 4 lines · Chan Jeong
From: Chan Jeong <[email protected]>
Subject: [Squashfs-devel] [PATCH 2/2] Squashfs-tools: add LZO support
To: [email protected]
Cc: "'Phillip Lougher'" <phillip-cnXvMjJKhjYG2Il/[email protected]>, "'Gunho Lee'" <[email protected]>, "'Tim Bird'" <[email protected]>,
[email protected], "'Hyo Jun Im'" <[email protected]>
Quoted 249 lines
Date: Tuesday, May 18, 2010, 12:05 AM
This patch adds LZO compression and
decompression to Squashfs tools.The patch is against the latest cvs version and requires the LZO library
from http://www.oberhumer.com/opensource/lzo.Signed-off-by Chan Jeong <[email protected]>--- Makefile | 20 +++++++++++ compressor.c | 7 ++++ lzo_wrapper.c | 99 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ squashfs_fs.h | 1 4 files changed, 127 insertions(+)diff -uprN -x .cvs squashfs-tools.cvs.orig/Makefile squashfs-tools.cvs/Makefile
--- squashfs-tools.cvs.orig/Makefile2010-05-13 02:17:06.000000000 +0900 +++ squashfs-tools.cvs/Makefile 2010-05-18 11:36:58.000000000 +0900(quoted diff) +4
-0@@ -15,6 +15,18 @@ #LZMA_SUPPORT = 1 #LZMA_DIR = ../../../LZMA/lzma465 +# +# Building LZO support +# +# The LZO library (http://www.oberhumer.com/opensource/lzo/)is supported.
(quoted diff) +2
-0+# +# To build using the LZO library (2.0.3 used indevelopment, other versions may
+# work) - download, unpack, build and install it, uncomment and setLZO_DIRto
+# installed directory prefix, and uncomment theLZO_SUPPORTline below.(quoted diff) +12
-0+ +#LZO_SUPPORT = 1 +#LZO_DIR = /usr/local + #Compression default. COMP_DEFAULT = gzip@@ -47,6 +59,14 @@ UNSQUASHFS_OBJS += xz_wrapper.o LIBS += -llzma endif +ifdef LZO_SUPPORT +CFLAGS += -DLZO_SUPPORT +INCLUDEDIR += -I$(LZO_DIR)/include +MKSQUASHFS_OBJS += lzo_wrapper.o +UNSQUASHFS_OBJS += lzo_wrapper.o +LIBS += -L$(LZO_DIR)/lib -llzo2 +endif + .PHONY: all all: mksquashfs unsquashfsdiff -uprN -x .cvs
squashfs-tools.cvs.orig/compressor.csquashfs-tools.cvs/compressor.c
---squashfs-tools.cvs.orig/compressor.c2009-08-29 10:05:34.000000000 +0900 +++ squashfs-tools.cvs/compressor.c 2010-05-18 11:37:46.000000000 +0900(quoted diff) +1
-0@@ -29,6 +29,8 @@ extern int gzip_compress(void **, char * extern int gzip_uncompress(char *, char *, int, int, int *); extern int lzma_compress(void **, char *, char *, int, int, int *); extern int lzma_uncompress(char *, char *, int, int, int *); +extern int lzo_compress(void **, char *, char *, int, int,int *);
+extern intlzo_uncompress(char *, char *, int, int, int *);struct compressor compressor[] = {
{gzip_compress,gzip_uncompress,ZLIB_COMPRESSION, "gzip", 1 },(quoted diff) +5
-0@@ -37,6 +39,11 @@ struct compressor compressor[] = { #else { NULL, NULL, LZMA_COMPRESSION, "lzma", 0 }, #endif +#ifdef LZO_SUPPORT + { lzo_compress, lzo_uncompress, LZO_COMPRESSION, "lzo", 1 }, +#else + { NULL, NULL, LZO_COMPRESSION, "lzo", 0 }, +#endif{ NULL, NULL , 0, "unknown", 0}
};diff -uprN -x .cvs
squashfs-tools.cvs.orig/lzo_wrapper.csquashfs-tools.cvs/lzo_wrapper.c
---squashfs-tools.cvs.orig/lzo_wrapper.c1970-01-01 09:00:00.000000000 +0900 +++ squashfs-tools.cvs/lzo_wrapper.c 2010-05-18 11:59:30.000000000 +0900(quoted diff) +5
-0@@ -0,0 +1,99 @@ +/* + * Copyright (c) 2010 LG Electronics + * Chan Jeong <[email protected]> + * + * This program is free software; you can redistribute itand/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2,
+ * or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ *lzo_wrapper.c
+ */(quoted diff) +10
-0+ +#include <stdlib.h> +#include <string.h> + +#include <lzo/lzoconf.h> +#include <lzo/lzo1x.h> + +/* worst-case expansion calculation during compression, + see LZO FAQ for more information */ +#define LZO_OUTPUT_BUFFER_SIZE(size)(size + (size/16) + 64 + 3)
(quoted diff) +2
-0+ +int lzo_compress(void **strm, char *d, char *s, int size,int
block_size,
+ int *error)(quoted diff) +9
-0+{ + int res = 0; + lzo_bytep out; + lzo_uint outlen; + lzo_voidp wrkmem; + void **buffers = (void **)*strm; + + if(buffers == NULL) { + if((buffers = *strm=
calloc(2, sizeof(void *))) == NULL)
+
gotomalloc_failed;
+
+ /* work memory */
+if((buffers[0] = malloc(LZO1X_1_MEM_COMPRESS)) == NULL)
+
gotomalloc_failed;
+
+ /* temporal output
buffer */
+if((buffers[1] = malloc(LZO_OUTPUT_BUFFER_SIZE(block_size))) == NULL)+
gotomalloc_failed;
+ }
+
+ wrkmem = buffers[0];
+ out = buffers[1];
+ res =lzo1x_1_compress((lzo_bytep)s, size, out, &outlen, wrkmem);
+if(res != LZO_E_OK){
+ /*
+ * All
other errors return failure, with the compressor + *
specific error code in *error
+ */
+ *error = res;
+ return -1;
+ }
+
+ if(outlen >= size) {
+ /*
+ * Output
buffer overflow. Return out of buffer space + */
+ return 0;
+ }
+
+ /*
+ * Success, return the
compressed size.
+ */
+memcpy(d, out, outlen);
+ return outlen;(quoted diff) +5
-0+ +malloc_failed: + if(buffers) { + if(buffers[0]) { +
free(buffers[0]);
+ }
+ free(buffers);
+ }
+ return -1;(quoted diff) +4
-0+} + + +int lzo_uncompress(char *d, char *s, int size, int
block_size, int *error)
+{
+ int res;
+lzo_uintbytes =block_size;
+
+ res = lzo1x_decompress((lzo_bytep)s,
size, (lzo_bytep)d, &bytes, NULL);(quoted diff) +4
-0+ + *error = res; + return res == LZO_E_OK ? bytes : -1; +}diff -uprN -x .cvs
squashfs-tools.cvs.orig/squashfs_fs.hsquashfs-tools.cvs/squashfs_fs.h
---squashfs-tools.cvs.orig/squashfs_fs.h2010-05-13 04:28:38.000000000 +0900 +++ squashfs-tools.cvs/squashfs_fs.h 2010-05-18 11:43:22.000000000 +0900(quoted diff) +1
-0@@ -238,6 +238,7 @@ typedef long long squashfs_inode_t; #define ZLIB_COMPRESSION 1 #define LZMA_COMPRESSION 2 +#define LZO_COMPRESSION3
struct
squashfs_super_block{
unsigned int
s_magic;
Quoted 7 lines
------------------------------------------------------------------------------
_______________________________________________
Squashfs-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/squashfs-devel
--
To unsubscribe from this list: send the line "unsubscribe linux-embedded" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
------------------------------------------------------------------------------
_______________________________________________
Squashfs-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/squashfs-devel
------------------------------------------------------------------------------