mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-24 21:54:01 +00:00
cmd: part: Add partition-related type command
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. Signed-off-by: Enric Balletbo i Serra <eballetbo@redhat.com> Reviewed-by: Simon Glass <sjg@chromium.org> [trini: Fix when CONFIG_PARTITION_TYPE_GUID is disabled and have the command check for "types" before "type"] Signed-off-by: Tom Rini <trini@konsulko.com>
This commit is contained in:
parent
a685e9c99f
commit
22e7f1d108
2 changed files with 53 additions and 0 deletions
35
cmd/part.c
35
cmd/part.c
|
@ -182,6 +182,31 @@ static int do_part_number(int argc, char *const argv[])
|
|||
return do_part_info(argc, argv, CMD_PART_INFO_NUMBER);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PARTITION_TYPE_GUID
|
||||
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;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int do_part_types(int argc, char * const argv[])
|
||||
{
|
||||
struct part_driver *drv = ll_entry_start(struct part_driver,
|
||||
|
@ -220,6 +245,10 @@ static int do_part(struct cmd_tbl *cmdtp, int flag, int argc,
|
|||
return do_part_number(argc - 2, argv + 2);
|
||||
else if (!strcmp(argv[1], "types"))
|
||||
return do_part_types(argc - 2, argv + 2);
|
||||
#ifdef CONFIG_PARTITION_TYPE_GUID
|
||||
else if (!strcmp(argv[1], "type"))
|
||||
return do_part_type(argc - 2, argv + 2);
|
||||
#endif
|
||||
return CMD_RET_USAGE;
|
||||
}
|
||||
|
||||
|
@ -244,6 +273,12 @@ 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"
|
||||
#ifdef CONFIG_PARTITION_TYPE_GUID
|
||||
"part type <interface> <dev>:<part>\n"
|
||||
" - print partition type\n"
|
||||
#endif
|
||||
"part type <interface> <dev>:<part> <varname>\n"
|
||||
" - set environment variable to partition type\n"
|
||||
"part types\n"
|
||||
" - list supported partition table types"
|
||||
);
|
||||
|
|
|
@ -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.
|
||||
|
||||
Examples
|
||||
|
@ -126,6 +138,12 @@ Examples
|
|||
=> env print varname
|
||||
varname=0x2
|
||||
=>
|
||||
=> part type host 0:1
|
||||
ebd0a0a2-b9e5-4433-87c0-68b6b72699c7
|
||||
=> part type host 0:1 varname
|
||||
=> env print varname
|
||||
varname=ebd0a0a2-b9e5-4433-87c0-68b6b72699c7
|
||||
=>
|
||||
=> part types
|
||||
Supported partition tables: EFI, AMIGA, DOS, ISO, MAC
|
||||
|
||||
|
|
Loading…
Reference in a new issue