From patchwork Fri Feb 11 13:31:10 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wolfgang Denk X-Patchwork-Id: 82755 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 1A4A9B7161 for ; Sat, 12 Feb 2011 00:31:25 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id A297B280B3; Fri, 11 Feb 2011 14:31:20 +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 blJi3rdPUTnJ; Fri, 11 Feb 2011 14:31:20 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id B38D1280BF; Fri, 11 Feb 2011 14:31:18 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 21ADF280BF for ; Fri, 11 Feb 2011 14:31:16 +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 flYfTFacbSWR for ; Fri, 11 Feb 2011 14:31:14 +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 mail-out.m-online.net (mail-out.m-online.net [212.18.0.9]) by theia.denx.de (Postfix) with ESMTP id 0936A280B3 for ; Fri, 11 Feb 2011 14:31:12 +0100 (CET) Received: from frontend1.mail.m-online.net (unknown [192.168.8.180]) by mail-out.m-online.net (Postfix) with ESMTP id 784621C01EC1 for ; Fri, 11 Feb 2011 14:31:12 +0100 (CET) X-Auth-Info: FnfsQ0/DcLUn8n/lWUDBdAnAIwDrqNw6g/0dEJYYisA= Received: from diddl.denx.de (host-80-81-18-216.customer.m-online.net [80.81.18.216]) by smtp-auth.mnet-online.de (Postfix) with ESMTPA id 6D52F1C0013E for ; Fri, 11 Feb 2011 14:31:12 +0100 (CET) Received: from gemini.denx.de (gemini.denx.de [10.0.0.2]) by diddl.denx.de (Postfix) with ESMTP id 533FB329659C for ; Fri, 11 Feb 2011 14:31:12 +0100 (CET) Received: by gemini.denx.de (Postfix, from userid 500) id 3B85814B9A39; Fri, 11 Feb 2011 14:31:12 +0100 (CET) From: Wolfgang Denk To: u-boot@lists.denx.de Date: Fri, 11 Feb 2011 14:31:10 +0100 Message-Id: <1297431070-29533-1-git-send-email-wd@denx.de> X-Mailer: git-send-email 1.7.4 Subject: [U-Boot] [PATCH] unzip: return uncompressed size in `filesize', and print it. X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.9 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 The unzip command did not provide a way for the caller to get any information about the uncompressed size. To make it better usable in scripts, we now store the uncompressed size in the `filesize' variable, like we do when for example loading a file over the network or when reading it from a file system. Following that analogy, it is only consequent to also print the size. Signed-off-by: Wolfgang Denk --- common/cmd_mem.c | 10 +++++++++- 1 files changed, 9 insertions(+), 1 deletions(-) diff --git a/common/cmd_mem.c b/common/cmd_mem.c index ccf420a..54e581a 100644 --- a/common/cmd_mem.c +++ b/common/cmd_mem.c @@ -1212,6 +1212,8 @@ int do_unzip ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { unsigned long src, dst; unsigned long src_len = ~0UL, dst_len = ~0UL; + int rc; + char buf[32]; switch (argc) { case 4: @@ -1225,7 +1227,13 @@ int do_unzip ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) return cmd_usage(cmdtp); } - return !!gunzip((void *) dst, dst_len, (void *) src, &src_len); + rc = gunzip((void *) dst, dst_len, (void *) src, &src_len); + + printf("Uncompressed size: %ld = 0x%lX\n", src_len, src_len); + sprintf(buf, "%lX", src_len); + setenv("filesize", buf); + + return !!rc; } #endif /* CONFIG_CMD_UNZIP */