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 1/3] cmd: part: Add subcommand to list supported partition tables
Date: Tue, 24 Mar 2020 16:17:03 +0100	[thread overview]
Message-ID: <20200324151705.1798021-2-lusus@denx.de> (raw)
In-Reply-To: <20200324151705.1798021-1-lusus@denx.de>

Add a subcommand "types" to the part command, which lists the supported
partition table types.

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:
- none

 cmd/part.c                 | 27 +++++++++++++++++++++++++--
 test/py/tests/test_part.py | 14 ++++++++++++++
 2 files changed, 39 insertions(+), 2 deletions(-)
 create mode 100644 test/py/tests/test_part.py

diff --git a/cmd/part.c b/cmd/part.c
index 5e4e45ca6d..fae5df7b71 100644
--- a/cmd/part.c
+++ b/cmd/part.c
@@ -182,6 +182,26 @@ static int do_part_number(int argc, char * const argv[])
 	return do_part_info(argc, argv, CMD_PART_INFO_NUMBER);
 }
 
+static int do_part_types(int argc, char * const argv[])
+{
+	struct part_driver *drv = ll_entry_start(struct part_driver,
+						 part_driver);
+	const int n_ents = ll_entry_count(struct part_driver, part_driver);
+	struct part_driver *entry;
+	int i = 0;
+
+	puts("Supported partition tables");
+
+	for (entry = drv; entry != drv + n_ents; entry++) {
+		printf("%c %s", i ? ',' : ':', entry->name);
+		i++;
+	}
+	if (!i)
+		puts(": <none>");
+	puts("\n");
+	return CMD_RET_SUCCESS;
+}
+
 static int do_part(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 	if (argc < 2)
@@ -197,7 +217,8 @@ static int do_part(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 		return do_part_size(argc - 2, argv + 2);
 	else if (!strcmp(argv[1], "number"))
 		return do_part_number(argc - 2, argv + 2);
-
+	else if (!strcmp(argv[1], "types"))
+		return do_part_types(argc - 2, argv + 2);
 	return CMD_RET_USAGE;
 }
 
@@ -221,5 +242,7 @@ U_BOOT_CMD(
 	"      part can be either partition number or partition name\n"
 	"part number <interface> <dev> <part> <varname>\n"
 	"    - set environment variable to the partition number using the partition name\n"
-	"      part must be specified as partition name"
+	"      part must be specified as partition name\n"
+	"part types\n"
+	"    - list supported partition table types"
 );
diff --git a/test/py/tests/test_part.py b/test/py/tests/test_part.py
new file mode 100644
index 0000000000..cba9804510
--- /dev/null
+++ b/test/py/tests/test_part.py
@@ -0,0 +1,14 @@
+# 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_part')
+ at pytest.mark.buildconfigspec('partitions')
+ at pytest.mark.buildconfigspec('efi_partition')
+def test_dm_compat(u_boot_console):
+    """Test that `part types` prints a result which includes `EFI`."""
+    output = u_boot_console.run_command('part types')
+    assert "Supported partition tables:" in output
+    assert "EFI" in output
-- 
2.25.1

  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 ` Niel Fourie [this message]
2020-07-08  3:01   ` [PATCH v3 1/3] cmd: part: Add subcommand to list supported partition tables Tom Rini
2020-03-24 15:17 ` [PATCH v3 2/3] cmd: fs: Add command to list supported fs types Niel Fourie
2020-07-08  3:02   ` 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-2-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.