Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5818fcc8 authored by Linus Torvalds's avatar Linus Torvalds
Browse files
* git://git.kernel.org/pub/scm/linux/kernel/git/pkl/squashfs-linus:
  Squashfs: Use vmalloc rather than kmalloc for zlib workspace
  Squashfs: handle corruption of directory structure
  Squashfs: wrap squashfs_mount() definition
  Squashfs: xz_wrapper doesn't need to include squashfs_fs_i.h anymore
  Squashfs: Update documentation to include compression options
  Squashfs: Update Kconfig help text to include xz compression
  Squashfs: add compression options support to xz decompressor
  Squashfs: extend decompressor framework to handle compression options
parents 0625bef6 117a91e0
Loading
Loading
Loading
Loading
+19 −9
Original line number Diff line number Diff line
@@ -59,12 +59,15 @@ obtained from this site also.
3. SQUASHFS FILESYSTEM DESIGN
-----------------------------

A squashfs filesystem consists of a maximum of eight parts, packed together on a byte
alignment:
A squashfs filesystem consists of a maximum of nine parts, packed together on a
byte alignment:

	 ---------------
	|  superblock 	|
	|---------------|
	|  compression  |
	|    options    |
	|---------------|
	|  datablocks   |
	|  & fragments  |
	|---------------|
@@ -91,7 +94,14 @@ the source directory, and checked for duplicates. Once all file data has been
written the completed inode, directory, fragment, export and uid/gid lookup
tables are written.

3.1 Inodes
3.1 Compression options
-----------------------

Compressors can optionally support compression specific options (e.g.
dictionary size).  If non-default compression options have been used, then
these are stored here.

3.2 Inodes
----------

Metadata (inodes and directories) are compressed in 8Kbyte blocks.  Each
@@ -114,7 +124,7 @@ directory inode are defined: inodes optimised for frequently occurring
regular files and directories, and extended types where extra
information has to be stored.

3.2 Directories
3.3 Directories
---------------

Like inodes, directories are packed into compressed metadata blocks, stored
@@ -144,7 +154,7 @@ decompressed to do a lookup irrespective of the length of the directory.
This scheme has the advantage that it doesn't require extra memory overhead
and doesn't require much extra storage on disk.

3.3 File data
3.4 File data
-------------

Regular files consist of a sequence of contiguous compressed blocks, and/or a
@@ -163,7 +173,7 @@ Larger files use multiple slots, with 1.75 TiB files using all 8 slots.
The index cache is designed to be memory efficient, and by default uses
16 KiB.

3.4 Fragment lookup table
3.5 Fragment lookup table
-------------------------

Regular files can contain a fragment index which is mapped to a fragment
@@ -173,7 +183,7 @@ A second index table is used to locate these. This second index table for
speed of access (and because it is small) is read at mount time and cached
in memory.

3.5 Uid/gid lookup table
3.6 Uid/gid lookup table
------------------------

For space efficiency regular files store uid and gid indexes, which are
@@ -182,7 +192,7 @@ stored compressed into metadata blocks. A second index table is used to
locate these.  This second index table for speed of access (and because it
is small) is read at mount time and cached in memory.

3.6 Export table
3.7 Export table
----------------

To enable Squashfs filesystems to be exportable (via NFS etc.) filesystems
@@ -196,7 +206,7 @@ This table is stored compressed into metadata blocks. A second index table is
used to locate these.  This second index table for speed of access (and because
it is small) is read at mount time and cached in memory.

3.7 Xattr table
3.8 Xattr table
---------------

The xattr table contains extended attributes for each inode.  The xattrs
+6 −6
Original line number Diff line number Diff line
@@ -5,12 +5,12 @@ config SQUASHFS
	help
	  Saying Y here includes support for SquashFS 4.0 (a Compressed
	  Read-Only File System).  Squashfs is a highly compressed read-only
	  filesystem for Linux.  It uses zlib/lzo compression to compress both
	  files, inodes and directories.  Inodes in the system are very small
	  and all blocks are packed to minimise data overhead. Block sizes
	  greater than 4K are supported up to a maximum of 1 Mbytes (default
	  block size 128K).  SquashFS 4.0 supports 64 bit filesystems and files
	  (larger than 4GB), full uid/gid information, hard links and
	  filesystem for Linux.  It uses zlib, lzo or xz compression to
	  compress both files, inodes and directories.  Inodes in the system
	  are very small and all blocks are packed to minimise data overhead.
	  Block sizes greater than 4K are supported up to a maximum of 1 Mbytes
	  (default block size 128K).  SquashFS 4.0 supports 64 bit filesystems
	  and files (larger than 4GB), full uid/gid information, hard links and
	  timestamps.

	  Squashfs is intended for general read-only filesystem use, for
+34 −0
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@

#include <linux/types.h>
#include <linux/mutex.h>
#include <linux/slab.h>
#include <linux/buffer_head.h>

#include "squashfs_fs.h"
@@ -74,3 +75,36 @@ const struct squashfs_decompressor *squashfs_lookup_decompressor(int id)

	return decompressor[i];
}


void *squashfs_decompressor_init(struct super_block *sb, unsigned short flags)
{
	struct squashfs_sb_info *msblk = sb->s_fs_info;
	void *strm, *buffer = NULL;
	int length = 0;

	/*
	 * Read decompressor specific options from file system if present
	 */
	if (SQUASHFS_COMP_OPTS(flags)) {
		buffer = kmalloc(PAGE_CACHE_SIZE, GFP_KERNEL);
		if (buffer == NULL)
			return ERR_PTR(-ENOMEM);

		length = squashfs_read_data(sb, &buffer,
			sizeof(struct squashfs_super_block), 0, NULL,
			PAGE_CACHE_SIZE, 1);

		if (length < 0) {
			strm = ERR_PTR(length);
			goto finished;
		}
	}

	strm = msblk->decompressor->init(msblk, buffer, length);

finished:
	kfree(buffer);

	return strm;
}
+1 −6
Original line number Diff line number Diff line
@@ -24,7 +24,7 @@
 */

struct squashfs_decompressor {
	void	*(*init)(struct squashfs_sb_info *);
	void	*(*init)(struct squashfs_sb_info *, void *, int);
	void	(*free)(void *);
	int	(*decompress)(struct squashfs_sb_info *, void **,
		struct buffer_head **, int, int, int, int, int);
@@ -33,11 +33,6 @@ struct squashfs_decompressor {
	int	supported;
};

static inline void *squashfs_decompressor_init(struct squashfs_sb_info *msblk)
{
	return msblk->decompressor->init(msblk);
}

static inline void squashfs_decompressor_free(struct squashfs_sb_info *msblk,
	void *s)
{
+9 −0
Original line number Diff line number Diff line
@@ -172,6 +172,11 @@ static int squashfs_readdir(struct file *file, void *dirent, filldir_t filldir)
		length += sizeof(dirh);

		dir_count = le32_to_cpu(dirh.count) + 1;

		/* dir_count should never be larger than 256 */
		if (dir_count > 256)
			goto failed_read;

		while (dir_count--) {
			/*
			 * Read directory entry.
@@ -183,6 +188,10 @@ static int squashfs_readdir(struct file *file, void *dirent, filldir_t filldir)

			size = le16_to_cpu(dire->size) + 1;

			/* size should never be larger than SQUASHFS_NAME_LEN */
			if (size > SQUASHFS_NAME_LEN)
				goto failed_read;

			err = squashfs_read_metadata(inode->i_sb, dire->name,
					&block, &offset, size);
			if (err < 0)
Loading