[U-Boot] [PATCH 2/2] cmd:gpt: randomly generate each partition uuid if undefined
Przemyslaw Marczak
p.marczak at samsung.com
Fri Feb 28 16:18:32 CET 2014
Changes:
- randomly generate each partition uuid if undefined
- print info about generated uuid
- save environment on gpt write success
- update doc/README.gpt
Signed-off-by: Przemyslaw Marczak <p.marczak at samsung.com>
Acked-by: Lukasz Majewski <l.majewski at samsung.com>
cc: Piotr Wilczek <p.wilczek at samsung.com>
cc: Tom Rini <trini at ti.com>
---
common/cmd_gpt.c | 29 +++++++++++++++++++++++------
doc/README.gpt | 1 +
2 files changed, 24 insertions(+), 6 deletions(-)
diff --git a/common/cmd_gpt.c b/common/cmd_gpt.c
index 1f12e6d..7be5fcf 100644
--- a/common/cmd_gpt.c
+++ b/common/cmd_gpt.c
@@ -31,6 +31,7 @@
*/
static char extract_env(const char *str, char **env)
{
+ int ret = -1;
char *e, *s;
if (!str || strlen(str) < 4)
@@ -43,16 +44,23 @@ static char extract_env(const char *str, char **env)
memset(s + strlen(s) - 1, '\0', 1);
memmove(s, s + 2, strlen(s) - 1);
e = getenv(s);
- free(s);
if (e == NULL) {
- printf("Environmental '%s' not set\n", str);
- return -1; /* env not set */
+ printf("%s unset. ", str);
+ e = get_uuid_str();
+ if (e) {
+ printf("Setting to: %s\n", e);
+ setenv(s, e);
+ ret = 0;
+ }
+ } else {
+ ret = 0;
}
+
*env = e;
- return 0;
+ free(s);
}
- return -1;
+ return ret;
}
/**
@@ -299,8 +307,17 @@ static int do_gpt(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
return CMD_RET_FAILURE;
}
- if (gpt_default(blk_dev_desc, argv[4]))
+ puts("Writing GPT: ");
+
+ ret = gpt_default(blk_dev_desc, argv[4]);
+ if (!ret) {
+ puts("success!\n");
+ saveenv();
+ return CMD_RET_SUCCESS;
+ } else {
+ puts("error!\n");
return CMD_RET_FAILURE;
+ }
} else {
return CMD_RET_USAGE;
}
diff --git a/doc/README.gpt b/doc/README.gpt
index 5c133f3..afe2538 100644
--- a/doc/README.gpt
+++ b/doc/README.gpt
@@ -176,3 +176,4 @@ Please, pay attention at -l switch for parted.
"uuid" program is recommended to generate UUID string. Moreover it can decode
(-d switch) passed in UUID string. It can be used to generate partitions UUID
passed to u-boot environment variables.
+If each partition "uuid" no exists then it will be randomly generated.
--
1.7.9.5
More information about the U-Boot
mailing list