From patchwork Sun Jul 21 08:53:25 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andreas_Bie=C3=9Fmann?= X-Patchwork-Id: 260506 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 A95042C00B9 for ; Sun, 21 Jul 2013 18:54:10 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 2490F4A113; Sun, 21 Jul 2013 10:54:07 +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 agzZwk96IWrV; Sun, 21 Jul 2013 10:54:06 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 589BC4A114; Sun, 21 Jul 2013 10:54:03 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id DAFEE4A109 for ; Sun, 21 Jul 2013 10:54:00 +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 4HqftqJeD5tO for ; Sun, 21 Jul 2013 10:53:56 +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 mail-bk0-f53.google.com (mail-bk0-f53.google.com [209.85.214.53]) by theia.denx.de (Postfix) with ESMTPS id 77B8D4A0F2 for ; Sun, 21 Jul 2013 10:53:49 +0200 (CEST) Received: by mail-bk0-f53.google.com with SMTP id e11so2071849bkh.26 for ; Sun, 21 Jul 2013 01:53:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=wxugrM6IRvVejcMSBelh+uuP0010nWyew4SO4Kl3/34=; b=g+UATrSW3TVZcd3LHsyWi6l1trMxIylG8ZlrOMQZ6aAAhhPMHwKeOFtxoUcEoaeTu1 03BV/N4N4IfRrXlFFE7GdGMoci86Q6r9sOhXLIHJGeFmQjr/c6jJDjmHtsmtKEBxGiwj ppU7k0AnqLPdkZFOTzruTagTEmtEUybfKLfrBqnX43whMvTgTaPrQd7gjfvi6rDojxbC qVRttdsWm79bBy8rg/QmVad0Rg3BfRElvKXhUKjQ3vwDdOfhVG1LOgqTOnFa12nQVaBw ZW7js7+SbTYkeACMK8NWKqnxhe8Nk4SX+dLTWWjjJui4pjozpxZwRGYVELGr5NK17AZ0 hAeg== X-Received: by 10.205.0.194 with SMTP id nn2mr3333182bkb.75.1374396829004; Sun, 21 Jul 2013 01:53:49 -0700 (PDT) Received: from localhost ([2a01:198:47b:1:210:75ff:fe1a:cd1e]) by mx.google.com with ESMTPSA id de17sm5647106bkb.5.2013.07.21.01.53.46 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sun, 21 Jul 2013 01:53:47 -0700 (PDT) From: =?UTF-8?q?Andreas=20Bie=C3=9Fmann?= To: u-boot@lists.denx.de Date: Sun, 21 Jul 2013 10:53:25 +0200 Message-Id: <1374396805-3008-2-git-send-email-andreas.devel@googlemail.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1374396805-3008-1-git-send-email-andreas.devel@googlemail.com> References: <1374396805-3008-1-git-send-email-andreas.devel@googlemail.com> MIME-Version: 1.0 Cc: Tom Rini Subject: [U-Boot] [PATCH] ext4fs: le32_to_cpu() used on a 16-bit field 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 From: Rommel Custodio Fix reading ext4_extent_header struture on BE machines. Some 16 bit fields where converted to 32 bit fields, due to the byte swap on BE machines the containing value was corrupted. Therefore reading ext4 filesystems on BE machines where broken before. Signed-off-by: Rommel Custodio [sent via git-send-email; rework commit message] Signed-off-by: Andreas Bießmann Reviewed-by: Simon Glass Tested-by: Simon Glass Tested-by: Lukasz Majewski --- fs/ext4/ext4_common.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/fs/ext4/ext4_common.c b/fs/ext4/ext4_common.c index 2776293..ff9c4ec 100644 --- a/fs/ext4/ext4_common.c +++ b/fs/ext4/ext4_common.c @@ -1432,7 +1432,7 @@ static struct ext4_extent_header *ext4fs_get_extent_block while (1) { index = (struct ext4_extent_idx *)(ext_block + 1); - if (le32_to_cpu(ext_block->eh_magic) != EXT4_EXT_MAGIC) + if (le16_to_cpu(ext_block->eh_magic) != EXT4_EXT_MAGIC) return 0; if (ext_block->eh_depth == 0) @@ -1440,14 +1440,14 @@ static struct ext4_extent_header *ext4fs_get_extent_block i = -1; do { i++; - if (i >= le32_to_cpu(ext_block->eh_entries)) + if (i >= le16_to_cpu(ext_block->eh_entries)) break; } while (fileblock > le32_to_cpu(index[i].ei_block)); if (--i < 0) return 0; - block = le32_to_cpu(index[i].ei_leaf_hi); + block = le16_to_cpu(index[i].ei_leaf_hi); block = (block << 32) + le32_to_cpu(index[i].ei_leaf_lo); if (ext4fs_devread((lbaint_t)block << log2_blksz, 0, fs->blksz, @@ -1548,17 +1548,17 @@ long int read_allocated_block(struct ext2_inode *inode, int fileblock) do { i++; - if (i >= le32_to_cpu(ext_block->eh_entries)) + if (i >= le16_to_cpu(ext_block->eh_entries)) break; } while (fileblock >= le32_to_cpu(extent[i].ee_block)); if (--i >= 0) { fileblock -= le32_to_cpu(extent[i].ee_block); - if (fileblock >= le32_to_cpu(extent[i].ee_len)) { + if (fileblock >= le16_to_cpu(extent[i].ee_len)) { free(buf); return 0; } - start = le32_to_cpu(extent[i].ee_start_hi); + start = le16_to_cpu(extent[i].ee_start_hi); start = (start << 32) + le32_to_cpu(extent[i].ee_start_lo); free(buf);