mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-30 10:49:28 +00:00
Merge git://git.kernel.org/pub/scm/linux/kernel/git/pkl/squashfs-linus
* git://git.kernel.org/pub/scm/linux/kernel/git/pkl/squashfs-linus: Squashfs: simplify CONFIG_SQUASHFS_LZO handling Squashfs: move squashfs_i() definition from squashfs.h Squashfs: get rid of default n in Kconfig Squashfs: add missing check in zlib_wrapper Squashfs: remove unnecessary variable in zlib_wrapper Squashfs: Add XZ compression configuration option Squashfs: add XZ compression support
This commit is contained in:
commit
5520ebd308
15 changed files with 203 additions and 30 deletions
|
@ -29,7 +29,6 @@ config SQUASHFS
|
||||||
config SQUASHFS_XATTR
|
config SQUASHFS_XATTR
|
||||||
bool "Squashfs XATTR support"
|
bool "Squashfs XATTR support"
|
||||||
depends on SQUASHFS
|
depends on SQUASHFS
|
||||||
default n
|
|
||||||
help
|
help
|
||||||
Saying Y here includes support for extended attributes (xattrs).
|
Saying Y here includes support for extended attributes (xattrs).
|
||||||
Xattrs are name:value pairs associated with inodes by
|
Xattrs are name:value pairs associated with inodes by
|
||||||
|
@ -40,7 +39,6 @@ config SQUASHFS_XATTR
|
||||||
config SQUASHFS_LZO
|
config SQUASHFS_LZO
|
||||||
bool "Include support for LZO compressed file systems"
|
bool "Include support for LZO compressed file systems"
|
||||||
depends on SQUASHFS
|
depends on SQUASHFS
|
||||||
default n
|
|
||||||
select LZO_DECOMPRESS
|
select LZO_DECOMPRESS
|
||||||
help
|
help
|
||||||
Saying Y here includes support for reading Squashfs file systems
|
Saying Y here includes support for reading Squashfs file systems
|
||||||
|
@ -53,10 +51,24 @@ config SQUASHFS_LZO
|
||||||
|
|
||||||
If unsure, say N.
|
If unsure, say N.
|
||||||
|
|
||||||
|
config SQUASHFS_XZ
|
||||||
|
bool "Include support for XZ compressed file systems"
|
||||||
|
depends on SQUASHFS
|
||||||
|
select XZ_DEC
|
||||||
|
help
|
||||||
|
Saying Y here includes support for reading Squashfs file systems
|
||||||
|
compressed with XZ compresssion. XZ gives better compression than
|
||||||
|
the default zlib compression, at the expense of greater CPU and
|
||||||
|
memory overhead.
|
||||||
|
|
||||||
|
XZ is not the standard compression used in Squashfs and so most
|
||||||
|
file systems will be readable without selecting this option.
|
||||||
|
|
||||||
|
If unsure, say N.
|
||||||
|
|
||||||
config SQUASHFS_EMBEDDED
|
config SQUASHFS_EMBEDDED
|
||||||
bool "Additional option for memory-constrained systems"
|
bool "Additional option for memory-constrained systems"
|
||||||
depends on SQUASHFS
|
depends on SQUASHFS
|
||||||
default n
|
|
||||||
help
|
help
|
||||||
Saying Y here allows you to specify cache size.
|
Saying Y here allows you to specify cache size.
|
||||||
|
|
||||||
|
|
|
@ -7,3 +7,4 @@ squashfs-y += block.o cache.o dir.o export.o file.o fragment.o id.o inode.o
|
||||||
squashfs-y += namei.o super.o symlink.o zlib_wrapper.o decompressor.o
|
squashfs-y += namei.o super.o symlink.o zlib_wrapper.o decompressor.o
|
||||||
squashfs-$(CONFIG_SQUASHFS_XATTR) += xattr.o xattr_id.o
|
squashfs-$(CONFIG_SQUASHFS_XATTR) += xattr.o xattr_id.o
|
||||||
squashfs-$(CONFIG_SQUASHFS_LZO) += lzo_wrapper.o
|
squashfs-$(CONFIG_SQUASHFS_LZO) += lzo_wrapper.o
|
||||||
|
squashfs-$(CONFIG_SQUASHFS_XZ) += xz_wrapper.o
|
||||||
|
|
|
@ -34,7 +34,6 @@
|
||||||
|
|
||||||
#include "squashfs_fs.h"
|
#include "squashfs_fs.h"
|
||||||
#include "squashfs_fs_sb.h"
|
#include "squashfs_fs_sb.h"
|
||||||
#include "squashfs_fs_i.h"
|
|
||||||
#include "squashfs.h"
|
#include "squashfs.h"
|
||||||
#include "decompressor.h"
|
#include "decompressor.h"
|
||||||
|
|
||||||
|
|
|
@ -55,7 +55,6 @@
|
||||||
|
|
||||||
#include "squashfs_fs.h"
|
#include "squashfs_fs.h"
|
||||||
#include "squashfs_fs_sb.h"
|
#include "squashfs_fs_sb.h"
|
||||||
#include "squashfs_fs_i.h"
|
|
||||||
#include "squashfs.h"
|
#include "squashfs.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -27,7 +27,6 @@
|
||||||
|
|
||||||
#include "squashfs_fs.h"
|
#include "squashfs_fs.h"
|
||||||
#include "squashfs_fs_sb.h"
|
#include "squashfs_fs_sb.h"
|
||||||
#include "squashfs_fs_i.h"
|
|
||||||
#include "decompressor.h"
|
#include "decompressor.h"
|
||||||
#include "squashfs.h"
|
#include "squashfs.h"
|
||||||
|
|
||||||
|
@ -41,23 +40,26 @@ static const struct squashfs_decompressor squashfs_lzma_unsupported_comp_ops = {
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifndef CONFIG_SQUASHFS_LZO
|
#ifndef CONFIG_SQUASHFS_LZO
|
||||||
static const struct squashfs_decompressor squashfs_lzo_unsupported_comp_ops = {
|
static const struct squashfs_decompressor squashfs_lzo_comp_ops = {
|
||||||
NULL, NULL, NULL, LZO_COMPRESSION, "lzo", 0
|
NULL, NULL, NULL, LZO_COMPRESSION, "lzo", 0
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef CONFIG_SQUASHFS_XZ
|
||||||
|
static const struct squashfs_decompressor squashfs_xz_comp_ops = {
|
||||||
|
NULL, NULL, NULL, XZ_COMPRESSION, "xz", 0
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
static const struct squashfs_decompressor squashfs_unknown_comp_ops = {
|
static const struct squashfs_decompressor squashfs_unknown_comp_ops = {
|
||||||
NULL, NULL, NULL, 0, "unknown", 0
|
NULL, NULL, NULL, 0, "unknown", 0
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct squashfs_decompressor *decompressor[] = {
|
static const struct squashfs_decompressor *decompressor[] = {
|
||||||
&squashfs_zlib_comp_ops,
|
&squashfs_zlib_comp_ops,
|
||||||
&squashfs_lzma_unsupported_comp_ops,
|
|
||||||
#ifdef CONFIG_SQUASHFS_LZO
|
|
||||||
&squashfs_lzo_comp_ops,
|
&squashfs_lzo_comp_ops,
|
||||||
#else
|
&squashfs_xz_comp_ops,
|
||||||
&squashfs_lzo_unsupported_comp_ops,
|
&squashfs_lzma_unsupported_comp_ops,
|
||||||
#endif
|
|
||||||
&squashfs_unknown_comp_ops
|
&squashfs_unknown_comp_ops
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -52,4 +52,13 @@ static inline int squashfs_decompress(struct squashfs_sb_info *msblk,
|
||||||
return msblk->decompressor->decompress(msblk, buffer, bh, b, offset,
|
return msblk->decompressor->decompress(msblk, buffer, bh, b, offset,
|
||||||
length, srclength, pages);
|
length, srclength, pages);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef CONFIG_SQUASHFS_XZ
|
||||||
|
extern const struct squashfs_decompressor squashfs_xz_comp_ops;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_SQUASHFS_LZO
|
||||||
|
extern const struct squashfs_decompressor squashfs_lzo_comp_ops;
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -39,7 +39,6 @@
|
||||||
|
|
||||||
#include "squashfs_fs.h"
|
#include "squashfs_fs.h"
|
||||||
#include "squashfs_fs_sb.h"
|
#include "squashfs_fs_sb.h"
|
||||||
#include "squashfs_fs_i.h"
|
|
||||||
#include "squashfs.h"
|
#include "squashfs.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -37,7 +37,6 @@
|
||||||
|
|
||||||
#include "squashfs_fs.h"
|
#include "squashfs_fs.h"
|
||||||
#include "squashfs_fs_sb.h"
|
#include "squashfs_fs_sb.h"
|
||||||
#include "squashfs_fs_i.h"
|
|
||||||
#include "squashfs.h"
|
#include "squashfs.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -29,7 +29,6 @@
|
||||||
|
|
||||||
#include "squashfs_fs.h"
|
#include "squashfs_fs.h"
|
||||||
#include "squashfs_fs_sb.h"
|
#include "squashfs_fs_sb.h"
|
||||||
#include "squashfs_fs_i.h"
|
|
||||||
#include "squashfs.h"
|
#include "squashfs.h"
|
||||||
#include "decompressor.h"
|
#include "decompressor.h"
|
||||||
|
|
||||||
|
|
|
@ -27,11 +27,6 @@
|
||||||
|
|
||||||
#define WARNING(s, args...) pr_warning("SQUASHFS: "s, ## args)
|
#define WARNING(s, args...) pr_warning("SQUASHFS: "s, ## args)
|
||||||
|
|
||||||
static inline struct squashfs_inode_info *squashfs_i(struct inode *inode)
|
|
||||||
{
|
|
||||||
return list_entry(inode, struct squashfs_inode_info, vfs_inode);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* block.c */
|
/* block.c */
|
||||||
extern int squashfs_read_data(struct super_block *, void **, u64, int, u64 *,
|
extern int squashfs_read_data(struct super_block *, void **, u64, int, u64 *,
|
||||||
int, int);
|
int, int);
|
||||||
|
@ -104,6 +99,3 @@ extern const struct xattr_handler *squashfs_xattr_handlers[];
|
||||||
|
|
||||||
/* zlib_wrapper.c */
|
/* zlib_wrapper.c */
|
||||||
extern const struct squashfs_decompressor squashfs_zlib_comp_ops;
|
extern const struct squashfs_decompressor squashfs_zlib_comp_ops;
|
||||||
|
|
||||||
/* lzo_wrapper.c */
|
|
||||||
extern const struct squashfs_decompressor squashfs_lzo_comp_ops;
|
|
||||||
|
|
|
@ -238,6 +238,7 @@ struct meta_index {
|
||||||
#define ZLIB_COMPRESSION 1
|
#define ZLIB_COMPRESSION 1
|
||||||
#define LZMA_COMPRESSION 2
|
#define LZMA_COMPRESSION 2
|
||||||
#define LZO_COMPRESSION 3
|
#define LZO_COMPRESSION 3
|
||||||
|
#define XZ_COMPRESSION 4
|
||||||
|
|
||||||
struct squashfs_super_block {
|
struct squashfs_super_block {
|
||||||
__le32 s_magic;
|
__le32 s_magic;
|
||||||
|
|
|
@ -45,4 +45,10 @@ struct squashfs_inode_info {
|
||||||
};
|
};
|
||||||
struct inode vfs_inode;
|
struct inode vfs_inode;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
static inline struct squashfs_inode_info *squashfs_i(struct inode *inode)
|
||||||
|
{
|
||||||
|
return list_entry(inode, struct squashfs_inode_info, vfs_inode);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -32,7 +32,6 @@
|
||||||
|
|
||||||
#include "squashfs_fs.h"
|
#include "squashfs_fs.h"
|
||||||
#include "squashfs_fs_sb.h"
|
#include "squashfs_fs_sb.h"
|
||||||
#include "squashfs_fs_i.h"
|
|
||||||
#include "squashfs.h"
|
#include "squashfs.h"
|
||||||
#include "xattr.h"
|
#include "xattr.h"
|
||||||
|
|
||||||
|
|
153
fs/squashfs/xz_wrapper.c
Normal file
153
fs/squashfs/xz_wrapper.c
Normal file
|
@ -0,0 +1,153 @@
|
||||||
|
/*
|
||||||
|
* Squashfs - a compressed read only filesystem for Linux
|
||||||
|
*
|
||||||
|
* Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
|
||||||
|
* 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
* xz_wrapper.c
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include <linux/mutex.h>
|
||||||
|
#include <linux/buffer_head.h>
|
||||||
|
#include <linux/slab.h>
|
||||||
|
#include <linux/xz.h>
|
||||||
|
|
||||||
|
#include "squashfs_fs.h"
|
||||||
|
#include "squashfs_fs_sb.h"
|
||||||
|
#include "squashfs_fs_i.h"
|
||||||
|
#include "squashfs.h"
|
||||||
|
#include "decompressor.h"
|
||||||
|
|
||||||
|
struct squashfs_xz {
|
||||||
|
struct xz_dec *state;
|
||||||
|
struct xz_buf buf;
|
||||||
|
};
|
||||||
|
|
||||||
|
static void *squashfs_xz_init(struct squashfs_sb_info *msblk)
|
||||||
|
{
|
||||||
|
int block_size = max_t(int, msblk->block_size, SQUASHFS_METADATA_SIZE);
|
||||||
|
|
||||||
|
struct squashfs_xz *stream = kmalloc(sizeof(*stream), GFP_KERNEL);
|
||||||
|
if (stream == NULL)
|
||||||
|
goto failed;
|
||||||
|
|
||||||
|
stream->state = xz_dec_init(XZ_PREALLOC, block_size);
|
||||||
|
if (stream->state == NULL)
|
||||||
|
goto failed;
|
||||||
|
|
||||||
|
return stream;
|
||||||
|
|
||||||
|
failed:
|
||||||
|
ERROR("Failed to allocate xz workspace\n");
|
||||||
|
kfree(stream);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void squashfs_xz_free(void *strm)
|
||||||
|
{
|
||||||
|
struct squashfs_xz *stream = strm;
|
||||||
|
|
||||||
|
if (stream) {
|
||||||
|
xz_dec_end(stream->state);
|
||||||
|
kfree(stream);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int squashfs_xz_uncompress(struct squashfs_sb_info *msblk, void **buffer,
|
||||||
|
struct buffer_head **bh, int b, int offset, int length, int srclength,
|
||||||
|
int pages)
|
||||||
|
{
|
||||||
|
enum xz_ret xz_err;
|
||||||
|
int avail, total = 0, k = 0, page = 0;
|
||||||
|
struct squashfs_xz *stream = msblk->stream;
|
||||||
|
|
||||||
|
mutex_lock(&msblk->read_data_mutex);
|
||||||
|
|
||||||
|
xz_dec_reset(stream->state);
|
||||||
|
stream->buf.in_pos = 0;
|
||||||
|
stream->buf.in_size = 0;
|
||||||
|
stream->buf.out_pos = 0;
|
||||||
|
stream->buf.out_size = PAGE_CACHE_SIZE;
|
||||||
|
stream->buf.out = buffer[page++];
|
||||||
|
|
||||||
|
do {
|
||||||
|
if (stream->buf.in_pos == stream->buf.in_size && k < b) {
|
||||||
|
avail = min(length, msblk->devblksize - offset);
|
||||||
|
length -= avail;
|
||||||
|
wait_on_buffer(bh[k]);
|
||||||
|
if (!buffer_uptodate(bh[k]))
|
||||||
|
goto release_mutex;
|
||||||
|
|
||||||
|
if (avail == 0) {
|
||||||
|
offset = 0;
|
||||||
|
put_bh(bh[k++]);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
stream->buf.in = bh[k]->b_data + offset;
|
||||||
|
stream->buf.in_size = avail;
|
||||||
|
stream->buf.in_pos = 0;
|
||||||
|
offset = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (stream->buf.out_pos == stream->buf.out_size
|
||||||
|
&& page < pages) {
|
||||||
|
stream->buf.out = buffer[page++];
|
||||||
|
stream->buf.out_pos = 0;
|
||||||
|
total += PAGE_CACHE_SIZE;
|
||||||
|
}
|
||||||
|
|
||||||
|
xz_err = xz_dec_run(stream->state, &stream->buf);
|
||||||
|
|
||||||
|
if (stream->buf.in_pos == stream->buf.in_size && k < b)
|
||||||
|
put_bh(bh[k++]);
|
||||||
|
} while (xz_err == XZ_OK);
|
||||||
|
|
||||||
|
if (xz_err != XZ_STREAM_END) {
|
||||||
|
ERROR("xz_dec_run error, data probably corrupt\n");
|
||||||
|
goto release_mutex;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (k < b) {
|
||||||
|
ERROR("xz_uncompress error, input remaining\n");
|
||||||
|
goto release_mutex;
|
||||||
|
}
|
||||||
|
|
||||||
|
total += stream->buf.out_pos;
|
||||||
|
mutex_unlock(&msblk->read_data_mutex);
|
||||||
|
return total;
|
||||||
|
|
||||||
|
release_mutex:
|
||||||
|
mutex_unlock(&msblk->read_data_mutex);
|
||||||
|
|
||||||
|
for (; k < b; k++)
|
||||||
|
put_bh(bh[k]);
|
||||||
|
|
||||||
|
return -EIO;
|
||||||
|
}
|
||||||
|
|
||||||
|
const struct squashfs_decompressor squashfs_xz_comp_ops = {
|
||||||
|
.init = squashfs_xz_init,
|
||||||
|
.free = squashfs_xz_free,
|
||||||
|
.decompress = squashfs_xz_uncompress,
|
||||||
|
.id = XZ_COMPRESSION,
|
||||||
|
.name = "xz",
|
||||||
|
.supported = 1
|
||||||
|
};
|
|
@ -29,7 +29,6 @@
|
||||||
|
|
||||||
#include "squashfs_fs.h"
|
#include "squashfs_fs.h"
|
||||||
#include "squashfs_fs_sb.h"
|
#include "squashfs_fs_sb.h"
|
||||||
#include "squashfs_fs_i.h"
|
|
||||||
#include "squashfs.h"
|
#include "squashfs.h"
|
||||||
#include "decompressor.h"
|
#include "decompressor.h"
|
||||||
|
|
||||||
|
@ -66,8 +65,8 @@ static int zlib_uncompress(struct squashfs_sb_info *msblk, void **buffer,
|
||||||
struct buffer_head **bh, int b, int offset, int length, int srclength,
|
struct buffer_head **bh, int b, int offset, int length, int srclength,
|
||||||
int pages)
|
int pages)
|
||||||
{
|
{
|
||||||
int zlib_err = 0, zlib_init = 0;
|
int zlib_err, zlib_init = 0;
|
||||||
int avail, bytes, k = 0, page = 0;
|
int k = 0, page = 0;
|
||||||
z_stream *stream = msblk->stream;
|
z_stream *stream = msblk->stream;
|
||||||
|
|
||||||
mutex_lock(&msblk->read_data_mutex);
|
mutex_lock(&msblk->read_data_mutex);
|
||||||
|
@ -75,11 +74,10 @@ static int zlib_uncompress(struct squashfs_sb_info *msblk, void **buffer,
|
||||||
stream->avail_out = 0;
|
stream->avail_out = 0;
|
||||||
stream->avail_in = 0;
|
stream->avail_in = 0;
|
||||||
|
|
||||||
bytes = length;
|
|
||||||
do {
|
do {
|
||||||
if (stream->avail_in == 0 && k < b) {
|
if (stream->avail_in == 0 && k < b) {
|
||||||
avail = min(bytes, msblk->devblksize - offset);
|
int avail = min(length, msblk->devblksize - offset);
|
||||||
bytes -= avail;
|
length -= avail;
|
||||||
wait_on_buffer(bh[k]);
|
wait_on_buffer(bh[k]);
|
||||||
if (!buffer_uptodate(bh[k]))
|
if (!buffer_uptodate(bh[k]))
|
||||||
goto release_mutex;
|
goto release_mutex;
|
||||||
|
@ -128,6 +126,11 @@ static int zlib_uncompress(struct squashfs_sb_info *msblk, void **buffer,
|
||||||
goto release_mutex;
|
goto release_mutex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (k < b) {
|
||||||
|
ERROR("zlib_uncompress error, data remaining\n");
|
||||||
|
goto release_mutex;
|
||||||
|
}
|
||||||
|
|
||||||
length = stream->total_out;
|
length = stream->total_out;
|
||||||
mutex_unlock(&msblk->read_data_mutex);
|
mutex_unlock(&msblk->read_data_mutex);
|
||||||
return length;
|
return length;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue