From patchwork Tue Mar 17 14:09:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niel Fourie X-Patchwork-Id: 243738 List-Id: U-Boot discussion From: lusus at denx.de (Niel Fourie) Date: Tue, 17 Mar 2020 15:09:05 +0100 Subject: [PATCH 2/3] cmd: fs: Add command to list supported fs types In-Reply-To: <20200317140906.858558-1-lusus@denx.de> References: <20200317140906.858558-1-lusus@denx.de> Message-ID: <20200317140906.858558-3-lusus@denx.de> Added command "fstypes" to list supported/included filesystems. Signed-off-by: Niel Fourie CC: Simon Glass --- cmd/fs.c | 11 +++++++++++ fs/fs.c | 20 ++++++++++++++++++++ include/fs.h | 5 +++++ 3 files changed, 36 insertions(+) diff --git a/cmd/fs.c b/cmd/fs.c index db74767b7b..26b47bd001 100644 --- a/cmd/fs.c +++ b/cmd/fs.c @@ -99,3 +99,14 @@ U_BOOT_CMD( "fstype : \n" "- set environment variable to filesystem type\n" ); + +static int do_fstypes_wrapper(cmd_tbl_t *cmdtp, int flag, int argc, + char * const argv[]) +{ + return do_fs_types(cmdtp, flag, argc, argv); +} + +U_BOOT_CMD( + fstypes, 1, 1, do_fstypes_wrapper, + "List supported filesystem types", "" +); diff --git a/fs/fs.c b/fs/fs.c index 0c66d60477..3e38b2e27a 100644 --- a/fs/fs.c +++ b/fs/fs.c @@ -900,3 +900,23 @@ int do_ln(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[], return 0; } + +int do_fs_types(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) +{ + struct fstype_info *drv = fstypes; + const int n_ents = ARRAY_SIZE(fstypes); + struct fstype_info *entry; + int i = 0; + + puts("Supported filesystems"); + for (entry = drv; entry != drv + n_ents; entry++) { + if (entry->fstype != FS_TYPE_ANY) { + printf("%c %s", i ? ',' : ':', entry->name); + i++; + } + } + if (!i) + puts(": "); + puts("\n"); + return CMD_RET_SUCCESS; +} diff --git a/include/fs.h b/include/fs.h index 37e35c2120..b3fd0b179d 100644 --- a/include/fs.h +++ b/include/fs.h @@ -254,4 +254,9 @@ int do_fs_uuid(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[], */ int do_fs_type(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]); +/* + * List supported filesystems. + */ +int do_fs_types(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]); + #endif /* _FS_H */