* [U-Boot] [PATCH v2 0/2] pxe: Allow use of environment variables in append
@ 2014-08-06 7:37 Hans de Goede
2014-08-06 7:37 ` [U-Boot] [PATCH v2 1/2] cli: Export cli_simple_process_macros for use outside of cli_simple Hans de Goede
2014-08-06 7:37 ` [U-Boot] [PATCH v2 2/2] pxe: Allow use of environment variables in append string Hans de Goede
0 siblings, 2 replies; 5+ messages in thread
From: Hans de Goede @ 2014-08-06 7:37 UTC (permalink / raw)
To: u-boot
Hi,
Here is v2 of my patch-set to expand $() / ${} in extlinux.conf append strings.
Changes in v2:
-Add "cli: Export cli_simple_process_macros for use outside" patch
-Use cli_simple_process_macros instead of run_cmd("setenv bootargs ..."), so
that only $() / ${} get processed and not ;
Regards,
Hans
^ permalink raw reply [flat|nested] 5+ messages in thread
* [U-Boot] [PATCH v2 1/2] cli: Export cli_simple_process_macros for use outside of cli_simple
2014-08-06 7:37 [U-Boot] [PATCH v2 0/2] pxe: Allow use of environment variables in append Hans de Goede
@ 2014-08-06 7:37 ` Hans de Goede
2014-08-23 12:41 ` [U-Boot] [U-Boot, v2, " Tom Rini
2014-08-06 7:37 ` [U-Boot] [PATCH v2 2/2] pxe: Allow use of environment variables in append string Hans de Goede
1 sibling, 1 reply; 5+ messages in thread
From: Hans de Goede @ 2014-08-06 7:37 UTC (permalink / raw)
To: u-boot
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
common/cli_simple.c | 4 ++--
include/cli.h | 8 ++++++++
2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/common/cli_simple.c b/common/cli_simple.c
index 353ceeb..6c65cc6 100644
--- a/common/cli_simple.c
+++ b/common/cli_simple.c
@@ -57,7 +57,7 @@ int cli_simple_parse_line(char *line, char *argv[])
return nargs;
}
-static void process_macros(const char *input, char *output)
+void cli_simple_process_macros(const char *input, char *output)
{
char c, prev;
const char *varname_start = NULL;
@@ -236,7 +236,7 @@ int cli_simple_run_command(const char *cmd, int flag)
debug_parser("token: \"%s\"\n", token);
/* find macros in this token and replace them */
- process_macros(token, finaltoken);
+ cli_simple_process_macros(token, finaltoken);
/* Extract arguments */
argc = cli_simple_parse_line(finaltoken, argv);
diff --git a/include/cli.h b/include/cli.h
index 6994262..6da7a4a 100644
--- a/include/cli.h
+++ b/include/cli.h
@@ -31,6 +31,14 @@ void cli_simple_loop(void);
int cli_simple_run_command(const char *cmd, int flag);
/**
+ * cli_simple_process_macros() - Expand $() and ${} format env. variables
+ *
+ * @param input Input string possible containing $() / ${} vars
+ * @param output Output string with $() / ${} vars expanded
+ */
+void cli_simple_process_macros(const char *input, char *output);
+
+/**
* cli_simple_run_command_list() - Execute a list of command
*
* The commands should be separated by ; or \n and will be executed
--
2.0.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [U-Boot] [PATCH v2 2/2] pxe: Allow use of environment variables in append string
2014-08-06 7:37 [U-Boot] [PATCH v2 0/2] pxe: Allow use of environment variables in append Hans de Goede
2014-08-06 7:37 ` [U-Boot] [PATCH v2 1/2] cli: Export cli_simple_process_macros for use outside of cli_simple Hans de Goede
@ 2014-08-06 7:37 ` Hans de Goede
2014-08-23 12:41 ` [U-Boot] [U-Boot, v2, " Tom Rini
1 sibling, 1 reply; 5+ messages in thread
From: Hans de Goede @ 2014-08-06 7:37 UTC (permalink / raw)
To: u-boot
Use cli_simple_process_macros, so that environment
variables (e.g. ${console}) can be used in append strings.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
--
Changes in v2:
-Use cli_simple_process_macros instead of run_cmd("setenv bootargs ..."), so
that only $() / ${} get processed and not ;
---
common/cmd_pxe.c | 29 +++++++++++++----------------
1 file changed, 13 insertions(+), 16 deletions(-)
diff --git a/common/cmd_pxe.c b/common/cmd_pxe.c
index ba48692..bd7aa65 100644
--- a/common/cmd_pxe.c
+++ b/common/cmd_pxe.c
@@ -14,6 +14,7 @@
#include <fs.h>
#include "menu.h"
+#include "cli.h"
#define MAX_TFTP_PATH_LEN 127
@@ -577,8 +578,12 @@ static int label_localboot(struct pxe_label *label)
if (!localcmd)
return -ENOENT;
- if (label->append)
- setenv("bootargs", label->append);
+ if (label->append) {
+ char bootargs[CONFIG_SYS_CBSIZE];
+
+ cli_simple_process_macros(label->append, bootargs);
+ setenv("bootargs", bootargs);
+ }
debug("running: %s\n", localcmd);
@@ -606,7 +611,6 @@ static int label_boot(cmd_tbl_t *cmdtp, struct pxe_label *label)
char initrd_str[22];
char mac_str[29] = "";
char ip_str[68] = "";
- char *bootargs;
int bootm_argc = 3;
int len = 0;
@@ -651,7 +655,6 @@ static int label_boot(cmd_tbl_t *cmdtp, struct pxe_label *label)
sprintf(ip_str, " ip=%s:%s:%s:%s",
getenv("ipaddr"), getenv("serverip"),
getenv("gatewayip"), getenv("netmask"));
- len += strlen(ip_str);
}
#ifdef CONFIG_CMD_NET
@@ -661,27 +664,21 @@ static int label_boot(cmd_tbl_t *cmdtp, struct pxe_label *label)
err = format_mac_pxe(mac_str + 8, sizeof(mac_str) - 8);
if (err < 0)
mac_str[0] = '\0';
- len += strlen(mac_str);
}
#endif
- if (label->append)
- len += strlen(label->append);
+ if ((label->ipappend & 0x3) || label->append) {
+ char bootargs[CONFIG_SYS_CBSIZE] = "";
+ char finalbootargs[CONFIG_SYS_CBSIZE];
- if (len) {
- bootargs = malloc(len + 1);
- if (!bootargs)
- return 1;
- bootargs[0] = '\0';
if (label->append)
strcpy(bootargs, label->append);
strcat(bootargs, ip_str);
strcat(bootargs, mac_str);
- setenv("bootargs", bootargs);
- printf("append: %s\n", bootargs);
-
- free(bootargs);
+ cli_simple_process_macros(bootargs, finalbootargs);
+ setenv("bootargs", finalbootargs);
+ printf("append: %s\n", finalbootargs);
}
bootm_argv[1] = getenv("kernel_addr_r");
--
2.0.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [U-Boot] [U-Boot, v2, 1/2] cli: Export cli_simple_process_macros for use outside of cli_simple
2014-08-06 7:37 ` [U-Boot] [PATCH v2 1/2] cli: Export cli_simple_process_macros for use outside of cli_simple Hans de Goede
@ 2014-08-23 12:41 ` Tom Rini
0 siblings, 0 replies; 5+ messages in thread
From: Tom Rini @ 2014-08-23 12:41 UTC (permalink / raw)
To: u-boot
On Wed, Aug 06, 2014 at 09:37:38AM +0200, Hans de Goede wrote:
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Applied to u-boot/master, thanks!
--
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140823/54860475/attachment.pgp>
^ permalink raw reply [flat|nested] 5+ messages in thread
* [U-Boot] [U-Boot, v2, 2/2] pxe: Allow use of environment variables in append string
2014-08-06 7:37 ` [U-Boot] [PATCH v2 2/2] pxe: Allow use of environment variables in append string Hans de Goede
@ 2014-08-23 12:41 ` Tom Rini
0 siblings, 0 replies; 5+ messages in thread
From: Tom Rini @ 2014-08-23 12:41 UTC (permalink / raw)
To: u-boot
On Wed, Aug 06, 2014 at 09:37:39AM +0200, Hans de Goede wrote:
> Use cli_simple_process_macros, so that environment
> variables (e.g. ${console}) can be used in append strings.
>
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Applied to u-boot/master, thanks!
--
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140823/9b13a77c/attachment.pgp>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2014-08-23 12:41 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-06 7:37 [U-Boot] [PATCH v2 0/2] pxe: Allow use of environment variables in append Hans de Goede
2014-08-06 7:37 ` [U-Boot] [PATCH v2 1/2] cli: Export cli_simple_process_macros for use outside of cli_simple Hans de Goede
2014-08-23 12:41 ` [U-Boot] [U-Boot, v2, " Tom Rini
2014-08-06 7:37 ` [U-Boot] [PATCH v2 2/2] pxe: Allow use of environment variables in append string Hans de Goede
2014-08-23 12:41 ` [U-Boot] [U-Boot, v2, " Tom Rini
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.