From patchwork Fri Aug 1 09:21:43 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 375656 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 6DFB014011D for ; Fri, 1 Aug 2014 19:22:08 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id E54234A033; Fri, 1 Aug 2014 11:22:06 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id zhQ9reJrzbz1; Fri, 1 Aug 2014 11:22:06 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id C00134A036; Fri, 1 Aug 2014 11:22:04 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 8A75C4A036 for ; Fri, 1 Aug 2014 11:22:02 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 0dlKz4sL8PFs for ; Fri, 1 Aug 2014 11:21:59 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by theia.denx.de (Postfix) with ESMTPS id 57EAF4A033 for ; Fri, 1 Aug 2014 11:21:55 +0200 (CEST) Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s719LljZ003170 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 1 Aug 2014 05:21:47 -0400 Received: from shalem.localdomain.com (vpn1-6-97.ams2.redhat.com [10.36.6.97]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s719Liep016145; Fri, 1 Aug 2014 05:21:45 -0400 From: Hans de Goede To: u-boot@lists.denx.de Date: Fri, 1 Aug 2014 11:21:43 +0200 Message-Id: <1406884903-24749-1-git-send-email-hdegoede@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 Cc: Dennis Gilmore , Ian Campbell Subject: [U-Boot] [PATCH] pxe: Allow use of environment variables in append string X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de Use run_command("setenv bootargs append>") so that environment variables (e.g. $console) can be used in append strings. Signed-off-by: Hans de Goede --- 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); }