+diff -Nur squashfs4.0/squashfs-tools/compressor.c squashfs4.0-lzma-snapshot/squashfs-tools/compressor.c
+--- squashfs4.0/squashfs-tools/compressor.c 1970-01-01 01:00:00.000000000 +0100
++++ squashfs4.0-lzma-snapshot/squashfs-tools/compressor.c 2009-10-20 06:03:37.000000000 +0200
+@@ -0,0 +1,78 @@
++/*
++ *
++ * Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
++ * Phillip Lougher <phillip@lougher.demon.co.uk>
++ *
++ * This program is free software; you can redistribute it and/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.
++ *
++ * compressor.c
++ */
++
++#include <stdio.h>
++#include <string.h>
++#include "compressor.h"
++#include "squashfs_fs.h"
++
++extern int gzip_compress(void **, char *, char *, int, int, int *);
++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 *);
++
++struct compressor compressor[] = {
++ { gzip_compress, gzip_uncompress, ZLIB_COMPRESSION, "gzip", 1 },
++#ifdef LZMA_SUPPORT
++ { lzma_compress, lzma_uncompress, LZMA_COMPRESSION, "lzma", 1 },
++#else
++ { NULL, NULL, LZMA_COMPRESSION, "lzma", 0 },
++#endif
++ { NULL, NULL , 0, "unknown", 0}
++};
++
++
++struct compressor *lookup_compressor(char *name)
++{
++ int i;
++
++ for(i = 0; compressor[i].id; i++)
++ if(strcmp(compressor[i].name, name) == 0)
++ break;
++
++ return &compressor[i];
++}
++
++
++struct compressor *lookup_compressor_id(int id)
++{
++ int i;
++
++ for(i = 0; compressor[i].id; i++)
++ if(id == compressor[i].id)
++ break;
++
++ return &compressor[i];
++}
++
++
++void display_compressors(char *indent, char *def_comp)
++{
++ int i;
++
++ for(i = 0; compressor[i].id; i++)
++ if(compressor[i].supported)
++ fprintf(stderr, "%s\t%s%s\n", indent,
++ compressor[i].name,
++ strcmp(compressor[i].name, def_comp) == 0 ?
++ " (default)" : "");
++}
+diff -Nur squashfs4.0/squashfs-tools/compressor.h squashfs4.0-lzma-snapshot/squashfs-tools/compressor.h
+--- squashfs4.0/squashfs-tools/compressor.h 1970-01-01 01:00:00.000000000 +0100
++++ squashfs4.0-lzma-snapshot/squashfs-tools/compressor.h 2009-10-20 06:03:37.000000000 +0200
+@@ -0,0 +1,33 @@
++/*
++ *
++ * Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
++ * Phillip Lougher <phillip@lougher.demon.co.uk>
++ *
++ * This program is free software; you can redistribute it and/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.
++ *
++ * compressor.h
++ */
++
++struct compressor {
++ int (*compress)(void **, char *, char *, int, int, int *);
++ int (*uncompress)(char *, char *, int, int, int *);
++ int id;
++ char *name;
++ int supported;
++};
++
++extern struct compressor *lookup_compressor(char *);
++extern struct compressor *lookup_compressor_id(int);
++extern void display_compressors(char *, char *);
+diff -Nur squashfs4.0/squashfs-tools/gzip_wrapper.c squashfs4.0-lzma-snapshot/squashfs-tools/gzip_wrapper.c
+--- squashfs4.0/squashfs-tools/gzip_wrapper.c 1970-01-01 01:00:00.000000000 +0100
++++ squashfs4.0-lzma-snapshot/squashfs-tools/gzip_wrapper.c 2009-10-20 06:03:37.000000000 +0200
+@@ -0,0 +1,80 @@
++/*
++ * Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
++ * Phillip Lougher <phillip@lougher.demon.co.uk>
++ *
++ * This program is free software; you can redistribute it and/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.
++ *
++ * gzip_wrapper.c
++ */
++
++#include <stdlib.h>
++#include <zlib.h>
++
++int gzip_compress(void **strm, char *d, char *s, int size, int block_size,
++ int *error)
++{
++ int res = 0;
++ z_stream *stream = *strm;
++
++ if(stream == NULL) {
++ if((stream = *strm = malloc(sizeof(z_stream))) == NULL)
++ goto failed;
++
++ stream->zalloc = Z_NULL;
++ stream->zfree = Z_NULL;
++ stream->opaque = 0;
++
++ if((res = deflateInit(stream, 9)) != Z_OK)
++ goto failed;
++ } else if((res = deflateReset(stream)) != Z_OK)
++ goto failed;
++
++ stream->next_in = (unsigned char *) s;
++ stream->avail_in = size;
++ stream->next_out = (unsigned char *) d;
++ stream->avail_out = block_size;
++
++ res = deflate(stream, Z_FINISH);
++ if(res == Z_STREAM_END)
++ /*
++ * Success, return the compressed size.
++ */
++ return (int) stream->total_out;
++ if(res == Z_OK)
++ /*
++ * Output buffer overflow. Return out of buffer space
++ */
++ return 0;
++failed:
++ /*
++ * All other errors return failure, with the compressor
++ * specific error code in *error
++ */
++ *error = res;
++ return -1;
++}
++
++
++int gzip_uncompress(char *d, char *s, int size, int block_size, int *error)
++{
++ int res;
++ unsigned long bytes = block_size;
++
++ res = uncompress((unsigned char *) d, &bytes,
++ (const unsigned char *) s, size);
++
++ *error = res;
++ return res == Z_OK ? (int) bytes : -1;
++}
+diff -Nur squashfs4.0/squashfs-tools/lzma_wrapper.c squashfs4.0-lzma-snapshot/squashfs-tools/lzma_wrapper.c
+--- squashfs4.0/squashfs-tools/lzma_wrapper.c 1970-01-01 01:00:00.000000000 +0100
++++ squashfs4.0-lzma-snapshot/squashfs-tools/lzma_wrapper.c 2009-10-14 05:32:57.000000000 +0200
+@@ -0,0 +1,93 @@
++/*
++ * Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
++ * Phillip Lougher <phillip@lougher.demon.co.uk>
++ *
++ * This program is free software; you can redistribute it and/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.
++ *
++ * lzma_wrapper.c
++ */
++
++#include <LzmaLib.h>
++
++#define LZMA_HEADER_SIZE (LZMA_PROPS_SIZE + 8)
++
++int lzma_compress(void **strm, char *dest, char *src, int size,int block_size,
++ int *error)
++{
++ unsigned char *d = (unsigned char *) dest, *s = (unsigned char *) src;
++ size_t props_size = LZMA_PROPS_SIZE,
++ outlen = block_size - LZMA_HEADER_SIZE;
++ int res;
++
++ res = LzmaCompress(d + LZMA_HEADER_SIZE, &outlen, s, size, d,
++ &props_size, 5, block_size, 3, 0, 2, 32, 1);
++
++ if(res == SZ_ERROR_OUTPUT_EOF) {
++ /*
++ * Output buffer overflow. Return out of buffer space error
++ */
++ return 0;
++ }
++
++ if(res != SZ_OK) {
++ /*
++ * All other errors return failure, with the compressor
++ * specific error code in *error
++ */
++ *error = res;
++ return -1;
++ }
++
++ /*
++ * Fill in the 8 byte little endian uncompressed size field in the
++ * LZMA header. 8 bytes is excessively large for squashfs but
++ * this is the standard LZMA header and which is expected by the kernel
++ * code
++ */
++ d[LZMA_PROPS_SIZE] = size & 255;
++ d[LZMA_PROPS_SIZE + 1] = (size >> 8) & 255;
++ d[LZMA_PROPS_SIZE + 2] = (size >> 16) & 255;
++ d[LZMA_PROPS_SIZE + 3] = (size >> 24) & 255;
++ d[LZMA_PROPS_SIZE + 4] = 0;
++ d[LZMA_PROPS_SIZE + 5] = 0;
++ d[LZMA_PROPS_SIZE + 6] = 0;
++ d[LZMA_PROPS_SIZE + 7] = 0;
++
++ /*
++ * Success, return the compressed size. Outlen returned by the LZMA
++ * compressor does not include the LZMA header space
++ */
++ return outlen + LZMA_HEADER_SIZE;
++}
++
++
++int lzma_uncompress(char *dest, char *src, int size, int block_size,
++ int *error)
++{
++ unsigned char *d = (unsigned char *) dest, *s = (unsigned char *) src;
++ size_t outlen, inlen = size - LZMA_HEADER_SIZE;
++ int res;
++
++ outlen = s[LZMA_PROPS_SIZE] |
++ (s[LZMA_PROPS_SIZE + 1] << 8) |
++ (s[LZMA_PROPS_SIZE + 2] << 16) |
++ (s[LZMA_PROPS_SIZE + 3] << 24);
++
++ res = LzmaUncompress(d, &outlen, s + LZMA_HEADER_SIZE, &inlen,
++ s, LZMA_PROPS_SIZE);
++
++ *error = res;
++ return res == SZ_OK ? outlen : -1;
++}
+diff -Nur squashfs4.0/squashfs-tools/Makefile squashfs4.0-lzma-snapshot/squashfs-tools/Makefile
+--- squashfs4.0/squashfs-tools/Makefile 2009-04-05 04:03:36.000000000 +0200
++++ squashfs4.0-lzma-snapshot/squashfs-tools/Makefile 2009-10-22 06:17:12.000000000 +0200
+@@ -1,40 +1,76 @@
++#
++# Building LZMA support
++# Download LZMA sdk (4.65 used in development, other versions may work),
++# set LZMA_DIR to unpacked source, and uncomment next line
++LZMA_SUPPORT = 1
++LZMA_DIR = ../../lzma-4.65
++
++#Compression default.
++COMP_DEFAULT = gzip
++
++INCLUDEDIR = -I.
+ INSTALL_DIR = /usr/local/bin
+
+-INCLUDEDIR = .
++MKSQUASHFS_OBJS = mksquashfs.o read_fs.o sort.o swap.o pseudo.o compressor.o \
++ gzip_wrapper.o
++
++UNSQUASHFS_OBJS = unsquashfs.o unsquash-1.o unsquash-2.o unsquash-3.o \
++ unsquash-4.o swap.o compressor.o gzip_wrapper.o
+
+-CFLAGS := -I$(INCLUDEDIR) -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_GNU_SOURCE -O2
++CFLAGS = $(INCLUDEDIR) -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE \
++ -D_GNU_SOURCE -DCOMP_DEFAULT=\"$(COMP_DEFAULT)\" -O2 -Wall
+
++ifdef LZMA_SUPPORT
++LZMA_OBJS = $(LZMA_DIR)/C/Alloc.o $(LZMA_DIR)/C/LzFind.o \
++ $(LZMA_DIR)/C/LzmaDec.o $(LZMA_DIR)/C/LzmaEnc.o $(LZMA_DIR)/C/LzmaLib.o
++INCLUDEDIR += -I$(LZMA_DIR)/C
++CFLAGS += -DLZMA_SUPPORT
++MKSQUASHFS_OBJS += lzma_wrapper.o $(LZMA_OBJS)
++UNSQUASHFS_OBJS += lzma_wrapper.o $(LZMA_OBJS)
++endif
++
++.PHONY: all
+ all: mksquashfs unsquashfs
+
+-mksquashfs: mksquashfs.o read_fs.o sort.o swap.o pseudo.o
+- $(CC) mksquashfs.o read_fs.o sort.o swap.o pseudo.o -lz -lpthread -lm -o $@
++mksquashfs: $(MKSQUASHFS_OBJS)
++ $(CC) $(MKSQUASHFS_OBJS) -lz -lpthread -lm -o $@
++
++mksquashfs.o: mksquashfs.c squashfs_fs.h mksquashfs.h global.h sort.h \
++ squashfs_swap.h
+
+-mksquashfs.o: mksquashfs.c squashfs_fs.h mksquashfs.h global.h sort.h squashfs_swap.h Makefile
++read_fs.o: read_fs.c squashfs_fs.h read_fs.h global.h squashfs_swap.h
+
+-read_fs.o: read_fs.c squashfs_fs.h read_fs.h global.h squashfs_swap.h Makefile
++sort.o: sort.c squashfs_fs.h global.h sort.h
+
+-sort.o: sort.c squashfs_fs.h global.h sort.h Makefile
++swap.o: swap.c
+
+-swap.o: swap.c Makefile
++pseudo.o: pseudo.c pseudo.h
+
+-pseudo.o: pseudo.c pseudo.h Makefile
++compressor.o: compressor.c compressor.h
+
+-unsquashfs: unsquashfs.o unsquash-1.o unsquash-2.o unsquash-3.o unsquash-4.o swap.o
+- $(CC) unsquashfs.o unsquash-1.o unsquash-2.o unsquash-3.o unsquash-4.o swap.o -lz -lpthread -lm -o $@
++unsquashfs: $(UNSQUASHFS_OBJS)
++ $(CC) $(UNSQUASHFS_OBJS) -lz -lpthread -lm -o $@
+
+-unsquashfs.o: unsquashfs.h unsquashfs.c squashfs_fs.h squashfs_swap.h squashfs_compat.h global.h Makefile
++unsquashfs.o: unsquashfs.h unsquashfs.c squashfs_fs.h squashfs_swap.h \
++ squashfs_compat.h global.h
+
+-unsquash-1.o: unsquashfs.h unsquash-1.c squashfs_fs.h squashfs_compat.h global.h Makefile
++unsquash-1.o: unsquashfs.h unsquash-1.c squashfs_fs.h squashfs_compat.h \
++ global.h
+
+-unsquash-2.o: unsquashfs.h unsquash-2.c unsquashfs.h squashfs_fs.h squashfs_compat.h global.h Makefile
++unsquash-2.o: unsquashfs.h unsquash-2.c unsquashfs.h squashfs_fs.h \
++ squashfs_compat.h global.h
+
+-unsquash-3.o: unsquashfs.h unsquash-3.c squashfs_fs.h squashfs_compat.h global.h Makefile
++unsquash-3.o: unsquashfs.h unsquash-3.c squashfs_fs.h squashfs_compat.h \
++ global.h
+
+-unsquash-4.o: unsquashfs.h unsquash-4.c squashfs_fs.h squashfs_swap.h global.h Makefile
++unsquash-4.o: unsquashfs.h unsquash-4.c squashfs_fs.h squashfs_swap.h \
++ global.h
+
++.PHONY: clean
+ clean:
+ -rm -f *.o mksquashfs unsquashfs
+
++.PHONY: install
+ install: mksquashfs unsquashfs
+ mkdir -p $(INSTALL_DIR)
+ cp mksquashfs $(INSTALL_DIR)
+diff -Nur squashfs4.0/squashfs-tools/mksquashfs.c squashfs4.0-lzma-snapshot/squashfs-tools/mksquashfs.c
+--- squashfs4.0/squashfs-tools/mksquashfs.c 2009-04-05 23:22:48.000000000 +0200
++++ squashfs4.0-lzma-snapshot/squashfs-tools/mksquashfs.c 2009-10-20 06:03:38.000000000 +0200
+@@ -36,7 +36,6 @@
+ #include <errno.h>
+ #include <dirent.h>
+ #include <string.h>
+-#include <zlib.h>
+ #include <stdlib.h>
+ #include <signal.h>
+ #include <setjmp.h>
+@@ -47,6 +46,7 @@
+ #include <math.h>
+ #include <regex.h>
+ #include <fnmatch.h>
++#include <sys/wait.h>
+
+ #ifndef linux
+ #define __BYTE_ORDER BYTE_ORDER
+@@ -64,6 +64,7 @@