From patchwork Fri Dec 2 16:12:09 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Riesch X-Patchwork-Id: 128897 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 17218B6F75 for ; Sat, 3 Dec 2011 03:12:28 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 10529280F1; Fri, 2 Dec 2011 17:12:17 +0100 (CET) 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 3hlhzYHnMoiO; Fri, 2 Dec 2011 17:12:16 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 20208280FE; Fri, 2 Dec 2011 17:12:05 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 26DD8280E2 for ; Fri, 2 Dec 2011 17:12:01 +0100 (CET) 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 gEsBvBD3bR+e for ; Fri, 2 Dec 2011 17:12:00 +0100 (CET) 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 ns.omicron.at (ns.omicron.at [212.183.10.25]) by theia.denx.de (Postfix) with ESMTPS id 6EF71280E5 for ; Fri, 2 Dec 2011 17:11:58 +0100 (CET) Received: from counter.omicron.at ([212.183.10.29]) by ns.omicron.at (8.13.1/8.13.1) with ESMTP id pB2GBoW7030155; Fri, 2 Dec 2011 17:11:55 +0100 Received: from mary.at.omicron.at (mary.at.omicron.at [172.22.100.48]) by counter.omicron.at (8.14.4/8.14.4) with ESMTP id pB2GBomd016995; Fri, 2 Dec 2011 17:11:50 +0100 Received: from localhost.localdomain (172.22.1.62) by mary-special.at.omicron.at (172.22.100.48) with Microsoft SMTP Server id 8.3.192.1; Fri, 2 Dec 2011 17:11:47 +0100 From: Christian Riesch To: Date: Fri, 2 Dec 2011 17:12:09 +0100 Message-ID: <1322842330-25213-6-git-send-email-christian.riesch@omicron.at> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1322842330-25213-1-git-send-email-christian.riesch@omicron.at> References: <1322842330-25213-1-git-send-email-christian.riesch@omicron.at> MIME-Version: 1.0 Cc: Heiko Schocher , Christian Riesch Subject: [U-Boot] [PATCH v4 5/6] mkimage: Fix variable length header support 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: , Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de Support for variable length images like AIS image was introduced in commit f0662105b674a3874227316abf8536bebc9b5995. A parameter "-s" was also introduced to prohibit copying of the image file automatically in the main program. However, this parameter was implemented incorrectly and the image file was copied nevertheless. Signed-off-by: Christian Riesch Cc: Stefano Babic Cc: Heiko Schocher Acked-by: Stefano Babic --- tools/mkimage.c | 97 ++++++++++++++++++++++++++++--------------------------- 1 files changed, 49 insertions(+), 48 deletions(-) diff --git a/tools/mkimage.c b/tools/mkimage.c index 36e28ec..eeb1b10 100644 --- a/tools/mkimage.c +++ b/tools/mkimage.c @@ -383,65 +383,66 @@ NXTARG: ; exit (EXIT_FAILURE); } - if (!params.skipcpy && - (params.type == IH_TYPE_MULTI || - params.type == IH_TYPE_SCRIPT)) { - char *file = params.datafile; - uint32_t size; - - for (;;) { - char *sep = NULL; - - if (file) { - if ((sep = strchr(file, ':')) != NULL) { - *sep = '\0'; + if (!params.skipcpy) { + if (params.type == IH_TYPE_MULTI || + params.type == IH_TYPE_SCRIPT) { + char *file = params.datafile; + uint32_t size; + + for (;;) { + char *sep = NULL; + + if (file) { + if ((sep = strchr(file, ':')) != NULL) { + *sep = '\0'; + } + + if (stat (file, &sbuf) < 0) { + fprintf (stderr, "%s: Can't stat %s: %s\n", + params.cmdname, file, strerror(errno)); + exit (EXIT_FAILURE); + } + size = cpu_to_uimage (sbuf.st_size); + } else { + size = 0; } - if (stat (file, &sbuf) < 0) { - fprintf (stderr, "%s: Can't stat %s: %s\n", - params.cmdname, file, strerror(errno)); + if (write(ifd, (char *)&size, sizeof(size)) != sizeof(size)) { + fprintf (stderr, "%s: Write error on %s: %s\n", + params.cmdname, params.imagefile, + strerror(errno)); exit (EXIT_FAILURE); } - size = cpu_to_uimage (sbuf.st_size); - } else { - size = 0; - } - if (write(ifd, (char *)&size, sizeof(size)) != sizeof(size)) { - fprintf (stderr, "%s: Write error on %s: %s\n", - params.cmdname, params.imagefile, - strerror(errno)); - exit (EXIT_FAILURE); - } + if (!file) { + break; + } - if (!file) { - break; + if (sep) { + *sep = ':'; + file = sep + 1; + } else { + file = NULL; + } } - if (sep) { - *sep = ':'; - file = sep + 1; - } else { - file = NULL; - } - } + file = params.datafile; - file = params.datafile; - - for (;;) { - char *sep = strchr(file, ':'); - if (sep) { - *sep = '\0'; - copy_file (ifd, file, 1); - *sep++ = ':'; - file = sep; - } else { - copy_file (ifd, file, 0); - break; + for (;;) { + char *sep = strchr(file, ':'); + if (sep) { + *sep = '\0'; + copy_file (ifd, file, 1); + *sep++ = ':'; + file = sep; + } else { + copy_file (ifd, file, 0); + break; + } } + } else { + copy_file (ifd, params.datafile, 0); } - } else { - copy_file (ifd, params.datafile, 0); } /* We're a bit of paranoid */