summaryrefslogtreecommitdiff
path: root/fs
diff options
context:
space:
mode:
authorGero Schumacher <Gero.Schumacher@peiker-cee.de>2019-02-26 15:45:22 +0000
committerTom Rini <trini@konsulko.com>2019-04-09 20:04:03 -0400
commit1c48fda3e5a88159130b4d4805fbdf367212afab (patch)
tree4a088301bce63febd6a4bea46fe3c6541d5f144e /fs
parentef79284e7a6ba141b56478f8ed1456ef5c27ae47 (diff)
downloadu-boot-1c48fda3e5a88159130b4d4805fbdf367212afab.tar.gz
u-boot-1c48fda3e5a88159130b4d4805fbdf367212afab.tar.bz2
u-boot-1c48fda3e5a88159130b4d4805fbdf367212afab.zip
fs: ext4: Problem with ext4load and sparse files
Hi, when I try to load a sparse file via ext4load, I am getting the error message 'invalid extent' After a deeper look in the code, it seems to be an issue in the function ext4fs_get_extent_block in fs/ext4/ext4_common.c: The file starts with 1k of zeros. The blocksize is 1024. So the first extend block contains the following information: eh_entries: 1 eh_depth: 1 ei_block 1 When the upper layer (ext4fs_read_file) asks for fileblock 0, we are running in the 'invalid extent' error message. For me it seems, that the code is not prepared for handling a sparse block at the beginning of the file. The following change, solved my problem: I am really not an expert in ext4 filesystems. Can somebody please have a look at this issue and give me a feedback, if I am totally wrong or not?
Diffstat (limited to 'fs')
-rw-r--r--fs/ext4/ext4_common.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/fs/ext4/ext4_common.c b/fs/ext4/ext4_common.c
index 59ad6c8f8c..feffbfa9a9 100644
--- a/fs/ext4/ext4_common.c
+++ b/fs/ext4/ext4_common.c
@@ -1547,8 +1547,12 @@ static struct ext4_extent_header *ext4fs_get_extent_block
break;
} while (fileblock >= le32_to_cpu(index[i].ei_block));
- if (--i < 0)
- return NULL;
+ /*
+ * If first logical block number is higher than requested fileblock,
+ * it is a sparse file. This is handled on upper layer.
+ */
+ if (i > 0)
+ i--;
block = le16_to_cpu(index[i].ei_leaf_hi);
block = (block << 32) + le32_to_cpu(index[i].ei_leaf_lo);