
From: Simon Glass <sjg@chromium.org> Most commands access the filesystem through the command-line interface rather than the filesystem API itself. Add a new header file which contains these functions, so we can separate commands from the API. Signed-off-by: Simon Glass <sjg@chromium.org> --- cmd/erofs.c | 2 +- cmd/ext2.c | 2 +- cmd/ext4.c | 2 +- cmd/fat.c | 2 +- cmd/fs.c | 2 +- cmd/fs_uuid.c | 1 + cmd/host.c | 2 +- cmd/pstore.c | 2 +- cmd/sqfs.c | 2 +- cmd/test.c | 2 +- include/erofs.h | 3 ++ include/fs_cmd.h | 83 +++++++++++++++++++++++++++++++++++++++++++++ include/fs_legacy.h | 71 -------------------------------------- include/squashfs.h | 3 ++ 14 files changed, 99 insertions(+), 80 deletions(-) create mode 100644 include/fs_cmd.h diff --git a/cmd/erofs.c b/cmd/erofs.c index f4ff12eadaa..e2479461652 100644 --- a/cmd/erofs.c +++ b/cmd/erofs.c @@ -8,7 +8,7 @@ */ #include <command.h> -#include <fs_legacy.h> +#include <fs_cmd.h> #include <erofs.h> static int do_erofs_ls(struct cmd_tbl *cmdtp, int flag, int argc, char * const argv[]) diff --git a/cmd/ext2.c b/cmd/ext2.c index 3de098193e7..d5150d08001 100644 --- a/cmd/ext2.c +++ b/cmd/ext2.c @@ -20,7 +20,7 @@ * Ext2fs support */ #include <command.h> -#include <fs_legacy.h> +#include <fs_cmd.h> static int do_ext2ls(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) diff --git a/cmd/ext4.c b/cmd/ext4.c index 02d3f7a174b..bf257c55e06 100644 --- a/cmd/ext4.c +++ b/cmd/ext4.c @@ -34,7 +34,7 @@ #include <ext4fs.h> #include <linux/stat.h> #include <malloc.h> -#include <fs_legacy.h> +#include <fs_cmd.h> #if defined(CONFIG_CMD_USB) && defined(CONFIG_USB_STORAGE) #include <usb.h> diff --git a/cmd/fat.c b/cmd/fat.c index aa01c36688b..e0e08d4a408 100644 --- a/cmd/fat.c +++ b/cmd/fat.c @@ -10,7 +10,7 @@ #include <command.h> #include <mapmem.h> #include <fat.h> -#include <fs_legacy.h> +#include <fs_cmd.h> #include <part.h> #include <asm/cache.h> diff --git a/cmd/fs.c b/cmd/fs.c index 51d587b8b16..7058f17b24f 100644 --- a/cmd/fs.c +++ b/cmd/fs.c @@ -6,7 +6,7 @@ */ #include <command.h> -#include <fs_legacy.h> +#include <fs_cmd.h> static int do_size_wrapper(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) diff --git a/cmd/fs_uuid.c b/cmd/fs_uuid.c index 6a91c633dcb..3c439a0338c 100644 --- a/cmd/fs_uuid.c +++ b/cmd/fs_uuid.c @@ -6,6 +6,7 @@ */ #include <command.h> +#include <fs_cmd.h> #include <fs_legacy.h> static int do_fs_uuid_wrapper(struct cmd_tbl *cmdtp, int flag, int argc, diff --git a/cmd/host.c b/cmd/host.c index 9832a88a5b0..f037b9b61f9 100644 --- a/cmd/host.c +++ b/cmd/host.c @@ -5,7 +5,7 @@ #include <command.h> #include <dm.h> -#include <fs_legacy.h> +#include <fs_cmd.h> #include <part.h> #include <sandbox_host.h> #include <dm/device_compat.h> diff --git a/cmd/pstore.c b/cmd/pstore.c index ab7ac656383..0eece5bfaf0 100644 --- a/cmd/pstore.c +++ b/cmd/pstore.c @@ -6,7 +6,7 @@ #include <config.h> #include <command.h> #include <fdtdec.h> -#include <fs_legacy.h> +#include <fs_cmd.h> #include <log.h> #include <mapmem.h> #include <memalign.h> diff --git a/cmd/sqfs.c b/cmd/sqfs.c index b10403c4379..463db01714b 100644 --- a/cmd/sqfs.c +++ b/cmd/sqfs.c @@ -8,7 +8,7 @@ */ #include <command.h> -#include <fs_legacy.h> +#include <fs_cmd.h> #include <squashfs.h> static int do_sqfs_ls(struct cmd_tbl *cmdtp, int flag, int argc, char * const argv[]) diff --git a/cmd/test.c b/cmd/test.c index cb24479f5b1..b2e853f379c 100644 --- a/cmd/test.c +++ b/cmd/test.c @@ -5,7 +5,7 @@ */ #include <command.h> -#include <fs_legacy.h> +#include <fs_cmd.h> #include <log.h> #include <vsprintf.h> diff --git a/include/erofs.h b/include/erofs.h index 1fbe82bf72c..26c4d5acefe 100644 --- a/include/erofs.h +++ b/include/erofs.h @@ -2,7 +2,10 @@ #ifndef _EROFS_H_ #define _EROFS_H_ +struct blk_desc; struct disk_partition; +struct fs_dirent; +struct fs_dir_stream; int erofs_opendir(const char *filename, struct fs_dir_stream **dirsp); int erofs_readdir(struct fs_dir_stream *dirs, struct fs_dirent **dentp); diff --git a/include/fs_cmd.h b/include/fs_cmd.h new file mode 100644 index 00000000000..3b58ad516e7 --- /dev/null +++ b/include/fs_cmd.h @@ -0,0 +1,83 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (c) 2012, NVIDIA CORPORATION. All rights reserved. + */ + +#ifndef _FS_CMD_H +#define _FS_CMD_H + +#include <fs_common.h> + +struct cmd_tbl; + +/** + * do_fat_fsload - Run the fatload command + * + * @cmdtp: Command information for fatload + * @flag: Command flags (CMD_FLAG\_...) + * @argc: Number of arguments + * @argv: List of arguments + * Return: result (see enum command_ret_t) + */ +int do_fat_fsload(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]); + +/** + * do_ext2load - Run the ext2load command + * + * @cmdtp: Command information for ext2load + * @flag: Command flags (CMD_FLAG\_...) + * @argc: Number of arguments + * @argv: List of arguments + * Return: result (see enum command_ret_t) + */ +int do_ext2load(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); + +/* + * Common implementation for various filesystem commands, optionally limited + * to a specific filesystem type via the fstype parameter. + */ +int do_size(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[], + int fstype); +int do_load(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[], + int fstype); +int do_ls(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[], + int fstype); +int file_exists(const char *dev_type, const char *dev_part, const char *file, + int fstype); +int do_save(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[], + int fstype); +int do_rm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[], + int fstype); +int do_mkdir(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[], + int fstype); +int do_ln(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[], + int fstype); +int do_mv(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[], + int fstype); + +/* + * Determine the UUID of the specified filesystem and print it. Optionally it is + * possible to store the UUID directly in env. + */ +int do_fs_uuid(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[], + int fstype); + +/* + * Determine the type of the specified filesystem and print it. Optionally it is + * possible to store the type directly in env. + */ +int do_fs_type(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); + +/** + * do_fs_types - List supported filesystems. + * + * @cmdtp: Command information for fstypes + * @flag: Command flags (CMD_FLAG\_...) + * @argc: Number of arguments + * @argv: List of arguments + * Return: result (see enum command_ret_t) + */ +int do_fs_types(struct cmd_tbl *cmdtp, int flag, int argc, char * const argv[]); + +#endif diff --git a/include/fs_legacy.h b/include/fs_legacy.h index 1a01fb09aa1..4a564950b74 100644 --- a/include/fs_legacy.h +++ b/include/fs_legacy.h @@ -9,33 +9,9 @@ #include <rtc.h> struct abuf; -struct cmd_tbl; struct blk_desc; -/** - * do_fat_fsload - Run the fatload command - * - * @cmdtp: Command information for fatload - * @flag: Command flags (CMD_FLAG\_...) - * @argc: Number of arguments - * @argv: List of arguments - * Return: result (see enum command_ret_t) - */ -int do_fat_fsload(struct cmd_tbl *cmdtp, int flag, int argc, - char *const argv[]); - -/** - * do_ext2load - Run the ext2load command - * - * @cmdtp: Command information for ext2load - * @flag: Command flags (CMD_FLAG\_...) - * @argc: Number of arguments - * @argv: List of arguments - * Return: result (see enum command_ret_t) - */ -int do_ext2load(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); - /* * Tell the fs layer which block device and partition to use for future * commands. This also internally identifies the filesystem that is present @@ -225,53 +201,6 @@ int fs_mkdir(const char *filename); */ int fs_rename(const char *old_path, const char *new_path); -/* - * Common implementation for various filesystem commands, optionally limited - * to a specific filesystem type via the fstype parameter. - */ -int do_size(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[], - int fstype); -int do_load(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[], - int fstype); -int do_ls(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[], - int fstype); -int file_exists(const char *dev_type, const char *dev_part, const char *file, - int fstype); -int do_save(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[], - int fstype); -int do_rm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[], - int fstype); -int do_mkdir(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[], - int fstype); -int do_ln(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[], - int fstype); -int do_mv(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[], - int fstype); - -/* - * Determine the UUID of the specified filesystem and print it. Optionally it is - * possible to store the UUID directly in env. - */ -int do_fs_uuid(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[], - int fstype); - -/* - * Determine the type of the specified filesystem and print it. Optionally it is - * possible to store the type directly in env. - */ -int do_fs_type(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); - -/** - * do_fs_types - List supported filesystems. - * - * @cmdtp: Command information for fstypes - * @flag: Command flags (CMD_FLAG\_...) - * @argc: Number of arguments - * @argv: List of arguments - * Return: result (see enum command_ret_t) - */ -int do_fs_types(struct cmd_tbl *cmdtp, int flag, int argc, char * const argv[]); - /** * fs_read_alloc() - Allocate space for a file and read it * diff --git a/include/squashfs.h b/include/squashfs.h index 7489eefa1f2..1e9b6a7a517 100644 --- a/include/squashfs.h +++ b/include/squashfs.h @@ -10,7 +10,10 @@ #ifndef _SQFS_H_ #define _SQFS_H_ +struct blk_desc; struct disk_partition; +struct fs_dirent; +struct fs_dir_stream; int sqfs_opendir(const char *filename, struct fs_dir_stream **dirsp); int sqfs_readdir(struct fs_dir_stream *dirs, struct fs_dirent **dentp); -- 2.43.0