From patchwork Thu Jul 9 17:51:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joao Marcos Costa X-Patchwork-Id: 241146 List-Id: U-Boot discussion From: joaomarcos.costa at bootlin.com (Joao Marcos Costa) Date: Thu, 9 Jul 2020 19:51:46 +0200 Subject: [PATCH 2/4] fs/squashfs: add filesystem commands In-Reply-To: <20200709175148.17193-1-joaomarcos.costa@bootlin.com> References: <20200709175148.17193-1-joaomarcos.costa@bootlin.com> Message-ID: <20200709175148.17193-3-joaomarcos.costa@bootlin.com> Add 'ls' (sqfsls) and 'load' (sqfsload) commands. Signed-off-by: Joao Marcos Costa --- cmd/Kconfig | 6 ++++++ cmd/Makefile | 1 + cmd/sqfs.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 50 insertions(+) create mode 100644 cmd/sqfs.c -- 2.17.1 diff --git a/cmd/Kconfig b/cmd/Kconfig index 6403bc45a5..fa2a697dea 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -1993,6 +1993,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 diff --git a/cmd/Makefile b/cmd/Makefile index f1dd513a4b..0553b0b70e 100644 --- a/cmd/Makefile +++ b/cmd/Makefile @@ -60,6 +60,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_FITUPD) += fitupd.o obj-$(CONFIG_CMD_FLASH) += flash.o obj-$(CONFIG_CMD_FPGA) += fpga.o diff --git a/cmd/sqfs.c b/cmd/sqfs.c new file mode 100644 index 0000000000..af42df728b --- /dev/null +++ b/cmd/sqfs.c @@ -0,0 +1,43 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2020 Bootlin + * + * Author: Joao Marcos Costa + * + * squashfs.c: implements SquashFS related commands + */ + +#include +#include + +int do_sqfs_ls(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) +{ + return do_ls(cmdtp, flag, argc, argv, FS_TYPE_SQUASHFS); +} + +U_BOOT_CMD( + sqfsls, 4, 1, do_sqfs_ls, + "List files in directory. Default: root (/).", + " [] [directory]\n"\ + " - list files from 'dev' on 'interface' in 'directory'\n" +); + +int do_sqfs_load(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) +{ + return do_load(cmdtp, flag, argc, argv, FS_TYPE_SQUASHFS); +} + +U_BOOT_CMD( + sqfsload, 7, 0, do_sqfs_load, + "load binary file from a SquashFS filesystem", + " [ [ [ [bytes [pos]]]]]\n" + " - Load binary file 'filename' from 'dev' on 'interface'\n" + " to address 'addr' from SquashFS filesystem.\n" + " 'pos' gives the file position to start loading from.\n" + " If 'pos' is omitted, 0 is used. 'pos' requires 'bytes'.\n" + " 'bytes' gives the size to load. If 'bytes' is 0 or omitted,\n" + " the load stops on end of file.\n" + " If either 'pos' or 'bytes' are not aligned to\n" + " ARCH_DMA_MINALIGN then a misaligned buffer warning will\n" + " be printed and performance will suffer for the load." +);