]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
cmd: fs: Add command to list supported fs types
authorNiel Fourie <lusus@denx.de>
Tue, 24 Mar 2020 15:17:04 +0000 (16:17 +0100)
committerTom Rini <trini@konsulko.com>
Tue, 7 Jul 2020 19:36:59 +0000 (15:36 -0400)
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>
[trini: Limit to sandbox]
Signed-off-by: Tom Rini <trini@konsulko.com>
cmd/fs.c
fs/fs.c
include/fs.h
test/py/tests/test_fs/test_fs_cmd.py [new file with mode: 0644]

index 3a0c465c1576bd7ea452bf8806dd6709a64f67d8..5ad11647c2d398ac26c57de1c736a78ba28fee52 100644 (file)
--- a/cmd/fs.c
+++ b/cmd/fs.c
@@ -100,3 +100,14 @@ U_BOOT_CMD(
        "fstype <interface> <dev>:<part> <varname>\n"
        "- set environment variable to filesystem type\n"
 );
+
+static int do_fstypes_wrapper(struct cmd_tbl *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 ad4caaeb1ec9c1f7f502df20d0dce92df6471b1a..8f8938c3c6b4d1347e942638dc57a903e84e6456 100644 (file)
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -903,3 +903,23 @@ int do_ln(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[],
 
        return 0;
 }
+
+int do_fs_types(struct cmd_tbl *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;
+}
index 29f737b8c2198b1dbd6595b44f1a3f63596ed82c..b08b1f40c59e30502d225ada6a68b5f7efe1f4a5 100644 (file)
@@ -259,4 +259,15 @@ int do_fs_uuid(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[],
  */
 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 /* _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 (file)
index 0000000..ba39a53
--- /dev/null
@@ -0,0 +1,13 @@
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (C) 2020
+# Niel Fourie, DENX Software Engineering, lusus@denx.de
+
+import pytest
+
+@pytest.mark.boardspec('sandbox')
+@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