lz4: add experimental support for lz4 compression

* IMPORTANT HIGHLY EXPERIMENTAL * only use for experimental
testing of lz4 compression.  LZ4 compressed filesystems produced
by this code will be guaranteed to become unreadable in a couple of
days!

This code produces "legacy" LZ4 format compression - this is the
format supported by the LZ4 kernel code currently in linux-next.

It is currently unclear whether the kernel code expects the LZ4
magic to be present - if so this has to be explictly added as it is not
generated by the LZ4 calls.

More importantly, it is unclear whether in the long term the
kernel code will continue to use the "legacy" format or move to the
more complicated newer format.

Due to this it is important to mark these LZ4 compressed streams as
using "legacy" format, to enable the code to distinquish between
"legacy" format and the newer format, in the event the kernel code
moves to the newer format.

This could be achieved by having two compression types, LZ4 == legacy, and
LZ4_XXX for any newer format, but this is messy, and makes an
unnecessary distinction (at the level of the compression type) between
the formats.

A better option is to make comp_opts (compression options) mandatory
for LZ4, and this comp_opt structure will encode the version of the
format, which will be used in the event the legacy format is superseded
in the kernel.

Currently this code lacks setting a comp_opts structure.  In the
near future this code will be added, and the presence of the
comp_opts structure in the filesystem will become mandatory - and
any filesystems generated by this code will become unreadable.  You have
been warned!

Checking into lz4 branch for this reason!

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
lz4: add setting of comp_opts structure

Currently the comp_opts structure has a version field.

The code expects a comp_opts structure to be present, and
it expects a version of LZ4_LEGACY.

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
lz4: add flags field to comp_opts structure

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
mksquashfs: add additional comment concerning use of compressor_extract_options

Add additional comment to the effect that compressor_extract_options is also
used to ensure that we know how decompress a filesystem compressed with the
compression options in the filesystem.

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
unsquashfs: Call compressor_extract_options

Unsquashfs should have been calling compressor_extract_options to
check that it knew how to decompress a filesystem compressed with
the options stored in the filesystem.

As it happens xz compression up till now has been the only
compressor to use compression options, and the code has always
been able to decompress xz compressed filesystems whatever the
compression options used, and so the check hasn't been needed.  But this
may change with other compressors.

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
xz_wrapper: only set *error if an error occurs in xz_uncompress()

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
lzo_wrapper: only set *error if an error occurs in lzo_uncompress()

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
lzma_wrapper: only set *error if an error occurs in lzma_uncompress()

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
gzip_wrapper: only set *error if an error occurs in gzip_uncompress()

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
unsquashfs; add aligned attribute to char buffer on stack in squashfs_stat()

this buffer is used to read a structure off disk which is then
used in-place rather than copying.  So the buffer should be aligned.

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
xz_wrapper: fix sizeof() in xz_display_options()

Sizeof() was incorrectly sizeof(comp_opts) or size of pointer,
rather than the size of the structure.  On 64-bit systems it
worked because it so happens that size pointer == 8, which is the
size of the structure.

This bug has shown up now on a 32-bit system (Raspberry Pi), where
the size of pointer is 4 bytes.

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
Merge branch 'lz4'
xz_wrapper: make global comp_opts a static inside xz_dump_options

This was global purely to allow xz_dump_options() to return
a pointer to it.  However, making it global runs the risk coding
mistakes which should refer to a local comp_opts are hidden as they
pick up the global instead.  As the global is potentially swapped and
not in host byte order this isn't a good thing.

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
lz4_wrapper: make global comp_opts a static inside lz4_dump_options

This was global purely to allow lz4_dump_options() to return
a pointer to it.  However, making it global runs the risk coding
mistakes which should refer to a local comp_opts are hidden as they
pick up the global instead.  As the global is potentially swapped and
not in host byte order this isn't a good thing.

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
Makefile: {compressor|mksquashfs}.c should be rebuilt if Makefile options change

If the selected compression algorithms are changed in the Makefile, then
compressor.c should be rebuilt.

Likewise if the compression default is changed, then
mksquashfs.c should be rebuilt.

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
lz4: add support for lz4 "high compression"

Add -Xhc option

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
xz_wrapper: fix comment on xz_options return values

Success is actually a value of 0 or greater, because the
return value reflects the number of additional arguments
successfully parsed.

It just so happened here that all the options have an additional
argument, and so 1 is always returned on success.

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
lz4_wrapper: implement lz4 compression options display

Add support to display the lz4 compression options specified
(currently only LZ4_HC) in lz4_display_options(), which is used
by the -stat option in unsquashfs.

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
lz4_wrapper: implement lz4_usage()

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
lz4_wrapper: get rid of lz4_options_post()

It's not needed.

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>