Add support for the SquashFS filesystem
Subsystems (2)
v3 cover Add support for the SquashFS filesystem
Hello!
This series adds support for the SquashFS filesystem. For now, zlib is the only supported compression type. This is my first contribution to U-Boot as well as to a major Open Source project.
Changes in v3:
- Replace CONFIG_IS_ENABLED by IS_ENABLED in fs/fs.c
Changes in v2:
- Replace sqfs_ls() by U-Boot's fs_ls_generic()
- Add info. to MAINTAINERS
- Fix build failures
- Fix style problems
Best regards,
Joao Marcos Costa
Joao Marcos Costa (5):
fs/squashfs: new filesystem
fs/squashfs: add filesystem commands include/u-boot, lib/zlib: add sources for zlib decompression fs/squashfs: add support for zlib decompression fs/fs.c: add symbolic link case to fs_ls_generic()
MAINTAINERS | 7 + cmd/Kconfig | 6 + cmd/Makefile | 1 + cmd/sqfs.c | 42 + common/spl/Kconfig | 9 + fs/Kconfig | 2 + fs/Makefile | 2 + fs/fs.c | 18 + fs/squashfs/Kconfig | 10 + fs/squashfs/Makefile | 7 + fs/squashfs/sqfs.c | 1521 +++++++++++++++++++++++++++++++ fs/squashfs/sqfs_decompressor.c | 53 ++ fs/squashfs/sqfs_decompressor.h | 58 ++ fs/squashfs/sqfs_dir.c | 107 +++ fs/squashfs/sqfs_filesystem.h | 300 ++++++ fs/squashfs/sqfs_inode.c | 142 +++ fs/squashfs/sqfs_utils.h | 49 + include/fs.h | 1 + include/squashfs.h | 25 + include/u-boot/zlib.h | 32 + lib/zlib/uncompr.c | 97 ++ lib/zlib/zlib.c | 1 + 22 files changed, 2490 insertions(+) create mode 100644 cmd/sqfs.c create mode 100644 fs/squashfs/Kconfig create mode 100644 fs/squashfs/Makefile create mode 100644 fs/squashfs/sqfs.c create mode 100644 fs/squashfs/sqfs_decompressor.c create mode 100644 fs/squashfs/sqfs_decompressor.h create mode 100644 fs/squashfs/sqfs_dir.c create mode 100644 fs/squashfs/sqfs_filesystem.h create mode 100644 fs/squashfs/sqfs_inode.c create mode 100644 fs/squashfs/sqfs_utils.h create mode 100644 include/squashfs.h create mode 100644 lib/zlib/uncompr.c
Signature · 1 line
2.17.1
PATCH v3 1/5 fs/squashfs: new filesystem
Add support for SquashFS filesystem. Right now, it does not support compression but support for zlib will be added in a follow-up commit.
---
Changes in v3:
- Replace CONFIG_IS_ENABLED by IS_ENABLED in fs/fs.c
Changes in v2:
- Add info. to MAINTAINERS
- Replace sqfs_ls() by U-Boot's fs_ls_generic()
- Improve string parsing when resolving symlink targets
- Replace cmd_tbl_t type by the cmd_tbl struct
- Add missing <command.h> in cmd/sqfs.c
- Fix build failures
- Replace "struct disk_partition_t" by "disk_partition"
- Remove CMD_RET* from the filesystem code
- Simplify superblock handling by adding "struct squashfs_ctxt", which encloses the complete global context (superblock, cur_dev and cur_part_info). The struct members are set up during probe() and cleaned up during close().
MAINTAINERS | 6 + common/spl/Kconfig | 9 + fs/Kconfig | 2 + fs/Makefile | 2 + fs/fs.c | 15 + fs/squashfs/Kconfig | 10 + fs/squashfs/Makefile | 7 + fs/squashfs/sqfs.c | 1521 +++++++++++++++++++++++++++++++ fs/squashfs/sqfs_decompressor.c | 29 + fs/squashfs/sqfs_decompressor.h | 58 ++ fs/squashfs/sqfs_dir.c | 107 +++ fs/squashfs/sqfs_filesystem.h | 300 ++++++ fs/squashfs/sqfs_inode.c | 142 +++ fs/squashfs/sqfs_utils.h | 49 + include/fs.h | 1 + include/squashfs.h | 25 + 16 files changed, 2283 insertions(+) create mode 100644 fs/squashfs/Kconfig create mode 100644 fs/squashfs/Makefile create mode 100644 fs/squashfs/sqfs.c create mode 100644 fs/squashfs/sqfs_decompressor.c create mode 100644 fs/squashfs/sqfs_decompressor.h create mode 100644 fs/squashfs/sqfs_dir.c create mode 100644 fs/squashfs/sqfs_filesystem.h create mode 100644 fs/squashfs/sqfs_inode.c create mode 100644 fs/squashfs/sqfs_utils.h create mode 100644 include/squashfs.h
MAINTAINERS +6 -0
@@ -944,6 +944,12 @@ S: Maintained F: drivers/spmi/ F: include/spmi/ +SQUASHFS +M: Joao Marcos Costa <[email protected]> +S: Maintained +F: fs/squashfs/ +F: include/sqfs.h + TDA19988 HDMI ENCODER M: Liviu Dudau <[email protected]> S: Maintained
common/spl/Kconfig +9 -0
@@ -577,6 +577,15 @@ config SPL_FS_EXT4 filesystem from within SPL. Support for the underlying block device (e.g. MMC or USB) must be enabled separately. +config SPL_FS_SQUASHFS + bool "Support SquashFS filesystems" + select FS_SQUASHFS + help + Enable support for SquashFS filesystems with SPL. This permits + U-Boot (or Linux in Falcon mode) to be loaded from a SquashFS + filesystem from within SPL. Support for the underlying block + device (e.g. MMC or USB) must be enabled separately. + config SPL_FS_FAT bool "Support FAT filesystems" select FS_FAT
fs/Kconfig +2 -0
@@ -22,4 +22,6 @@ source "fs/cramfs/Kconfig" source "fs/yaffs2/Kconfig" +source "fs/squashfs/Kconfig" + endmenu
fs/Makefile +2 -0
@@ -9,6 +9,7 @@ obj-$(CONFIG_FS_LOADER) += fs.o obj-$(CONFIG_SPL_FS_FAT) += fat/ obj-$(CONFIG_SPL_FS_EXT4) += ext4/ obj-$(CONFIG_SPL_FS_CBFS) += cbfs/ +obj-$(CONFIG_SPL_FS_SQUASHFS) += squashfs/ else obj-y += fs.o
@@ -23,5 +24,6 @@ obj-$(CONFIG_SANDBOX) += sandbox/ obj-$(CONFIG_CMD_UBIFS) += ubifs/ obj-$(CONFIG_YAFFS2) += yaffs2/ obj-$(CONFIG_CMD_ZFS) += zfs/ +obj-$(CONFIG_FS_SQUASHFS) += squashfs/ endif obj-y += fs_internal.o
fs/fs.c +15 -0
@@ -22,6 +22,7 @@#include <div64.h> #include <linux/math64.h> #include <efi_loader.h> +#include <squashfs.h> DECLARE_GLOBAL_DATA_PTR ;
@@ -276,6 +277,20 @@ static struct fstype_info fstypes[] = { .mkdir = fs_mkdir_unsupported, .ln = fs_ln_unsupported, }, +#endif +#if IS_ENABLED (CONFIG_FS_SQUASHFS ) + { + .fstype = FS_TYPE_SQUASHFS, + .name = "squashfs", + .probe = sqfs_probe, + .opendir = sqfs_opendir, + .readdir = sqfs_readdir, + .ls = fs_ls_generic, + .read = sqfs_read, + .size = sqfs_size, + .close = sqfs_close, + .closedir = sqfs_closedir, + }, #endif { .fstype = FS_TYPE_ANY,
fs/squashfs/Kconfig new file +10 -0
@@ -0,0 +1,10 @@ +config FS_SQUASHFS + bool "Enable SquashFS filesystem support" + help + This provides support for reading images from SquashFS filesystem. + Squashfs is a compressed read-only filesystem for Linux. + It uses zlib, lz4, lzo, or xz compression to compress files, inodes + and directories. Squashfs is intended for general read-only + filesystem use, for archival use (i.e. in cases where a .tar.gz file + may be used), and in constrained block device/memory systems (e.g. + embedded systems) where low overhead is needed.
fs/squashfs/Makefile new file +7 -0
@@ -0,0 +1,7 @@ +# SPDX-License-Identifier: GPL-2.0+ +# + +obj-$(CONFIG_$(SPL_)FS_SQUASHFS) = sqfs.o \ + sqfs_inode.o \ + sqfs_dir.o \ + sqfs_decompressor.o
fs/squashfs/sqfs.c new file +1521 -0
1,521 lines not on this page · raw message
fs/squashfs/sqfs_decompressor.c new file +29 -0
@@ -0,0 +1,29 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Copyright (C) 2020 Bootlin +* +* Author: Joao Marcos Costa <[email protected]> +*/ + +#include <errno.h> +#include <stdint.h> +#include <stdio.h> +#include <stdlib.h> + +#include "sqfs_decompressor.h" +#include "sqfs_filesystem.h" +#include "sqfs_utils.h" + +int sqfs_decompress (u16 comp_type,void *dest,unsigned long *dest_len, +void *source,u32 lenp) +{ +int ret =0 ; + +switch (comp_type) { +default : +printf ("Error: unknown compression type.\n" ); +return -EINVAL ; + } + +return ret; +}
fs/squashfs/sqfs_decompressor.h new file +58 -0
58 lines not on this page · raw message
fs/squashfs/sqfs_dir.c new file +107 -0
107 lines not on this page · raw message
fs/squashfs/sqfs_filesystem.h new file +300 -0
300 lines not on this page · raw message
fs/squashfs/sqfs_inode.c new file +142 -0
142 lines not on this page · raw message
fs/squashfs/sqfs_utils.h new file +49 -0
49 lines not on this page · raw message
include/fs.h +1 -0
@@ -15,6 +15,7 @@ struct cmd_tbl;#define FS_TYPE_SANDBOX 3#define FS_TYPE_UBIFS 4#define FS_TYPE_BTRFS 5 +#define FS_TYPE_SQUASHFS 6struct blk_desc ;
include/squashfs.h new file +25 -0
@@ -0,0 +1,25 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Copyright (C) 2020 Bootlin +* +* Author: Joao Marcos Costa <[email protected]> +* +* squashfs.h: SquashFS filesystem implementation. +*/ + +#ifndef _SQFS_H_ +#define _SQFS_H_ + +struct disk_partition ; + +int sqfs_opendir (const char *filename,struct fs_dir_stream **dirsp); +int sqfs_readdir (struct fs_dir_stream *dirs,struct fs_dirent **dentp); +int sqfs_probe (struct blk_desc *fs_dev_desc, +struct disk_partition *fs_partition); +int sqfs_read (const char *filename,void *buf,loff_t offset, +loff_t len,loff_t *actread); +int sqfs_size (const char *filename,loff_t *size); +void sqfs_close (void ); +void sqfs_closedir (struct fs_dir_stream *dirs); + +#endif /* SQFS_H */
Signature · 1 line
2.17.1
PATCH v3 2/5 fs/squashfs: add filesystem commands
In reply to Joao Marcos CostaAdd 'ls' and 'load' commands.
---
Changes in v3:
- No changes since v2.
Changes in v2:
- Add info. to MAINTAINERS
- Add 'static' keyword to do_sqfs_*(). These functions' prototypes are no longer needed in include/fs.h.
- Change commit message.
MAINTAINERS | 1 + cmd/Kconfig | 6 ++++++ cmd/Makefile | 1 + cmd/sqfs.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 50 insertions(+) create mode 100644 cmd/sqfs.c
MAINTAINERS +1 -0
@@ -949,6 +949,7 @@ M: Joao Marcos Costa <[email protected]> S: Maintained F: fs/squashfs/ F: include/sqfs.h +F: cmd/sqfs.c TDA19988 HDMI ENCODER M: Liviu Dudau <[email protected]>
cmd/Kconfig +6 -0
@@ -2059,6 +2059,12 @@ config CMD_FAT help Support for the FAT fs +config CMD_SQUASHFS + bool "SquashFS command support" + select FS_SQUASHFS + help + Enables SquashFS filesystem commands (e.g. load, ls). + config CMD_FS_GENERIC bool "filesystem commands" help
cmd/Makefile +1 -0
@@ -62,6 +62,7 @@ obj-$(CONFIG_CMD_EXT4) += ext4.o obj-$(CONFIG_CMD_EXT2) += ext2.o obj-$(CONFIG_CMD_FAT) += fat.o obj-$(CONFIG_CMD_FDT) += fdt.o +obj-$(CONFIG_CMD_SQUASHFS) += sqfs.o obj-$(CONFIG_CMD_FLASH) += flash.o obj-$(CONFIG_CMD_FPGA) += fpga.o obj-$(CONFIG_CMD_FPGAD) += fpgad.o
cmd/sqfs.c new file +42 -0
42 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v3 3/5 include/u-boot, lib/zlib: add sources for zlib decompression
In reply to Joao Marcos CostaAdd zlib (v1.2.11) uncompr() function to U-Boot. SquashFS depends on this function to decompress data from a raw disk image. The actual support for zlib into SquashFS sources will be added in a follow-up commit.
---
Changes in v3:
- No changes since v2.
Changes in v2:
- Changed commit title and message, which were wrong and/or misleading in v1. include/u-boot/zlib.h | 32 ++++++++++++++ lib/zlib/uncompr.c | 97 +++++++++++++++++++++++++++++++++++++++++++ lib/zlib/zlib.c | 1 + 3 files changed, 130 insertions(+) create mode 100644 lib/zlib/uncompr.c
include/u-boot/zlib.h +32 -0
@@ -110,6 +110,12 @@ extern "C" {# define voidp z_voidp#endif +#if defined(ZLIB_CONST ) && !defined(z_const) +# define z_const const +#else +# define z_const +#endif +#if defined(__MSDOS__) && !defined(MSDOS )# define MSDOS #endif
@@ -710,6 +716,32 @@ ZEXTERN uInt ZEXPORT crc32 OF((uInt crc, const Bytef *buf, uInt len));if (crc != original_crc) error(); */ +ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen, + const Bytef *source, uLong sourceLen)); +/* +Decompresses the source buffer into the destination buffer. sourceLen is +the byte length of the source buffer. Upon entry, destLen is the total size +of the destination buffer, which must be large enough to hold the entire +uncompressed data. (The size of the uncompressed data must have been saved +previously by the compressor and transmitted to the decompressor by some +mechanism outside the scope of this compression library.) Upon exit, destLen +is the actual size of the uncompressed data. + +uncompress returns Z_OK if success, Z_MEM_ERROR if there was not +enough memory, Z_BUF_ERROR if there was not enough room in the output +buffer, or Z_DATA_ERROR if the input data was corrupted or incomplete. In +the case where there is not enough room, uncompress() will fill the output +buffer with the uncompressed data up to that point. +*/ + +ZEXTERN int ZEXPORT uncompress2 OF((Bytef *dest, uLongf *destLen, + const Bytef *source, uLong *sourceLen)); +/* +Same as uncompress, except that sourceLen is a pointer, where the +length of the source is *sourceLen. On return, *sourceLen is the number of +source bytes consumed. +*/ + ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int windowBits, const char *version, int stream_size));#define inflateInit (strm) \
lib/zlib/uncompr.c new file +97 -0
97 lines not on this page · raw message
lib/zlib/zlib.c +1 -0
@@ -30,3 +30,4 @@#include "inflate.c" #include "zutil.c" #include "adler32.c" +#include "uncompr.c"
Signature · 1 line
2.17.1
PATCH v3 3/5 include/u-boot, lib/zlib: add sources for zlib decompression
Quoted 10 lines · Joao Marcos Costa
Add zlib (v1.2.11)
uncompr()function to U-Boot. SquashFS depends on this function to decompress data from a raw disk image. The actual support for zlib into SquashFS sources will be added in a follow-up commit.Signed-off-by Joao Marcos Costa <[email protected]>---
Changes in v3:
- No changes since v2.
Changes in v2:
Quoted 7 lines
- Changed commit title and message, which were wrong and/or misleading in v1. include/u-boot/zlib.h | 32 ++++++++++++++ lib/zlib/uncompr.c | 97 +++++++++++++++++++++++++++++++++++++++++++ lib/zlib/zlib.c | 1 + 3 files changed, 130 insertions(+) create mode 100644 lib/zlib/uncompr.c
Can you confirm that on a platform where we aren't enabling squashfs the new zlib functionality ends up being discarded at link time? Thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 659 bytes Desc: not available URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200729/28864363/attachment.sig>
PATCH v3 3/5 include/u-boot, lib/zlib: add sources for zlib decompression
Quoted 20 lines · On Wed, 29 Jul 2020 11:27:45 -0400 Tom Rini <[email protected]> wrote:
Quoted 12 lines · Joao Marcos Costa
Add zlib (v1.2.11)
uncompr()function to U-Boot. SquashFS depends on this function to decompress data from a raw disk image. The actual support for zlib into SquashFS sources will be added in a follow-up commit.Signed-off-by Joao Marcos Costa <[email protected]>---
Changes in v3:
- No changes since v2.
Changes in v2:
- Changed commit title and message, which were wrong and/or
misleading in v1.Quoted 5 lines
include/u-boot/zlib.h | 32 ++++++++++++++ lib/zlib/uncompr.c | 97 +++++++++++++++++++++++++++++++++++++++++++ lib/zlib/zlib.c | 1 + 3 files changed, 130 insertions(+) create mode 100644 lib/zlib/uncompr.c
Quoted 4 lines
Can you confirm that on a platform where we aren't enabling squashfs the new zlib functionality ends up being discarded at link time? Thanks!
I dumped lib/zlib/zlib.o with readelf and the new functionality is not discarded, even though the SquashFS support is not enabled, but this issue will be fixed in the next version (v4). Thank you!
PATCH v3 3/5 include/u-boot, lib/zlib: add sources for zlib decompression
Quoted 23 lines · Joao Marcos Costa
Quoted 20 lines · On Wed, 29 Jul 2020 11:27:45 -0400 Tom Rini <[email protected]> wrote:
Quoted 17 lines · Joao Marcos Costa
Add zlib (v1.2.11)
uncompr()function to U-Boot. SquashFS depends on this function to decompress data from a raw disk image. The actual support for zlib into SquashFS sources will be added in a follow-up commit.Signed-off-by Joao Marcos Costa <[email protected]>---
Changes in v3:
- No changes since v2.
Changes in v2:
- Changed commit title and message, which were wrong and/or
misleading in v1.include/u-boot/zlib.h | 32 ++++++++++++++ lib/zlib/uncompr.c | 97 +++++++++++++++++++++++++++++++++++++++++++ lib/zlib/zlib.c | 1 + 3 files changed, 130 insertions(+) create mode 100644 lib/zlib/uncompr.c
Quoted 8 lines
Quoted 4 lines
Can you confirm that on a platform where we aren't enabling squashfs the new zlib functionality ends up being discarded at link time? Thanks!
I dumped
lib/zlib/zlib.owith readelf and the new functionality is not discarded, even though the SquashFS support is not enabled, but this issue will be fixed in the next version (v4). Thank you!
Well, don't dump lib/zlib/zlib.o, that won't say. Check u-boot.map :)
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 659 bytes Desc: not available URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200729/b7e9d8a4/attachment.sig>
PATCH v3 3/5 include/u-boot, lib/zlib: add sources for zlib decompression
Quoted 29 lines · On Wed, 29 Jul 2020 12:54:23 -0400 Tom Rini <[email protected]> wrote:
Quoted 28 lines · Joao Marcos Costa
Quoted 24 lines · On Wed, 29 Jul 2020 11:27:45 -0400 Tom Rini <[email protected]> wrote:
Quoted 12 lines · Joao Marcos Costa
Add zlib (v1.2.11)
uncompr()function to U-Boot. SquashFS depends on this function to decompress data from a raw disk image. The actual support for zlib into SquashFS sources will be added in a follow-up commit.Signed-off-by Joao Marcos Costa <[email protected]>---
Changes in v3:
- No changes since v2.
Changes in v2:
- Changed commit title and message, which were wrong
and/or misleading in v1.Quoted 5 lines
include/u-boot/zlib.h | 32 ++++++++++++++ lib/zlib/uncompr.c | 97 +++++++++++++++++++++++++++++++++++++++++++ lib/zlib/zlib.c | 1 + 3 files changed, 130 insertions(+) create mode 100644 lib/zlib/uncompr.cCan you confirm that on a platform where we aren't enabling squashfs the new zlib functionality ends up being discarded at link time? Thanks!
Quoted 6 lines
Quoted 3 lines
I dumped
lib/zlib/zlib.owith readelf and the new functionality is not discarded, even though the SquashFS support is not enabled, but this issue will be fixed in the next version (v4). Thank you!Well, don't dump
lib/zlib/zlib.o, that won't say. Check u-boot.map :)
Thanks for the tip! Now I can confirm that the functionality is discarded when squashfs is not enabled. I just would like to know if I should send the tests in the same patch as the SquashFS commands, or should it be into a separate patch?
PATCH v3 3/5 include/u-boot, lib/zlib: add sources for zlib decompression
Quoted 36 lines · Joao Marcos Costa
Quoted 33 lines · On Wed, 29 Jul 2020 12:54:23 -0400 Tom Rini <[email protected]> wrote:
Quoted 31 lines · Joao Marcos Costa
Quoted 20 lines · On Wed, 29 Jul 2020 11:27:45 -0400 Tom Rini <[email protected]> wrote:
Quoted 12 lines · Joao Marcos Costa
Add zlib (v1.2.11)
uncompr()function to U-Boot. SquashFS depends on this function to decompress data from a raw disk image. The actual support for zlib into SquashFS sources will be added in a follow-up commit.Signed-off-by Joao Marcos Costa <[email protected]>---
Changes in v3:
- No changes since v2.
Changes in v2:
- Changed commit title and message, which were wrong
and/or misleading in v1.Quoted 5 lines
include/u-boot/zlib.h | 32 ++++++++++++++ lib/zlib/uncompr.c | 97 +++++++++++++++++++++++++++++++++++++++++++ lib/zlib/zlib.c | 1 + 3 files changed, 130 insertions(+) create mode 100644 lib/zlib/uncompr.cQuoted 4 lines
Can you confirm that on a platform where we aren't enabling squashfs the new zlib functionality ends up being discarded at link time? Thanks!
I dumped
lib/zlib/zlib.owith readelf and the new functionality is not discarded, even though the SquashFS support is not enabled, but this issue will be fixed in the next version (v4). Thank you!
Quoted 7 lines
Quoted 2 lines
Well, don't dump
lib/zlib/zlib.o, that won't say. Check u-boot.map :)Thanks for the tip! Now I can confirm that the functionality is discarded when squashfs is not enabled. I just would like to know if I should send the tests in the same patch as the SquashFS commands, or should it be into a separate patch?
A separate patch, and are you able to run them on sandbox then? So it should also enable squashfs on that target. Thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 659 bytes Desc: not available URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200730/3294f73f/attachment.sig>
PATCH v3 3/5 include/u-boot, lib/zlib: add sources for zlib decompression
Quoted 42 lines · On Thu, 30 Jul 2020 08:17:59 -0400 Tom Rini <[email protected]> wrote:
Quoted 41 lines · Joao Marcos Costa
Quoted 37 lines · On Wed, 29 Jul 2020 12:54:23 -0400 Tom Rini <[email protected]> wrote:
Quoted 28 lines · Joao Marcos Costa
Quoted 20 lines · On Wed, 29 Jul 2020 11:27:45 -0400 Tom Rini <[email protected]> wrote:
Quoted 12 lines · Joao Marcos Costa
Add zlib (v1.2.11)
uncompr()function to U-Boot. SquashFS depends on this function to decompress data from a raw disk image. The actual support for zlib into SquashFS sources will be added in a follow-up commit.Signed-off-by: Joao Marcos Costa <[email protected]> ---
Changes in v3:
- No changes since v2.
Changes in v2:
- Changed commit title and message, which were wrong
and/or misleading in v1.Quoted 5 lines
include/u-boot/zlib.h | 32 ++++++++++++++ lib/zlib/uncompr.c | 97 +++++++++++++++++++++++++++++++++++++++++++ lib/zlib/zlib.c | 1 + 3 files changed, 130 insertions(+) create mode 100644 lib/zlib/uncompr.cQuoted 4 lines
Can you confirm that on a platform where we aren't enabling squashfs the new zlib functionality ends up being discarded at link time? Thanks!
Quoted 4 lines
I dumped
lib/zlib/zlib.owith readelf and the new functionality is not discarded, even though the SquashFS support is not enabled, but this issue will be fixed in the next version (v4). Thank you!Well, don't dump
lib/zlib/zlib.o, that won't say. Check u-boot.map :)
Quoted 8 lines
Quoted 4 lines
Thanks for the tip! Now I can confirm that the functionality is discarded when squashfs is not enabled. I just would like to know if I should send the tests in the same patch as the SquashFS commands, or should it be into a separate patch?
A separate patch, and are you able to run them on sandbox then? So it should also enable squashfs on that target. Thanks!
This will be addressed in v4. Thanks!
PATCH v3 4/5 fs/squashfs: add support for zlib decompression
In reply to Joao Marcos CostaAdd call to zlib's 'uncompress' function. Add function to display the right error message depending on the decompression's return value.
---
Changes in v3:
- No changes since v2.
Changes in v2:
- No changes since v1.
fs/squashfs/sqfs_decompressor.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
fs/squashfs/sqfs_decompressor.c +24 -0
@@ -9,17 +9,41 @@#include <stdint.h> #include <stdio.h> #include <stdlib.h> +#include <u-boot/zlib.h> #include "sqfs_decompressor.h" #include "sqfs_filesystem.h" #include "sqfs_utils.h" +static void zlib_decompression_status (int ret) +{ +switch (ret) { +case Z_BUF_ERROR : +printf ("Error: 'dest' buffer is not large enough.\n" ); +break ; +case Z_DATA_ERROR : +printf ("Error: corrupted compressed data.\n" ); +break ; +case Z_MEM_ERROR : +printf ("Error: insufficient memory.\n" ); +break ; + } +} +int sqfs_decompress (u16 comp_type,void *dest,unsigned long *dest_len,void *source,u32 lenp) {int ret =0 ;switch (comp_type) { +case SQFS_COMP_ZLIB : + ret =uncompress (dest, dest_len, source, lenp); +if (ret) { +zlib_decompression_status (ret); +return -EINVAL ; + } + +break ;default :printf ("Error: unknown compression type.\n" );return -EINVAL ;
Signature · 1 line
2.17.1
PATCH v3 5/5 fs/fs.c: add symbolic link case to fs_ls_generic()
In reply to Joao Marcos CostaAdds an 'else if' statement inside the loop to check for symbolic links.
---
Changes in v3:
- No changes since v2.
Changes in v2:
- This patch was added in v2 and did not exist in the last version.
fs/fs.c | 3 +++ 1 file changed, 3 insertions(+)
fs/fs.c +3 -0
@@ -59,6 +59,9 @@ static int fs_ls_generic(const char *dirname)if (dent->type ==FS_DT_DIR ) {printf (" %s/\n" , dent->name); ndirs++; + }else if (dent->type ==FS_DT_LNK ) { +printf (" <SYM> %s\n" , dent->name); + nfiles++; }else {printf (" %8lld %s\n" , dent->size, dent->name); nfiles++;
Signature · 1 line
2.17.1
v3 cover Add support for the SquashFS filesystem
In reply to Joao Marcos CostaQuoted 51 lines · On Tue, 21 Jul 2020 11:22:54 +0200 Joao Marcos Costa…
Hello!
This series adds support for the SquashFS filesystem. For now, zlib is the only supported compression type. This is my first contribution to U-Boot as well as to a major Open Source project.
Changes in v3:
- ReplaceCONFIG_IS_ENABLEDbyIS_ENABLEDinfs/fs.c
Changes in v2:
- Replacesqfs_ls()by U-Boot'sfs_ls_generic()
- Add info. toMAINTAINERS
- Fix build failures
- Fix style problemsBest regards,
Joao Marcos CostaJoao Marcos Costa (5):
fs/squashfs: new filesystem
fs/squashfs: add filesystem commandsinclude/u-boot, lib/zlib: add sources for zlib decompression fs/squashfs: add support for zlib decompressionfs/fs.c: add symbolic link case tofs_ls_generic()MAINTAINERS | 7 + cmd/Kconfig | 6 + cmd/Makefile | 1 + cmd/sqfs.c | 42 + common/spl/Kconfig | 9 + fs/Kconfig | 2 + fs/Makefile | 2 + fs/fs.c | 18 + fs/squashfs/Kconfig | 10 + fs/squashfs/Makefile | 7 + fs/squashfs/sqfs.c | 1521 +++++++++++++++++++++++++++++++ fs/squashfs/sqfs_decompressor.c | 53 ++ fs/squashfs/sqfs_decompressor.h | 58 ++ fs/squashfs/sqfs_dir.c | 107 +++ fs/squashfs/sqfs_filesystem.h | 300 ++++++ fs/squashfs/sqfs_inode.c | 142 +++ fs/squashfs/sqfs_utils.h | 49 + include/fs.h | 1 + include/squashfs.h | 25 + include/u-boot/zlib.h | 32 + lib/zlib/uncompr.c | 97 ++ lib/zlib/zlib.c | 1 + 22 files changed, 2490 insertions(+) create mode 100644 cmd/sqfs.c create mode 100644 fs/squashfs/Kconfig create mode 100644 fs/squashfs/Makefile create mode 100644 fs/squashfs/sqfs.c
Quoted 9 lines
create mode 100644 fs/squashfs/sqfs_decompressor.c create mode 100644 fs/squashfs/sqfs_decompressor.h create mode 100644 fs/squashfs/sqfs_dir.c create mode 100644 fs/squashfs/sqfs_filesystem.h create mode 100644 fs/squashfs/sqfs_inode.c create mode 100644 fs/squashfs/sqfs_utils.h create mode 100644 include/squashfs.h create mode 100644 lib/zlib/uncompr.c
Hello again,
I am currently writing tests for the SquashFS support. I wrote two Python scripts to test 'ls' and 'load' commands, but I need a SquashFS image to do so, and I would like to know what is the better approach for this:
- Add a compiled SquashFS image into the same directory as the tests, i.e.: test/py/tests/test_fs/test_squashfs. This is a +-7MB sized binary file.
- Use the scripts to generate an image, with mksquashfs. However, mksquashfs becomes a dependency.
Best regards,
Joao Marcos
v3 cover Add support for the SquashFS filesystem
Quoted 66 lines · Joao Marcos Costa
Quoted 51 lines · On Tue, 21 Jul 2020 11:22:54 +0200 Joao Marcos Costa…
Hello!
This series adds support for the SquashFS filesystem. For now, zlib is the only supported compression type. This is my first contribution to U-Boot as well as to a major Open Source project.
Changes in v3:
- ReplaceCONFIG_IS_ENABLEDbyIS_ENABLEDinfs/fs.c
Changes in v2:
- Replacesqfs_ls()by U-Boot'sfs_ls_generic()
- Add info. toMAINTAINERS
- Fix build failures
- Fix style problemsBest regards,
Joao Marcos CostaJoao Marcos Costa (5):
fs/squashfs: new filesystem
fs/squashfs: add filesystem commandsinclude/u-boot, lib/zlib: add sources for zlib decompression fs/squashfs: add support for zlib decompressionfs/fs.c: add symbolic link case tofs_ls_generic()MAINTAINERS | 7 + cmd/Kconfig | 6 + cmd/Makefile | 1 + cmd/sqfs.c | 42 + common/spl/Kconfig | 9 + fs/Kconfig | 2 + fs/Makefile | 2 + fs/fs.c | 18 + fs/squashfs/Kconfig | 10 + fs/squashfs/Makefile | 7 + fs/squashfs/sqfs.c | 1521 +++++++++++++++++++++++++++++++ fs/squashfs/sqfs_decompressor.c | 53 ++ fs/squashfs/sqfs_decompressor.h | 58 ++ fs/squashfs/sqfs_dir.c | 107 +++ fs/squashfs/sqfs_filesystem.h | 300 ++++++ fs/squashfs/sqfs_inode.c | 142 +++ fs/squashfs/sqfs_utils.h | 49 + include/fs.h | 1 + include/squashfs.h | 25 + include/u-boot/zlib.h | 32 + lib/zlib/uncompr.c | 97 ++ lib/zlib/zlib.c | 1 + 22 files changed, 2490 insertions(+) create mode 100644 cmd/sqfs.c create mode 100644 fs/squashfs/Kconfig create mode 100644 fs/squashfs/Makefile create mode 100644 fs/squashfs/sqfs.cQuoted 9 lines
create mode 100644 fs/squashfs/sqfs_decompressor.c create mode 100644 fs/squashfs/sqfs_decompressor.h create mode 100644 fs/squashfs/sqfs_dir.c create mode 100644 fs/squashfs/sqfs_filesystem.h create mode 100644 fs/squashfs/sqfs_inode.c create mode 100644 fs/squashfs/sqfs_utils.h create mode 100644 include/squashfs.h create mode 100644 lib/zlib/uncompr.cHello again,
Quoted 9 lines
I am currently writing tests for the SquashFS support. I wrote two Python scripts to test 'ls' and 'load' commands, but I need a SquashFS image to do so, and I would like to know what is the better approach for this:
- Add a compiled SquashFS image into the same directory as the tests, i.e.: test/py/tests/test_fs/test_squashfs. This is a +-7MB sized binary file.
- Use the scripts to generate an image, with mksquashfs. However, mksquashfs becomes a dependency.
We should dynamically make the images, just like ext* and fat. The tests should skip when the required tools aren't found, in the same manner we do for other fs tests. Thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 659 bytes Desc: not available URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200729/ed3c01b8/attachment.sig>
v3 cover Add support for the SquashFS filesystem
Quoted 77 lines · On Wed, 29 Jul 2020 11:21:26 -0400 Tom Rini <[email protected]> wrote:
Quoted 66 lines · Joao Marcos Costa
Quoted 51 lines · On Tue, 21 Jul 2020 11:22:54 +0200 Joao Marcos Costa…
Hello!
This series adds support for the SquashFS filesystem. For now, zlib is the only supported compression type. This is my first contribution to U-Boot as well as to a major Open Source project.
Changes in v3:
- ReplaceCONFIG_IS_ENABLEDbyIS_ENABLEDinfs/fs.c
Changes in v2:
- Replacesqfs_ls()by U-Boot'sfs_ls_generic()
- Add info. toMAINTAINERS
- Fix build failures
- Fix style problemsBest regards,
Joao Marcos CostaJoao Marcos Costa (5):
fs/squashfs: new filesystem
fs/squashfs: add filesystem commandsinclude/u-boot, lib/zlib: add sources for zlib decompression fs/squashfs: add support for zlib decompressionfs/fs.c: add symbolic link case tofs_ls_generic()MAINTAINERS | 7 + cmd/Kconfig | 6 + cmd/Makefile | 1 + cmd/sqfs.c | 42 + common/spl/Kconfig | 9 + fs/Kconfig | 2 + fs/Makefile | 2 + fs/fs.c | 18 + fs/squashfs/Kconfig | 10 + fs/squashfs/Makefile | 7 + fs/squashfs/sqfs.c | 1521 +++++++++++++++++++++++++++++++ fs/squashfs/sqfs_decompressor.c | 53 ++ fs/squashfs/sqfs_decompressor.h | 58 ++ fs/squashfs/sqfs_dir.c | 107 +++ fs/squashfs/sqfs_filesystem.h | 300 ++++++ fs/squashfs/sqfs_inode.c | 142 +++ fs/squashfs/sqfs_utils.h | 49 + include/fs.h | 1 + include/squashfs.h | 25 + include/u-boot/zlib.h | 32 + lib/zlib/uncompr.c | 97 ++ lib/zlib/zlib.c | 1 + 22 files changed, 2490 insertions(+) create mode 100644 cmd/sqfs.c create mode 100644 fs/squashfs/Kconfig create mode 100644 fs/squashfs/Makefile create mode 100644 fs/squashfs/sqfs.cQuoted 9 lines
create mode 100644 fs/squashfs/sqfs_decompressor.c create mode 100644 fs/squashfs/sqfs_decompressor.h create mode 100644 fs/squashfs/sqfs_dir.c create mode 100644 fs/squashfs/sqfs_filesystem.h create mode 100644 fs/squashfs/sqfs_inode.c create mode 100644 fs/squashfs/sqfs_utils.h create mode 100644 include/squashfs.h create mode 100644 lib/zlib/uncompr.cHello again,
Quoted 9 lines
I am currently writing tests for the SquashFS support. I wrote two Python scripts to test 'ls' and 'load' commands, but I need a SquashFS image to do so, and I would like to know what is the better approach for this:
- Add a compiled SquashFS image into the same directory as the tests, i.e.: test/py/tests/test_fs/test_squashfs. This is a +-7MB sized binary file.
- Use the scripts to generate an image, with mksquashfs. However, mksquashfs becomes a dependency.
Quoted 4 lines
We should dynamically make the images, just like ext* and fat. The tests should skip when the required tools aren't found, in the same manner we do for other fs tests. Thanks!
Ok, thank you!
Best regards,
Joao Marcos