Commit c49b0eb0 authored by Gerard Koskamp's avatar Gerard Koskamp Committed by Tom Rini
Browse files

fs/squashfs: Fix index off by 1 for inode SQFS_LDIR_TYPE

I've created a squashfs file system with Yocto (it use squashfs-tools)
and u-boot command sqfsls give the error:'Error while searching inode:
unknown type.'
After some digging in the code I found that the index is off by 1.
This patch fix this issue and I can successful use the sqfsls command.
After search for the squashfs format I found a link talk about a
similar issue but this time in the documentation. The link is:
https://github.com/AgentD/squashfs-tools-ng/commit/e6588526838caece9529

Signed-off-by: default avatarGerard Koskamp <gerard.koskamp@nedap.com>
Tested-by: default avatarJoao Marcos Costa <joaomarcos.costa@bootlin.com>
parent e0407253
...@@ -49,7 +49,7 @@ int sqfs_inode_size(struct squashfs_base_inode *inode, u32 blk_size) ...@@ -49,7 +49,7 @@ int sqfs_inode_size(struct squashfs_base_inode *inode, u32 blk_size)
return sizeof(*ldir); return sizeof(*ldir);
di = ldir->index; di = ldir->index;
while (l < i_count + 1) { while (l < i_count) {
sz = get_unaligned_le32(&di->size) + 1; sz = get_unaligned_le32(&di->size) + 1;
index_list_size += sz; index_list_size += sz;
di = (void *)di + sizeof(*di) + sz; di = (void *)di + sizeof(*di) + sz;
...@@ -57,7 +57,7 @@ int sqfs_inode_size(struct squashfs_base_inode *inode, u32 blk_size) ...@@ -57,7 +57,7 @@ int sqfs_inode_size(struct squashfs_base_inode *inode, u32 blk_size)
} }
return sizeof(*ldir) + index_list_size + return sizeof(*ldir) + index_list_size +
(i_count + 1) * SQFS_DIR_INDEX_BASE_LENGTH; i_count * SQFS_DIR_INDEX_BASE_LENGTH;
} }
case SQFS_LREG_TYPE: { case SQFS_LREG_TYPE: {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment