summaryrefslogtreecommitdiff
path: root/cmd/gpt.c
diff options
context:
space:
mode:
authorAlison Chaiken <alison@peloton-tech.com>2017-06-25 16:43:23 -0700
committerTom Rini <trini@konsulko.com>2017-08-04 09:56:04 -0400
commit73d6d18b7147c90d6f8a60acb8dad663a225e63d (patch)
tree0df0ea577d085439b7a87dac0d92e0b46cb5862a /cmd/gpt.c
parente6faf21f259ccc0601d06d458e33fb742deb1843 (diff)
GPT: add accessor function for disk GUID
In order to read the GPT, modify the partition name strings, and then write out a new GPT, the disk GUID is needed. While there is an existing accessor for the partition UUIDs, there is none yet for the disk GUID. Changes since v6: none. Signed-off-by: Alison Chaiken <alison@peloton-tech.com>
Diffstat (limited to 'cmd/gpt.c')
-rw-r--r--cmd/gpt.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/cmd/gpt.c b/cmd/gpt.c
index 3e98821868..65fb80b3df 100644
--- a/cmd/gpt.c
+++ b/cmd/gpt.c
@@ -398,6 +398,23 @@ static int gpt_verify(struct blk_desc *blk_dev_desc, const char *str_part)
return ret;
}
+static int do_disk_guid(struct blk_desc *dev_desc, char * const namestr)
+{
+ int ret;
+ char disk_guid[UUID_STR_LEN + 1];
+
+ ret = get_disk_guid(dev_desc, disk_guid);
+ if (ret < 0)
+ return CMD_RET_FAILURE;
+
+ if (namestr)
+ setenv(namestr, disk_guid);
+ else
+ printf("%s\n", disk_guid);
+
+ return ret;
+}
+
/**
* do_gpt(): Perform GPT operations
*
@@ -436,6 +453,8 @@ static int do_gpt(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
} else if ((strcmp(argv[1], "verify") == 0)) {
ret = gpt_verify(blk_dev_desc, argv[4]);
printf("Verify GPT: ");
+ } else if (strcmp(argv[1], "guid") == 0) {
+ ret = do_disk_guid(blk_dev_desc, argv[4]);
} else {
return CMD_RET_USAGE;
}
@@ -458,4 +477,11 @@ U_BOOT_CMD(gpt, CONFIG_SYS_MAXARGS, 1, do_gpt,
" Example usage:\n"
" gpt write mmc 0 $partitions\n"
" gpt verify mmc 0 $partitions\n"
+ " guid <interface> <dev>\n"
+ " - print disk GUID\n"
+ " guid <interface> <dev> <varname>\n"
+ " - set environment variable to disk GUID\n"
+ " Example usage:\n"
+ " gpt guid mmc 0\n"
+ " gpt guid mmc 0 varname\n"
);