From 3903182498a9278304d45bc072be4863bac0fb6b Mon Sep 17 00:00:00 2001 From: Marcus Haehnel Date: Thu, 18 Aug 2016 17:47:01 +0200 Subject: [PATCH 1/3] Backport fix for blocksize http://lists.infradead.org/pipermail/barebox/2014-July/020288.html --- 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 083e45eed59..1db2fdee2d3 100644 --- a/fs/ext4/ext4_common.c +++ b/fs/ext4/ext4_common.c @@ -1415,6 +1415,7 @@ static struct ext4_extent_header *ext4fs_get_extent_block struct ext4_extent_idx *index; unsigned long long block; struct ext_filesystem *fs = get_fs(); + int blksz = EXT2_BLOCK_SIZE(data); int i; while (1) { @@ -1438,7 +1439,7 @@ static struct ext4_extent_header *ext4fs_get_extent_block block = le32_to_cpu(index[i].ei_leaf_hi); block = (block << 32) + le32_to_cpu(index[i].ei_leaf_lo); - if (ext4fs_devread(block << log2_blksz, 0, fs->blksz, buf)) + if (ext4fs_devread(block << log2_blksz, 0, blksz, buf)) ext_block = (struct ext4_extent_header *)buf; else return 0; From 66ae21fd7e2faccf0236d8dd9c80f9cc9238549b Mon Sep 17 00:00:00 2001 From: Marcus Haehnel Date: Thu, 18 Aug 2016 17:48:31 +0200 Subject: [PATCH 2/3] Backport fix for wrong field sizes http://lists.infradead.org/pipermail/barebox/2014-July/020289.html --- fs/ext4/ext4_common.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/fs/ext4/ext4_common.c b/fs/ext4/ext4_common.c index 1db2fdee2d3..61af81ca386 100644 --- a/fs/ext4/ext4_common.c +++ b/fs/ext4/ext4_common.c @@ -1421,7 +1421,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) @@ -1429,14 +1429,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(block << log2_blksz, 0, blksz, buf)) @@ -1530,7 +1530,7 @@ 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) { @@ -1540,7 +1540,7 @@ long int read_allocated_block(struct ext2_inode *inode, int fileblock) 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); From 1fac2e198335a83ac824fc0d186eac0ea357ce56 Mon Sep 17 00:00:00 2001 From: Marcus Haehnel Date: Thu, 18 Aug 2016 17:49:23 +0200 Subject: [PATCH 3/3] Backport fix for invalid extent http://lists.infradead.org/pipermail/barebox/2014-July/020290.html --- 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 61af81ca386..9af74488d77 100644 --- a/fs/ext4/ext4_common.c +++ b/fs/ext4/ext4_common.c @@ -1431,7 +1431,7 @@ static struct ext4_extent_header *ext4fs_get_extent_block i++; if (i >= le16_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;