public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] pxe: Allow use of environment variables in append string
@ 2014-08-01  9:21 Hans de Goede
  2014-08-01 19:07 ` Stephen Warren
  0 siblings, 1 reply; 3+ messages in thread
From: Hans de Goede @ 2014-08-01  9:21 UTC (permalink / raw)
  To: u-boot

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@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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-08-04 18:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-01  9:21 [U-Boot] [PATCH] pxe: Allow use of environment variables in append string Hans de Goede
2014-08-01 19:07 ` Stephen Warren
2014-08-04 18:29   ` Hans de Goede

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox