mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] ext4 fixes from U-Boot
@ 2014-07-25  8:42 Sascha Hauer
  2014-07-25  8:42 ` [PATCH 1/3] fs: ext4: fix "invalid extent block" error Sascha Hauer
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Sascha Hauer @ 2014-07-25  8:42 UTC (permalink / raw)
  To: barebox

The following are some ext4 fixes taken from U-Boot.

----------------------------------------------------------------
Sascha Hauer (3):
      fs: ext4: fix "invalid extent block" error
      fs: ext4: use EXT2_BLOCK_SIZE instead of fs->blksz
      fs: ext4: le32_to_cpu() used on a 16-bit field

 fs/ext4/ext4_common.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/3] fs: ext4: fix "invalid extent block" error
  2014-07-25  8:42 [PATCH] ext4 fixes from U-Boot Sascha Hauer
@ 2014-07-25  8:42 ` Sascha Hauer
  2014-07-25  8:42 ` [PATCH 2/3] fs: ext4: use EXT2_BLOCK_SIZE instead of fs->blksz Sascha Hauer
  2014-07-25  8:42 ` [PATCH 3/3] fs: ext4: le32_to_cpu() used on a 16-bit field Sascha Hauer
  2 siblings, 0 replies; 4+ messages in thread
From: Sascha Hauer @ 2014-07-25  8:42 UTC (permalink / raw)
  To: barebox

From U-Boot commit:

| commit b5bbac1a9b07016602559ff483df265fef6c1f83
| Author: Ionut Nicu <ioan.nicu.ext@nsn.com>
| Date:   Mon Jan 13 12:00:08 2014 +0100
|
|     ext4fs: fix "invalid extent block" error
|
|     For files where we actually have extent indexes following
|     an extent header (ext_block->eh_depth != 0), the do/while
|     loop from ext4fs_get_extent_block() does not select the
|     proper extent index structure.
|
|     For example, if we have:
|
|     ext_block->eh_depth = 1
|     ext_block->eh_entries = 1
|     fileblock = 0
|     index[0].ei_block = 0
|
|     the do/while loop will exit with i set to 0 and the
|     ext4fs_get_extent_block() function will return 0, even if
|     there was a valid extent index structure following the
|     header.
|
|     Signed-off-by: Ionut Nicu <ioan.nicu.ext@nsn.com>
|     Signed-off-by: Mathias Rulf <mathias.rulf@nsn.com>

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 fs/ext4/ext4_common.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/ext4/ext4_common.c b/fs/ext4/ext4_common.c
index ceb965f..5bff868 100644
--- a/fs/ext4/ext4_common.c
+++ b/fs/ext4/ext4_common.c
@@ -60,7 +60,7 @@ static struct ext4_extent_header *ext4fs_get_extent_block(struct ext2_data *data
 			i++;
 			if (i >= le32_to_cpu(ext_block->eh_entries))
 				break;
-		} while (fileblock > le32_to_cpu(index[i].ei_block));
+		} while (fileblock >= le32_to_cpu(index[i].ei_block));
 
 		if (--i < 0)
 			return 0;
-- 
2.0.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 2/3] fs: ext4: use EXT2_BLOCK_SIZE instead of fs->blksz
  2014-07-25  8:42 [PATCH] ext4 fixes from U-Boot Sascha Hauer
  2014-07-25  8:42 ` [PATCH 1/3] fs: ext4: fix "invalid extent block" error Sascha Hauer
@ 2014-07-25  8:42 ` Sascha Hauer
  2014-07-25  8:42 ` [PATCH 3/3] fs: ext4: le32_to_cpu() used on a 16-bit field Sascha Hauer
  2 siblings, 0 replies; 4+ messages in thread
From: Sascha Hauer @ 2014-07-25  8:42 UTC (permalink / raw)
  To: barebox

From U-Boot commit:

| commit 470173274d9ceb18a7140ef93e20be6c2236e7d9
| Author: Ionut Nicu <ioan.nicu.ext@nsn.com>
| Date:   Mon Jan 13 11:59:24 2014 +0100
|
|     ext4fs: use EXT2_BLOCK_SIZE instead of fs->blksz
|
|     Using fs->blksz in ext4fs_get_extent_block() is not
|     correct since fs->blksz is not initialized on the
|     read path. Use EXT2_BLOCK_SIZE() instead which will
|     produce the desired output.
|
|     Signed-off-by: Ionut Nicu <ioan.nicu.ext@nsn.com>
|     Signed-off-by: Mathias Rulf <mathias.rulf@nsn.com>

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 fs/ext4/ext4_common.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/ext4/ext4_common.c b/fs/ext4/ext4_common.c
index 5bff868..1bd9215 100644
--- a/fs/ext4/ext4_common.c
+++ b/fs/ext4/ext4_common.c
@@ -45,6 +45,7 @@ static struct ext4_extent_header *ext4fs_get_extent_block(struct ext2_data *data
 	struct ext4_extent_idx *index;
 	unsigned long long block;
 	struct ext_filesystem *fs = data->fs;
+	int blksz = EXT2_BLOCK_SIZE(data);
 	int i, ret;
 
 	while (1) {
@@ -68,7 +69,7 @@ static struct ext4_extent_header *ext4fs_get_extent_block(struct ext2_data *data
 		block = le32_to_cpu(index[i].ei_leaf_hi);
 		block = (block << 32) + le32_to_cpu(index[i].ei_leaf_lo);
 
-		ret = ext4fs_devread(fs, block << log2_blksz, 0, fs->blksz, buf);
+		ret = ext4fs_devread(fs, block << log2_blksz, 0, blksz, buf);
 		if (ret)
 			return NULL;
 		else
-- 
2.0.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 3/3] fs: ext4: le32_to_cpu() used on a 16-bit field
  2014-07-25  8:42 [PATCH] ext4 fixes from U-Boot Sascha Hauer
  2014-07-25  8:42 ` [PATCH 1/3] fs: ext4: fix "invalid extent block" error Sascha Hauer
  2014-07-25  8:42 ` [PATCH 2/3] fs: ext4: use EXT2_BLOCK_SIZE instead of fs->blksz Sascha Hauer
@ 2014-07-25  8:42 ` Sascha Hauer
  2 siblings, 0 replies; 4+ messages in thread
From: Sascha Hauer @ 2014-07-25  8:42 UTC (permalink / raw)
  To: barebox

From U-Boot commit:

| commit 8b415f703f88d1d3b0466830047affbbf7f24913
| Author: Rommel Custodio <sessyargc+uboot@gmail.com>
| Date:   Sun Jul 21 10:53:25 2013 +0200
|
|     ext4fs: le32_to_cpu() used on a 16-bit field
|
|     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 <sessyargc+uboot@gmail.com>
|     [sent via git-send-email; rework commit message]
|     Signed-off-by: Andreas Bießmann <andreas.devel@googlemail.com>
|     Reviewed-by: Simon Glass <sjg@chromium.org>
|     Tested-by: Simon Glass <sjg@chromium.org>
|     Tested-by: Lukasz Majewski <l.majewski@samsung.com>

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 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 1bd9215..ab0e6b5 100644
--- a/fs/ext4/ext4_common.c
+++ b/fs/ext4/ext4_common.c
@@ -51,7 +51,7 @@ static struct ext4_extent_header *ext4fs_get_extent_block(struct ext2_data *data
 	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)
@@ -59,14 +59,14 @@ static struct ext4_extent_header *ext4fs_get_extent_block(struct ext2_data *data
 		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);
 
 		ret = ext4fs_devread(fs, block << log2_blksz, 0, blksz, buf);
@@ -187,18 +187,18 @@ long int read_allocated_block(struct ext2fs_node *node, 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);
-- 
2.0.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-07-25  8:42 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-25  8:42 [PATCH] ext4 fixes from U-Boot Sascha Hauer
2014-07-25  8:42 ` [PATCH 1/3] fs: ext4: fix "invalid extent block" error Sascha Hauer
2014-07-25  8:42 ` [PATCH 2/3] fs: ext4: use EXT2_BLOCK_SIZE instead of fs->blksz Sascha Hauer
2014-07-25  8:42 ` [PATCH 3/3] fs: ext4: le32_to_cpu() used on a 16-bit field Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox