From patchwork Tue Nov 4 02:50:01 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suriyan Ramasami X-Patchwork-Id: 406410 X-Patchwork-Delegate: sjg@chromium.org 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 C008F1400E0 for ; Tue, 4 Nov 2014 15:08:36 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 47C1A4B920; Tue, 4 Nov 2014 03:51:02 +0100 (CET) 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 gQAumTGXMOoo; Tue, 4 Nov 2014 03:51:02 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id D68DD4B95C; Tue, 4 Nov 2014 03:50:54 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 980AA4B8DB for ; Tue, 4 Nov 2014 03:50:51 +0100 (CET) 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 gJEsUd2xJdbl for ; Tue, 4 Nov 2014 03:50:51 +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-pd0-f182.google.com (mail-pd0-f182.google.com [209.85.192.182]) by theia.denx.de (Postfix) with ESMTPS id A85684B924 for ; Tue, 4 Nov 2014 03:50:43 +0100 (CET) Received: by mail-pd0-f182.google.com with SMTP id fp1so12779518pdb.13 for ; Mon, 03 Nov 2014 18:50:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=2DOjiyXof4E3nYvxKwXLEtknQtJ3Gi6gPZk/PoyxXFk=; b=Gy1XKLVsu08t3YAPLcKbm/jCozkEgBLCZ+ILgzvJRF3JEthlIisi4NGDZx4Dq3AaFP vX7C2p3YnwLmYQlidobEuKZGV6UW0MJPjmYCaQiONvddvcm06T6Q7LD3IGNRlk1uoV9s DQRyw/kpDNc9KFlbrJd+f4t2p0DGRkTBQ7Wcrc2LNfMnJaLIbljPqCY6K3Lvjomv746p JmlLDEFNcolI2VrEYmtJYdepnDqkNU+XLuY2VOFqqBWtpmUffx/QxfxubhxLzPWMugFm hctP7K5X9LtmORyusVZ17/K1HD2cRkD1Ebfc9xLpyxSJv09Bhlu89MkO9OGZQHJGGg0I /ncQ== X-Received: by 10.68.183.193 with SMTP id eo1mr73773pbc.168.1415069442562; Mon, 03 Nov 2014 18:50:42 -0800 (PST) Received: from localhost.localdomain ([73.170.223.86]) by mx.google.com with ESMTPSA id al4sm18362124pbc.19.2014.11.03.18.50.40 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 03 Nov 2014 18:50:41 -0800 (PST) From: Suriyan Ramasami To: Simon Glass Date: Mon, 3 Nov 2014 18:50:01 -0800 Message-Id: <1415069408-2978-6-git-send-email-suriyan.r@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1415069408-2978-1-git-send-email-suriyan.r@gmail.com> References: <1415069408-2978-1-git-send-email-suriyan.r@gmail.com> Cc: Suriyan Ramasami , Jeroen Hofstee , u-boot@lists.denx.de Subject: [U-Boot] [PATCH v6 5/6] sandbox: Use md5sum and fatwrite to enable testing of fs commands X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.13 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 Enable md5sum to check the MD5 of the read and written files to check their contents for validity. Use map_sysmem() to map buffer in a sandbox environment. Signed-off-by: Suriyan Ramasami Acked-by: Simon Glass --- Changes in v6: * Simon - Split this into a separate patch Changes in v5: None common/cmd_md5sum.c | 12 ++++++++++-- include/configs/sandbox.h | 2 ++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/common/cmd_md5sum.c b/common/cmd_md5sum.c index 3ac8cc4..d22ace5 100644 --- a/common/cmd_md5sum.c +++ b/common/cmd_md5sum.c @@ -11,6 +11,7 @@ #include #include #include +#include /* * Store the resulting sum to an address or variable @@ -79,6 +80,7 @@ int do_md5sum(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) int verify = 0; int ac; char * const *av; + void *buf; if (argc < 3) return CMD_RET_USAGE; @@ -96,7 +98,9 @@ int do_md5sum(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) addr = simple_strtoul(*av++, NULL, 16); len = simple_strtoul(*av++, NULL, 16); - md5_wd((unsigned char *) addr, len, output, CHUNKSZ_MD5); + buf = map_sysmem(addr, len); + md5_wd(buf, len, output, CHUNKSZ_MD5); + unmap_sysmem(buf); if (!verify) { printf("md5 for %08lx ... %08lx ==> ", addr, addr + len - 1); @@ -135,6 +139,7 @@ static int do_md5sum(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) unsigned long addr, len; unsigned int i; u8 output[16]; + void *buf; if (argc < 3) return CMD_RET_USAGE; @@ -142,7 +147,10 @@ static int do_md5sum(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) addr = simple_strtoul(argv[1], NULL, 16); len = simple_strtoul(argv[2], NULL, 16); - md5_wd((unsigned char *) addr, len, output, CHUNKSZ_MD5); + buf = map_sysmem(addr, len); + md5_wd(buf, len, output, CHUNKSZ_MD5); + unmap_sysmem(buf); + printf("md5 for %08lx ... %08lx ==> ", addr, addr + len - 1); for (i = 0; i < 16; i++) printf("%02x", output[i]); diff --git a/include/configs/sandbox.h b/include/configs/sandbox.h index ee4b244..2b03841 100644 --- a/include/configs/sandbox.h +++ b/include/configs/sandbox.h @@ -48,6 +48,7 @@ #define CONFIG_ANDROID_BOOT_IMAGE #define CONFIG_FS_FAT +#define CONFIG_FAT_WRITE #define CONFIG_FS_EXT4 #define CONFIG_EXT4_WRITE #define CONFIG_CMD_FAT @@ -57,6 +58,7 @@ #define CONFIG_DOS_PARTITION #define CONFIG_HOST_MAX_DEVICES 4 #define CONFIG_CMD_FS_GENERIC +#define CONFIG_CMD_MD5SUM #define CONFIG_SYS_VSNPRINTF