[U-Boot] [PATCH] pxe: Allow use of environment variables in append string
Hans de Goede
hdegoede at redhat.com
Fri Aug 1 11:21:43 CEST 2014
Use run_command("setenv bootargs <label->append>") so that environment
variables (e.g. $console) can be used in append strings.
Signed-off-by: Hans de Goede <hdegoede at redhat.com>
---
common/cmd_pxe.c | 23 ++++++++++++++++-------
1 file changed, 16 insertions(+), 7 deletions(-)
diff --git a/common/cmd_pxe.c b/common/cmd_pxe.c
index ba48692..3866604 100644
--- a/common/cmd_pxe.c
+++ b/common/cmd_pxe.c
@@ -571,14 +571,23 @@ static void label_print(void *data)
static int label_localboot(struct pxe_label *label)
{
char *localcmd;
+ char *bootargs;
localcmd = from_env("localcmd");
if (!localcmd)
return -ENOENT;
- if (label->append)
- setenv("bootargs", label->append);
+ if (label->append) {
+ bootargs = malloc(strlen("setenv bootargs ") +
+ strlen(label->append) + 1);
+ if (!bootargs)
+ return 1;
+ strcpy(bootargs, "setenv bootargs ");
+ strcat(bootargs, label->append);
+ run_command(bootargs, 0);
+ free(bootargs);
+ }
debug("running: %s\n", localcmd);
@@ -669,17 +678,17 @@ static int label_boot(cmd_tbl_t *cmdtp, struct pxe_label *label)
len += strlen(label->append);
if (len) {
- bootargs = malloc(len + 1);
+ bootargs = malloc(strlen("setenv bootargs ") + len + 1);
if (!bootargs)
return 1;
- bootargs[0] = '\0';
+ strcpy(bootargs, "setenv bootargs ");
if (label->append)
- strcpy(bootargs, label->append);
+ strcat(bootargs, label->append);
strcat(bootargs, ip_str);
strcat(bootargs, mac_str);
- setenv("bootargs", bootargs);
- printf("append: %s\n", bootargs);
+ run_command(bootargs, 0);
+ printf("append: %s\n", getenv("bootargs"));
free(bootargs);
}
--
2.0.3
More information about the U-Boot
mailing list