* [PATCH] cmd: part: Add partition-related type command
@ 2022-07-27 13:35 Enric Balletbo i Serra
2022-07-27 14:06 ` Tom Rini
2022-07-27 14:19 ` Heinrich Schuchardt
0 siblings, 2 replies; 3+ messages in thread
From: Enric Balletbo i Serra @ 2022-07-27 13:35 UTC (permalink / raw)
To: u-boot; +Cc: Enric Balletbo i Serra, Heinrich Schuchardt
This implements the following command:
part type mmc 0:1
-> print partittion type UUID
part type mmc 0:1 uuid
-> set environment variable to partition type UUID
"part type" can be useful when writing a bootcmd which searches for a
specific partition type to enable automatic discovery of partitions and
their intended usage or mount point.
Signed-off-by: Enric Balletbo i Serra <eballetbo@redhat.com>
---
cmd/part.c | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/cmd/part.c b/cmd/part.c
index 9d419c967c..26b0cc84fe 100644
--- a/cmd/part.c
+++ b/cmd/part.c
@@ -182,6 +182,29 @@ static int do_part_number(int argc, char *const argv[])
return do_part_info(argc, argv, CMD_PART_INFO_NUMBER);
}
+static int do_part_type(int argc, char *const argv[])
+{
+ int part;
+ struct blk_desc *dev_desc;
+ struct disk_partition info;
+
+ if (argc < 2)
+ return CMD_RET_USAGE;
+ if (argc > 3)
+ return CMD_RET_USAGE;
+
+ part = blk_get_device_part_str(argv[0], argv[1], &dev_desc, &info, 0);
+ if (part < 0)
+ return 1;
+
+ if (argc > 2)
+ env_set(argv[2], info.type_guid);
+ else
+ printf("%s\n", info.type_guid);
+
+ return 0;
+}
+
static int do_part_types(int argc, char * const argv[])
{
struct part_driver *drv = ll_entry_start(struct part_driver,
@@ -218,6 +241,8 @@ static int do_part(struct cmd_tbl *cmdtp, int flag, int argc,
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], "type"))
+ return do_part_type(argc - 2, argv + 2);
else if (!strcmp(argv[1], "types"))
return do_part_types(argc - 2, argv + 2);
return CMD_RET_USAGE;
@@ -244,6 +269,10 @@ U_BOOT_CMD(
"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\n"
+ "part type <interface> <dev>:<part>\n"
+ " - print partition type\n"
+ "part type <interface> <dev>:<part> <varname>\n"
+ " - set environment variable to partition type\n"
"part types\n"
" - list supported partition table types"
);
--
2.37.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] cmd: part: Add partition-related type command
2022-07-27 13:35 [PATCH] cmd: part: Add partition-related type command Enric Balletbo i Serra
@ 2022-07-27 14:06 ` Tom Rini
2022-07-27 14:19 ` Heinrich Schuchardt
1 sibling, 0 replies; 3+ messages in thread
From: Tom Rini @ 2022-07-27 14:06 UTC (permalink / raw)
To: Enric Balletbo i Serra
Cc: u-boot, Enric Balletbo i Serra, Heinrich Schuchardt
[-- Attachment #1: Type: text/plain, Size: 824 bytes --]
On Wed, Jul 27, 2022 at 03:35:34PM +0200, Enric Balletbo i Serra wrote:
> This implements the following command:
>
> part type mmc 0:1
> -> print partittion type UUID
> part type mmc 0:1 uuid
> -> set environment variable to partition type UUID
>
> "part type" can be useful when writing a bootcmd which searches for a
> specific partition type to enable automatic discovery of partitions and
> their intended usage or mount point.
>
> Signed-off-by: Enric Balletbo i Serra <eballetbo@redhat.com>
> ---
>
> cmd/part.c | 29 +++++++++++++++++++++++++++++
> 1 file changed, 29 insertions(+)
Seems reasonable. Please update some of the existing tests (I don't
know if test/py/tests/test_gpt.py or test/py/tests/test_part.py or
perhaps both would be easier) for v2.
--
Tom
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] cmd: part: Add partition-related type command
2022-07-27 13:35 [PATCH] cmd: part: Add partition-related type command Enric Balletbo i Serra
2022-07-27 14:06 ` Tom Rini
@ 2022-07-27 14:19 ` Heinrich Schuchardt
1 sibling, 0 replies; 3+ messages in thread
From: Heinrich Schuchardt @ 2022-07-27 14:19 UTC (permalink / raw)
To: Enric Balletbo i Serra; +Cc: Enric Balletbo i Serra, u-boot, Tom Rini
On 7/27/22 15:35, Enric Balletbo i Serra wrote:
> This implements the following command:
>
> part type mmc 0:1
> -> print partittion type UUID
%s/partittion/partition/
> part type mmc 0:1 uuid
> -> set environment variable to partition type UUID
>
> "part type" can be useful when writing a bootcmd which searches for a
Does such a command exist? Do you plan to implement such a command?
> specific partition type to enable automatic discovery of partitions and
> their intended usage or mount point.
>
> Signed-off-by: Enric Balletbo i Serra <eballetbo@redhat.com>
> ---
>
> cmd/part.c | 29 +++++++++++++++++++++++++++++
> 1 file changed, 29 insertions(+)
>
> diff --git a/cmd/part.c b/cmd/part.c
> index 9d419c967c..26b0cc84fe 100644
> --- a/cmd/part.c
> +++ b/cmd/part.c
> @@ -182,6 +182,29 @@ static int do_part_number(int argc, char *const argv[])
> return do_part_info(argc, argv, CMD_PART_INFO_NUMBER);
> }
>
> +static int do_part_type(int argc, char *const argv[])
> +{
> + int part;
> + struct blk_desc *dev_desc;
> + struct disk_partition info;
> +
> + if (argc < 2)
> + return CMD_RET_USAGE;
> + if (argc > 3)
> + return CMD_RET_USAGE;
> +
> + part = blk_get_device_part_str(argv[0], argv[1], &dev_desc, &info, 0);
> + if (part < 0)
> + return 1;
> +
> + if (argc > 2)
> + env_set(argv[2], info.type_guid);
> + else
> + printf("%s\n", info.type_guid);
> +
> + return 0;
> +}
> +
> static int do_part_types(int argc, char * const argv[])
> {
> struct part_driver *drv = ll_entry_start(struct part_driver,
> @@ -218,6 +241,8 @@ static int do_part(struct cmd_tbl *cmdtp, int flag, int argc,
> 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], "type"))
> + return do_part_type(argc - 2, argv + 2);
> else if (!strcmp(argv[1], "types"))
> return do_part_types(argc - 2, argv + 2);
> return CMD_RET_USAGE;
> @@ -244,6 +269,10 @@ U_BOOT_CMD(
> "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\n"
> + "part type <interface> <dev>:<part>\n"
> + " - print partition type\n"
> + "part type <interface> <dev>:<part> <varname>\n"
> + " - set environment variable to partition type\n"
For each command we want a man-page in doc/usage/cmd. I miss a
corresponding change in /doc.
Best regards
Heinrich
> "part types\n"
> " - list supported partition table types"
> );
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-07-27 14:19 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-27 13:35 [PATCH] cmd: part: Add partition-related type command Enric Balletbo i Serra
2022-07-27 14:06 ` Tom Rini
2022-07-27 14:19 ` Heinrich Schuchardt
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.