cmd: part: Add partition-related type command
v2 cover cmd: part: Add partition-related type command
This series are a consequence on the discussion of the patch [1]. It introduces some new patches in order to address the feedback received, adds the documentation and fixes a small typo found during the work on these patches.
Best regards,
Enric
[1] https://patchwork.ozlabs.org/project/uboot/patch/[email protected]/
Changes in v2:
- New patch (1) in the series to fix a trivial type
- New patch (2) in the series to introduce the documentation of the part type command
- Fix typo s/partittion/partition/ in commit message
- Add gpt test for the part type command
- Add the man-page for part command in doc/usage/cmd
Enric Balletbo i Serra (4):
doc: man-page for the part command
doc/README.gpt: Fix typo 'a optionnal'
cmd: part: Add partition-related type command
test/py: gpt: add test for the gpt partition type GUID identifier
cmd/part.c | 29 ++++++++++ doc/README.gpt | 2 +- doc/usage/cmd/part.rst | 109 ++++++++++++++++++++++++++++++++++++++ test/py/tests/test_gpt.py | 23 ++++++++ 4 files changed, 162 insertions(+), 1 deletion(-) create mode 100644 doc/usage/cmd/part.rst
Signature · 1 line
2.38.1
PATCH v2 1/4 doc: man-page for the part command
Provide a man-page for the part command.
---
Changes in v2:
- New patch (1) in the series to fix a trivial type
- New patch (2) in the series to introduce the documentation of the part type command
- Fix typo s/partittion/partition/ in commit message
- Add gpt test for the part type command
- Add the man-page for part command in doc/usage/cmd
doc/usage/cmd/part.rst | 97 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 doc/usage/cmd/part.rst
doc/usage/cmd/part.rst new file +97 -0
@@ -0,0 +1,97 @@ +.. SPDX-License-Identifier: GPL-2.0+: + +part command +=============== + +Synopis +------- + +:: + + part uuid <interface> <dev>:<part> [varname] + part list <interface> <dev> [flags] [varname] + part start <interface> <dev> <part> <varname> + part size <interface> <dev> <part> <varname> + part number <interface> <dev> <part> <varname> + part types + +Description +----------- + +The `part` command is used to manage disk partition related commands. + +The 'part uuid' command prints or sets an environment variable to partition UUID + + interface + interface for accessing the block device (mmc, sata, scsi, usb, ....) + dev + device number + part + partition number + varname + an optional environment variable to store the current partition UUID value into. + +The 'part list' command prints or sets an environment variable to the list of partitions + + interface + interface for accessing the block device (mmc, sata, scsi, usb, ....) + dev + device number + part + partition number + flags + -bootable + lists only bootable partitions + varname + an optional environment variable to store the list of partitions value into. + +The 'part start' sets an environment variable to the start of the partition (in blocks), +part can be either partition number or partition name. + + interface + interface for accessing the block device (mmc, sata, scsi, usb, ....) + dev + device number + part + partition number + varname + a variable to store the current start of the partition value into. + +The 'part size' sets an environment variable to the size of the partition (in blocks), +part can be either partition number or partition name. + + interface + interface for accessing the block device (mmc, sata, scsi, usb, ....) + dev + device number + part + partition number + varname + a variable to store the current size of the partition value into. + +The 'part number' sets an environment variable to the partition number using the partition name, +part must be specified as partition name. + + interface + interface for accessing the block device (mmc, sata, scsi, usb, ....) + dev + device number + part + partition number + varname + a variable to store the current partition number value into + +The 'part types' command list supported partition table types. + +Example +------- + +This example shows listing supported partition types:: + + U-Boot> part types + Supported partition tables: EFI, AMIGA, DOS, ISO, MAC + +Return value +------------ + +The return value $? is always 0 (true).
Signature · 1 line
2.38.1
Re: [PATCH v2 1/4] doc: man-page for the part command
Quoted 14 lines · Enric Balletbo i Serra
Provide a man-page for the part command.
Signed-off-by Enric Balletbo i Serra <[email protected]>---
Changes in v2:
- New patch (1) in the series to fix a trivial type
- New patch (2) in the series to introduce the documentation of the part type command
- Fix typo s/partittion/partition/ in commit message
- Add gpt test for the part type command
- Add the man-page for part command in doc/usage/cmd
Quoted 3 lines
doc/usage/cmd/part.rst | 97 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 doc/usage/cmd/part.rst
Re: [PATCH v2 1/4] doc: man-page for the part command
In reply to Enric Balletbo i Serradoc/usage/cmd/part.rst
Quoted 22 lines · Enric Balletbo i Serra
Provide a man-page for the part command.
Signed-off-by Enric Balletbo i Serra <[email protected]>---
Changes in v2:
- New patch (1) in the series to fix a trivial type
- New patch (2) in the series to introduce the documentation of the part type command
- Fix typo s/partittion/partition/ in commit message
- Add gpt test for the part type command
- Add the man-page for part command in doc/usage/cmddoc/usage/cmd/part.rst | 97 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+)create mode 100644
doc/usage/cmd/part.rstdoc/usage/cmd/part.rst new file +0
-0
Thanks for providing this man-page.
The patch lacks an entry in doc/usage/cmd/index.rst.
Quoted 83 lines
doc/usage/cmd/part.rst new file +82
-0@@ -0,0 +1,97 @@ +.. SPDX-License-Identifier: GPL-2.0+: + +part command +=============== + +Synopis +------- + +:: + + part uuid <interface> <dev>:<part> [varname] + part list <interface> <dev> [flags] [varname] + part start <interface> <dev> <part> <varname> + part size <interface> <dev> <part> <varname> + part number <interface> <dev> <part> <varname> + part types + +Description +----------- + +The `part` command is used to manage disk partition related commands. + +The 'part uuid' command prints or sets an environment variable to partition UUID + + interface + interface for accessing the block device (mmc, sata, scsi, usb, ....) + dev + device number + part + partition number + varname + an optional environment variable to store the current partition UUID value into. + +The 'part list' command prints or sets an environment variable to the list of partitions + + interface + interface for accessing the block device (mmc, sata, scsi, usb, ....) + dev + device number + part + partition number + flags + -bootable + lists only bootable partitions + varname + an optional environment variable to store the list of partitions value into. + +The 'part start' sets an environment variable to the start of the partition (in blocks), +part can be either partition number or partition name. + + interface + interface for accessing the block device (mmc, sata, scsi, usb, ....) + dev + device number + part + partition number + varname + a variable to store the current start of the partition value into. + +The 'part size' sets an environment variable to the size of the partition (in blocks), +part can be either partition number or partition name. + + interface + interface for accessing the block device (mmc, sata, scsi, usb, ....) + dev + device number + part + partition number + varname + a variable to store the current size of the partition value into. + +The 'part number' sets an environment variable to the partition number using the partition name, +part must be specified as partition name. + + interfaceH + interface for accessing the block device (mmc, sata, scsi, usb, ....) + dev + device number + part + partition number + varname + a variable to store the current partition number value into
doc/usage/cmd/part.rst line 92
Quoted 10 lines
doc/usage/cmd/part.rst new file +10
-0+ +The 'part types' command list supported partition table types. + +Example +------- + +This example shows listing supported partition types:: + + U-Boot> part types + Supported partition tables: EFI, AMIGA, DOS, ISO, MAC
Please, provide examples for the other sub-commands too.
doc/usage/cmd/part.rst line 97
Quoted 5 lines
doc/usage/cmd/part.rst new file +5
-0+ +Return value +------------ + +The return value $? is always 0 (true).
1 (false) is returned in case of errors. Please, have a look at the code.
Best regards
Heinrich
PATCH v2 2/4 doc/README.gpt: Fix typo 'a optionnal'
In reply to Enric Balletbo i SerraChange the string 'a optionnal' to 'an optional'.
---
(no changes since v1)
doc/README.gpt | 2 +- doc/usage/cmd/part.rst | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-)
doc/README.gpt +1 -1
@@ -260,7 +260,7 @@ Partition type GUID: For created partition, the used partition type GUID is PARTITION_BASIC_DATA_GUID (EBD0A0A2-B9E5-4433-87C0-68B6B72699C7). -If you define 'CONFIG_PARTITION_TYPE_GUID', a optionnal parameter 'type' +If you define 'CONFIG_PARTITION_TYPE_GUID', an optional parameter 'type' can specify a other partition type guid: "uuid_disk=...;name=u-boot,size=60MiB,uuid=...;
doc/usage/cmd/part.rst +3 -3
@@ -45,7 +45,7 @@ The 'part list' command prints or sets an environment variable to the list of pa varname an optional environment variable to store the list of partitions value into. -The 'part start' sets an environment variable to the start of the partition (in blocks), +The 'part start' commnad sets an environment variable to the start of the partition (in blocks), part can be either partition number or partition name. interface
@@ -57,7 +57,7 @@ part can be either partition number or partition name. varname a variable to store the current start of the partition value into. -The 'part size' sets an environment variable to the size of the partition (in blocks), +The 'part size' command sets an environment variable to the size of the partition (in blocks), part can be either partition number or partition name. interface
@@ -69,7 +69,7 @@ part can be either partition number or partition name. varname a variable to store the current size of the partition value into. -The 'part number' sets an environment variable to the partition number using the partition name, +The 'part number' command sets an environment variable to the partition number using the partition name, part must be specified as partition name. interface
Signature · 1 line
2.38.1
Re: [PATCH v2 2/4] doc/README.gpt: Fix typo 'a optionnal'
Quoted 2 lines · Enric Balletbo i Serra
Change the string 'a optionnal' to 'an optional'.
among other things
Quoted 9 lines
Signed-off-by Enric Balletbo i Serra <[email protected]>---
(no changes since v1)
doc/README.gpt | 2 +- doc/usage/cmd/part.rst | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-)
PATCH v2 3/4 cmd: part: Add partition-related type command
In reply to Enric Balletbo i SerraThis implements the following command:
part type mmc 0:1
-> print partition 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.
---
(no changes since v1)
cmd/part.c | 29 +++++++++++++++++++++++++++++ doc/usage/cmd/part.rst | 12 ++++++++++++ 2 files changed, 41 insertions(+)
cmd/part.c +29 -0
@@ -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" );
doc/usage/cmd/part.rst +12 -0
@@ -13,6 +13,7 @@ Synopis part start <interface> <dev> <part> <varname> part size <interface> <dev> <part> <varname> part number <interface> <dev> <part> <varname> + part type <interface> <dev>:<part> [varname] part types Description
@@ -81,6 +82,17 @@ part must be specified as partition name. varname a variable to store the current partition number value into +The 'part type' command prints or sets an environment variable to the partition type UUID. + + interface + interface for accessing the block device (mmc, sata, scsi, usb, ....) + dev + device number + part + partition number + varname + a variable to store the current partition type UUID value into + The 'part types' command list supported partition table types. Example
Signature · 1 line
2.38.1
Quoted 12 lines · Enric Balletbo i Serra
This implements the following command:
part type mmc 0:1
-> print partition 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.
Quoted 9 lines
Signed-off-by Enric Balletbo i Serra <[email protected]>---
(no changes since v1)
cmd/part.c | 29 +++++++++++++++++++++++++++++ doc/usage/cmd/part.rst | 12 ++++++++++++ 2 files changed, 41 insertions(+)
PATCH v2 4/4 test/py: gpt: add test for the gpt partition type GUID identifier
In reply to Enric Balletbo i SerraAdd sandbox test for the gpt partition type command, the test uses the persistent data test_gpt_disk_image.bin to check that the first partition type GUID that identifies the type of the partition has the "Linux filesystem data" type ( 0FC63DAF-8483-4772-8E79-3D69D8477DE4 ).
---
(no changes since v1)
test/py/tests/test_gpt.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)
test/py/tests/test_gpt.py +23 -0
@@ -134,6 +134,29 @@ def test_gpt_save_guid(state_disk_image, u_boot_console): output = u_boot_console.run_command('printenv newguid') assert '375a56f7-d6c9-4e81-b5f0-09d41ca89efe' in output [email protected]('sandbox') [email protected]('cmd_gpt') [email protected]('sgdisk') +def test_gpt_part_type_uuid(state_disk_image, u_boot_console): + """Test the gpt partittion type UUID command.""" + + u_boot_console.run_command('host bind 0 ' + state_disk_image.path) + output = u_boot_console.run_command('part type host 0:1') + assert '0fc63daf-8483-4772-8e79-3d69d8477de4' in output + [email protected]('sandbox') [email protected]('cmd_gpt') [email protected]('sgdisk') +def test_gpt_part_type_save_uuid(state_disk_image, u_boot_console): + """Test the gpt partittion type to save UUID into a string.""" + + if u_boot_console.config.buildconfig.get('config_cmd_gpt', 'n') != 'y': + pytest.skip('gpt command not supported') + u_boot_console.run_command('host bind 0 ' + state_disk_image.path) + output = u_boot_console.run_command('part type host 0:1 newguid') + output = u_boot_console.run_command('printenv newguid') + assert '0fc63daf-8483-4772-8e79-3d69d8477de4' in output + @pytest.mark.boardspec('sandbox') @pytest.mark.buildconfigspec('cmd_gpt') @pytest.mark.buildconfigspec('cmd_gpt_rename')
Signature · 1 line
2.38.1