All of lore.kernel.org
 help / color / mirror / Atom feed
From: Niel Fourie <lusus@denx.de>
To: u-boot@lists.denx.de
Subject: [PATCH v3 2/3] cmd: fs: Add command to list supported fs types
Date: Tue, 24 Mar 2020 16:17:04 +0100	[thread overview]
Message-ID: <20200324151705.1798021-3-lusus@denx.de> (raw)
In-Reply-To: <20200324151705.1798021-1-lusus@denx.de>

Added command "fstypes" to list supported/included filesystems.

Signed-off-by: Niel Fourie <lusus@denx.de>
Cc: Simon Glass <sjg@chromium.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
---
Changes in v2:
- Add Python test
Changes in v3:
- Rewrote comment for do_fs_types() in fs.h

 cmd/fs.c                             | 11 +++++++++++
 fs/fs.c                              | 20 ++++++++++++++++++++
 include/fs.h                         | 11 +++++++++++
 test/py/tests/test_fs/test_fs_cmd.py | 12 ++++++++++++
 4 files changed, 54 insertions(+)
 create mode 100644 test/py/tests/test_fs/test_fs_cmd.py

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 <interface> <dev>:<part> <varname>\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(": <none>");
+	puts("\n");
+	return CMD_RET_SUCCESS;
+}
diff --git a/include/fs.h b/include/fs.h
index 37e35c2120..514c248e50 100644
--- a/include/fs.h
+++ b/include/fs.h
@@ -254,4 +254,15 @@ 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[]);
 
+/**
+ * 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(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
+
 #endif /* _FS_H */
diff --git a/test/py/tests/test_fs/test_fs_cmd.py b/test/py/tests/test_fs/test_fs_cmd.py
new file mode 100644
index 0000000000..86ba92e025
--- /dev/null
+++ b/test/py/tests/test_fs/test_fs_cmd.py
@@ -0,0 +1,12 @@
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (C) 2020
+# Niel Fourie, DENX Software Engineering, lusus at denx.de
+
+import pytest
+
+ at pytest.mark.buildconfigspec('cmd_fs_generic')
+def test_dm_compat(u_boot_console):
+    """Test that `fstypes` prints a result which includes `sandbox`."""
+    output = u_boot_console.run_command('fstypes')
+    assert "Supported filesystems:" in output
+    assert "sandbox" in output
-- 
2.25.1

  parent reply	other threads:[~2020-03-24 15:17 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-24 15:17 [PATCH v3 0/3] cmd: add driver, fs and part type listing commands Niel Fourie
2020-03-24 15:17 ` [PATCH v3 1/3] cmd: part: Add subcommand to list supported partition tables Niel Fourie
2020-07-08  3:01   ` Tom Rini
2020-03-24 15:17 ` Niel Fourie [this message]
2020-07-08  3:02   ` [PATCH v3 2/3] cmd: fs: Add command to list supported fs types Tom Rini
2020-03-24 15:17 ` [PATCH v3 3/3] cmd: dm: Fixed/Added DM driver listing subcommands Niel Fourie
2020-07-08  3:02   ` Tom Rini
2020-05-26  7:57 ` [PATCH v3 0/3] cmd: add driver, fs and part type listing commands Wolfgang Denk
2020-05-26 19:24   ` Tom Rini
2020-05-31 14:07     ` Simon Glass

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200324151705.1798021-3-lusus@denx.de \
    --to=lusus@denx.de \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.